use of com.hazelcast.test.TestHazelcastInstanceFactory in project hazelcast by hazelcast.
the class FrozenPartitionTableTest method partitionTable_isFrozen_whenMemberReJoins_duringClusterStateIsFrozen.
@Test
public void partitionTable_isFrozen_whenMemberReJoins_duringClusterStateIsFrozen() {
Config config = new Config();
TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(4);
HazelcastInstance[] instances = factory.newInstances(config, 3);
HazelcastInstance hz1 = instances[0];
HazelcastInstance hz2 = instances[1];
HazelcastInstance hz3 = instances[2];
Address hz3Address = getNode(hz3).getThisAddress();
warmUpPartitions(instances);
final Map<Integer, List<Address>> partitionTable = getPartitionTable(hz1);
changeClusterStateEventually(hz2, ClusterState.FROZEN);
terminateInstance(hz3);
hz3 = factory.newHazelcastInstance(hz3Address);
assertClusterSizeEventually(3, hz1);
assertClusterSizeEventually(3, hz2);
assertClusterSizeEventually(3, hz3);
for (HazelcastInstance instance : Arrays.asList(hz1, hz2, hz3)) {
final HazelcastInstance hz = instance;
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
assertPartitionTablesSame(partitionTable, getPartitionTable(hz));
}
});
}
}
use of com.hazelcast.test.TestHazelcastInstanceFactory in project hazelcast by hazelcast.
the class LocalMapStatsTest method testHits_whenMultipleNodes.
@Test
public void testHits_whenMultipleNodes() throws InterruptedException {
TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(2);
final HazelcastInstance[] instances = factory.newInstances(getConfig());
MultiMap<Object, Object> multiMap0 = instances[0].getMultiMap("testHits_whenMultipleNodes");
MultiMap<Object, Object> multiMap1 = instances[1].getMultiMap("testHits_whenMultipleNodes");
// InternalPartitionService is used in order to determine owners of these keys that we will use.
InternalPartitionService partitionService = getNode(instances[0]).getPartitionService();
Address address = partitionService.getPartitionOwner(partitionService.getPartitionId("test1"));
boolean inFirstInstance = address.equals(getNode(instances[0]).getThisAddress());
multiMap0.get("test0");
multiMap0.put("test1", 1);
multiMap1.get("test1");
assertEquals(inFirstInstance ? 1 : 0, multiMap0.getLocalMultiMapStats().getHits());
assertEquals(inFirstInstance ? 0 : 1, multiMap1.getLocalMultiMapStats().getHits());
multiMap0.get("test1");
multiMap1.get("test1");
assertEquals(inFirstInstance ? 0 : 3, multiMap1.getLocalMultiMapStats().getHits());
}
use of com.hazelcast.test.TestHazelcastInstanceFactory in project hazelcast by hazelcast.
the class LocalMapStatsTest method testLocalMapStats_withMemberGroups.
@Test
public void testLocalMapStats_withMemberGroups() throws Exception {
final String mapName = randomMapName();
final String[] firstMemberGroup = { "127.0.0.1", "127.0.0.2" };
final String[] secondMemberGroup = { "127.0.0.3" };
final Config config = createConfig(mapName, firstMemberGroup, secondMemberGroup);
final String[] addressArray = concatenateArrays(firstMemberGroup, secondMemberGroup);
final TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(addressArray);
final HazelcastInstance node1 = factory.newHazelcastInstance(config);
final HazelcastInstance node2 = factory.newHazelcastInstance(config);
final HazelcastInstance node3 = factory.newHazelcastInstance(config);
final IMap<Object, Object> test = node3.getMap(mapName);
test.put(1, 1);
assertBackupEntryCount(1, mapName, factory.getAllHazelcastInstances());
}
use of com.hazelcast.test.TestHazelcastInstanceFactory in project hazelcast by hazelcast.
the class MemberMapRecordStateStressTest method setUp.
@Before
public void setUp() throws Exception {
factory = new TestHazelcastInstanceFactory();
stop.set(false);
}
use of com.hazelcast.test.TestHazelcastInstanceFactory in project hazelcast by hazelcast.
the class NearCacheBatchInvalidationTest method testBatchInvalidationRemovesEntries.
@Test
public void testBatchInvalidationRemovesEntries() throws Exception {
String mapName = randomMapName();
Config config = newConfig(mapName);
config.setProperty(GroupProperty.PARTITION_COUNT.getName(), "1");
configureBatching(config, true, 12, 1);
TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory();
HazelcastInstance node1 = factory.newHazelcastInstance(config);
HazelcastInstance node2 = factory.newHazelcastInstance(config);
final IMap<Integer, Integer> map1 = node1.getMap(mapName);
final IMap<Integer, Integer> map2 = node2.getMap(mapName);
int size = 1000;
// fill map-1
for (int i = 0; i < size; i++) {
map1.put(i, i);
}
// fill Near Cache on node-1
for (int i = 0; i < size; i++) {
map1.get(i);
}
// fill Near Cache on node-2
for (int i = 0; i < size; i++) {
map2.get(i);
}
// generate invalidation data
for (int i = 0; i < size; i++) {
map1.put(i, i);
}
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
NearCache nearCache1 = ((NearCachedMapProxyImpl) map1).getNearCache();
NearCache nearCache2 = ((NearCachedMapProxyImpl) map2).getNearCache();
assertEquals(0, nearCache1.size() + nearCache2.size());
}
});
}
Aggregations