Search in sources :

Example 1 with NodeState

use of com.hazelcast.instance.NodeState 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 NodeState

use of com.hazelcast.instance.NodeState in project hazelcast by hazelcast.

the class MemberHazelcastInstanceInfoPlugin method run.

@Override
public void run(DiagnosticsLogWriter writer) {
    writer.startSection("HazelcastInstance");
    writer.writeKeyValueEntry("thisAddress", nodeEngine.getNode().getThisAddress().toString());
    writer.writeKeyValueEntry("isRunning", nodeEngine.getNode().isRunning());
    writer.writeKeyValueEntry("isLite", nodeEngine.getNode().isLiteMember());
    writer.writeKeyValueEntry("joined", nodeEngine.getNode().joined());
    NodeState state = nodeEngine.getNode().getState();
    writer.writeKeyValueEntry("nodeState", state == null ? "null" : state.toString());
    writer.writeKeyValueEntry("clusterId", nodeEngine.getClusterService().getClusterId());
    writer.writeKeyValueEntry("clusterSize", nodeEngine.getClusterService().getSize());
    writer.writeKeyValueEntry("isMaster", nodeEngine.getClusterService().isMaster());
    Address masterAddress = nodeEngine.getClusterService().getMasterAddress();
    writer.writeKeyValueEntry("masterAddress", masterAddress == null ? "null" : masterAddress.toString());
    writer.startSection("Members");
    for (Member member : nodeEngine.getClusterService().getMemberImpls()) {
        writer.writeEntry(member.getAddress().toString());
    }
    writer.endSection();
    writer.endSection();
}
Also used : NodeState(com.hazelcast.instance.NodeState) Address(com.hazelcast.nio.Address) Member(com.hazelcast.core.Member)

Example 3 with NodeState

use of com.hazelcast.instance.NodeState 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)

Example 4 with NodeState

use of com.hazelcast.instance.NodeState in project hazelcast by hazelcast.

the class HttpGetCommandProcessor method handleHealthcheck.

private void handleHealthcheck(HttpGetCommand command) {
    Node node = textCommandService.getNode();
    NodeState nodeState = node.getState();
    ClusterServiceImpl clusterService = node.getClusterService();
    ClusterState clusterState = clusterService.getClusterState();
    int clusterSize = clusterService.getMembers().size();
    InternalPartitionService partitionService = node.getPartitionService();
    boolean memberStateSafe = partitionService.isMemberStateSafe();
    boolean clusterSafe = memberStateSafe && !partitionService.hasOnGoingMigration();
    long migrationQueueSize = partitionService.getMigrationQueueSize();
    StringBuilder res = new StringBuilder();
    res.append("Hazelcast::NodeState=").append(nodeState).append("\n");
    res.append("Hazelcast::ClusterState=").append(clusterState).append("\n");
    res.append("Hazelcast::ClusterSafe=").append(Boolean.toString(clusterSafe).toUpperCase()).append("\n");
    res.append("Hazelcast::MigrationQueueSize=").append(migrationQueueSize).append("\n");
    res.append("Hazelcast::ClusterSize=").append(clusterSize).append("\n");
    command.setResponse(MIME_TEXT_PLAIN, stringToBytes(res.toString()));
}
Also used : ClusterState(com.hazelcast.cluster.ClusterState) NodeState(com.hazelcast.instance.NodeState) InternalPartitionService(com.hazelcast.internal.partition.InternalPartitionService) Node(com.hazelcast.instance.Node) ClusterServiceImpl(com.hazelcast.internal.cluster.impl.ClusterServiceImpl)

Aggregations

NodeState (com.hazelcast.instance.NodeState)4 HazelcastInstanceNotActiveException (com.hazelcast.core.HazelcastInstanceNotActiveException)2 Address (com.hazelcast.nio.Address)2 AllowedDuringPassiveState (com.hazelcast.spi.impl.AllowedDuringPassiveState)2 ClusterState (com.hazelcast.cluster.ClusterState)1 Member (com.hazelcast.core.Member)1 Node (com.hazelcast.instance.Node)1 ClusterServiceImpl (com.hazelcast.internal.cluster.impl.ClusterServiceImpl)1 InternalPartitionService (com.hazelcast.internal.partition.InternalPartitionService)1 OperationAccessor.setCallerAddress (com.hazelcast.spi.OperationAccessor.setCallerAddress)1 RetryableHazelcastException (com.hazelcast.spi.exception.RetryableHazelcastException)1