Search in sources :

Example 1 with TestPutOperation

use of com.hazelcast.internal.partition.service.TestPutOperation 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());
    }
}
Also used : TestPutOperation(com.hazelcast.internal.partition.service.TestPutOperation) TestGetOperation(com.hazelcast.internal.partition.service.TestGetOperation) Config(com.hazelcast.config.Config) LinkedList(java.util.LinkedList) NodeEngine(com.hazelcast.spi.NodeEngine) HazelcastInstance(com.hazelcast.core.HazelcastInstance) Future(java.util.concurrent.Future) Collection(java.util.Collection) OperationService(com.hazelcast.spi.OperationService) Test(org.junit.Test)

Aggregations

Config (com.hazelcast.config.Config)1 HazelcastInstance (com.hazelcast.core.HazelcastInstance)1 TestGetOperation (com.hazelcast.internal.partition.service.TestGetOperation)1 TestPutOperation (com.hazelcast.internal.partition.service.TestPutOperation)1 NodeEngine (com.hazelcast.spi.NodeEngine)1 OperationService (com.hazelcast.spi.OperationService)1 Collection (java.util.Collection)1 LinkedList (java.util.LinkedList)1 Future (java.util.concurrent.Future)1 Test (org.junit.Test)1