/** * @param grpSize Group size to use in {@link org.apache.ignite.igfs.IgfsGroupDataBlocksKeyMapper}. * @return 2 preconfigured data cache. */ private CacheConfiguration dataCache(int grpSize) { CacheConfiguration dataCache = defaultCacheConfiguration(); dataCache.setAffinityMapper(new IgfsGroupDataBlocksKeyMapper(grpSize)); dataCache.setAtomicityMode(TRANSACTIONAL); return dataCache; }
/** * @param mapper IGFS blocks mapper. * @param fileId IGFS file ID. * @param blockId File block ID. * @param partCnt Total partitions count. * @return Partition index. */ private int partition(IgfsGroupDataBlocksKeyMapper mapper, IgniteUuid fileId, long blockId, int partCnt) { return U.safeAbs((Integer) mapper.affinityKey(new IgfsBlockKey(fileId, null, false, blockId)) % partCnt); }
/** {@inheritDoc} */ @SuppressWarnings("unchecked") @Override protected void onKernalStart0() throws IgniteCheckedException { dataCachePrj = igfsCtx.kernalContext().cache().getOrStartCache(dataCacheName); assert dataCachePrj != null; dataCache = (IgniteInternalCache)dataCachePrj; AffinityKeyMapper mapper = igfsCtx.kernalContext().cache() .internalCache(dataCacheName).configuration().getAffinityMapper(); grpSize = mapper instanceof IgfsGroupDataBlocksKeyMapper ? ((IgfsGroupDataBlocksKeyMapper)mapper).getGroupSize() : 1; grpBlockSize = igfsCtx.configuration().getBlockSize() * (long)grpSize; assert grpBlockSize != 0; igfsCtx.kernalContext().cache().internalCache(dataCacheName).preloader() .startFuture().listen(new CI1<IgniteInternalFuture<Object>>() { @Override public void apply(IgniteInternalFuture<Object> f) { dataCacheStartLatch.countDown(); } }); new Thread(delWorker).start(); }
/** * Check hash code generation for the given group size and partitions count. * * @throws Exception If failed. */ public void checkDistribution(int grpSize, int partCnt) throws Exception { IgniteUuid fileId = IgniteUuid.randomUuid(); IgfsGroupDataBlocksKeyMapper mapper = new IgfsGroupDataBlocksKeyMapper(grpSize); int lastPart = 0; boolean first = true; for (int i = 0; i < 10; i++) { // Ensure that all blocks within the group has the same hash codes. boolean firstInGroup = true; for (int j = 0; j < grpSize; j++) { int part = partition(mapper, fileId, i * grpSize + j, partCnt); if (firstInGroup) { if (first) first = false; else assert checkPartition(lastPart, part, partCnt) : "[fileId = " + fileId + ", i=" + i + ", j=" + j + ", grpSize= " + grpSize + ", partCnt=" + partCnt + ", lastPart=" + lastPart + ", part=" + part + ']'; firstInGroup = false; } else assert part == lastPart; lastPart = part; } } }
igfsCfg.getName(), igfsCfg.getBlockSize(), ((IgfsGroupDataBlocksKeyMapper)affMapper).getGroupSize(), igfsCfg.getMetaCacheConfiguration().getName(), dataCacheName,
/** * @return IGFS data cache configuration. */ protected CacheConfiguration dataCacheConfiguration() { CacheConfiguration cfg = new CacheConfiguration(DEFAULT_CACHE_NAME); cfg.setCacheMode(PARTITIONED); cfg.setAtomicityMode(TRANSACTIONAL); cfg.setAffinityMapper(new IgfsGroupDataBlocksKeyMapper(igfsBlockGroupSize)); cfg.setWriteSynchronizationMode(FULL_SYNC); return cfg; }
/** {@inheritDoc} */ @SuppressWarnings("unchecked") @Override protected void onKernalStart0() throws IgniteCheckedException { dataCachePrj = igfsCtx.kernalContext().cache().getOrStartCache(dataCacheName); assert dataCachePrj != null; dataCache = (IgniteInternalCache)dataCachePrj; AffinityKeyMapper mapper = igfsCtx.kernalContext().cache() .internalCache(dataCacheName).configuration().getAffinityMapper(); grpSize = mapper instanceof IgfsGroupDataBlocksKeyMapper ? ((IgfsGroupDataBlocksKeyMapper)mapper).getGroupSize() : 1; grpBlockSize = igfsCtx.configuration().getBlockSize() * (long)grpSize; assert grpBlockSize != 0; igfsCtx.kernalContext().cache().internalCache(dataCacheName).preloader() .startFuture().listen(new CI1<IgniteInternalFuture<Object>>() { @Override public void apply(IgniteInternalFuture<Object> f) { dataCacheStartLatch.countDown(); } }); new Thread(delWorker).start(); }
/** {@inheritDoc} */ protected CacheConfiguration cacheConfiguration(@NotNull String cacheName) { CacheConfiguration cacheCfg = defaultCacheConfiguration(); cacheCfg.setName(cacheName); cacheCfg.setCacheMode(PARTITIONED); cacheCfg.setBackups(0); cacheCfg.setAffinityMapper(new IgfsGroupDataBlocksKeyMapper(128)); cacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC); cacheCfg.setAtomicityMode(TRANSACTIONAL); return cacheCfg; }
igfsCfg.getName(), igfsCfg.getBlockSize(), ((IgfsGroupDataBlocksKeyMapper)affMapper).getGroupSize(), igfsCfg.getMetaCacheConfiguration().getName(), dataCacheName,
ccfgData.setAffinityMapper(new IgfsGroupDataBlocksKeyMapper());
/** {@inheritDoc} */ protected CacheConfiguration cacheConfiguration(@NotNull String cacheName) { CacheConfiguration cacheCfg = defaultCacheConfiguration(); cacheCfg.setName(cacheName); if ("meta".equals(cacheName)) cacheCfg.setCacheMode(REPLICATED); else { cacheCfg.setCacheMode(PARTITIONED); cacheCfg.setNearConfiguration(null); cacheCfg.setBackups(0); cacheCfg.setAffinityMapper(new IgfsGroupDataBlocksKeyMapper(DATA_BLOCK_GROUP_CNT)); } cacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC); cacheCfg.setAtomicityMode(TRANSACTIONAL); return cacheCfg; }
/** {@inheritDoc} */ protected CacheConfiguration cacheConfiguration(@NotNull String cacheName) { CacheConfiguration cacheCfg = defaultCacheConfiguration(); cacheCfg.setName(cacheName); if ("meta".equals(cacheName)) cacheCfg.setCacheMode(REPLICATED); else { cacheCfg.setCacheMode(PARTITIONED); cacheCfg.setNearConfiguration(null); cacheCfg.setBackups(0); cacheCfg.setAffinityMapper(new IgfsGroupDataBlocksKeyMapper(128)); } cacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC); cacheCfg.setAtomicityMode(TRANSACTIONAL); return cacheCfg; }
/** {@inheritDoc} */ protected CacheConfiguration cacheConfiguration(@NotNull String cacheName) { CacheConfiguration cacheCfg = defaultCacheConfiguration(); cacheCfg.setName(cacheName); if ("meta".equals(cacheName)) cacheCfg.setCacheMode(REPLICATED); else { cacheCfg.setCacheMode(PARTITIONED); cacheCfg.setNearConfiguration(null); cacheCfg.setBackups(0); cacheCfg.setAffinityMapper(new IgfsGroupDataBlocksKeyMapper(128)); } cacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC); cacheCfg.setAtomicityMode(TRANSACTIONAL); return cacheCfg; }
/** {@inheritDoc} */ protected CacheConfiguration cacheConfiguration(@NotNull String cacheName) { CacheConfiguration cacheCfg = defaultCacheConfiguration(); cacheCfg.setName(cacheName); if (META_CACHE_NAME.equals(cacheName)) cacheCfg.setCacheMode(REPLICATED); else { cacheCfg.setCacheMode(PARTITIONED); cacheCfg.setNearConfiguration(null); cacheCfg.setBackups(0); cacheCfg.setAffinityMapper(new IgfsGroupDataBlocksKeyMapper(128)); } cacheCfg.setWriteSynchronizationMode(FULL_SYNC); cacheCfg.setAtomicityMode(TRANSACTIONAL); return cacheCfg; }
/** {@inheritDoc} */ protected CacheConfiguration cacheConfiguration(@NotNull String cacheName) { CacheConfiguration cacheCfg = defaultCacheConfiguration(); cacheCfg.setName(cacheName); if ("meta".equals(cacheName)) cacheCfg.setCacheMode(REPLICATED); else { cacheCfg.setCacheMode(PARTITIONED); cacheCfg.setNearConfiguration(null); cacheCfg.setBackups(0); cacheCfg.setAffinityMapper(new IgfsGroupDataBlocksKeyMapper(CFG_GRP_SIZE)); } cacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC); cacheCfg.setAtomicityMode(TRANSACTIONAL); cacheCfg.setRebalanceMode(CacheRebalanceMode.SYNC); return cacheCfg; }
/** * Creates base grid configuration. * * @param cacheCtn Caches count. * * @return Base grid configuration. * @throws Exception In case of any error. */ IgniteConfiguration gridConfigurationManyIgfsCaches(int cacheCtn) throws Exception { IgniteConfiguration cfg = getConfiguration(getTestIgniteInstanceName()); List<CacheConfiguration> cachesCfg = new ArrayList<>(); for (int i = 0; i < cacheCtn; ++i) { CacheConfiguration dataCacheCfg = defaultCacheConfiguration(); dataCacheCfg.setName("partitioned" + i); dataCacheCfg.setCacheMode(CacheMode.PARTITIONED); dataCacheCfg.setAffinityMapper(new IgfsGroupDataBlocksKeyMapper(128)); dataCacheCfg.setBackups(0); dataCacheCfg.setAtomicityMode(TRANSACTIONAL); CacheConfiguration metaCacheCfg = defaultCacheConfiguration(); metaCacheCfg.setName("replicated" + i); metaCacheCfg.setCacheMode(CacheMode.REPLICATED); metaCacheCfg.setAtomicityMode(TRANSACTIONAL); cachesCfg.add(dataCacheCfg); cachesCfg.add(metaCacheCfg); } cfg.setCacheConfiguration(cachesCfg.toArray(new CacheConfiguration[cachesCfg.size()])); return cfg; }
/** * Check distribution for integer overflow. * * @throws Exception If failed. */ public void checkIntOverflowDistribution(int partCnt) throws Exception { IgniteUuid fileId = IgniteUuid.randomUuid(); IgfsGroupDataBlocksKeyMapper mapper = new IgfsGroupDataBlocksKeyMapper(1); int part1 = partition(mapper, fileId, Integer.MAX_VALUE - 1, partCnt); int part2 = partition(mapper, fileId, Integer.MAX_VALUE, partCnt); int part3 = partition(mapper, fileId, (long)Integer.MAX_VALUE + 1, partCnt); assert checkPartition(part1, part2, partCnt) : "[fileId = " + fileId + "part1=" + part1 + ", part2=" + part2 + ", partCnt=" + partCnt + ']'; assert checkPartition(part2, part3, partCnt) : "[fileId = " + fileId + "part1=" + part2 + ", part3=" + part3 + ", partCnt=" + partCnt + ']'; }
/** * Gets data cache configuration. * * @return Data cache configuration. */ protected CacheConfiguration dataConfiguration() { CacheConfiguration cfg = defaultCacheConfiguration(); cfg.setCacheMode(PARTITIONED); cfg.setBackups(0); cfg.setAffinityMapper(new IgfsGroupDataBlocksKeyMapper(IGFS_GROUP_SIZE)); cfg.setNearConfiguration(null); cfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC); cfg.setAtomicityMode(TRANSACTIONAL); return cfg; }
/** * Gets cache configuration. * * @param igniteInstanceName Ignite instance name. * @return Cache configuration. */ protected CacheConfiguration dataCacheConfiguration(String igniteInstanceName) { CacheConfiguration cacheCfg = defaultCacheConfiguration(); cacheCfg.setCacheMode(PARTITIONED); cacheCfg.setNearConfiguration(null); cacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC); cacheCfg.setAffinityMapper(new IgfsGroupDataBlocksKeyMapper(GRP_SIZE)); cacheCfg.setBackups(0); cacheCfg.setAtomicityMode(TRANSACTIONAL); return cacheCfg; }
/** * Gets cache configuration. * * @param igniteInstanceName Ignite instance name. * @return Cache configuration. */ protected CacheConfiguration cacheConfiguration(String igniteInstanceName, String cacheName) { CacheConfiguration cacheCfg = defaultCacheConfiguration(); cacheCfg.setName(cacheName); cacheCfg.setCacheMode(PARTITIONED); cacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC); cacheCfg.setAffinityMapper(new IgfsGroupDataBlocksKeyMapper(GRP_SIZE)); cacheCfg.setBackups(0); cacheCfg.setAtomicityMode(TRANSACTIONAL); return cacheCfg; }