Search in sources :

Example 21 with QuorumConfig

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

the class QuorumListenerTest 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();
            }
        }
    }));
    MapConfig fourNodeMapConfig = new MapConfig("fourNode");
    fourNodeMapConfig.setQuorumName(fourNodeQuorumName);
    MapConfig threeNodeMapConfig = new MapConfig("threeNode");
    threeNodeMapConfig.setQuorumName(threeNodeQuorumName);
    Config config = new Config();
    config.addMapConfig(fourNodeMapConfig);
    config.addQuorumConfig(fourNodeQuorumConfig);
    config.addMapConfig(threeNodeMapConfig);
    config.addQuorumConfig(threeNodeQuorumConfig);
    factory.newHazelcastInstance(config);
    factory.newHazelcastInstance(config);
    assertOpenEventually(quorumFailureLatch);
}
Also used : QuorumConfig(com.hazelcast.config.QuorumConfig) QuorumListenerConfig(com.hazelcast.config.QuorumListenerConfig) Config(com.hazelcast.config.Config) QuorumListenerConfig(com.hazelcast.config.QuorumListenerConfig) MapConfig(com.hazelcast.config.MapConfig) QuorumConfig(com.hazelcast.config.QuorumConfig) QuorumEvent(com.hazelcast.quorum.QuorumEvent) QuorumListener(com.hazelcast.quorum.QuorumListener) MapConfig(com.hazelcast.config.MapConfig) CountDownLatch(java.util.concurrent.CountDownLatch) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 22 with QuorumConfig

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

the class TransactionalMapReadQuorumTest method initialize.

@BeforeClass
public static void initialize() throws Exception {
    QuorumConfig quorumConfig = new QuorumConfig();
    quorumConfig.setEnabled(true);
    quorumConfig.setSize(3);
    quorumConfig.setName(QUORUM_ID);
    quorumConfig.setType(QuorumType.READ);
    MapConfig mapConfig = new MapConfig(MAP_NAME_PREFIX + "*");
    mapConfig.setQuorumName(QUORUM_ID);
    cluster = new PartitionedCluster(new TestHazelcastInstanceFactory()).partitionFiveMembersThreeAndTwo(mapConfig, quorumConfig);
}
Also used : QuorumConfig(com.hazelcast.config.QuorumConfig) PartitionedCluster(com.hazelcast.quorum.PartitionedCluster) MapConfig(com.hazelcast.config.MapConfig) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory) BeforeClass(org.junit.BeforeClass)

Example 23 with QuorumConfig

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

the class BaseQuorumListenerTest method testCustomResolverFiresQuorumFailureEvent.

@Test
public void testCustomResolverFiresQuorumFailureEvent() {
    CountDownLatch quorumNotPresent = new CountDownLatch(1);
    QuorumListenerConfig listenerConfig = new QuorumListenerConfig(quorumListener(null, quorumNotPresent));
    String distributedObjectName = randomString();
    String quorumName = randomString();
    QuorumConfig quorumConfig = new QuorumConfig().setName(quorumName).setEnabled(true).addListenerConfig(listenerConfig).setQuorumFunctionImplementation(new QuorumFunction() {

        @Override
        public boolean apply(Collection<Member> members) {
            return false;
        }
    });
    Config config = new Config().addQuorumConfig(quorumConfig);
    addQuorumConfig(config, distributedObjectName, quorumName);
    TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory();
    factory.newHazelcastInstance(config);
    factory.newHazelcastInstance();
    assertOpenEventually(quorumNotPresent, 15);
}
Also used : QuorumConfig(com.hazelcast.config.QuorumConfig) QuorumListenerConfig(com.hazelcast.config.QuorumListenerConfig) Config(com.hazelcast.config.Config) QuorumListenerConfig(com.hazelcast.config.QuorumListenerConfig) QuorumConfig(com.hazelcast.config.QuorumConfig) CountDownLatch(java.util.concurrent.CountDownLatch) Member(com.hazelcast.core.Member) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 24 with QuorumConfig

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

the class BaseQuorumListenerTest method addQuorum.

protected Config addQuorum(Config config, String distributedObjectName, QuorumListener listener) {
    String quorumName = randomString();
    QuorumListenerConfig listenerConfig = new QuorumListenerConfig();
    listenerConfig.setImplementation(listener);
    config.addQuorumConfig(new QuorumConfig(quorumName, true, 3).addListenerConfig(listenerConfig));
    addQuorumConfig(config, distributedObjectName, quorumName);
    return config;
}
Also used : QuorumConfig(com.hazelcast.config.QuorumConfig) QuorumListenerConfig(com.hazelcast.config.QuorumListenerConfig)

Example 25 with QuorumConfig

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

the class PartitionedCluster method createFiveMemberCluster.

public PartitionedCluster createFiveMemberCluster(QueueConfig queueConfig, QuorumConfig quorumConfig) {
    Config config = createClusterConfig().addQueueConfig(queueConfig).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

QuorumConfig (com.hazelcast.config.QuorumConfig)52 MapConfig (com.hazelcast.config.MapConfig)31 Config (com.hazelcast.config.Config)29 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)25 QuickTest (com.hazelcast.test.annotation.QuickTest)25 Test (org.junit.Test)25 ParallelTest (com.hazelcast.test.annotation.ParallelTest)23 PartitionedCluster (com.hazelcast.quorum.PartitionedCluster)18 HazelcastInstance (com.hazelcast.core.HazelcastInstance)17 CacheSimpleConfig (com.hazelcast.config.CacheSimpleConfig)16 BeforeClass (org.junit.BeforeClass)16 QuorumListenerConfig (com.hazelcast.config.QuorumListenerConfig)15 CountDownLatch (java.util.concurrent.CountDownLatch)13 QuorumEvent (com.hazelcast.quorum.QuorumEvent)11 QuorumListener (com.hazelcast.quorum.QuorumListener)11 Member (com.hazelcast.core.Member)10 TestHazelcastFactory (com.hazelcast.client.test.TestHazelcastFactory)7 HazelcastServerCachingProvider (com.hazelcast.cache.impl.HazelcastServerCachingProvider)5 LockConfig (com.hazelcast.config.LockConfig)5 QueueConfig (com.hazelcast.config.QueueConfig)5