Search in sources :

Example 36 with IgfsGroupDataBlocksKeyMapper

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()]));
}
Also used : IgfsGroupDataBlocksKeyMapper(org.apache.ignite.igfs.IgfsGroupDataBlocksKeyMapper) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) AffinityKeyMapper(org.apache.ignite.cache.affinity.AffinityKeyMapper) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) FileSystemConfiguration(org.apache.ignite.configuration.FileSystemConfiguration) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration)

Example 37 with IgfsGroupDataBlocksKeyMapper

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());
}
Also used : IgfsPerBlockLruEvictionPolicy(org.apache.ignite.cache.eviction.igfs.IgfsPerBlockLruEvictionPolicy) IgfsMode(org.apache.ignite.igfs.IgfsMode) IgfsGroupDataBlocksKeyMapper(org.apache.ignite.igfs.IgfsGroupDataBlocksKeyMapper) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) HashMap(java.util.HashMap) TcpDiscoveryVmIpFinder(org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder) Ignite(org.apache.ignite.Ignite) FileSystemConfiguration(org.apache.ignite.configuration.FileSystemConfiguration) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)

Example 38 with IgfsGroupDataBlocksKeyMapper

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);
}
Also used : IgfsGroupDataBlocksKeyMapper(org.apache.ignite.igfs.IgfsGroupDataBlocksKeyMapper) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) TcpDiscoveryVmIpFinder(org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder) Ignite(org.apache.ignite.Ignite) FileSystemConfiguration(org.apache.ignite.configuration.FileSystemConfiguration) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)

Example 39 with IgfsGroupDataBlocksKeyMapper

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;
}
Also used : IgfsGroupDataBlocksKeyMapper(org.apache.ignite.igfs.IgfsGroupDataBlocksKeyMapper) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration)

Example 40 with IgfsGroupDataBlocksKeyMapper

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");
}
Also used : IgfsGroupDataBlocksKeyMapper(org.apache.ignite.igfs.IgfsGroupDataBlocksKeyMapper) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) Ignite(org.apache.ignite.Ignite) FileSystemConfiguration(org.apache.ignite.configuration.FileSystemConfiguration) NearCacheConfiguration(org.apache.ignite.configuration.NearCacheConfiguration) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) NearCacheConfiguration(org.apache.ignite.configuration.NearCacheConfiguration) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)

Aggregations

IgfsGroupDataBlocksKeyMapper (org.apache.ignite.igfs.IgfsGroupDataBlocksKeyMapper)43 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)40 FileSystemConfiguration (org.apache.ignite.configuration.FileSystemConfiguration)24 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)23 TcpDiscoverySpi (org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)21 TcpDiscoveryVmIpFinder (org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder)12 IgfsIpcEndpointConfiguration (org.apache.ignite.igfs.IgfsIpcEndpointConfiguration)6 HashMap (java.util.HashMap)5 Ignite (org.apache.ignite.Ignite)5 IgfsMode (org.apache.ignite.igfs.IgfsMode)4 ArrayList (java.util.ArrayList)3 NearCacheConfiguration (org.apache.ignite.configuration.NearCacheConfiguration)3 AffinityKeyMapper (org.apache.ignite.cache.affinity.AffinityKeyMapper)2 IgniteUuid (org.apache.ignite.lang.IgniteUuid)2 HashSet (java.util.HashSet)1 Map (java.util.Map)1 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)1 IgfsPerBlockLruEvictionPolicy (org.apache.ignite.cache.eviction.igfs.IgfsPerBlockLruEvictionPolicy)1 HadoopConfiguration (org.apache.ignite.configuration.HadoopConfiguration)1 IgniteInternalFuture (org.apache.ignite.internal.IgniteInternalFuture)1