use of org.apache.ignite.igfs.IgfsGroupDataBlocksKeyMapper in project ignite by apache.
the class IgfsProcessor method start.
/** {@inheritDoc} */
@Override
public void start(boolean activeOnStart) throws IgniteCheckedException {
IgniteConfiguration igniteCfg = ctx.config();
if (igniteCfg.isDaemon())
return;
FileSystemConfiguration[] cfgs = igniteCfg.getFileSystemConfiguration();
assert cfgs != null && cfgs.length > 0;
// Start IGFS instances.
for (FileSystemConfiguration cfg : cfgs) {
assert cfg.getName() != null;
FileSystemConfiguration cfg0 = new FileSystemConfiguration(cfg);
boolean metaClient = true;
CacheConfiguration[] cacheCfgs = igniteCfg.getCacheConfiguration();
String metaCacheName = cfg.getMetaCacheConfiguration().getName();
if (cacheCfgs != null) {
for (CacheConfiguration cacheCfg : cacheCfgs) {
if (F.eq(cacheCfg.getName(), metaCacheName)) {
metaClient = false;
break;
}
}
}
if (igniteCfg.isClientMode() != null && igniteCfg.isClientMode())
metaClient = true;
IgfsContext igfsCtx = new IgfsContext(ctx, cfg0, new IgfsMetaManager(cfg0.isRelaxedConsistency(), metaClient), new IgfsDataManager(), new IgfsServerManager(), new IgfsFragmentizerManager());
// Start managers first.
for (IgfsManager mgr : igfsCtx.managers()) mgr.start(igfsCtx);
igfsCache.put(cfg0.getName(), igfsCtx);
}
if (log.isDebugEnabled())
log.debug("IGFS processor started.");
// doesn't have configured caches.
if (igniteCfg.isDaemon() || F.isEmpty(igniteCfg.getFileSystemConfiguration()) || F.isEmpty(igniteCfg.getCacheConfiguration()))
return;
final Map<String, CacheConfiguration> cacheCfgs = new HashMap<>();
assert igniteCfg.getCacheConfiguration() != null;
for (CacheConfiguration ccfg : igniteCfg.getCacheConfiguration()) cacheCfgs.put(ccfg.getName(), ccfg);
Collection<IgfsAttributes> attrVals = new ArrayList<>();
assert igniteCfg.getFileSystemConfiguration() != null;
for (FileSystemConfiguration igfsCfg : igniteCfg.getFileSystemConfiguration()) {
String dataCacheName = igfsCfg.getDataCacheConfiguration().getName();
CacheConfiguration cacheCfg = cacheCfgs.get(dataCacheName);
if (cacheCfg == null)
// No cache for the given IGFS configuration.
continue;
AffinityKeyMapper affMapper = cacheCfg.getAffinityMapper();
if (!(affMapper instanceof IgfsGroupDataBlocksKeyMapper))
// Configuration will be validated later, while starting IgfsProcessor.
continue;
attrVals.add(new IgfsAttributes(igfsCfg.getName(), igfsCfg.getBlockSize(), ((IgfsGroupDataBlocksKeyMapper) affMapper).getGroupSize(), igfsCfg.getMetaCacheConfiguration().getName(), dataCacheName, igfsCfg.getDefaultMode(), igfsCfg.getPathModes(), igfsCfg.isFragmentizerEnabled()));
}
ctx.addNodeAttribute(ATTR_IGFS, attrVals.toArray(new IgfsAttributes[attrVals.size()]));
}
use of org.apache.ignite.igfs.IgfsGroupDataBlocksKeyMapper in project ignite by apache.
the class IgfsCachePerBlockLruEvictionPolicySelfTest method startPrimary.
/**
* Start a grid with the primary file system.
*
* @throws Exception If failed.
*/
private void startPrimary() throws Exception {
FileSystemConfiguration igfsCfg = new FileSystemConfiguration();
igfsCfg.setName(IGFS_PRIMARY);
igfsCfg.setBlockSize(512);
igfsCfg.setDefaultMode(DUAL_SYNC);
igfsCfg.setPrefetchBlocks(1);
igfsCfg.setSequentialReadsBeforePrefetch(Integer.MAX_VALUE);
igfsCfg.setSecondaryFileSystem(secondaryFs.asSecondary());
Map<String, IgfsMode> pathModes = new HashMap<>();
pathModes.put(FILE.toString(), PRIMARY);
igfsCfg.setPathModes(pathModes);
CacheConfiguration dataCacheCfg = defaultCacheConfiguration();
dataCacheCfg.setCacheMode(PARTITIONED);
dataCacheCfg.setNearConfiguration(null);
dataCacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
dataCacheCfg.setAtomicityMode(TRANSACTIONAL);
evictPlc = new IgfsPerBlockLruEvictionPolicy();
dataCacheCfg.setEvictionPolicy(evictPlc);
dataCacheCfg.setOnheapCacheEnabled(true);
dataCacheCfg.setAffinityMapper(new IgfsGroupDataBlocksKeyMapper(128));
dataCacheCfg.setBackups(0);
CacheConfiguration metaCacheCfg = defaultCacheConfiguration();
metaCacheCfg.setCacheMode(REPLICATED);
metaCacheCfg.setNearConfiguration(null);
metaCacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
metaCacheCfg.setAtomicityMode(TRANSACTIONAL);
igfsCfg.setMetaCacheConfiguration(metaCacheCfg);
igfsCfg.setDataCacheConfiguration(dataCacheCfg);
IgniteConfiguration cfg = new IgniteConfiguration();
cfg.setIgniteInstanceName("grid-primary");
TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
discoSpi.setIpFinder(new TcpDiscoveryVmIpFinder(true));
cfg.setDiscoverySpi(discoSpi);
cfg.setFileSystemConfiguration(igfsCfg);
cfg.setLocalHost("127.0.0.1");
cfg.setConnectorConfiguration(null);
Ignite g = G.start(cfg);
igfsPrimary = (IgfsImpl) g.fileSystem(IGFS_PRIMARY);
dataCache = igfsPrimary.context().kernalContext().cache().internalCache(igfsPrimary.context().configuration().getDataCacheConfiguration().getName());
}
use of org.apache.ignite.igfs.IgfsGroupDataBlocksKeyMapper in project ignite by apache.
the class IgfsCachePerBlockLruEvictionPolicySelfTest method startSecondary.
/**
* Start a grid with the secondary file system.
*
* @throws Exception If failed.
*/
private void startSecondary() throws Exception {
FileSystemConfiguration igfsCfg = new FileSystemConfiguration();
igfsCfg.setName(IGFS_SECONDARY);
igfsCfg.setBlockSize(512);
igfsCfg.setDefaultMode(PRIMARY);
igfsCfg.setIpcEndpointConfiguration(SECONDARY_REST_CFG);
CacheConfiguration dataCacheCfg = defaultCacheConfiguration();
dataCacheCfg.setCacheMode(PARTITIONED);
dataCacheCfg.setNearConfiguration(null);
dataCacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
dataCacheCfg.setAffinityMapper(new IgfsGroupDataBlocksKeyMapper(128));
dataCacheCfg.setBackups(0);
dataCacheCfg.setAtomicityMode(TRANSACTIONAL);
CacheConfiguration metaCacheCfg = defaultCacheConfiguration();
metaCacheCfg.setCacheMode(REPLICATED);
metaCacheCfg.setNearConfiguration(null);
metaCacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
metaCacheCfg.setAtomicityMode(TRANSACTIONAL);
igfsCfg.setMetaCacheConfiguration(metaCacheCfg);
igfsCfg.setDataCacheConfiguration(dataCacheCfg);
IgniteConfiguration cfg = new IgniteConfiguration();
cfg.setIgniteInstanceName("grid-secondary");
TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
discoSpi.setIpFinder(new TcpDiscoveryVmIpFinder(true));
cfg.setDiscoverySpi(discoSpi);
cfg.setFileSystemConfiguration(igfsCfg);
cfg.setLocalHost("127.0.0.1");
cfg.setConnectorConfiguration(null);
Ignite g = G.start(cfg);
secondaryFs = (IgfsImpl) g.fileSystem(IGFS_SECONDARY);
}
use of org.apache.ignite.igfs.IgfsGroupDataBlocksKeyMapper in project ignite by apache.
the class IgfsDataManagerSelfTest method cacheConfiguration.
/** {@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;
}
use of org.apache.ignite.igfs.IgfsGroupDataBlocksKeyMapper in project ignite by apache.
the class IgfsAbstractRecordResolverSelfTest method beforeTestsStarted.
/** {@inheritDoc} */
@Override
protected void beforeTestsStarted() throws Exception {
FileSystemConfiguration igfsCfg = new FileSystemConfiguration();
igfsCfg.setName("igfs");
igfsCfg.setBlockSize(512);
igfsCfg.setDefaultMode(PRIMARY);
CacheConfiguration dataCacheCfg = new CacheConfiguration(DEFAULT_CACHE_NAME);
dataCacheCfg.setCacheMode(PARTITIONED);
dataCacheCfg.setAtomicityMode(TRANSACTIONAL);
dataCacheCfg.setNearConfiguration(new NearCacheConfiguration());
dataCacheCfg.setWriteSynchronizationMode(FULL_SYNC);
dataCacheCfg.setAffinityMapper(new IgfsGroupDataBlocksKeyMapper(128));
dataCacheCfg.setBackups(0);
CacheConfiguration metaCacheCfg = new CacheConfiguration(DEFAULT_CACHE_NAME);
metaCacheCfg.setCacheMode(REPLICATED);
metaCacheCfg.setAtomicityMode(TRANSACTIONAL);
metaCacheCfg.setWriteSynchronizationMode(FULL_SYNC);
igfsCfg.setMetaCacheConfiguration(metaCacheCfg);
igfsCfg.setDataCacheConfiguration(dataCacheCfg);
IgniteConfiguration cfg = new IgniteConfiguration();
cfg.setIgniteInstanceName("grid");
TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
discoSpi.setIpFinder(ipFinder);
cfg.setDiscoverySpi(discoSpi);
cfg.setFileSystemConfiguration(igfsCfg);
Ignite g = G.start(cfg);
igfs = g.fileSystem("igfs");
}
Aggregations