use of com.hazelcast.core.ReplicatedMap in project hazelcast by hazelcast.
the class ReplicatedMapAbstractTest method createMapOnEachInstance.
public List<ReplicatedMap> createMapOnEachInstance(HazelcastInstance[] instances, String replicatedMapName) {
ArrayList<ReplicatedMap> maps = new ArrayList<ReplicatedMap>();
for (HazelcastInstance instance : instances) {
ReplicatedMap<Object, Object> replicatedMap = instance.getReplicatedMap(replicatedMapName);
maps.add(replicatedMap);
}
return maps;
}
use of com.hazelcast.core.ReplicatedMap in project hazelcast by hazelcast.
the class ReplicatedMapWriteOrderTest method testDataIntegrity.
@Test
public void testDataIntegrity() throws InterruptedException {
System.out.println("nodeCount = " + nodeCount);
System.out.println("operations = " + operations);
System.out.println("keyCount = " + keyCount);
Config config = new Config();
config.getReplicatedMapConfig("test").setReplicationDelayMillis(0);
TestHazelcastInstanceFactory factory = new TestHazelcastInstanceFactory(nodeCount);
final HazelcastInstance[] instances = factory.newInstances(config);
String replicatedMapName = "test";
final List<ReplicatedMap> maps = createMapOnEachInstance(instances, replicatedMapName);
ArrayList<Integer> keys = generateRandomIntegerList(keyCount);
Thread[] threads = createThreads(nodeCount, maps, keys, operations);
for (Thread thread : threads) {
thread.start();
}
for (Thread thread : threads) {
thread.join();
}
for (int i = 0; i < keyCount; i++) {
final String key = "foo-" + keys.get(i);
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
System.out.println("---------------------");
System.out.println("key = " + key);
printValues();
assertValuesAreEqual();
}
private void printValues() throws Exception {
for (int j = 0; j < maps.size(); j++) {
ReplicatedMap map = maps.get(j);
System.out.println("value[" + j + "] = " + map.get(key) + " , store version : " + getStore(map, key).getVersion());
}
}
private void assertValuesAreEqual() {
for (int i = 0; i < maps.size() - 1; i++) {
ReplicatedMap map1 = maps.get(i);
ReplicatedMap map2 = maps.get(i + 1);
Object v1 = map1.get(key);
Object v2 = map2.get(key);
assertNotNull(v1);
assertNotNull(v2);
assertEquals(v1, v2);
}
}
}, 120);
}
}
use of com.hazelcast.core.ReplicatedMap in project hazelcast by hazelcast.
the class MBeanTest method testReplicatedMap.
@Test
public void testReplicatedMap() throws Exception {
String replicatedMapName = randomString();
ReplicatedMap replicatedMap = holder.getHz().getReplicatedMap(replicatedMapName);
replicatedMap.size();
holder.assertMBeanExistEventually("ReplicatedMap", replicatedMap.getName());
}
use of com.hazelcast.core.ReplicatedMap in project hazelcast by hazelcast.
the class MBeanDestroyTest method testReplicatedMap.
@Test
public void testReplicatedMap() throws Exception {
String replicatedMapName = randomString();
ReplicatedMap replicatedMap = holder.getHz().getReplicatedMap(replicatedMapName);
replicatedMap.size();
holder.assertMBeanExistEventually("ReplicatedMap", replicatedMap.getName());
destroyObjectAndAssert(replicatedMap, "ReplicatedMap");
}
use of com.hazelcast.core.ReplicatedMap in project hazelcast by hazelcast.
the class ClientReplicatedMapTest method testNearCacheInvalidation_withClear.
@Test
public void testNearCacheInvalidation_withClear() {
hazelcastFactory.newHazelcastInstance();
ClientConfig config = getClientConfigWithNearCacheInvalidationEnabled();
HazelcastInstance client1 = hazelcastFactory.newHazelcastClient(config);
HazelcastInstance client2 = hazelcastFactory.newHazelcastClient(config);
String mapName = randomString();
final ReplicatedMap<Integer, Integer> replicatedMap1 = client1.getReplicatedMap(mapName);
replicatedMap1.put(1, 1);
// puts key 1 to Near Cache
replicatedMap1.get(1);
ReplicatedMap replicatedMap2 = client2.getReplicatedMap(mapName);
// this should invalidate Near Cache of replicatedMap1
replicatedMap2.clear();
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
assertEquals(null, replicatedMap1.get(1));
}
});
}
Aggregations