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