use of com.hazelcast.instance.impl.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 = true;
if (state == NodeState.SHUT_DOWN) {
notifyError(new HazelcastInstanceNotActiveException("State: " + state + " Operation: " + op.getClass()));
allowed = false;
} else if (!(op instanceof AllowedDuringPassiveState) && context.clusterService.getClusterState() == ClusterState.PASSIVE) {
// Similar to OperationRunnerImpl.checkNodeState(op)
notifyError(new IllegalStateException("Cluster is in " + ClusterState.PASSIVE + " state! Operation: " + op));
allowed = false;
}
return allowed;
}
use of com.hazelcast.instance.impl.NodeState in project hazelcast by hazelcast.
the class HttpGetCommandProcessor method handleHealthcheck.
private void handleHealthcheck(HttpGetCommand command, String uri) {
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();
long migrationQueueSize = partitionService.getMigrationQueueSize();
String healthParameter = uri.substring(URI_HEALTH_URL.length());
if (healthParameter.equals(HEALTH_PATH_PARAM_NODE_STATE)) {
if (NodeState.SHUT_DOWN.equals(nodeState)) {
command.send503();
} else {
prepareResponse(command, Json.value(nodeState.toString()));
}
} else if (healthParameter.equals(HEALTH_PATH_PARAM_CLUSTER_STATE)) {
prepareResponse(command, Json.value(clusterState.toString()));
} else if (healthParameter.equals(HEALTH_PATH_PARAM_CLUSTER_SAFE)) {
if (isClusterSafe()) {
command.send200();
} else {
command.send503();
}
} else if (healthParameter.equals(HEALTH_PATH_PARAM_MIGRATION_QUEUE_SIZE)) {
prepareResponse(command, Json.value(migrationQueueSize));
} else if (healthParameter.equals(HEALTH_PATH_PARAM_CLUSTER_SIZE)) {
prepareResponse(command, Json.value(clusterSize));
} else if (healthParameter.isEmpty()) {
JsonObject response = new JsonObject().add("nodeState", nodeState.toString()).add("clusterState", clusterState.toString()).add("clusterSafe", isClusterSafe()).add("migrationQueueSize", migrationQueueSize).add("clusterSize", clusterSize);
prepareResponse(command, response);
} else {
command.send400();
}
}
use of com.hazelcast.instance.impl.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);
}
}
use of com.hazelcast.instance.impl.NodeState in project hazelcast by hazelcast.
the class HttpHeadCommandProcessor method handleHealthcheck.
private void handleHealthcheck(HttpHeadCommand 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();
long migrationQueueSize = partitionService.getMigrationQueueSize();
Map<String, Object> headervals = new LinkedHashMap<>();
headervals.put("NodeState", nodeState);
headervals.put("ClusterState", clusterState);
headervals.put("MigrationQueueSize", migrationQueueSize);
headervals.put("ClusterSize", clusterSize);
command.setResponse(SC_200, headervals);
}
use of com.hazelcast.instance.impl.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().getClusterService().isJoined());
NodeState state = nodeEngine.getNode().getState();
writer.writeKeyValueEntry("nodeState", state == null ? "null" : state.toString());
UUID clusterId = nodeEngine.getClusterService().getClusterId();
writer.writeKeyValueEntry("clusterId", clusterId != null ? clusterId.toString() : "null");
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();
}
Aggregations