Search in sources :

Example 11 with ClusterServiceImpl

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

the class MemberAttributeChangedOperation method run.

@Override
public void run() throws Exception {
    final ClusterServiceImpl cs = getService();
    cs.updateMemberAttribute(getCallerUuid(), operationType, key, value);
}
Also used : ClusterServiceImpl(com.hazelcast.internal.cluster.impl.ClusterServiceImpl)

Example 12 with ClusterServiceImpl

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

the class MemberInfoUpdateOperation method run.

@Override
public void run() throws Exception {
    checkLocalMemberUuid();
    ClusterServiceImpl clusterService = getService();
    Address callerAddress = getConnectionEndpointOrThisAddress();
    if (clusterService.updateMembers(memberInfos, callerAddress)) {
        processPartitionState();
    }
}
Also used : Address(com.hazelcast.nio.Address) ClusterServiceImpl(com.hazelcast.internal.cluster.impl.ClusterServiceImpl)

Example 13 with ClusterServiceImpl

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

the class MemberInfoUpdateOperation method getConnectionEndpointOrThisAddress.

final Address getConnectionEndpointOrThisAddress() {
    ClusterServiceImpl clusterService = getService();
    NodeEngineImpl nodeEngine = clusterService.getNodeEngine();
    Node node = nodeEngine.getNode();
    Connection conn = getConnection();
    return conn != null ? conn.getEndPoint() : node.getThisAddress();
}
Also used : NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) Node(com.hazelcast.instance.Node) ClusterServiceImpl(com.hazelcast.internal.cluster.impl.ClusterServiceImpl) Connection(com.hazelcast.nio.Connection)

Example 14 with ClusterServiceImpl

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

the class InternalPartitionServiceImpl method searchUnknownAddressesInPartitionTable.

private void searchUnknownAddressesInPartitionTable(Address sender, Set<Address> unknownAddresses, int partitionId, Address[] addresses) {
    final ClusterServiceImpl clusterService = node.clusterService;
    final ClusterState clusterState = clusterService.getClusterState();
    for (int index = 0; index < InternalPartition.MAX_REPLICA_COUNT; index++) {
        Address address = addresses[index];
        if (address != null && node.clusterService.getMember(address) == null) {
            if (clusterState == ClusterState.ACTIVE || !clusterService.isMemberRemovedWhileClusterIsNotActive(address)) {
                if (logger.isFinestEnabled()) {
                    logger.finest("Unknown " + address + " found in partition table sent from master " + sender + ". It has probably already left the cluster. partitionId=" + partitionId);
                }
                unknownAddresses.add(address);
            }
        }
    }
}
Also used : ClusterState(com.hazelcast.cluster.ClusterState) Address(com.hazelcast.nio.Address) ClusterServiceImpl(com.hazelcast.internal.cluster.impl.ClusterServiceImpl)

Example 15 with ClusterServiceImpl

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

the class PartitionReplicaStateChecker method invokeReplicaSyncOperations.

@SuppressWarnings("checkstyle:npathcomplexity")
private int invokeReplicaSyncOperations(int maxBackupCount, Semaphore semaphore, AtomicBoolean result) {
    Address thisAddress = node.getThisAddress();
    ExecutionCallback<Object> callback = new ReplicaSyncResponseCallback(result, semaphore);
    ClusterServiceImpl clusterService = node.getClusterService();
    ClusterState clusterState = clusterService.getClusterState();
    boolean isClusterActive = clusterState == ClusterState.ACTIVE || clusterState == ClusterState.IN_TRANSITION;
    int ownedCount = 0;
    for (InternalPartition partition : partitionStateManager.getPartitions()) {
        Address owner = partition.getOwnerOrNull();
        if (owner == null) {
            result.set(false);
            continue;
        }
        if (!thisAddress.equals(owner)) {
            continue;
        }
        ownedCount++;
        if (maxBackupCount == 0) {
            if (partition.isMigrating()) {
                result.set(false);
            }
            continue;
        }
        for (int index = 1; index <= maxBackupCount; index++) {
            Address replicaAddress = partition.getReplicaAddress(index);
            if (replicaAddress == null) {
                result.set(false);
                semaphore.release();
                continue;
            }
            if (!isClusterActive && clusterService.isMemberRemovedWhileClusterIsNotActive(replicaAddress)) {
                semaphore.release();
                continue;
            }
            CheckReplicaVersionTask task = new CheckReplicaVersionTask(nodeEngine, partitionService, partition.getPartitionId(), index, callback);
            nodeEngine.getOperationService().execute(task);
        }
    }
    return ownedCount;
}
Also used : ClusterState(com.hazelcast.cluster.ClusterState) Address(com.hazelcast.nio.Address) ClusterServiceImpl(com.hazelcast.internal.cluster.impl.ClusterServiceImpl) InternalPartition(com.hazelcast.internal.partition.InternalPartition)

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