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);
}
}
}
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]);
}
});
}
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]);
}
});
}
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();
}
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);
}
Aggregations