Search in sources :

Example 41 with CacheSimpleConfig

use of com.hazelcast.config.CacheSimpleConfig in project hazelcast by hazelcast.

the class CacheQuorumConfigTest method cacheConfigXmlTest.

@Test
public void cacheConfigXmlTest() throws IOException {
    final String cacheName = "configtestCache" + randomString();
    Config config = new XmlConfigBuilder(configUrl).build();
    CacheSimpleConfig cacheConfig1 = config.getCacheConfig(cacheName);
    final String quorumName = cacheConfig1.getQuorumName();
    assertEquals("cache-quorum", quorumName);
    QuorumConfig quorumConfig = config.getQuorumConfig(quorumName);
    assertEquals(3, quorumConfig.getSize());
    assertEquals(QuorumType.READ_WRITE, quorumConfig.getType());
}
Also used : QuorumConfig(com.hazelcast.config.QuorumConfig) CacheSimpleConfig(com.hazelcast.config.CacheSimpleConfig) XmlConfigBuilder(com.hazelcast.config.XmlConfigBuilder) Config(com.hazelcast.config.Config) CacheSimpleConfig(com.hazelcast.config.CacheSimpleConfig) QuorumConfig(com.hazelcast.config.QuorumConfig) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 42 with CacheSimpleConfig

use of com.hazelcast.config.CacheSimpleConfig in project hazelcast by hazelcast.

the class TestJCache method cacheConfigXmlTest_ClusterQuorum.

@Test
public void cacheConfigXmlTest_ClusterQuorum() {
    assertNotNull(instance1);
    CacheSimpleConfig simpleConfig = instance1.getConfig().getCacheConfig("cacheWithQuorumRef");
    assertNotNull(simpleConfig);
    assertEquals("cacheQuorumRefString", simpleConfig.getQuorumName());
}
Also used : CacheSimpleConfig(com.hazelcast.config.CacheSimpleConfig) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 43 with CacheSimpleConfig

use of com.hazelcast.config.CacheSimpleConfig in project hazelcast by hazelcast.

the class ClientCacheWriteQuorumTest method initialize.

@BeforeClass
public static void initialize() throws Exception {
    QuorumConfig quorumConfig = new QuorumConfig();
    quorumConfig.setName(QUORUM_ID);
    quorumConfig.setType(QuorumType.WRITE);
    quorumConfig.setEnabled(true);
    quorumConfig.setSize(3);
    CacheSimpleConfig cacheConfig = new CacheSimpleConfig();
    cacheConfig.setName(CACHE_NAME_PREFIX + "*");
    cacheConfig.setQuorumName(QUORUM_ID);
    factory = new TestHazelcastFactory();
    cluster = new PartitionedCluster(factory).createFiveMemberCluster(cacheConfig, quorumConfig);
    initializeClients();
    initializeCaches();
    cluster.splitFiveMembersThreeAndTwo();
    verifyClients();
}
Also used : QuorumConfig(com.hazelcast.config.QuorumConfig) CacheSimpleConfig(com.hazelcast.config.CacheSimpleConfig) TestHazelcastFactory(com.hazelcast.client.test.TestHazelcastFactory) PartitionedCluster(com.hazelcast.quorum.PartitionedCluster) BeforeClass(org.junit.BeforeClass)

Example 44 with CacheSimpleConfig

use of com.hazelcast.config.CacheSimpleConfig in project hazelcast by hazelcast.

the class AbstractCacheService method createDistributedObject.

@Override
public DistributedObject createDistributedObject(String fullCacheName) {
    try {
        /*
             * In here, `fullCacheName` is the full cache name.
             * Full cache name contains, Hazelcast prefix, cache name prefix and pure cache name.
             */
        if (fullCacheName.equals(SETUP_REF)) {
            // workaround to make clients older than 3.7 to work with 3.7+ servers due to changes in the cache init!
            CacheSimpleConfig cacheSimpleConfig = new CacheSimpleConfig();
            cacheSimpleConfig.setName("setupRef");
            CacheConfig cacheConfig = new CacheConfig(cacheSimpleConfig);
            cacheConfig.setManagerPrefix(HazelcastCacheManager.CACHE_MANAGER_PREFIX);
            return new CacheProxy(cacheConfig, nodeEngine, this);
        } else {
            // At first, lookup cache name in the created cache configs.
            CacheConfig cacheConfig = getCacheConfig(fullCacheName);
            if (cacheConfig == null) {
                /*
                     * Prefixed cache name contains cache name prefix and pure cache name, but not Hazelcast prefix (`/hz/`).
                     * Cache name prefix is generated by using specified URI and classloader scopes.
                     * This means, if there is no specified URI and classloader, prefixed cache name is pure cache name.
                     * This means, if there is no specified URI and classloader, prefixed cache name is pure cache name.
                     */
                // If cache config is not created yet, remove Hazelcast prefix and get prefixed cache name.
                String cacheName = fullCacheName.substring(HazelcastCacheManager.CACHE_MANAGER_PREFIX.length());
                // Lookup prefixed cache name in the config.
                cacheConfig = findCacheConfig(cacheName);
                checkCacheSimpleConfig(cacheName, cacheConfig);
                cacheConfig.setManagerPrefix(HazelcastCacheManager.CACHE_MANAGER_PREFIX);
            }
            checkCacheConfig(fullCacheName, cacheConfig);
            putCacheConfigIfAbsent(cacheConfig);
            return new CacheProxy(cacheConfig, nodeEngine, this);
        }
    } catch (Throwable t) {
        throw ExceptionUtil.rethrow(t);
    }
}
Also used : CacheSimpleConfig(com.hazelcast.config.CacheSimpleConfig) CacheConfig(com.hazelcast.config.CacheConfig)

Example 45 with CacheSimpleConfig

use of com.hazelcast.config.CacheSimpleConfig in project hazelcast by hazelcast.

the class PartitionedCluster method createFiveMemberCluster.

public PartitionedCluster createFiveMemberCluster(CacheSimpleConfig cacheSimpleConfig, QuorumConfig quorumConfig) {
    Config config = createClusterConfig().addCacheConfig(cacheSimpleConfig).addQuorumConfig(quorumConfig);
    createInstances(config);
    return this;
}
Also used : Config(com.hazelcast.config.Config) QueueConfig(com.hazelcast.config.QueueConfig) CacheSimpleConfig(com.hazelcast.config.CacheSimpleConfig) LockConfig(com.hazelcast.config.LockConfig) MapConfig(com.hazelcast.config.MapConfig) QuorumConfig(com.hazelcast.config.QuorumConfig)

Aggregations

CacheSimpleConfig (com.hazelcast.config.CacheSimpleConfig)84 Test (org.junit.Test)41 Config (com.hazelcast.config.Config)40 QuickTest (com.hazelcast.test.annotation.QuickTest)37 EvictionConfig (com.hazelcast.config.EvictionConfig)17 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)17 BeforeClass (org.junit.BeforeClass)16 CachePartitionLostListenerConfig (com.hazelcast.config.CachePartitionLostListenerConfig)15 MapConfig (com.hazelcast.config.MapConfig)11 ClientConfig (com.hazelcast.client.config.ClientConfig)10 EventJournalConfig (com.hazelcast.config.EventJournalConfig)10 MergePolicyConfig (com.hazelcast.config.MergePolicyConfig)10 HazelcastInstance (com.hazelcast.core.HazelcastInstance)10 ExpiryPolicyFactoryConfig (com.hazelcast.config.CacheSimpleConfig.ExpiryPolicyFactoryConfig)9 QuorumConfig (com.hazelcast.config.QuorumConfig)9 CacheConfig (com.hazelcast.config.CacheConfig)8 TimedExpiryPolicyFactoryConfig (com.hazelcast.config.CacheSimpleConfig.ExpiryPolicyFactoryConfig.TimedExpiryPolicyFactoryConfig)8 QueueConfig (com.hazelcast.config.QueueConfig)8 CacheSimpleEntryListenerConfig (com.hazelcast.config.CacheSimpleEntryListenerConfig)7 CardinalityEstimatorConfig (com.hazelcast.config.CardinalityEstimatorConfig)7