Search in sources :

Example 21 with HazelcastInstanceNotActiveException

use of com.hazelcast.core.HazelcastInstanceNotActiveException in project hazelcast by hazelcast.

the class ClusterMergeTask method executeMergeTasks.

private void executeMergeTasks(Collection<Runnable> tasks) {
    // execute merge tasks
    Collection<Future> futures = new LinkedList<Future>();
    for (Runnable task : tasks) {
        Future f = node.nodeEngine.getExecutionService().submit(SYSTEM_EXECUTOR, task);
        futures.add(f);
    }
    long callTimeoutMillis = node.getProperties().getMillis(GroupProperty.OPERATION_CALL_TIMEOUT_MILLIS);
    for (Future f : futures) {
        try {
            waitOnFutureInterruptible(f, callTimeoutMillis, TimeUnit.MILLISECONDS);
        } catch (HazelcastInstanceNotActiveException e) {
            EmptyStatement.ignore(e);
        } catch (Exception e) {
            node.getLogger(getClass()).severe("While merging...", e);
        }
    }
}
Also used : HazelcastInstanceNotActiveException(com.hazelcast.core.HazelcastInstanceNotActiveException) Future(java.util.concurrent.Future) LinkedList(java.util.LinkedList) HazelcastInstanceNotActiveException(com.hazelcast.core.HazelcastInstanceNotActiveException) TimeoutException(java.util.concurrent.TimeoutException) ExecutionException(java.util.concurrent.ExecutionException)

Example 22 with HazelcastInstanceNotActiveException

use of com.hazelcast.core.HazelcastInstanceNotActiveException in project hazelcast by hazelcast.

the class AdvancedClusterStateTest method changeClusterState_shouldFail_withoutBackup_whenInitiatorDies_beforePrepare.

@Test
public void changeClusterState_shouldFail_withoutBackup_whenInitiatorDies_beforePrepare() throws Exception {
    final TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(3);
    final HazelcastInstance[] instances = factory.newInstances();
    final HazelcastInstance hz = instances[instances.length - 1];
    TransactionManagerServiceImpl transactionManagerService = spyTransactionManagerService(hz);
    TransactionOptions options = new TransactionOptions().setDurability(0).setTimeout(30, TimeUnit.SECONDS);
    when(transactionManagerService.newAllowedDuringPassiveStateTransaction(options)).thenAnswer(new TransactionAnswer() {

        @Override
        protected void beforePrepare() {
            terminateInstance(hz);
        }
    });
    try {
        hz.getCluster().changeClusterState(ClusterState.FROZEN, options);
        fail("This instance is terminated. Cannot commit the transaction!");
    } catch (HazelcastInstanceNotActiveException ignored) {
    }
    assertTrueEventually(new AssertTask() {

        @Override
        public void run() throws Exception {
            assertClusterState(ClusterState.ACTIVE, instances[0], instances[1]);
        }
    });
}
Also used : HazelcastInstanceNotActiveException(com.hazelcast.core.HazelcastInstanceNotActiveException) HazelcastInstance(com.hazelcast.core.HazelcastInstance) TransactionManagerServiceImpl(com.hazelcast.transaction.impl.TransactionManagerServiceImpl) TransactionOptions(com.hazelcast.transaction.TransactionOptions) AssertTask(com.hazelcast.test.AssertTask) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory) HazelcastInstanceNotActiveException(com.hazelcast.core.HazelcastInstanceNotActiveException) TargetNotMemberException(com.hazelcast.spi.exception.TargetNotMemberException) TransactionException(com.hazelcast.transaction.TransactionException) ExecutionException(java.util.concurrent.ExecutionException) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 23 with HazelcastInstanceNotActiveException

use of com.hazelcast.core.HazelcastInstanceNotActiveException in project hazelcast by hazelcast.

the class AdvancedClusterStateTest method changeClusterState_shouldNotFail_whenInitiatorDies_afterPrepare.

@Test
public void changeClusterState_shouldNotFail_whenInitiatorDies_afterPrepare() throws Exception {
    final TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(3);
    final HazelcastInstance[] instances = factory.newInstances();
    final HazelcastInstance hz = instances[instances.length - 1];
    TransactionManagerServiceImpl transactionManagerService = spyTransactionManagerService(hz);
    TransactionOptions options = TransactionOptions.getDefault().setDurability(1);
    when(transactionManagerService.newAllowedDuringPassiveStateTransaction(options)).thenAnswer(new TransactionAnswer() {

        @Override
        protected void afterPrepare() {
            terminateInstance(hz);
        }
    });
    try {
        hz.getCluster().changeClusterState(ClusterState.FROZEN, options);
        fail("This instance is terminated. Cannot commit the transaction!");
    } catch (HazelcastInstanceNotActiveException ignored) {
    }
    assertTrueEventually(new AssertTask() {

        @Override
        public void run() throws Exception {
            assertClusterState(ClusterState.FROZEN, instances[0], instances[1]);
        }
    });
}
Also used : HazelcastInstanceNotActiveException(com.hazelcast.core.HazelcastInstanceNotActiveException) HazelcastInstance(com.hazelcast.core.HazelcastInstance) TransactionManagerServiceImpl(com.hazelcast.transaction.impl.TransactionManagerServiceImpl) TransactionOptions(com.hazelcast.transaction.TransactionOptions) AssertTask(com.hazelcast.test.AssertTask) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory) HazelcastInstanceNotActiveException(com.hazelcast.core.HazelcastInstanceNotActiveException) TargetNotMemberException(com.hazelcast.spi.exception.TargetNotMemberException) TransactionException(com.hazelcast.transaction.TransactionException) ExecutionException(java.util.concurrent.ExecutionException) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 24 with HazelcastInstanceNotActiveException

use of com.hazelcast.core.HazelcastInstanceNotActiveException in project hazelcast by hazelcast.

the class OperationParkerImpl method shutdown.

public void shutdown() {
    logger.finest("Stopping tasks...");
    expirationTaskFuture.cancel(true);
    expirationExecutor.shutdown();
    final Object response = new HazelcastInstanceNotActiveException();
    final Address thisAddress = nodeEngine.getThisAddress();
    for (Queue<ParkedOperation> parkQueue : parkQueueMap.values()) {
        for (ParkedOperation parkedOperation : parkQueue) {
            if (!parkedOperation.isValid()) {
                continue;
            }
            Operation op = parkedOperation.getOperation();
            // only for local invocations, remote ones will be expired via #onMemberLeft()
            if (thisAddress.equals(op.getCallerAddress())) {
                try {
                    OperationResponseHandler responseHandler = op.getOperationResponseHandler();
                    responseHandler.sendResponse(op, response);
                } catch (Exception e) {
                    logger.finest("While sending HazelcastInstanceNotActiveException response...", e);
                }
            }
        }
        parkQueue.clear();
    }
    parkQueueMap.clear();
}
Also used : HazelcastInstanceNotActiveException(com.hazelcast.core.HazelcastInstanceNotActiveException) Address(com.hazelcast.nio.Address) BlockingOperation(com.hazelcast.spi.BlockingOperation) Operation(com.hazelcast.spi.Operation) OperationResponseHandler(com.hazelcast.spi.OperationResponseHandler) HazelcastInstanceNotActiveException(com.hazelcast.core.HazelcastInstanceNotActiveException) PartitionMigratingException(com.hazelcast.spi.exception.PartitionMigratingException)

Example 25 with HazelcastInstanceNotActiveException

use of com.hazelcast.core.HazelcastInstanceNotActiveException in project hazelcast by hazelcast.

the class AbstractMessageTask method handleAuthenticationFailure.

private void handleAuthenticationFailure() {
    Exception exception;
    if (nodeEngine.isRunning()) {
        String message = "Client " + endpoint + " must authenticate before any operation.";
        logger.severe(message);
        exception = new RetryableHazelcastException(new AuthenticationException(message));
    } else {
        exception = new HazelcastInstanceNotActiveException();
    }
    sendClientMessage(exception);
    connection.close("Authentication failed. " + exception.getMessage(), null);
}
Also used : HazelcastInstanceNotActiveException(com.hazelcast.core.HazelcastInstanceNotActiveException) RetryableHazelcastException(com.hazelcast.spi.exception.RetryableHazelcastException) AuthenticationException(com.hazelcast.client.AuthenticationException) HazelcastInstanceNotActiveException(com.hazelcast.core.HazelcastInstanceNotActiveException) RetryableHazelcastException(com.hazelcast.spi.exception.RetryableHazelcastException) AuthenticationException(com.hazelcast.client.AuthenticationException)

Aggregations

HazelcastInstanceNotActiveException (com.hazelcast.core.HazelcastInstanceNotActiveException)34 HazelcastException (com.hazelcast.core.HazelcastException)8 ParallelTest (com.hazelcast.test.annotation.ParallelTest)8 QuickTest (com.hazelcast.test.annotation.QuickTest)8 OOfflineNodeException (com.orientechnologies.common.concur.OOfflineNodeException)8 Test (org.junit.Test)8 HazelcastInstance (com.hazelcast.core.HazelcastInstance)7 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)7 ONeedRetryException (com.orientechnologies.common.concur.ONeedRetryException)7 OException (com.orientechnologies.common.exception.OException)7 OIOException (com.orientechnologies.common.io.OIOException)7 ODistributedRedirectException (com.orientechnologies.orient.enterprise.channel.binary.ODistributedRedirectException)7 TransactionException (com.hazelcast.transaction.TransactionException)6 OCallable (com.orientechnologies.common.util.OCallable)6 ExecutionException (java.util.concurrent.ExecutionException)6 SerializationUtil.createSerializerAdapter (com.hazelcast.internal.serialization.impl.SerializationUtil.createSerializerAdapter)5 TargetNotMemberException (com.hazelcast.spi.exception.TargetNotMemberException)5 AssertTask (com.hazelcast.test.AssertTask)5 Callable (java.util.concurrent.Callable)5 TransactionOptions (com.hazelcast.transaction.TransactionOptions)4