use of com.hazelcast.core.HazelcastInstance in project hazelcast by hazelcast.
the class InternalPartitionServiceLiteMemberTest method test_liteMemberCanTerminate_withClusterSize2.
@Test(timeout = 120000)
public void test_liteMemberCanTerminate_withClusterSize2() {
final TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(2);
final HazelcastInstance lite1 = factory.newHazelcastInstance(liteMemberConfig);
final HazelcastInstance lite2 = factory.newHazelcastInstance(liteMemberConfig);
assertClusterSizeEventually(2, lite1);
assertClusterSizeEventually(2, lite2);
lite1.getLifecycleService().terminate();
}
use of com.hazelcast.core.HazelcastInstance in project hazelcast by hazelcast.
the class MigrationCommitServiceTest method migrateWithSuccess.
private void migrateWithSuccess(final MigrationInfo migration) {
InternalPartitionServiceImpl partitionService = (InternalPartitionServiceImpl) getPartitionService(instances[0]);
partitionService.getMigrationManager().scheduleMigration(migration);
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
for (HazelcastInstance instance : factory.getAllHazelcastInstances()) {
InternalPartitionImpl partition = getPartition(instance, migration.getPartitionId());
assertEquals(partition.getReplicaAddress(migration.getDestinationNewReplicaIndex()), migration.getDestination());
}
}
});
}
use of com.hazelcast.core.HazelcastInstance in project hazelcast by hazelcast.
the class MigrationCommitServiceTest method setup.
@Before
public void setup() throws Exception {
blockMigrationStartLatch = new CountDownLatch(1);
factory = createHazelcastInstanceFactory(NODE_COUNT);
instances = factory.newInstances(createConfig(), NODE_COUNT);
warmUpPartitions(instances);
waitAllForSafeState(instances);
InternalOperationService operationService = getOperationService(instances[0]);
for (int partitionId = 0; partitionId < PARTITION_COUNT; partitionId++) {
operationService.invokeOnPartition(null, new TestIncrementOperation(), partitionId).get();
}
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
for (int partitionId = 0; partitionId < PARTITION_COUNT; partitionId++) {
InternalPartitionService partitionService = getPartitionService(instances[0]);
InternalPartition partition = partitionService.getPartition(partitionId);
for (int i = 0; i <= BACKUP_COUNT; i++) {
Address replicaAddress = partition.getReplicaAddress(i);
if (replicaAddress != null) {
TestMigrationAwareService service = getService(replicaAddress);
assertNotNull(service.get(partitionId));
}
}
}
}
});
for (HazelcastInstance instance : instances) {
TestMigrationAwareService service = getNodeEngineImpl(instance).getService(TestMigrationAwareService.SERVICE_NAME);
service.clearEvents();
}
}
use of com.hazelcast.core.HazelcastInstance in project hazelcast by hazelcast.
the class MigrationCommitServiceTest method clearReplicaIndex.
private Address clearReplicaIndex(final int partitionId, int replicaIndexToClear) {
final InternalPartitionServiceImpl partitionService = (InternalPartitionServiceImpl) getPartitionService(instances[0]);
InternalPartitionImpl partition = (InternalPartitionImpl) partitionService.getPartition(partitionId);
final Address oldReplicaOwner = partition.getReplicaAddress(replicaIndexToClear);
partition.setReplicaAddress(replicaIndexToClear, null);
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
assertTrue(partitionService.syncPartitionRuntimeState());
}
});
HazelcastInstance oldReplicaOwnerInstance = factory.getInstance(oldReplicaOwner);
ClearReplicaRunnable op = new ClearReplicaRunnable(partitionId, getNodeEngineImpl(oldReplicaOwnerInstance));
getOperationService(oldReplicaOwnerInstance).execute(op);
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
long[] replicaVersions = getReplicaVersions(factory.getInstance(oldReplicaOwner), partitionId);
assertArrayEquals(new long[InternalPartition.MAX_BACKUP_COUNT], replicaVersions);
}
});
TestMigrationAwareService migrationAwareService = getService(oldReplicaOwner);
migrationAwareService.clearPartitionReplica(partitionId);
for (HazelcastInstance instance : instances) {
TestMigrationAwareService service = getNodeEngineImpl(instance).getService(TestMigrationAwareService.SERVICE_NAME);
service.clearEvents();
}
return oldReplicaOwner;
}
use of com.hazelcast.core.HazelcastInstance in project hazelcast by hazelcast.
the class AbstractGracefulShutdownCorrectnessTest method testPartitionData_whenNodesShutdown.
@Test(timeout = 6000 * 10 * 10)
public void testPartitionData_whenNodesShutdown() throws InterruptedException {
Config config = getConfig(true, false);
HazelcastInstance hz = factory.newHazelcastInstance(config);
startNodes(config, nodeCount);
warmUpPartitions(factory.getAllHazelcastInstances());
fillData(hz);
assertSizeAndDataEventually();
shutdownNodes(shutdownNodeCount);
assertSizeAndData();
}
Aggregations