Search in sources :

Example 1 with TestIncrementOperation

use of com.hazelcast.internal.partition.service.TestIncrementOperation 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();
    }
}
Also used : TestMigrationAwareService(com.hazelcast.internal.partition.service.TestMigrationAwareService) HazelcastInstance(com.hazelcast.core.HazelcastInstance) Address(com.hazelcast.nio.Address) InternalPartitionService(com.hazelcast.internal.partition.InternalPartitionService) AssertTask(com.hazelcast.test.AssertTask) TestIncrementOperation(com.hazelcast.internal.partition.service.TestIncrementOperation) InternalOperationService(com.hazelcast.spi.impl.operationservice.InternalOperationService) InternalPartition(com.hazelcast.internal.partition.InternalPartition) CountDownLatch(java.util.concurrent.CountDownLatch) ExpectedRuntimeException(com.hazelcast.test.ExpectedRuntimeException) Before(org.junit.Before)

Aggregations

HazelcastInstance (com.hazelcast.core.HazelcastInstance)1 InternalPartition (com.hazelcast.internal.partition.InternalPartition)1 InternalPartitionService (com.hazelcast.internal.partition.InternalPartitionService)1 TestIncrementOperation (com.hazelcast.internal.partition.service.TestIncrementOperation)1 TestMigrationAwareService (com.hazelcast.internal.partition.service.TestMigrationAwareService)1 Address (com.hazelcast.nio.Address)1 InternalOperationService (com.hazelcast.spi.impl.operationservice.InternalOperationService)1 AssertTask (com.hazelcast.test.AssertTask)1 ExpectedRuntimeException (com.hazelcast.test.ExpectedRuntimeException)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 Before (org.junit.Before)1