Search in sources :

Example 46 with CacheSimpleConfig

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

the class CacheQuorumListenerTest method testDifferentQuorumsGetCorrectEvents.

@Test
public void testDifferentQuorumsGetCorrectEvents() {
    TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(3);
    final CountDownLatch quorumFailureLatch = new CountDownLatch(2);
    String fourNodeQuorumName = "fourNode";
    QuorumConfig fourNodeQuorumConfig = new QuorumConfig(fourNodeQuorumName, true, 4);
    fourNodeQuorumConfig.addListenerConfig(new QuorumListenerConfig(new QuorumListener() {

        public void onChange(QuorumEvent quorumEvent) {
            if (!quorumEvent.isPresent()) {
                quorumFailureLatch.countDown();
            }
        }
    }));
    String threeNodeQuorumName = "threeNode";
    QuorumConfig threeNodeQuorumConfig = new QuorumConfig(threeNodeQuorumName, true, 3);
    threeNodeQuorumConfig.addListenerConfig(new QuorumListenerConfig(new QuorumListener() {

        public void onChange(QuorumEvent quorumEvent) {
            if (!quorumEvent.isPresent()) {
                quorumFailureLatch.countDown();
            }
        }
    }));
    CacheSimpleConfig fourNodeCacheConfig = new CacheSimpleConfig();
    fourNodeCacheConfig.setName("fourNode");
    fourNodeCacheConfig.setQuorumName(fourNodeQuorumName);
    CacheSimpleConfig threeNodeCacheConfig = new CacheSimpleConfig();
    threeNodeCacheConfig.setName("threeNode");
    threeNodeCacheConfig.setQuorumName(threeNodeQuorumName);
    Config config = new Config();
    config.addCacheConfig(fourNodeCacheConfig);
    config.addQuorumConfig(fourNodeQuorumConfig);
    config.addCacheConfig(threeNodeCacheConfig);
    config.addQuorumConfig(threeNodeQuorumConfig);
    HazelcastInstance h1 = factory.newHazelcastInstance(config);
    factory.newHazelcastInstance(config);
    HazelcastServerCachingProvider cachingProvider = HazelcastServerCachingProvider.createCachingProvider(h1);
    Cache<Object, Object> fourNode = cachingProvider.getCacheManager().getCache("fourNode");
    Cache<Object, Object> threeNode = cachingProvider.getCacheManager().getCache("threeNode");
    try {
        threeNode.put(generateKeyOwnedBy(h1), "bar");
        fail("Expected a QuorumException");
    } catch (QuorumException expected) {
        EmptyStatement.ignore(expected);
    }
    try {
        fourNode.put(generateKeyOwnedBy(h1), "bar");
        fail("Expected a QuorumException");
    } catch (QuorumException expected) {
        EmptyStatement.ignore(expected);
    }
    assertOpenEventually(quorumFailureLatch, 15);
}
Also used : QuorumConfig(com.hazelcast.config.QuorumConfig) CacheSimpleConfig(com.hazelcast.config.CacheSimpleConfig) QuorumListenerConfig(com.hazelcast.config.QuorumListenerConfig) CacheSimpleConfig(com.hazelcast.config.CacheSimpleConfig) QuorumConfig(com.hazelcast.config.QuorumConfig) Config(com.hazelcast.config.Config) QuorumListenerConfig(com.hazelcast.config.QuorumListenerConfig) QuorumEvent(com.hazelcast.quorum.QuorumEvent) QuorumListener(com.hazelcast.quorum.QuorumListener) CountDownLatch(java.util.concurrent.CountDownLatch) QuorumException(com.hazelcast.quorum.QuorumException) HazelcastInstance(com.hazelcast.core.HazelcastInstance) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory) HazelcastServerCachingProvider(com.hazelcast.cache.impl.HazelcastServerCachingProvider) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 47 with CacheSimpleConfig

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

the class CacheWriteQuorumTest method initialize.

@BeforeClass
public static void initialize() throws Exception {
    CacheSimpleConfig cacheConfig = new CacheSimpleConfig();
    cacheConfig.setName(CACHE_NAME_PREFIX + "*");
    cacheConfig.setQuorumName(QUORUM_ID);
    QuorumConfig quorumConfig = new QuorumConfig();
    quorumConfig.setName(QUORUM_ID);
    quorumConfig.setType(QuorumType.WRITE);
    quorumConfig.setEnabled(true);
    quorumConfig.setSize(3);
    PartitionedCluster cluster = new PartitionedCluster(new TestHazelcastInstanceFactory()).partitionFiveMembersThreeAndTwo(cacheConfig, quorumConfig);
    cachingProvider1 = HazelcastServerCachingProvider.createCachingProvider(cluster.h1);
    cachingProvider2 = HazelcastServerCachingProvider.createCachingProvider(cluster.h2);
    cachingProvider3 = HazelcastServerCachingProvider.createCachingProvider(cluster.h3);
    cachingProvider4 = HazelcastServerCachingProvider.createCachingProvider(cluster.h4);
    cachingProvider5 = HazelcastServerCachingProvider.createCachingProvider(cluster.h5);
}
Also used : QuorumConfig(com.hazelcast.config.QuorumConfig) CacheSimpleConfig(com.hazelcast.config.CacheSimpleConfig) PartitionedCluster(com.hazelcast.quorum.PartitionedCluster) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory) BeforeClass(org.junit.BeforeClass)

Example 48 with CacheSimpleConfig

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

the class TestInClusterSupport method setupCluster.

@BeforeClass
public static void setupCluster() {
    int parallelism = Runtime.getRuntime().availableProcessors() / MEMBER_COUNT / 2;
    JetConfig config = new JetConfig();
    config.getInstanceConfig().setCooperativeThreadCount(parallelism <= 2 ? 2 : parallelism);
    Config hzConfig = config.getHazelcastConfig();
    hzConfig.addCacheConfig(new CacheSimpleConfig().setName("*"));
    hzConfig.getMapEventJournalConfig(JOURNALED_MAP_PREFIX + '*').setEnabled(true);
    hzConfig.getCacheEventJournalConfig(JOURNALED_CACHE_PREFIX + '*').setEnabled(true);
    member = createCluster(MEMBER_COUNT, config);
    client = factory.newClient();
}
Also used : CacheSimpleConfig(com.hazelcast.config.CacheSimpleConfig) Config(com.hazelcast.config.Config) JetConfig(com.hazelcast.jet.config.JetConfig) CacheSimpleConfig(com.hazelcast.config.CacheSimpleConfig) JetConfig(com.hazelcast.jet.config.JetConfig) BeforeClass(org.junit.BeforeClass)

Example 49 with CacheSimpleConfig

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

the class SinksTest method setUp.

@BeforeClass
public static void setUp() {
    Config config = new Config();
    config.getGroupConfig().setName(randomName());
    config.addCacheConfig(new CacheSimpleConfig().setName("*"));
    remoteHz = createRemoteCluster(config, 2).get(0);
    clientConfig = getClientConfigForRemoteCluster(remoteHz);
}
Also used : CacheSimpleConfig(com.hazelcast.config.CacheSimpleConfig) CacheSimpleConfig(com.hazelcast.config.CacheSimpleConfig) ClientConfig(com.hazelcast.client.config.ClientConfig) Config(com.hazelcast.config.Config) BeforeClass(org.junit.BeforeClass)

Example 50 with CacheSimpleConfig

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

the class SourcesTest method setUp.

@BeforeClass
public static void setUp() {
    Config config = new Config();
    config.getGroupConfig().setName(randomName());
    config.addCacheConfig(new CacheSimpleConfig().setName("*"));
    remoteHz = createRemoteCluster(config, 2).get(0);
    clientConfig = getClientConfigForRemoteCluster(remoteHz);
}
Also used : CacheSimpleConfig(com.hazelcast.config.CacheSimpleConfig) CacheSimpleConfig(com.hazelcast.config.CacheSimpleConfig) ClientConfig(com.hazelcast.client.config.ClientConfig) Config(com.hazelcast.config.Config) BeforeClass(org.junit.BeforeClass)

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