Search in sources :

Example 31 with ClusterServiceImpl

use of com.hazelcast.internal.cluster.impl.ClusterServiceImpl in project hazelcast by hazelcast.

the class MemberRemoveOperation method run.

@Override
public void run() {
    ClusterServiceImpl clusterService = getService();
    Address caller = getCallerAddress();
    ILogger logger = getLogger();
    if (!isCallerValid(caller)) {
        return;
    }
    String msg = "Removing member " + address + (memberUuid != null ? ", uuid: " + memberUuid : "") + ", requested by: " + caller;
    if (logger.isFineEnabled()) {
        logger.fine(msg);
    }
    if (memberUuid != null) {
        clusterService.removeAddress(address, memberUuid, msg);
    } else {
        clusterService.removeAddress(address, msg);
    }
}
Also used : Address(com.hazelcast.nio.Address) ClusterServiceImpl(com.hazelcast.internal.cluster.impl.ClusterServiceImpl) ILogger(com.hazelcast.logging.ILogger)

Example 32 with ClusterServiceImpl

use of com.hazelcast.internal.cluster.impl.ClusterServiceImpl in project hazelcast by hazelcast.

the class SetMasterOperation method run.

@Override
public void run() {
    ClusterServiceImpl clusterService = getService();
    clusterService.getClusterJoinManager().setMaster(masterAddress, getCallerAddress());
}
Also used : ClusterServiceImpl(com.hazelcast.internal.cluster.impl.ClusterServiceImpl)

Example 33 with ClusterServiceImpl

use of com.hazelcast.internal.cluster.impl.ClusterServiceImpl in project hazelcast by hazelcast.

the class SplitBrainMergeValidationOperation method masterCheck.

private boolean masterCheck(Node node) {
    ILogger logger = getLogger();
    Address caller = getCallerAddress();
    ClusterServiceImpl service = getService();
    if (node.isMaster()) {
        if (service.getMember(caller) != null) {
            logger.info("Removing " + caller + ", since it thinks it's already split from this cluster " + "and looking to merge.");
            removeCaller = true;
        }
        return true;
    } else {
        // ping master to check if it's still valid
        service.getClusterHeartbeatManager().sendMasterConfirmation();
        logger.info("Ignoring join check from " + caller + ", because this node is not master...");
        return false;
    }
}
Also used : Address(com.hazelcast.nio.Address) ClusterServiceImpl(com.hazelcast.internal.cluster.impl.ClusterServiceImpl) ILogger(com.hazelcast.logging.ILogger)

Example 34 with ClusterServiceImpl

use of com.hazelcast.internal.cluster.impl.ClusterServiceImpl in project hazelcast by hazelcast.

the class FinalizeJoinOperation method sendPostJoinOperations.

private void sendPostJoinOperations() {
    final ClusterServiceImpl clusterService = getService();
    final NodeEngineImpl nodeEngine = clusterService.getNodeEngine();
    // Post join operations must be lock free; means no locks at all;
    // no partition locks, no key-based locks, no service level locks!
    final Operation[] postJoinOperations = nodeEngine.getPostJoinOperations();
    final OperationService operationService = nodeEngine.getOperationService();
    if (postJoinOperations != null && postJoinOperations.length > 0) {
        final Collection<Member> members = clusterService.getMembers();
        for (Member member : members) {
            if (!member.localMember()) {
                PostJoinOperation operation = new PostJoinOperation(postJoinOperations);
                operationService.createInvocationBuilder(ClusterServiceImpl.SERVICE_NAME, operation, member.getAddress()).setTryCount(POST_JOIN_TRY_COUNT).invoke();
            }
        }
    }
}
Also used : NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) ClusterServiceImpl(com.hazelcast.internal.cluster.impl.ClusterServiceImpl) Operation(com.hazelcast.spi.Operation) InternalOperationService(com.hazelcast.spi.impl.operationservice.InternalOperationService) OperationService(com.hazelcast.spi.OperationService) Member(com.hazelcast.core.Member)

Example 35 with ClusterServiceImpl

use of com.hazelcast.internal.cluster.impl.ClusterServiceImpl 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

ClusterServiceImpl (com.hazelcast.internal.cluster.impl.ClusterServiceImpl)41 Node (com.hazelcast.instance.Node)13 Address (com.hazelcast.nio.Address)13 ILogger (com.hazelcast.logging.ILogger)9 NodeEngineImpl (com.hazelcast.spi.impl.NodeEngineImpl)8 ClusterState (com.hazelcast.cluster.ClusterState)6 MemberImpl (com.hazelcast.instance.MemberImpl)5 HazelcastInstance (com.hazelcast.core.HazelcastInstance)4 OperationService (com.hazelcast.spi.OperationService)4 Member (com.hazelcast.core.Member)3 MemberLeftException (com.hazelcast.core.MemberLeftException)3 ClusterStateManager (com.hazelcast.internal.cluster.impl.ClusterStateManager)3 Config (com.hazelcast.config.Config)2 InternalPartition (com.hazelcast.internal.partition.InternalPartition)2 Connection (com.hazelcast.nio.Connection)2 Operation (com.hazelcast.spi.Operation)2 InternalOperationService (com.hazelcast.spi.impl.operationservice.InternalOperationService)2 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)2 ParallelTest (com.hazelcast.test.annotation.ParallelTest)2 QuickTest (com.hazelcast.test.annotation.QuickTest)2