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

The following examples show how to use org.apache.ignite.configuration.CacheConfiguration#setGroupName() . 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: IgniteTopologyValidatorGridSplitCacheTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/**  */
protected Collection<CacheConfiguration> getCacheConfigurations() {
    CacheConfiguration[] ccfgs = new CacheConfiguration[CACHES_CNT];

    for (int cnt = 0; cnt < CACHES_CNT; cnt++) {
        CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME);

        ccfg.setName(testCacheName(cnt));
        ccfg.setCacheMode(PARTITIONED);
        ccfg.setWriteSynchronizationMode(PRIMARY_SYNC);
        ccfg.setBackups(0);
        ccfg.setTopologyValidator(new SplitAwareTopologyValidator());

        if (useCacheGrp)
            ccfg.setGroupName("testGroup");

        ccfgs[cnt] = ccfg;
    }

    return Arrays.asList(ccfgs);
}
 
Example 2
Source File: TxOnCachesStopTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a list of cache configurations.
 *
 * @return List of cache configurations.
 */
private List<CacheConfiguration> createCacheConfigurations() {
    String GRP_NAME = "test-destroy-group";

    List<CacheConfiguration> cacheCfgs = new ArrayList<>(CACHE_CNT);

    for (int i = 0; i < CACHE_CNT; ++i) {
        CacheConfiguration<Integer, byte[]> c = new CacheConfiguration<>("test-cache-" + i);
        c.setBackups(2);
        c.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
        c.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
        c.setAffinity(new RendezvousAffinityFunction(false, 32));
        c.setGroupName(GRP_NAME);

        cacheCfgs.add(c);
    }

    return cacheCfgs;
}
 
Example 3
Source File: IgniteDynamicClientCacheStartSelfTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/**
 * @param grp Group name.
 * @param atomicityMode Atomicity mode.
 * @return Cache configurations.
 */
private List<CacheConfiguration> cacheConfigurations(@Nullable String grp, CacheAtomicityMode atomicityMode) {
    List<CacheConfiguration> ccfgs = new ArrayList<>();

    for (int i = 0; i < 3; i++) {
        CacheConfiguration ccfg = new CacheConfiguration();

        ccfg.setGroupName(grp);
        ccfg.setName("cache-" + atomicityMode + "-" + i);
        ccfg.setWriteSynchronizationMode(FULL_SYNC);

        ccfgs.add(ccfg);
    }

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

    CacheConfiguration ccfg = new CacheConfiguration();

    ccfg.setName(CACHE_NAME);
    ccfg.setGroupName("Group1");
    ccfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
    ccfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
    ccfg.setAffinity(new RendezvousAffinityFunction(false, 128));
    ccfg.setBackups(2);
    ccfg.setExpiryPolicyFactory(CreatedExpiryPolicy.factoryOf(new Duration(TimeUnit.SECONDS, 1)));

    cfg.setCacheConfiguration(ccfg);

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

    CacheConfiguration ccfg2 = new CacheConfiguration();

    ccfg2.setName(CACHE_NAME);
    ccfg2.setGroupName(CACHE_GROUP_NAME);
    ccfg2.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
    ccfg2.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
    ccfg2.setAffinity(new RendezvousAffinityFunction(false, 32));
    ccfg2.setIndexedTypes(Integer.class, Integer.class);
    ccfg2.setBackups(2);

    cfg.setCacheConfiguration(ccfg2);

    return cfg;
}
 
Example 6
Source File: IgniteCacheGroupsTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/**
 * @param grpName Cache group name.
 * @param name Cache name.
 * @param cacheMode Cache mode.
 * @param atomicityMode Atomicity mode.
 * @param backups Backups number.
 * @param heapCache On heap cache flag.
 * @return Cache configuration.
 */
private CacheConfiguration cacheConfiguration(
    String grpName,
    String name,
    CacheMode cacheMode,
    CacheAtomicityMode atomicityMode,
    int backups,
    boolean heapCache
) {
    CacheConfiguration ccfg = new CacheConfiguration();

    ccfg.setName(name);
    ccfg.setGroupName(grpName);
    ccfg.setAtomicityMode(atomicityMode);
    ccfg.setBackups(backups);
    ccfg.setCacheMode(cacheMode);
    ccfg.setWriteSynchronizationMode(FULL_SYNC);
    ccfg.setOnheapCacheEnabled(heapCache);

    return ccfg;
}
 
Example 7
Source File: IgniteCacheGroupsPartitionLossPolicySelfTest.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);

    for (CacheConfiguration ccfg : cfg.getCacheConfiguration()) {
        assertNull(ccfg.getGroupName());

        ccfg.setGroupName(GROUP_NAME);
    }

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

    ccfg.setGroupName("group1");

    return ccfg;
}
 
Example 9
Source File: IgnitePdsWithTtlTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * Returns a new cache configuration with the given name and {@code GROUP_NAME} group.
 * @param name Cache name.
 * @return Cache configuration.
 */
private CacheConfiguration getCacheConfiguration(String name) {
    CacheConfiguration ccfg = new CacheConfiguration();

    ccfg.setName(name);
    ccfg.setGroupName(GROUP_NAME);
    ccfg.setAffinity(new RendezvousAffinityFunction(false, PART_SIZE));
    ccfg.setExpiryPolicyFactory(AccessedExpiryPolicy.factoryOf(new Duration(TimeUnit.SECONDS, EXPIRATION_TIMEOUT)));
    ccfg.setEagerTtl(true);
    ccfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
    ccfg.setRebalanceMode(CacheRebalanceMode.SYNC);

    return ccfg;
}
 
Example 10
Source File: CacheParallelStartTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * @param cacheName Cache name.
 * @return Cache configuration.
 */
private CacheConfiguration cacheConfiguration(String cacheName, int i) {
    CacheConfiguration cfg = defaultCacheConfiguration();

    cfg.setName(cacheName + i);
    cfg.setBackups(1);
    cfg.setGroupName(STATIC_CACHE_CACHE_GROUP_NAME + i % GROUPS_COUNT);
    cfg.setIndexedTypes(Long.class, Long.class);

    return cfg;
}
 
Example 11
Source File: CacheDiscoveryDataConcurrentJoinTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * @param cacheName Cache name.
 * @return Cache configuration.
 */
private CacheConfiguration cacheConfiguration(String cacheName) {
    CacheConfiguration ccfg = new CacheConfiguration(cacheName);

    ccfg.setName(cacheName);
    ccfg.setAtomicityMode(TRANSACTIONAL);
    ccfg.setAffinity(new RendezvousAffinityFunction(false, 16));

    if (withCacheGrp)
        ccfg.setGroupName("group1");

    return ccfg;
}
 
Example 12
Source File: GridCacheLocalAtomicWithGroupFullApiSelfTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override protected CacheConfiguration cacheConfiguration(String igniteInstanceName) throws Exception {
    CacheConfiguration ccfg = super.cacheConfiguration(igniteInstanceName);

    ccfg.setGroupName("group1");

    return ccfg;
}
 
Example 13
Source File: GridCacheLocalWithGroupFullApiSelfTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override protected CacheConfiguration cacheConfiguration(String igniteInstanceName) throws Exception {
    CacheConfiguration ccfg = super.cacheConfiguration(igniteInstanceName);

    ccfg.setGroupName("group1");

    return ccfg;
}
 
Example 14
Source File: DataStructuresProcessor.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * @param cfg Collection configuration.
 * @param name Cache name.
 * @param grpName Group name.
 * @return Cache configuration.
 */
private CacheConfiguration cacheConfiguration(CollectionConfiguration cfg, String name, String grpName) {
    CacheConfiguration ccfg = new CacheConfiguration();

    ccfg.setName(name);
    ccfg.setGroupName(grpName);
    ccfg.setBackups(cfg.getBackups());
    ccfg.setCacheMode(cfg.getCacheMode());
    ccfg.setAtomicityMode(cfg.getAtomicityMode());
    ccfg.setNodeFilter(cfg.getNodeFilter());
    ccfg.setWriteSynchronizationMode(FULL_SYNC);
    ccfg.setRebalanceMode(SYNC);

    return ccfg;
}
 
Example 15
Source File: GridCachePartitionedNearDisabledMultiNodeWithGroupFullApiSelfTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override protected CacheConfiguration cacheConfiguration(String igniteInstanceName) throws Exception {
    CacheConfiguration ccfg = super.cacheConfiguration(igniteInstanceName);

    ccfg.setGroupName("group1");

    return ccfg;
}
 
Example 16
Source File: IgniteCacheGroupsSqlTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * @param grpName Group name.
 * @param cacheName Cache name.
 * @param queryEntity Query entity.
 * @return Cache configuration.
 */
private CacheConfiguration cacheConfiguration(String grpName, String cacheName, QueryEntity queryEntity) {
    CacheConfiguration ccfg = new CacheConfiguration();

    ccfg.setWriteSynchronizationMode(FULL_SYNC);
    ccfg.setGroupName(grpName);
    ccfg.setName(cacheName);

    ccfg.setQueryEntities(F.asList(queryEntity));

    return ccfg;
}
 
Example 17
Source File: IgnitePdsSingleNodeWithIndexingAndGroupPutGetPersistenceSelfTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override protected void configure(IgniteConfiguration cfg) {
    super.configure(cfg);

    for (CacheConfiguration ccfg : cfg.getCacheConfiguration()) {
        AffinityFunction aff = ccfg.getAffinity();

        int parts = aff != null ? aff.partitions() : RendezvousAffinityFunction.DFLT_PARTITION_COUNT;

        ccfg.setGroupName("testGroup-parts" + parts);
    }
}
 
Example 18
Source File: EncryptedCacheGroupCreateTest.java    From ignite with Apache License 2.0 4 votes vote down vote up
/** @throws Exception If failed. */
@Test
public void testCreateEncryptedCacheGroup() throws Exception {
    KeystoreEncryptionKey key = createEncryptedCache(ENCRYPTED_CACHE, ENCRYPTED_GROUP);

    CacheConfiguration<Long, String> ccfg = new CacheConfiguration<>(ENCRYPTED_CACHE + "2");

    ccfg.setEncryptionEnabled(true);
    ccfg.setGroupName(ENCRYPTED_GROUP);

    IgniteEx grid = grid(0);

    grid.createCache(ccfg);

    IgniteInternalCache<Object, Object> encrypted2 = grid.cachex(ENCRYPTED_CACHE + "2");

    GridEncryptionManager encMgr = encrypted2.context().kernalContext().encryption();

    KeystoreEncryptionKey key2 = (KeystoreEncryptionKey)encMgr.groupKey(CU.cacheGroupId(ENCRYPTED_CACHE, ENCRYPTED_GROUP));

    assertNotNull(key2);
    assertNotNull(key2.key());

    assertEquals(key.key(), key2.key());
}
 
Example 19
Source File: IgniteClusterSnapshotSelfTest.java    From ignite with Apache License 2.0 4 votes vote down vote up
/** @throws Exception If fails. */
@Test
public void testClusterSnapshotWithSharedCacheGroup() throws Exception {
    CacheConfiguration<Integer, Integer> ccfg1 = txCacheConfig(new CacheConfiguration<>("tx1"));
    CacheConfiguration<Integer, Integer> ccfg2 = txCacheConfig(new CacheConfiguration<>("tx2"));

    ccfg1.setGroupName("group");
    ccfg2.setGroupName("group");

    IgniteEx ignite = startGridsWithCache(3, CACHE_KEYS_RANGE, Integer::new, ccfg1, ccfg2);

    ignite.snapshot().createSnapshot(SNAPSHOT_NAME).get();

    stopAllGrids();

    IgniteEx snp = startGridsFromSnapshot(3, SNAPSHOT_NAME);

    awaitPartitionMapExchange();

    assertSnapshotCacheKeys(snp.cache(ccfg1.getName()));
    assertSnapshotCacheKeys(snp.cache(ccfg2.getName()));
}
 
Example 20
Source File: GridCacheConfigurationValidationSelfTest.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);

    // Default cache config.
    CacheConfiguration dfltCacheCfg = defaultCacheConfiguration();

    dfltCacheCfg.setCacheMode(PARTITIONED);
    dfltCacheCfg.setRebalanceMode(ASYNC);
    dfltCacheCfg.setWriteSynchronizationMode(FULL_SYNC);
    dfltCacheCfg.setAffinity(new RendezvousAffinityFunction());
    dfltCacheCfg.setIndexedTypes(
        Integer.class, String.class
    );
    dfltCacheCfg.setName(CACHE_NAME_WITH_SPECIAL_CHARACTERS_PARTITIONED);

    // Non-default cache configuration.
    CacheConfiguration namedCacheCfg = defaultCacheConfiguration();

    namedCacheCfg.setCacheMode(PARTITIONED);
    namedCacheCfg.setRebalanceMode(ASYNC);
    namedCacheCfg.setWriteSynchronizationMode(FULL_SYNC);
    namedCacheCfg.setAffinity(new RendezvousAffinityFunction());

    // Local cache configuration.
    CacheConfiguration localCacheCfg = defaultCacheConfiguration();

    localCacheCfg.setCacheMode(LOCAL);

    // Modify cache config according to test parameters.
    if (igniteInstanceName.contains(WRONG_PRELOAD_MODE_IGNITE_INSTANCE_NAME))
        dfltCacheCfg.setRebalanceMode(SYNC);
    else if (igniteInstanceName.contains(WRONG_CACHE_MODE_IGNITE_INSTANCE_NAME))
        dfltCacheCfg.setCacheMode(REPLICATED);
    else if (igniteInstanceName.contains(WRONG_AFFINITY_IGNITE_INSTANCE_NAME))
        dfltCacheCfg.setAffinity(new TestRendezvousAffinityFunction());
    else if (igniteInstanceName.contains(WRONG_AFFINITY_MAPPER_IGNITE_INSTANCE_NAME))
        dfltCacheCfg.setAffinityMapper(new TestCacheDefaultAffinityKeyMapper());

    if (igniteInstanceName.contains(DUP_CACHES_IGNITE_INSTANCE_NAME))
        cfg.setCacheConfiguration(namedCacheCfg, namedCacheCfg);
    else if (igniteInstanceName.contains(DUP_DFLT_CACHES_IGNITE_INSTANCE_NAME))
        cfg.setCacheConfiguration(dfltCacheCfg, dfltCacheCfg);
    else {
        // Normal configuration.
        if (!cfg.isClientMode())
            cfg.setCacheConfiguration(dfltCacheCfg, namedCacheCfg, localCacheCfg);
    }

    if (igniteInstanceName.contains(RESERVED_FOR_DATASTRUCTURES_CACHE_NAME_IGNITE_INSTANCE_NAME))
        namedCacheCfg.setName(DataStructuresProcessor.ATOMICS_CACHE_NAME + "@abc");
    else {
        namedCacheCfg.setCacheMode(REPLICATED);
        namedCacheCfg.setName(CACHE_NAME_WITH_SPECIAL_CHARACTERS_REPLICATED);
    }

    if (igniteInstanceName.contains(RESERVED_FOR_DATASTRUCTURES_CACHE_GROUP_NAME_IGNITE_INSTANCE_NAME))
        namedCacheCfg.setGroupName("default-ds-group");

    return cfg;
}