Search in sources :

Example 1 with NoDataMemberInClusterException

use of com.hazelcast.partition.NoDataMemberInClusterException 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);
            }
        }
    });
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) AssertTask(com.hazelcast.test.AssertTask) NoDataMemberInClusterException(com.hazelcast.partition.NoDataMemberInClusterException) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory) NoDataMemberInClusterException(com.hazelcast.partition.NoDataMemberInClusterException) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 2 with NoDataMemberInClusterException

use of com.hazelcast.partition.NoDataMemberInClusterException 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);
            }
        }
    });
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) AssertTask(com.hazelcast.test.AssertTask) NoDataMemberInClusterException(com.hazelcast.partition.NoDataMemberInClusterException) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory) NoDataMemberInClusterException(com.hazelcast.partition.NoDataMemberInClusterException) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 3 with NoDataMemberInClusterException

use of com.hazelcast.partition.NoDataMemberInClusterException in project hazelcast by hazelcast.

the class OperationServiceImpl_invokeOnPartitionLiteMemberTest method test_invokeOnPartition_onLiteMember.

@Test
public void test_invokeOnPartition_onLiteMember() throws InterruptedException {
    final TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(1);
    final HazelcastInstance instance = factory.newHazelcastInstance(liteMemberConfig);
    final InternalOperationService operationService = getOperationService(instance);
    final InternalCompletableFuture<Object> future = operationService.invokeOnPartition(null, operation, 0);
    try {
        future.get();
        fail("partition operation should not run on lite member!");
    } catch (ExecutionException e) {
        assertTrue(e.getCause() instanceof NoDataMemberInClusterException);
    }
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) InternalOperationService(com.hazelcast.spi.impl.operationservice.InternalOperationService) ExecutionException(java.util.concurrent.ExecutionException) NoDataMemberInClusterException(com.hazelcast.partition.NoDataMemberInClusterException) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 4 with NoDataMemberInClusterException

use of com.hazelcast.partition.NoDataMemberInClusterException in project hazelcast by hazelcast.

the class OperationServiceImpl_invokeOnPartitionLiteMemberTest method test_asyncInvokeOnPartition_onLiteMember.

@Test
public void test_asyncInvokeOnPartition_onLiteMember() {
    final TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(1);
    final HazelcastInstance instance = factory.newHazelcastInstance(liteMemberConfig);
    final InternalOperationService operationService = getOperationService(instance);
    final DummyExecutionCallback callback = new DummyExecutionCallback();
    operationService.asyncInvokeOnPartition(null, operation, 0, callback);
    assertOpenEventually(callback.responseLatch);
    assertTrue(callback.response instanceof NoDataMemberInClusterException);
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) InternalOperationService(com.hazelcast.spi.impl.operationservice.InternalOperationService) NoDataMemberInClusterException(com.hazelcast.partition.NoDataMemberInClusterException) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 5 with NoDataMemberInClusterException

use of com.hazelcast.partition.NoDataMemberInClusterException in project hazelcast by hazelcast.

the class KeysAssignmentOperation method run.

@Override
public void run() throws Exception {
    MapReduceService mapReduceService = getService();
    JobSupervisor supervisor = mapReduceService.getJobSupervisor(getName(), getJobId());
    if (supervisor == null) {
        this.result = new KeysAssignmentResult(NO_SUPERVISOR, null);
        return;
    }
    Map<Object, Address> assignment = new HashMap<Object, Address>();
    // Precheck if still all members are available
    if (!supervisor.checkAssignedMembersAvailable()) {
        TopologyChangedStrategy tcs = supervisor.getConfiguration().getTopologyChangedStrategy();
        if (tcs == CANCEL_RUNNING_OPERATION) {
            Exception exception = new TopologyChangedException();
            supervisor.cancelAndNotify(exception);
            this.result = new KeysAssignmentResult(CHECK_STATE_FAILED, assignment);
            return;
        // TODO Not yet fully supported
        /* } else if (tcs == DISCARD_AND_RESTART) {
             *   supervisor.cancelNotifyAndRestart();
             */
        } else {
            Exception exception = new TopologyChangedException("Unknown or unsupported TopologyChangedStrategy");
            supervisor.cancelAndNotify(exception);
            this.result = new KeysAssignmentResult(CHECK_STATE_FAILED, assignment);
            return;
        }
    }
    try {
        for (Object key : keys) {
            Address address = supervisor.assignKeyReducerAddress(key);
            assignment.put(key, address);
        }
        this.result = new KeysAssignmentResult(SUCCESSFUL, assignment);
    } catch (NoDataMemberInClusterException e) {
        supervisor.cancelAndNotify(e);
        this.result = new KeysAssignmentResult(CHECK_STATE_FAILED, assignment);
    }
}
Also used : TopologyChangedStrategy(com.hazelcast.mapreduce.TopologyChangedStrategy) Address(com.hazelcast.nio.Address) HashMap(java.util.HashMap) MapReduceService(com.hazelcast.mapreduce.impl.MapReduceService) NoDataMemberInClusterException(com.hazelcast.partition.NoDataMemberInClusterException) TopologyChangedException(com.hazelcast.mapreduce.TopologyChangedException) JobSupervisor(com.hazelcast.mapreduce.impl.task.JobSupervisor) IOException(java.io.IOException) TopologyChangedException(com.hazelcast.mapreduce.TopologyChangedException) NoDataMemberInClusterException(com.hazelcast.partition.NoDataMemberInClusterException)

Aggregations

NoDataMemberInClusterException (com.hazelcast.partition.NoDataMemberInClusterException)5 HazelcastInstance (com.hazelcast.core.HazelcastInstance)4 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)4 ParallelTest (com.hazelcast.test.annotation.ParallelTest)4 QuickTest (com.hazelcast.test.annotation.QuickTest)4 Test (org.junit.Test)4 InternalOperationService (com.hazelcast.spi.impl.operationservice.InternalOperationService)2 AssertTask (com.hazelcast.test.AssertTask)2 TopologyChangedException (com.hazelcast.mapreduce.TopologyChangedException)1 TopologyChangedStrategy (com.hazelcast.mapreduce.TopologyChangedStrategy)1 MapReduceService (com.hazelcast.mapreduce.impl.MapReduceService)1 JobSupervisor (com.hazelcast.mapreduce.impl.task.JobSupervisor)1 Address (com.hazelcast.nio.Address)1 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 ExecutionException (java.util.concurrent.ExecutionException)1