Search in sources :

Example 41 with ClusterService

use of com.hazelcast.internal.cluster.ClusterService in project hazelcast by hazelcast.

the class HttpGetCommandProcessor method handleCluster.

/**
 * Sets the HTTP response to a string containing basic cluster information:
 * <ul>
 * <li>Member list</li>
 * <li>Client connection count</li>
 * <li>Connection count</li>
 * </ul>
 *
 * @param command the HTTP request
 */
private void handleCluster(HttpGetCommand command) {
    Node node = textCommandService.getNode();
    Server server = node.getServer();
    ClusterServiceImpl clusterService = node.getClusterService();
    JsonArray membersArray = new JsonArray();
    clusterService.getMembers().stream().map(m -> new JsonObject().add("address", m.getAddress().toString()).add("liteMember", m.isLiteMember()).add("localMember", m.localMember()).add("uuid", m.getUuid().toString()).add("memberVersion", m.getVersion().toString())).forEach(membersArray::add);
    ServerConnectionManager cm = server.getConnectionManager(CLIENT);
    int clientCount = cm == null ? 0 : cm.connectionCount(ServerConnection::isClient);
    JsonObject response = new JsonObject().add("members", membersArray).add("connectionCount", clientCount).add("allConnectionCount", server.connectionCount());
    prepareResponse(command, response);
}
Also used : JsonArray(com.hazelcast.internal.json.JsonArray) Address(com.hazelcast.cluster.Address) LoggingServiceImpl(com.hazelcast.logging.impl.LoggingServiceImpl) ServerConnection(com.hazelcast.internal.server.ServerConnection) JsonArray(com.hazelcast.internal.json.JsonArray) Level(java.util.logging.Level) Json(com.hazelcast.internal.json.Json) ClusterService(com.hazelcast.internal.cluster.ClusterService) SC_500(com.hazelcast.internal.ascii.rest.HttpStatusCode.SC_500) CPGroup(com.hazelcast.cp.CPGroup) InternalPartitionService(com.hazelcast.internal.partition.InternalPartitionService) StringUtil.equalsIgnoreCase(com.hazelcast.internal.util.StringUtil.equalsIgnoreCase) CPSession(com.hazelcast.cp.session.CPSession) JsonObject(com.hazelcast.internal.json.JsonObject) ClusterServiceImpl(com.hazelcast.internal.cluster.impl.ClusterServiceImpl) CPGroupId(com.hazelcast.cp.CPGroupId) ServerConnectionManager(com.hazelcast.internal.server.ServerConnectionManager) TextCommandService(com.hazelcast.internal.ascii.TextCommandService) StringUtil(com.hazelcast.internal.util.StringUtil) ExceptionUtil.peel(com.hazelcast.internal.util.ExceptionUtil.peel) CPSubsystemManagementService(com.hazelcast.cp.CPSubsystemManagementService) Collection(java.util.Collection) Server(com.hazelcast.internal.server.Server) NodeState(com.hazelcast.instance.impl.NodeState) MAP(com.hazelcast.internal.ascii.rest.RestCallExecution.ObjectType.MAP) Node(com.hazelcast.instance.impl.Node) CLIENT(com.hazelcast.instance.EndpointQualifier.CLIENT) CompletionStage(java.util.concurrent.CompletionStage) CPMember(com.hazelcast.cp.CPMember) ClusterState(com.hazelcast.cluster.ClusterState) CPSubsystem(com.hazelcast.cp.CPSubsystem) QUEUE(com.hazelcast.internal.ascii.rest.RestCallExecution.ObjectType.QUEUE) Server(com.hazelcast.internal.server.Server) ServerConnectionManager(com.hazelcast.internal.server.ServerConnectionManager) Node(com.hazelcast.instance.impl.Node) ClusterServiceImpl(com.hazelcast.internal.cluster.impl.ClusterServiceImpl) JsonObject(com.hazelcast.internal.json.JsonObject)

Example 42 with ClusterService

use of com.hazelcast.internal.cluster.ClusterService in project hazelcast by hazelcast.

the class HttpPostCommandProcessor method handleClusterShutdown.

private void handleClusterShutdown(HttpPostCommand command) throws UnsupportedEncodingException {
    decodeParamsAndAuthenticate(command, 2);
    ClusterService clusterService = getNode().getClusterService();
    sendResponse(command, response(SUCCESS));
    clusterService.shutdown();
}
Also used : ClusterService(com.hazelcast.internal.cluster.ClusterService)

Example 43 with ClusterService

use of com.hazelcast.internal.cluster.ClusterService in project hazelcast by hazelcast.

the class SplitBrainMergeValidationOp method preCheck.

private boolean preCheck(Node node) {
    ILogger logger = getLogger();
    ClusterService clusterService = node.getClusterService();
    if (!clusterService.isJoined()) {
        logger.info("Ignoring join check from " + getCallerAddress() + ", because this node is not joined to a cluster yet...");
        return false;
    }
    if (!node.isRunning()) {
        logger.info("Ignoring join check from " + getCallerAddress() + " because this node is not active...");
        return false;
    }
    final ClusterState clusterState = clusterService.getClusterState();
    if (!clusterState.isJoinAllowed()) {
        logger.info("Ignoring join check from " + getCallerAddress() + " because cluster is in " + clusterState + " state...");
        return false;
    }
    return true;
}
Also used : ClusterState(com.hazelcast.cluster.ClusterState) ClusterService(com.hazelcast.internal.cluster.ClusterService) ILogger(com.hazelcast.logging.ILogger)

Example 44 with ClusterService

use of com.hazelcast.internal.cluster.ClusterService in project hazelcast by hazelcast.

the class MemberHeartbeatPlugin method run.

@Override
public void run(DiagnosticsLogWriter writer) {
    ClusterService cs = nodeEngine.getClusterService();
    if (!(cs instanceof ClusterServiceImpl)) {
        // we don't want to cause problems
        return;
    }
    render(writer, (ClusterServiceImpl) cs);
}
Also used : ClusterService(com.hazelcast.internal.cluster.ClusterService) ClusterServiceImpl(com.hazelcast.internal.cluster.impl.ClusterServiceImpl)

Example 45 with ClusterService

use of com.hazelcast.internal.cluster.ClusterService in project hazelcast by hazelcast.

the class TimedMemberStateFactory method createNodeState.

protected void createNodeState(MemberStateImpl memberState) {
    Node node = instance.node;
    ClusterService cluster = instance.node.clusterService;
    NodeStateImpl nodeState = new NodeStateImpl(cluster.getClusterState(), node.getState(), cluster.getClusterVersion(), node.getVersion());
    memberState.setNodeState(nodeState);
}
Also used : ClusterService(com.hazelcast.internal.cluster.ClusterService) NodeStateImpl(com.hazelcast.internal.monitor.impl.NodeStateImpl) Node(com.hazelcast.instance.impl.Node)

Aggregations

ClusterService (com.hazelcast.internal.cluster.ClusterService)53 Address (com.hazelcast.cluster.Address)11 Member (com.hazelcast.cluster.Member)10 ArrayList (java.util.ArrayList)10 MemberImpl (com.hazelcast.cluster.impl.MemberImpl)8 OperationService (com.hazelcast.spi.impl.operationservice.OperationService)8 Future (java.util.concurrent.Future)8 UUID (java.util.UUID)6 CPMember (com.hazelcast.cp.CPMember)5 ILogger (com.hazelcast.logging.ILogger)5 Accessors.getClusterService (com.hazelcast.test.Accessors.getClusterService)5 ClusterState (com.hazelcast.cluster.ClusterState)4 Node (com.hazelcast.instance.impl.Node)4 JsonObject (com.hazelcast.internal.json.JsonObject)4 AbstractJobTracker (com.hazelcast.mapreduce.impl.AbstractJobTracker)4 NodeEngine (com.hazelcast.spi.impl.NodeEngine)4 Operation (com.hazelcast.spi.impl.operationservice.Operation)4 Member (com.hazelcast.core.Member)3 CPGroupId (com.hazelcast.cp.CPGroupId)3 ClusterServiceImpl (com.hazelcast.internal.cluster.impl.ClusterServiceImpl)3