Java Code Examples for org.apache.ignite.configuration.CacheConfiguration#setAffinityMapper()

The following examples show how to use org.apache.ignite.configuration.CacheConfiguration#setAffinityMapper() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: IgfsCacheSelfTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/** */
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;
}
 
Example 2
Source File: GridCacheAbstractUsersAffinityMapperSelfTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);

    CacheConfiguration cacheCfg = new CacheConfiguration(DEFAULT_CACHE_NAME);

    cacheCfg.setCacheMode(getCacheMode());
    cacheCfg.setAtomicityMode(getAtomicMode());
    cacheCfg.setNearConfiguration(nearConfiguration());
    cacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
    cacheCfg.setRebalanceMode(SYNC);
    cacheCfg.setAffinityMapper(AFFINITY_MAPPER);

    cfg.setCacheConfiguration(cacheCfg);

    return cfg;
}
 
Example 3
Source File: IgfsServerManagerIpcEndpointRegistrationAbstractSelfTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/**
 * Creates base grid configuration.
 *
 * @return Base grid configuration.
 * @throws Exception In case of any error.
 */
protected IgniteConfiguration gridConfiguration() throws Exception {
    IgniteConfiguration cfg = getConfiguration(getTestIgniteInstanceName());

    CacheConfiguration cc = defaultCacheConfiguration();

    cc.setName("partitioned");
    cc.setCacheMode(CacheMode.PARTITIONED);
    cc.setAffinityMapper(new IgfsGroupDataBlocksKeyMapper(128));
    cc.setBackups(0);
    cc.setAtomicityMode(TRANSACTIONAL);

    CacheConfiguration metaCfg = defaultCacheConfiguration();

    metaCfg.setName("replicated");
    metaCfg.setCacheMode(CacheMode.REPLICATED);
    metaCfg.setAtomicityMode(TRANSACTIONAL);

    cfg.setCacheConfiguration(metaCfg, cc);

    return cfg;
}
 
Example 4
Source File: IgfsProcessorSelfTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/** */
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;
}
 
Example 5
Source File: IgfsBackupFailoverSelfTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * Start grid with IGFS.
 *
 * @param igniteInstanceName Ignite instance name.
 * @param mode IGFS mode.
 * @param secondaryFs Secondary file system (optional).
 * @return Started grid instance.
 * @throws Exception If failed.
 */
protected Ignite startGridWithIgfs(
    String igniteInstanceName, IgfsMode mode, @Nullable IgfsSecondaryFileSystem secondaryFs
) throws Exception {
    final FileSystemConfiguration igfsCfg = new FileSystemConfiguration();

    igfsCfg.setName("igfs");
    igfsCfg.setBlockSize(igfsBlockSize);
    igfsCfg.setDefaultMode(mode);
    igfsCfg.setSecondaryFileSystem(secondaryFs);

    CacheConfiguration<?,?> dataCacheCfg = defaultCacheConfiguration();

    dataCacheCfg.setCacheMode(PARTITIONED);
    dataCacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
    dataCacheCfg.setAffinityMapper(new IgfsGroupDataBlocksKeyMapper(affGrpSize));
    dataCacheCfg.setBackups(numBackups);
    dataCacheCfg.setAtomicityMode(TRANSACTIONAL);

    CacheConfiguration metaCacheCfg = defaultCacheConfiguration();

    metaCacheCfg.setCacheMode(REPLICATED);
    metaCacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
    metaCacheCfg.setAtomicityMode(TRANSACTIONAL);

    igfsCfg.setMetaCacheConfiguration(metaCacheCfg);
    igfsCfg.setDataCacheConfiguration(dataCacheCfg);

    IgniteConfiguration cfg = new IgniteConfiguration();

    cfg.setIgniteInstanceName(igniteInstanceName);

    cfg.setCacheConfiguration(dataCacheCfg, metaCacheCfg);
    cfg.setFileSystemConfiguration(igfsCfg);

    cfg.setLocalHost("127.0.0.1");

    return startGrid(igniteInstanceName, cfg);
}
 
Example 6
Source File: GridCacheReplicatedPreloadSelfTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 *
 * @param cacheCfg Configuration.
 */
private void loadExternalClassesToCfg(CacheConfiguration cacheCfg) {
    try {
        Object sf = getExternalClassLoader().
            loadClass("org.apache.ignite.tests.p2p.CacheDeploymentTestStoreFactory").newInstance();

        cacheCfg.setCacheStoreFactory((Factory)sf);

        Object sslf = getExternalClassLoader().
            loadClass("org.apache.ignite.tests.p2p.CacheDeploymentStoreSessionListenerFactory").newInstance();

        cacheCfg.setCacheStoreSessionListenerFactories((Factory)sslf);

        Object cpc = getExternalClassLoader().
            loadClass("org.apache.ignite.tests.p2p.CacheDeploymentCachePluginConfiguration").newInstance();

        cacheCfg.setPluginConfigurations((CachePluginConfiguration)cpc);

        Object akm = getExternalClassLoader().
            loadClass("org.apache.ignite.tests.p2p.CacheDeploymentAffinityKeyMapper").newInstance();

        cacheCfg.setAffinityMapper((AffinityKeyMapper)akm);

        Object pred = getExternalClassLoader().
            loadClass("org.apache.ignite.tests.p2p.CacheDeploymentAlwaysTruePredicate2").newInstance();

        cacheCfg.setNodeFilter((IgnitePredicate)pred);
    }
    catch (Exception e) {
        throw new RuntimeException(e);
    }
}
 
Example 7
Source File: IgfsAbstractRecordResolverSelfTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@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");

    cfg.setFileSystemConfiguration(igfsCfg);

    Ignite g = G.start(cfg);

    igfs = g.fileSystem("igfs");
}
 
Example 8
Source File: IgfsMetricsSelfTest.java    From ignite with Apache License 2.0 4 votes vote down vote up
/**
 * Get configuration for a grid with the primary file system.
 *
 * @param idx Node index.
 * @return Configuration.
 * @throws Exception If failed.
 */
@SuppressWarnings("unchecked")
private IgniteConfiguration primaryConfiguration(int idx) throws Exception {
    FileSystemConfiguration igfsCfg = new FileSystemConfiguration();

    igfsCfg.setName(IGFS_PRIMARY);
    igfsCfg.setBlockSize(PRIMARY_BLOCK_SIZE);
    igfsCfg.setDefaultMode(DUAL_SYNC);
    igfsCfg.setSecondaryFileSystem(igfsSecondary.asSecondary());

    Map<String, IgfsMode> pathModes = new HashMap<>();

    pathModes.put("/primary", PRIMARY);

    igfsCfg.setPathModes(pathModes);

    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-" + idx);

    cfg.setFileSystemConfiguration(igfsCfg);

    cfg.setLocalHost("127.0.0.1");

    return cfg;
}
 
Example 9
Source File: IgfsBlockMessageSystemPoolStarvationSelfTest.java    From ignite with Apache License 2.0 4 votes vote down vote up
/**
 * Create node configuration.
 *
 * @param name Node name.
 * @param ipFinder IpFinder.
 * @return Configuration.
 * @throws Exception If failed.
 */
private IgniteConfiguration config(String name, TcpDiscoveryVmIpFinder ipFinder) throws Exception {
    // Data cache configuration.
    CacheConfiguration dataCcfg = new CacheConfiguration(DEFAULT_CACHE_NAME);

    dataCcfg.setCacheMode(CacheMode.REPLICATED);
    dataCcfg.setAtomicityMode(TRANSACTIONAL);
    dataCcfg.setWriteSynchronizationMode(FULL_SYNC);
    dataCcfg.setAffinityMapper(new DummyAffinityMapper(1));
    dataCcfg.setMaxConcurrentAsyncOperations(1);

    // Meta cache configuration.
    CacheConfiguration metaCcfg = new CacheConfiguration(DEFAULT_CACHE_NAME);

    metaCcfg.setCacheMode(CacheMode.REPLICATED);
    metaCcfg.setAtomicityMode(TRANSACTIONAL);
    metaCcfg.setWriteSynchronizationMode(FULL_SYNC);

    // File system configuration.
    FileSystemConfiguration igfsCfg = new FileSystemConfiguration();

    igfsCfg.setDefaultMode(IgfsMode.PRIMARY);
    igfsCfg.setFragmentizerEnabled(false);
    igfsCfg.setBlockSize(1024);
    igfsCfg.setDataCacheConfiguration(dataCcfg);
    igfsCfg.setMetaCacheConfiguration(metaCcfg);
    igfsCfg.setName(IGFS_NAME);

    // Ignite configuration.
    IgniteConfiguration cfg = getConfiguration(name);

    TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();

    discoSpi.setIpFinder(ipFinder);

    cfg.setDiscoverySpi(discoSpi);
    cfg.setFileSystemConfiguration(igfsCfg);

    cfg.setLocalHost("127.0.0.1");
    cfg.setConnectorConfiguration(null);

    cfg.setStripedPoolSize(2);
    cfg.setSystemThreadPoolSize(2);
    cfg.setRebalanceThreadPoolSize(1);
    cfg.setPublicThreadPoolSize(1);

    return cfg;
}
 
Example 10
Source File: IgfsCachePerBlockLruEvictionPolicySelfTest.java    From ignite with Apache License 2.0 4 votes vote down vote up
/**
 * 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);
}
 
Example 11
Source File: IgniteSqlCreateTableTemplateTest.java    From ignite with Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc} */
@Override public IgniteConfiguration getConfiguration(String name) throws Exception {
    IgniteConfiguration configuration = new IgniteConfiguration();
    configuration.setIgniteInstanceName(name);

    CacheConfiguration defaultCacheConfiguration = new CacheConfiguration();

    defaultCacheConfiguration.setName("DEFAULT_TEMPLATE*");

    CacheConfiguration customCacheConfiguration = new CacheConfiguration();

    customCacheConfiguration.setName("CUSTOM_TEMPLATE*");

    MockAffinityKeyMapper customAffinityMapper = new MockAffinityKeyMapper();

    customCacheConfiguration.setAffinityMapper(customAffinityMapper);

    configuration.setCacheConfiguration(defaultCacheConfiguration, customCacheConfiguration);

    return configuration;
}
 
Example 12
Source File: HadoopAbstractMapReduceTest.java    From ignite with Apache License 2.0 4 votes vote down vote up
/**
 * Start grid with IGFS.
 *
 * @param igniteInstanceName Ignite instance 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 igniteInstanceName, String igfsName, IgfsMode mode,
    @Nullable IgfsSecondaryFileSystem secondaryFs, @Nullable IgfsIpcEndpointConfiguration restCfg) throws Exception {
    FileSystemConfiguration igfsCfg = new FileSystemConfiguration();

    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);

    CacheConfiguration metaCacheCfg = defaultCacheConfiguration();

    metaCacheCfg.setName("metaCache");
    metaCacheCfg.setCacheMode(REPLICATED);
    metaCacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
    metaCacheCfg.setAtomicityMode(TRANSACTIONAL);

    igfsCfg.setDataCacheConfiguration(dataCacheCfg);
    igfsCfg.setMetaCacheConfiguration(metaCacheCfg);

    IgniteConfiguration cfg = new IgniteConfiguration();

    cfg.setIgniteInstanceName(igniteInstanceName);

    TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();

    discoSpi.setIpFinder(new TcpDiscoveryVmIpFinder(true));

    cfg.setDiscoverySpi(discoSpi);
    cfg.setFileSystemConfiguration(igfsCfg);

    cfg.setLocalHost("127.0.0.1");
    cfg.setConnectorConfiguration(null);

    HadoopConfiguration hadoopCfg = createHadoopConfiguration();

    if (hadoopCfg != null)
        cfg.setHadoopConfiguration(hadoopCfg);

    return G.start(cfg);
}
 
Example 13
Source File: HadoopIgfsDualAbstractSelfTest.java    From ignite with Apache License 2.0 4 votes vote down vote up
/**
 * Start grid with IGFS.
 *
 * @param igniteInstanceName Ignite instance 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 igniteInstanceName, String igfsName, IgfsMode mode,
    @Nullable IgfsSecondaryFileSystem secondaryFs, @Nullable IgfsIpcEndpointConfiguration restCfg) throws Exception {
    FileSystemConfiguration igfsCfg = new FileSystemConfiguration();

    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);

    CacheConfiguration metaCacheCfg = defaultCacheConfiguration();

    metaCacheCfg.setName("metaCache");
    metaCacheCfg.setCacheMode(REPLICATED);
    metaCacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
    metaCacheCfg.setAtomicityMode(TRANSACTIONAL);

    igfsCfg.setDataCacheConfiguration(dataCacheCfg);
    igfsCfg.setMetaCacheConfiguration(metaCacheCfg);

    IgniteConfiguration cfg = new IgniteConfiguration();

    cfg.setIgniteInstanceName(igniteInstanceName);

    TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();

    discoSpi.setIpFinder(new TcpDiscoveryVmIpFinder(true));

    cfg.setDiscoverySpi(discoSpi);
    cfg.setFileSystemConfiguration(igfsCfg);

    cfg.setLocalHost("127.0.0.1");
    cfg.setConnectorConfiguration(null);

    return G.start(cfg);
}
 
Example 14
Source File: IgfsCachePerBlockLruEvictionPolicySelfTest.java    From ignite with Apache License 2.0 4 votes vote down vote up
/**
 * 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());
}
 
Example 15
Source File: IgfsMetricsSelfTest.java    From ignite with Apache License 2.0 4 votes vote down vote up
/**
 * Start a grid with the secondary file system.
 *
 * @throws Exception If failed.
 */
@SuppressWarnings("unchecked")
private void startSecondary() throws Exception {
    FileSystemConfiguration igfsCfg = new FileSystemConfiguration();

    igfsCfg.setName(IGFS_SECONDARY);
    igfsCfg.setBlockSize(SECONDARY_BLOCK_SIZE);
    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");

    Ignite g = G.start(cfg);

    igfsSecondary = (IgfsImpl)g.fileSystem(IGFS_SECONDARY);
}
 
Example 16
Source File: IgfsOneClientNodeTest.java    From ignite with Apache License 2.0 4 votes vote down vote up
/** */
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;
}
 
Example 17
Source File: IgfsModesSelfTest.java    From ignite with Apache License 2.0 4 votes vote down vote up
/**
 * Startup secondary file system.
 *
 * @throws Exception If failed.
 */
private void startUpSecondary() throws Exception {
    FileSystemConfiguration igfsCfg = new FileSystemConfiguration();

    igfsCfg.setName("igfs-secondary");
    igfsCfg.setBlockSize(512 * 1024);
    igfsCfg.setDefaultMode(PRIMARY);

    IgfsIpcEndpointConfiguration endpointCfg = new IgfsIpcEndpointConfiguration();

    endpointCfg.setType(IgfsIpcEndpointType.TCP);
    endpointCfg.setPort(11500);

    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.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
    metaCacheCfg.setAtomicityMode(TRANSACTIONAL);

    igfsCfg.setMetaCacheConfiguration(metaCacheCfg);
    igfsCfg.setDataCacheConfiguration(dataCacheCfg);

    IgniteConfiguration cfg = new IgniteConfiguration();

    cfg.setIgniteInstanceName("igfs-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);

    igfsSecondary = (IgfsImpl)G.start(cfg).fileSystem("igfs-secondary");
}
 
Example 18
Source File: IgfsAbstractBaseSelfTest.java    From ignite with Apache License 2.0 4 votes vote down vote up
/**
 * Start grid with IGFS.
 *
 * @param igniteInstanceName Ignite instance name.
 * @param igfsName IGFS name
 * @param mode IGFS mode.
 * @param secondaryFs Secondary file system (optional).
 * @param restCfg Rest configuration string (optional).
 * @param ipFinder IP finder.
 * @return Started grid instance.
 * @throws Exception If failed.
 */
@SuppressWarnings("unchecked")
protected Ignite startGridWithIgfs(String igniteInstanceName, String igfsName, IgfsMode mode,
    @Nullable IgfsSecondaryFileSystem secondaryFs, @Nullable IgfsIpcEndpointConfiguration restCfg,
    TcpDiscoveryIpFinder ipFinder) throws Exception {
    FileSystemConfiguration igfsCfg = new FileSystemConfiguration();

    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);
    igfsCfg.setRelaxedConsistency(relaxedConsistency());
    igfsCfg.setFragmentizerEnabled(fragmentizerEnabled());

    CacheConfiguration dataCacheCfg = defaultCacheConfiguration();

    dataCacheCfg.setNearConfiguration(null);
    dataCacheCfg.setCacheMode(PARTITIONED);
    dataCacheCfg.setNearConfiguration(null);
    dataCacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
    dataCacheCfg.setAffinityMapper(new IgfsGroupDataBlocksKeyMapper(2));
    dataCacheCfg.setBackups(0);
    dataCacheCfg.setAtomicityMode(TRANSACTIONAL);

    CacheConfiguration metaCacheCfg = defaultCacheConfiguration();

    metaCacheCfg.setNearConfiguration(null);
    metaCacheCfg.setCacheMode(REPLICATED);
    metaCacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
    metaCacheCfg.setAtomicityMode(TRANSACTIONAL);

    prepareCacheConfigurations(dataCacheCfg, metaCacheCfg);

    igfsCfg.setDataCacheConfiguration(dataCacheCfg);
    igfsCfg.setMetaCacheConfiguration(metaCacheCfg);

    IgniteConfiguration cfg = new IgniteConfiguration();

    cfg.setIgniteInstanceName(igniteInstanceName);

    TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();

    discoSpi.setIpFinder(ipFinder);

    cfg.setDiscoverySpi(discoSpi);
    cfg.setFileSystemConfiguration(igfsCfg);

    cfg.setLocalHost("127.0.0.1");
    cfg.setConnectorConfiguration(null);

    return G.start(cfg);
}
 
Example 19
Source File: HadoopIgfs20FileSystemAbstractSelfTest.java    From ignite with Apache License 2.0 4 votes vote down vote up
/**
 * Starts the nodes for this test.
 *
 * @throws Exception If failed.
 */
private void startNodes() throws Exception {
    if (mode != PRIMARY) {
        // Start secondary IGFS.
        FileSystemConfiguration igfsCfg = new FileSystemConfiguration();

        igfsCfg.setName("igfs_secondary");
        igfsCfg.setIpcEndpointConfiguration(secondaryIpcEndpointConfiguration());
        igfsCfg.setManagementPort(-1);
        igfsCfg.setBlockSize(512 * 1024);
        igfsCfg.setPrefetchBlocks(1);

        CacheConfiguration dataCacheCfg = defaultCacheConfiguration();

        dataCacheCfg.setName("partitioned");
        dataCacheCfg.setCacheMode(PARTITIONED);
        dataCacheCfg.setNearConfiguration(null);
        dataCacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
        dataCacheCfg.setAffinityMapper(new IgfsGroupDataBlocksKeyMapper(GRP_SIZE));
        dataCacheCfg.setBackups(0);
        dataCacheCfg.setAtomicityMode(TRANSACTIONAL);

        CacheConfiguration metaCacheCfg = defaultCacheConfiguration();

        metaCacheCfg.setName("replicated");
        metaCacheCfg.setCacheMode(REPLICATED);
        metaCacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
        metaCacheCfg.setAtomicityMode(TRANSACTIONAL);

        igfsCfg.setDataCacheConfiguration(dataCacheCfg);
        igfsCfg.setMetaCacheConfiguration(metaCacheCfg);

        IgniteConfiguration cfg = new IgniteConfiguration();

        cfg.setIgniteInstanceName("grid_secondary");

        TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();

        discoSpi.setIpFinder(new TcpDiscoveryVmIpFinder(true));

        cfg.setDiscoverySpi(discoSpi);
        cfg.setCacheConfiguration(metaCacheCfg, dataCacheCfg);
        cfg.setFileSystemConfiguration(igfsCfg);
        cfg.setIncludeEventTypes(EVT_TASK_FAILED, EVT_TASK_FINISHED, EVT_JOB_MAPPED);
        cfg.setLocalHost(U.getLocalHost().getHostAddress());
        cfg.setCommunicationSpi(communicationSpi());

        G.start(cfg);
    }

    startGrids(4);

    awaitPartitionMapExchange();
}
 
Example 20
Source File: IgniteHadoopFileSystemLoggerStateSelfTest.java    From ignite with Apache License 2.0 2 votes vote down vote up
/**
 * Startup the grid and instantiate the file system.
 *
 * @throws Exception If failed.
 */
private void startUp() throws Exception {
    FileSystemConfiguration igfsCfg = new FileSystemConfiguration();

    igfsCfg.setName("igfs");
    igfsCfg.setBlockSize(512 * 1024);
    igfsCfg.setDefaultMode(PRIMARY);

    IgfsIpcEndpointConfiguration endpointCfg = new IgfsIpcEndpointConfiguration();

    endpointCfg.setType(IgfsIpcEndpointType.TCP);
    endpointCfg.setPort(10500);

    igfsCfg.setIpcEndpointConfiguration(endpointCfg);

    CacheConfiguration dataCacheCfg = defaultCacheConfiguration();

    dataCacheCfg.setName("partitioned");
    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.setName("replicated");
    metaCacheCfg.setCacheMode(REPLICATED);
    metaCacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
    metaCacheCfg.setAtomicityMode(TRANSACTIONAL);

    igfsCfg.setDataCacheConfiguration(dataCacheCfg);
    igfsCfg.setMetaCacheConfiguration(metaCacheCfg);

    IgniteConfiguration cfg = new IgniteConfiguration();

    cfg.setIgniteInstanceName("igfs-grid");

    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);

    igfs = (IgfsEx)g.fileSystem("igfs");

    igfs.globalSampling(sampling);

    fs = fileSystem();
}