use of com.hazelcast.test.AssertTask in project hazelcast by hazelcast.
the class InternalPartitionServiceLiteMemberTest method test_getPartitionOwnerOrWait_onLiteMemberAfterDataMemberTerminates.
@Test
public void test_getPartitionOwnerOrWait_onLiteMemberAfterDataMemberTerminates() {
final TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(2);
final HazelcastInstance master = factory.newHazelcastInstance();
final HazelcastInstance lite = factory.newHazelcastInstance(liteMemberConfig);
warmUpPartitions(master, lite);
master.getLifecycleService().terminate();
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
try {
final InternalPartitionServiceImpl partitionService = getInternalPartitionServiceImpl(lite);
partitionService.getPartitionOwnerOrWait(0);
fail();
} catch (NoDataMemberInClusterException expected) {
ignore(expected);
}
}
});
}
use of com.hazelcast.test.AssertTask in project hazelcast by hazelcast.
the class InternalPartitionServiceLiteMemberTest method test_getPartitionOwnerOrWait_onLiteMemberAfterDataMemberShutsDown.
@Test
public void test_getPartitionOwnerOrWait_onLiteMemberAfterDataMemberShutsDown() {
final TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(2);
final HazelcastInstance master = factory.newHazelcastInstance();
final HazelcastInstance lite = factory.newHazelcastInstance(liteMemberConfig);
assertClusterSizeEventually(2, master);
assertClusterSizeEventually(2, lite);
warmUpPartitions(master, lite);
master.getLifecycleService().shutdown();
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
try {
final InternalPartitionServiceImpl partitionService = getInternalPartitionServiceImpl(lite);
partitionService.getPartitionOwnerOrWait(0);
fail();
} catch (NoDataMemberInClusterException expected) {
ignore(expected);
}
}
});
}
use of com.hazelcast.test.AssertTask in project hazelcast by hazelcast.
the class LocalMapStatsTest method testLastAccessTime_updatedConcurrently.
@Test
public void testLastAccessTime_updatedConcurrently() throws InterruptedException {
final long startTime = Clock.currentTimeMillis();
final IMap<String, String> map = getMap();
final String key = "key";
map.put(key, "value");
map.put(key, "value");
final LocalMapStats localMapStats = map.getLocalMapStats();
final long lastUpdateTime = localMapStats.getLastUpdateTime();
new Thread(new Runnable() {
@Override
public void run() {
sleepAtLeastMillis(1);
map.put(key, "value2");
// causes the local stats object to update
map.getLocalMapStats();
}
}).start();
assertTrue(lastUpdateTime >= startTime);
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
assertTrue(localMapStats.getLastUpdateTime() > lastUpdateTime);
}
});
}
use of com.hazelcast.test.AssertTask in project hazelcast by hazelcast.
the class LocalMapStatsTest_WhenMigration method testHitsGenerated_newNode.
@Test
public void testHitsGenerated_newNode() throws Exception {
for (int i = 0; i < 100; i++) {
map.put(i, i);
map.get(i);
}
hz2 = factory.newHazelcastInstance();
final IMap<Object, Object> trial = hz2.getMap("trial");
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
long hits2 = trial.getLocalMapStats().getHits();
long hits1 = map.getLocalMapStats().getHits();
assertEquals(100, hits1 + hits2);
}
});
}
use of com.hazelcast.test.AssertTask in project hazelcast by hazelcast.
the class ListenerTest method testMapPartitionLostListener_registeredViaImplementationInConfigObject.
@Test
public void testMapPartitionLostListener_registeredViaImplementationInConfigObject() {
final String name = randomString();
Config config = getConfig();
MapConfig mapConfig = config.getMapConfig(name);
MapPartitionLostListener listener = mock(MapPartitionLostListener.class);
mapConfig.addMapPartitionLostListenerConfig(new MapPartitionLostListenerConfig(listener));
mapConfig.setBackupCount(0);
HazelcastInstance instance = createHazelcastInstance(config);
instance.getMap(name);
final EventService eventService = getNode(instance).getNodeEngine().getEventService();
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
final Collection<EventRegistration> registrations = eventService.getRegistrations(MapService.SERVICE_NAME, name);
assertFalse(registrations.isEmpty());
}
});
}
Aggregations