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);
}
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);
}
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();
}
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);
}
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);
}
Aggregations