Java Code Examples for org.apache.ignite.configuration.IgniteConfiguration#setCacheConfiguration()

The following examples show how to use org.apache.ignite.configuration.IgniteConfiguration#setCacheConfiguration() . 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: GridCachePartitionedNodeRestartTxSelfTest.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 = defaultCacheConfiguration();

    cacheCfg.setCacheMode(PARTITIONED);
    cacheCfg.setWriteSynchronizationMode(FULL_SYNC);
    cacheCfg.setAtomicityMode(TRANSACTIONAL);
    cacheCfg.setRebalanceMode(SYNC);
    cacheCfg.setBackups(1);

    cfg.setCacheConfiguration(cacheCfg);

    AtomicConfiguration atomicCfg = new AtomicConfiguration();

    atomicCfg.setCacheMode(PARTITIONED);
    atomicCfg.setGroupName("testGroup");
    atomicCfg.setBackups(1);

    cfg.setAtomicConfiguration(atomicCfg);

    return cfg;
}
 
Example 2
Source File: GridCacheMultiNodeLoadTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);

    CacheConfiguration cacheCfg = defaultCacheConfiguration();

    cacheCfg.setName(CACHE_NAME);
    cacheCfg.setCacheMode(PARTITIONED);
    cacheCfg.setNearConfiguration(null);
    cacheCfg.setWriteSynchronizationMode(FULL_SYNC);

    LruEvictionPolicy plc = new LruEvictionPolicy();
    plc.setMaxSize(100000);

    cacheCfg.setEvictionPolicy(plc);
    cacheCfg.setOnheapCacheEnabled(true);
    cacheCfg.setBackups(1);

    cacheCfg.setRebalanceMode(SYNC);

    cfg.setCacheConfiguration(cacheCfg);

    return cfg;
}
 
Example 3
Source File: GridCacheColocatedOptimisticTransactionSelfTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration c = super.getConfiguration(igniteInstanceName);

    c.getTransactionConfiguration().setTxSerializableEnabled(true);

    CacheConfiguration cc = new CacheConfiguration(DEFAULT_CACHE_NAME);

    cc.setName(CACHE);
    cc.setCacheMode(PARTITIONED);
    cc.setAtomicityMode(TRANSACTIONAL);
    cc.setNearConfiguration(null);
    cc.setBackups(1);
    cc.setWriteSynchronizationMode(FULL_SYNC);

    c.setCacheConfiguration(cc);

    return c;
}
 
Example 4
Source File: CacheMvccProcessorLazyStartTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/**
 * @throws Exception If failed.
 */
@Test
public void testPreconfiguredCacheMvccStarted() throws Exception {
    CacheConfiguration ccfg = cacheConfiguration(CacheMode.PARTITIONED, CacheWriteSynchronizationMode.FULL_SYNC, 0, 1);

    IgniteConfiguration cfg1 = getConfiguration();
    cfg1.setCacheConfiguration(ccfg);
    IgniteConfiguration cfg2 = getConfiguration("node2");

    IgniteEx node1 = startGrid(cfg1);
    IgniteEx node2 = startGrid(cfg2);

    IgniteCache cache = node1.cache(ccfg.getName());

    cache.put(1, 1);
    cache.put(1, 2);

    assertTrue(mvccEnabled(node1));
    assertTrue(mvccEnabled(node2));
}
 
Example 5
Source File: GridCachePreloadingEvictionsSelfTest.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 partCacheCfg = defaultCacheConfiguration();

    partCacheCfg.setCacheMode(PARTITIONED);
    partCacheCfg.setAffinity(new GridCacheModuloAffinityFunction(1, 1));
    partCacheCfg.setWriteSynchronizationMode(FULL_SYNC);
    partCacheCfg.setNearConfiguration(null);
    partCacheCfg.setEvictionPolicy(null);
    partCacheCfg.setRebalanceMode(ASYNC);
    partCacheCfg.setAtomicityMode(TRANSACTIONAL);

    // This test requires artificial slowing down of the preloading.
    partCacheCfg.setRebalanceThrottle(2000);

    cfg.setCacheConfiguration(partCacheCfg);

    cfg.setUserAttributes(F.asMap(GridCacheModuloAffinityFunction.IDX_ATTR, idxGen.getAndIncrement()));

    cfg.setNetworkTimeout(60000);

    return cfg;
}
 
Example 6
Source File: JdbcThinPartitionAwarenessSelfTest.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<?,?> cache = defaultCacheConfiguration();

    cache.setCacheMode(PARTITIONED);
    cache.setBackups(1);
    cache.setIndexedTypes(
        Integer.class, Person.class
    );

    cfg.setCacheConfiguration(cache);

    return cfg;
}
 
Example 7
Source File: GridCacheStoreManagerDeserializationTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(final String igniteInstanceName) throws Exception {
    IgniteConfiguration c = super.getConfiguration(igniteInstanceName);

    if (igniteInstanceName != null && igniteInstanceName.toLowerCase().startsWith("binary"))
        c.setMarshaller(new BinaryMarshaller());
    else
        c.setMarshaller(new JdkMarshaller());

    c.setCacheConfiguration(cacheConfiguration());

    return c;
}
 
Example 8
Source File: IgniteBaselineAffinityTopologyActivationTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);

    if (consId != null)
        cfg.setConsistentId(consId);

    cfg.setDataStorageConfiguration(
        new DataStorageConfiguration().setDefaultDataRegionConfiguration(
            new DataRegionConfiguration()
                .setPersistenceEnabled(true).setMaxSize(10L * 1024 * 1024)

        ).setWalMode(WALMode.LOG_ONLY)
    );

    cfg.setCommunicationSpi(new SingleMessageInterceptorCommunicationSpi());

    cfg.setCacheConfiguration(new CacheConfiguration<Integer, Integer>()
        .setName(CACHE_NAME)
        .setCacheMode(PARTITIONED)
        .setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL)
        .setBackups(1)
        .setAffinity(new RendezvousAffinityFunction(32, null))
    );

    return cfg;
}
 
Example 9
Source File: IgniteClientReconnectCacheQueriesFailoverTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);

    CacheConfiguration<Object, Object> ccfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME);

    ccfg.setCacheMode(PARTITIONED);
    ccfg.setBackups(1);
    ccfg.setIndexedTypes(Integer.class, Person.class);

    cfg.setCacheConfiguration(ccfg);

    return cfg;
}
 
Example 10
Source File: IgnitePdsWholeClusterRestartTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(gridName);

    DataStorageConfiguration memCfg = new DataStorageConfiguration()
        .setDefaultDataRegionConfiguration(
            new DataRegionConfiguration().setMaxSize(100L * 1024 * 1024).setPersistenceEnabled(true))
        .setWalMode(WALMode.LOG_ONLY);

    cfg.setDataStorageConfiguration(memCfg);

    CacheConfiguration ccfg1 = defaultCacheConfiguration();

    ccfg1.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
    ccfg1.setRebalanceMode(CacheRebalanceMode.SYNC);
    ccfg1.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
    ccfg1.setAffinity(new RendezvousAffinityFunction(false, 32));
    ccfg1.setBackups(2);

    cfg.setActiveOnStart(false);

    // To avoid hostname lookup on start.
    cfg.setCheckpointSpi(new NoopCheckpointSpi());

    cfg.setCacheConfiguration(ccfg1);

    cfg.setConsistentId(gridName);

    return cfg;
}
 
Example 11
Source File: IgniteCacheNearOnlyTxTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);

    if (getTestIgniteInstanceName(1).equals(igniteInstanceName)) {
        cfg.setClientMode(true);

        cfg.setCacheConfiguration();
    }

    return cfg;
}
 
Example 12
Source File: CacheScanPartitionQueryFallbackSelfTest.java    From ignite with Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);

    ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setForceServerMode(true);

    cfg.setCommunicationSpi(commSpiFactory.create());

    CacheConfiguration ccfg = defaultCacheConfiguration();
    ccfg.setCacheMode(cacheMode);
    ccfg.setAtomicityMode(CacheAtomicityMode.ATOMIC);
    ccfg.setBackups(backups);

    if (syncRebalance)
        ccfg.setRebalanceMode(CacheRebalanceMode.SYNC);

    ccfg.setNearConfiguration(null);

    cfg.setCacheConfiguration(ccfg);

    return cfg;
}
 
Example 13
Source File: ClientAffinityAssignmentWithBaselineTest.java    From ignite with Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);

    if (!igniteInstanceName.startsWith(CLIENT_GRID_NAME)) {
        cfg.setDataStorageConfiguration(
            new DataStorageConfiguration()
                .setWalSegmentSize(4 * 1024 * 1024)
                .setDefaultDataRegionConfiguration(
                    new DataRegionConfiguration()
                        .setPersistenceEnabled(true)
                        .setMaxSize(200 * 1024 * 1024)
                )
        );
    }

    if (igniteInstanceName.contains(FLAKY_NODE_NAME)) {
        File store = U.resolveWorkDirectory(U.defaultWorkDirectory(), DFLT_STORE_DIR, false);

        cfg.getDataStorageConfiguration().setWalPath(new File(store, FLAKY_WAL_PATH).getAbsolutePath());
        cfg.getDataStorageConfiguration().setWalArchivePath(new File(store, FLAKY_WAL_ARCHIVE_PATH).getAbsolutePath());
        cfg.getDataStorageConfiguration().setStoragePath(new File(store, FLAKY_STORAGE_PATH).getAbsolutePath());
    }

    cfg.setConsistentId(igniteInstanceName);

    List<CacheConfiguration> srvConfigs = new ArrayList<>();
    srvConfigs.add(cacheConfig(PARTITIONED_TX_CACHE_NAME));
    srvConfigs.add(cacheConfig(PARTITIONED_TX_PRIM_SYNC_CACHE_NAME));
    srvConfigs.add(cacheConfig(REPLICATED_ATOMIC_CACHE_NAME));

    List<CacheConfiguration> clientConfigs = new ArrayList<>(srvConfigs);

    // Skip some configs in client static configuration to check that clients receive correct cache descriptors.
    srvConfigs.add(cacheConfig(PARTITIONED_ATOMIC_CACHE_NAME));
    srvConfigs.add(cacheConfig(REPLICATED_TX_CACHE_NAME));

    // Skip config in server static configuration to check that caches received on client join start correctly.
    clientConfigs.add(cacheConfig(PARTITIONED_TX_CLIENT_CACHE_NAME));

    if (igniteInstanceName.startsWith(CLIENT_GRID_NAME))
        cfg.setCacheConfiguration(clientConfigs.toArray(new CacheConfiguration[clientConfigs.size()]));
    else
        cfg.setCacheConfiguration(srvConfigs.toArray(new CacheConfiguration[srvConfigs.size()]));

    // Enforce different mac adresses to emulate distributed environment by default.
    cfg.setUserAttributes(Collections.singletonMap(
        IgniteNodeAttributes.ATTR_MACS_OVERRIDE, UUID.randomUUID().toString()));

    return cfg;
}
 
Example 14
Source File: IoStatisticsCacheSelfTest.java    From ignite with Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String name) throws Exception {
    final IgniteConfiguration cfg = super.getConfiguration(name);

    cfg.setConsistentId("consistentId");

    final CacheConfiguration atomicCacheCfg = new CacheConfiguration()
        .setAtomicityMode(CacheAtomicityMode.ATOMIC)
        .setName(ATOMIC_CACHE_NAME);

    final CacheConfiguration mvccCacheCfg = new CacheConfiguration()
        .setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT)
        .setName(MVCC_CACHE_NAME);

    final CacheConfiguration transactionalCacheCfg = new CacheConfiguration()
        .setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL)
        .setName(TRANSACTIONAL_CACHE_NAME);

    final CacheConfiguration atomic1CacheGrpCfg = new CacheConfiguration()
        .setAtomicityMode(CacheAtomicityMode.ATOMIC)
        .setName(CACHE1_IN_GROUP_NAME)
        .setGroupName(CACHE_GROUP_NAME);

    final CacheConfiguration atomic2CacheGrpCfg = new CacheConfiguration()
        .setAtomicityMode(CacheAtomicityMode.ATOMIC)
        .setName(CACHE2_IN_GROUP_NAME)
        .setGroupName(CACHE_GROUP_NAME);

    DataStorageConfiguration dsCfg = new DataStorageConfiguration()
        .setDefaultDataRegionConfiguration(
            new DataRegionConfiguration()
                .setMaxSize(100L * 1024 * 1024)
                .setPersistenceEnabled(persist()))
        .setPageSize(4 * 1024)
        .setWalMode(WALMode.NONE);

    cfg.setDataStorageConfiguration(dsCfg);

    cfg.setCacheConfiguration(transactionalCacheCfg, atomicCacheCfg, mvccCacheCfg,
        atomic1CacheGrpCfg, atomic2CacheGrpCfg);

    return cfg;
}
 
Example 15
Source File: GridCachePutAllFailoverSelfTest.java    From ignite with Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);

    ((TcpCommunicationSpi)cfg.getCommunicationSpi()).setSharedMemoryPort(-1);

    cfg.setPeerClassLoadingEnabled(false);

    cfg.setDeploymentMode(DeploymentMode.CONTINUOUS);

    TcpDiscoverySpi discoverySpi = (TcpDiscoverySpi)cfg.getDiscoverySpi();

    discoverySpi.setAckTimeout(60000);
    discoverySpi.setForceServerMode(true);

    cfg.setDiscoverySpi(discoverySpi);

    if (igniteInstanceName.startsWith("master")) {
        cfg.setUserAttributes(ImmutableMap.of("segment", "master"));

        // For sure.
        failoverSpi.setMaximumFailoverAttempts(100);

        cfg.setFailoverSpi(failoverSpi);
    }
    else if (igniteInstanceName.startsWith("worker")) {
        cfg.setUserAttributes(ImmutableMap.of("segment", "worker"));

        CacheConfiguration cacheCfg = defaultCacheConfiguration();
        cacheCfg.setName("partitioned");
        cacheCfg.setAtomicityMode(atomicityMode());
        cacheCfg.setCacheMode(PARTITIONED);

        cacheCfg.setBackups(backups);

        cacheCfg.setNearConfiguration(nearEnabled ? new NearCacheConfiguration() : null);

        cacheCfg.setWriteSynchronizationMode(FULL_SYNC);

        cfg.setCacheConfiguration(cacheCfg);
    }
    else
        throw new IllegalStateException("Unexpected Ignite instance name: " + igniteInstanceName);

    return cfg;
}
 
Example 16
Source File: GridCacheWriteBehindStoreAbstractTest.java    From ignite with Apache License 2.0 3 votes vote down vote up
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Override protected IgniteConfiguration getConfiguration() throws Exception {
    MvccFeatureChecker.skipIfNotSupported(MvccFeatureChecker.Feature.CACHE_STORE);

    IgniteConfiguration c = super.getConfiguration();

    TcpDiscoverySpi disco = new TcpDiscoverySpi();

    disco.setIpFinder(new TcpDiscoveryVmIpFinder(true));

    c.setDiscoverySpi(disco);

    CacheConfiguration cc = defaultCacheConfiguration();

    cc.setCacheMode(cacheMode());
    cc.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
    cc.setAtomicityMode(TRANSACTIONAL);

    cc.setCacheStoreFactory(singletonFactory(store));
    cc.setReadThrough(true);
    cc.setWriteThrough(true);
    cc.setLoadPreviousValue(true);

    cc.setWriteBehindEnabled(true);
    cc.setWriteBehindFlushFrequency(WRITE_FROM_BEHIND_FLUSH_FREQUENCY);

    c.setCacheConfiguration(cc);

    return c;
}
 
Example 17
Source File: IgniteCacheFullTextQueryNodeJoiningSelfTest.java    From ignite with Apache License 2.0 3 votes vote down vote up
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);

    CacheConfiguration cache = new CacheConfiguration(DEFAULT_CACHE_NAME);

    cache.setCacheMode(PARTITIONED);
    cache.setAtomicityMode(atomicityMode());
    cache.setWriteSynchronizationMode(FULL_SYNC);
    cache.setBackups(1);
    cache.setRebalanceMode(CacheRebalanceMode.SYNC);

    QueryEntity qryEntity = new QueryEntity();

    qryEntity.setKeyType(AffinityKey.class.getName());
    qryEntity.setValueType(IndexedEntity.class.getName());

    LinkedHashMap<String, String> fields = new LinkedHashMap<>();

    fields.put("val", String.class.getName());

    qryEntity.setFields(fields);

    qryEntity.setIndexes(Arrays.asList(new QueryIndex("val", QueryIndexType.FULLTEXT)));

    cache.setQueryEntities(Arrays.asList(qryEntity));

    cfg.setCacheConfiguration(cache);

    TcpCommunicationSpi commSpi = new TcpCommunicationSpi();

    commSpi.setSharedMemoryPort(-1);

    cfg.setCommunicationSpi(commSpi);

    return cfg;
}
 
Example 18
Source File: ClusterStateNoRebalanceAbstractTest.java    From ignite with Apache License 2.0 3 votes vote down vote up
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(gridName);

    cfg.setActiveOnStart(false);

    cfg.setCacheConfiguration(cacheConfiguration(DEFAULT_CACHE_NAME));

    cfg.setClientMode(gridName.startsWith("client"));

    cfg.setCommunicationSpi(new TestCommunicationSpi());

    return cfg;
}
 
Example 19
Source File: IgniteAtomicLongApiAbstractSelfTest.java    From ignite with Apache License 2.0 3 votes vote down vote up
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);

    CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME);

    ccfg.setName(TRANSACTIONAL_CACHE_NAME);
    ccfg.setAtomicityMode(TRANSACTIONAL);

    cfg.setCacheConfiguration(ccfg);

    return cfg;
}
 
Example 20
Source File: GridCacheReplicatedBasicApiTest.java    From ignite with Apache License 2.0 3 votes vote down vote up
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);

    CacheConfiguration cacheCfg = defaultCacheConfiguration();

    cacheCfg.setCacheMode(REPLICATED);

    cfg.setCacheConfiguration(cacheCfg);

    return cfg;
}