/** * @param name Cache name. * @param cacheMode Cache mode. * @param parts Number of partitions. * @return Cache configuration. */ private CacheConfiguration cacheConfiguration(String name, CacheMode cacheMode, int parts) { CacheConfiguration ccfg = new CacheConfiguration(); ccfg.setName(name); ccfg.setCacheMode(cacheMode); ccfg.setAtomicityMode(TRANSACTIONAL); ccfg.setWriteSynchronizationMode(FULL_SYNC); if (cacheMode == PARTITIONED) ccfg.setBackups(1); ccfg.setAffinity(new RendezvousAffinityFunction(false, parts)); return ccfg; }
/** * @param ignite Ignite instance. * @param ccfg Cache configuration. * @return Data transfer object for cache store configuration properties. */ public static VisorCacheStoreConfiguration from(Ignite ignite, CacheConfiguration ccfg) { VisorCacheStoreConfiguration cfg = new VisorCacheStoreConfiguration(); GridCacheAdapter<Object, Object> c = ((IgniteKernal) ignite).internalCache(ccfg.getName()); CacheStore store = c != null && c.context().started() ? c.context().store().configuredStore() : null; cfg.jdbcStore = store instanceof CacheAbstractJdbcStore; cfg.store = compactClass(store); cfg.storeFactory = compactClass(ccfg.getCacheStoreFactory()); cfg.readThrough = ccfg.isReadThrough(); cfg.writeThrough = ccfg.isWriteThrough(); cfg.writeBehindEnabled = ccfg.isWriteBehindEnabled(); cfg.batchSz = ccfg.getWriteBehindBatchSize(); cfg.flushFreq = ccfg.getWriteBehindFlushFrequency(); cfg.flushSz = ccfg.getWriteBehindFlushSize(); cfg.flushThreadCnt = ccfg.getWriteBehindFlushThreadCount(); return cfg; }
/** * Start grid with IGFS. * * @param gridName Grid name. * @param igfsName IGFS name * @param mode IGFS mode. * @param secondaryFs Secondary file system (optional). * @param restCfg Rest configuration string (optional). * @return Started grid instance. * @throws Exception If failed. */ protected Ignite startGridWithIgfs( String gridName, String igfsName, IgfsMode mode, @Nullable IgfsSecondaryFileSystem secondaryFs, @Nullable IgfsIpcEndpointConfiguration restCfg) throws Exception { FileSystemConfiguration igfsCfg = new FileSystemConfiguration(); igfsCfg.setDataCacheName("dataCache"); igfsCfg.setMetaCacheName("metaCache"); igfsCfg.setName(igfsName); igfsCfg.setBlockSize(IGFS_BLOCK_SIZE); igfsCfg.setDefaultMode(mode); igfsCfg.setIpcEndpointConfiguration(restCfg); igfsCfg.setSecondaryFileSystem(secondaryFs); igfsCfg.setPrefetchBlocks(PREFETCH_BLOCKS); igfsCfg.setSequentialReadsBeforePrefetch(SEQ_READS_BEFORE_PREFETCH); CacheConfiguration dataCacheCfg = defaultCacheConfiguration(); dataCacheCfg.setName("dataCache"); dataCacheCfg.setCacheMode(PARTITIONED); dataCacheCfg.setNearConfiguration(null); dataCacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC); dataCacheCfg.setAffinityMapper(new IgfsGroupDataBlocksKeyMapper(2)); dataCacheCfg.setBackups(0); dataCacheCfg.setAtomicityMode(TRANSACTIONAL); dataCacheCfg.setOffHeapMaxMemory(0); CacheConfiguration metaCacheCfg = defaultCacheConfiguration(); metaCacheCfg.setName("metaCache"); metaCacheCfg.setCacheMode(REPLICATED); metaCacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC); metaCacheCfg.setAtomicityMode(TRANSACTIONAL); IgniteConfiguration cfg = new IgniteConfiguration(); cfg.setGridName(gridName); TcpDiscoverySpi discoSpi = new TcpDiscoverySpi(); discoSpi.setIpFinder(new TcpDiscoveryVmIpFinder(true)); cfg.setDiscoverySpi(discoSpi); cfg.setCacheConfiguration(dataCacheCfg, metaCacheCfg); cfg.setFileSystemConfiguration(igfsCfg); cfg.setLocalHost("127.0.0.1"); cfg.setConnectorConfiguration(null); return G.start(cfg); }