Search in sources :

Example 1 with AllowedDuringPassiveState

use of com.hazelcast.spi.impl.AllowedDuringPassiveState in project hazelcast by hazelcast.

the class Invocation method engineActive.

private boolean engineActive() {
    NodeState state = context.node.getState();
    if (state == NodeState.ACTIVE) {
        return true;
    }
    boolean allowed = state == NodeState.PASSIVE && (op instanceof AllowedDuringPassiveState);
    if (!allowed) {
        notifyError(new HazelcastInstanceNotActiveException("State: " + state + " Operation: " + op.getClass()));
        remote = false;
    }
    return allowed;
}
Also used : AllowedDuringPassiveState(com.hazelcast.spi.impl.AllowedDuringPassiveState) HazelcastInstanceNotActiveException(com.hazelcast.core.HazelcastInstanceNotActiveException) NodeState(com.hazelcast.instance.NodeState)

Example 2 with AllowedDuringPassiveState

use of com.hazelcast.spi.impl.AllowedDuringPassiveState in project hazelcast by hazelcast.

the class OperationRunnerImpl method checkNodeState.

private void checkNodeState(Operation op) {
    NodeState state = node.getState();
    if (state == NodeState.ACTIVE) {
        return;
    }
    Address localAddress = node.getThisAddress();
    if (state == NodeState.SHUT_DOWN) {
        throw new HazelcastInstanceNotActiveException("Member " + localAddress + " is shut down! Operation: " + op);
    }
    if (op instanceof AllowedDuringPassiveState) {
        return;
    }
    // Cluster is in passive state. There is no need to retry.
    if (nodeEngine.getClusterService().getClusterState() == ClusterState.PASSIVE) {
        throw new IllegalStateException("Cluster is in " + ClusterState.PASSIVE + " state! Operation: " + op);
    }
    // Operation will fail since node is shutting down or cluster is passive.
    if (op.getPartitionId() < 0) {
        throw new HazelcastInstanceNotActiveException("Member " + localAddress + " is currently passive! Operation: " + op);
    }
    // Since operation has a partition id, it must be retried on another node.
    throw new RetryableHazelcastException("Member " + localAddress + " is currently shutting down! Operation: " + op);
}
Also used : AllowedDuringPassiveState(com.hazelcast.spi.impl.AllowedDuringPassiveState) HazelcastInstanceNotActiveException(com.hazelcast.core.HazelcastInstanceNotActiveException) NodeState(com.hazelcast.instance.NodeState) Address(com.hazelcast.nio.Address) OperationAccessor.setCallerAddress(com.hazelcast.spi.OperationAccessor.setCallerAddress) RetryableHazelcastException(com.hazelcast.spi.exception.RetryableHazelcastException)

Aggregations

HazelcastInstanceNotActiveException (com.hazelcast.core.HazelcastInstanceNotActiveException)2 NodeState (com.hazelcast.instance.NodeState)2 AllowedDuringPassiveState (com.hazelcast.spi.impl.AllowedDuringPassiveState)2 Address (com.hazelcast.nio.Address)1 OperationAccessor.setCallerAddress (com.hazelcast.spi.OperationAccessor.setCallerAddress)1 RetryableHazelcastException (com.hazelcast.spi.exception.RetryableHazelcastException)1