use of com.hazelcast.core.HazelcastInstance in project hazelcast by hazelcast.
the class AbstractGracefulShutdownCorrectnessTest method testPartitionData_whenNodesStartedShutdown_withRestart.
@Test(timeout = 6000 * 10 * 10)
public void testPartitionData_whenNodesStartedShutdown_withRestart() throws InterruptedException {
Config config = getConfig(true, false);
HazelcastInstance hz = factory.newHazelcastInstance(config);
fillData(hz);
assertSizeAndDataEventually();
Collection<Address> addresses = Collections.emptySet();
int size = 1;
while (size < (nodeCount + 1)) {
int startCount = (shutdownNodeCount + 1) - addresses.size();
startNodes(config, addresses);
startNodes(config, startCount);
size += (shutdownNodeCount + 1);
assertSizeAndDataEventually();
addresses = shutdownNodes(shutdownNodeCount);
size -= shutdownNodeCount;
assertSizeAndData();
}
}
use of com.hazelcast.core.HazelcastInstance in project hazelcast by hazelcast.
the class AbstractGracefulShutdownCorrectnessTest method testPartitionData_whenNodesStartedShutdown_whileOperationsOngoing.
@Test(timeout = 6000 * 10 * 10)
public void testPartitionData_whenNodesStartedShutdown_whileOperationsOngoing() throws InterruptedException {
final Config config = getConfig(true, false);
Future future = spawn(new Runnable() {
@Override
public void run() {
LinkedList<HazelcastInstance> instances = new LinkedList<HazelcastInstance>(Arrays.asList(factory.newInstances(config, nodeCount)));
try {
for (int i = 0; i < 3; i++) {
shutdownNodes(instances, shutdownNodeCount);
Collection<HazelcastInstance> startedInstances = startNodes(config, shutdownNodeCount);
instances.addAll(startedInstances);
}
shutdownNodes(instances, shutdownNodeCount);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
});
HazelcastInstance hz = factory.newHazelcastInstance(config);
NodeEngine nodeEngine = getNodeEngineImpl(hz);
OperationService operationService = nodeEngine.getOperationService();
int partitionCount = nodeEngine.getPartitionService().getPartitionCount();
int value = 0;
while (!future.isDone()) {
value++;
for (int p = 0; p < partitionCount; p++) {
operationService.invokeOnPartition(null, new TestPutOperation(value), p).join();
}
}
for (int p = 0; p < partitionCount; p++) {
Integer actual = (Integer) operationService.invokeOnPartition(null, new TestGetOperation(), p).join();
assertEquals(value, actual.intValue());
}
}
use of com.hazelcast.core.HazelcastInstance in project hazelcast by hazelcast.
the class AbstractMigrationCorrectnessTest method testPartitionData_whenNodesStartedParallel.
@Test
public void testPartitionData_whenNodesStartedParallel() throws InterruptedException {
Config config = getConfig(true, false);
HazelcastInstance hz = factory.newHazelcastInstance(config);
fillData(hz);
assertSizeAndDataEventually();
startNodes(config, nodeCount);
assertSizeAndDataEventually();
}
use of com.hazelcast.core.HazelcastInstance in project hazelcast by hazelcast.
the class AbstractMigrationCorrectnessTest method testPartitionData_whenBackupNodesStartedTerminated.
public void testPartitionData_whenBackupNodesStartedTerminated(boolean checkAfterTerminate) throws InterruptedException {
Config config = getConfig(true, false);
HazelcastInstance hz = factory.newHazelcastInstance(config);
fillData(hz);
assertSizeAndDataEventually();
int size = 1;
while (size < (nodeCount + 1)) {
startNodes(config, backupCount + 1);
size += (backupCount + 1);
assertSizeAndDataEventually();
terminateNodes(backupCount);
size -= backupCount;
if (checkAfterTerminate) {
assertSizeAndDataEventually();
}
}
}
use of com.hazelcast.core.HazelcastInstance in project hazelcast by hazelcast.
the class AbstractPartitionAssignmentsCorrectnessTest method assertPartitionAssignments.
static void assertPartitionAssignments(TestHazelcastInstanceFactory factory) {
Collection<HazelcastInstance> instances = factory.getAllHazelcastInstances();
final int replicaCount = Math.min(instances.size(), InternalPartition.MAX_REPLICA_COUNT);
for (HazelcastInstance hz : instances) {
Node node = getNode(hz);
InternalPartitionService partitionService = node.getPartitionService();
InternalPartition[] partitions = partitionService.getInternalPartitions();
for (InternalPartition partition : partitions) {
for (int i = 0; i < replicaCount; i++) {
Address replicaAddress = partition.getReplicaAddress(i);
assertNotNull("Replica " + i + " is not found in " + partition, replicaAddress);
assertTrue("Not member: " + replicaAddress, node.getClusterService().getMember(replicaAddress) != null);
}
}
}
}
Aggregations