Search in sources :

Example 6 with ClusterState

use of com.hazelcast.cluster.ClusterState in project hazelcast by hazelcast.

the class ClusterStateManager method initialClusterState.

void initialClusterState(ClusterState initialState, Version version) {
    clusterServiceLock.lock();
    try {
        final ClusterState currentState = getState();
        if (currentState != ClusterState.ACTIVE && currentState != initialState) {
            logger.warning("Initial state is already set! " + "Current state: " + currentState + ", Given state: " + initialState);
            return;
        }
        // no need to validate again
        setClusterStateAndVersion(initialState, version, true);
    } finally {
        clusterServiceLock.unlock();
    }
}
Also used : ClusterState(com.hazelcast.cluster.ClusterState)

Example 7 with ClusterState

use of com.hazelcast.cluster.ClusterState 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 8 with ClusterState

use of com.hazelcast.cluster.ClusterState in project hazelcast by hazelcast.

the class InternalPartitionServiceImpl method memberAdded.

@Override
public void memberAdded(MemberImpl member) {
    logger.fine("Adding " + member);
    lock.lock();
    try {
        if (!member.localMember()) {
            partitionStateManager.updateMemberGroupsSize();
        }
        lastMaster = node.getMasterAddress();
        if (node.isMaster()) {
            if (partitionStateManager.isInitialized()) {
                final ClusterState clusterState = nodeEngine.getClusterService().getClusterState();
                if (clusterState == ClusterState.ACTIVE) {
                    migrationManager.triggerControlTask();
                }
            }
        }
    } finally {
        lock.unlock();
    }
}
Also used : ClusterState(com.hazelcast.cluster.ClusterState)

Example 9 with ClusterState

use of com.hazelcast.cluster.ClusterState in project hazelcast by hazelcast.

the class InternalPartitionServiceImpl method triggerMasterToAssignPartitions.

private void triggerMasterToAssignPartitions() {
    if (partitionStateManager.isInitialized()) {
        return;
    }
    if (!node.joined()) {
        return;
    }
    ClusterState clusterState = node.getClusterService().getClusterState();
    if (clusterState != ClusterState.ACTIVE) {
        logger.warning("Partitions can't be assigned since cluster-state= " + clusterState);
        return;
    }
    if (!triggerMasterFlag.compareAndSet(false, true)) {
        return;
    }
    try {
        final Address masterAddress = node.getMasterAddress();
        if (masterAddress != null && !masterAddress.equals(node.getThisAddress())) {
            Future f = nodeEngine.getOperationService().createInvocationBuilder(SERVICE_NAME, new AssignPartitions(), masterAddress).setTryCount(1).invoke();
            f.get(1, TimeUnit.SECONDS);
        }
    } catch (Exception e) {
        logger.finest(e);
    } finally {
        triggerMasterFlag.set(false);
    }
}
Also used : ClusterState(com.hazelcast.cluster.ClusterState) Address(com.hazelcast.nio.Address) Future(java.util.concurrent.Future) AssignPartitions(com.hazelcast.internal.partition.operation.AssignPartitions) HazelcastInstanceNotActiveException(com.hazelcast.core.HazelcastInstanceNotActiveException) TargetNotMemberException(com.hazelcast.spi.exception.TargetNotMemberException) NoDataMemberInClusterException(com.hazelcast.partition.NoDataMemberInClusterException) MemberLeftException(com.hazelcast.core.MemberLeftException) ExecutionException(java.util.concurrent.ExecutionException)

Example 10 with ClusterState

use of com.hazelcast.cluster.ClusterState in project hazelcast by hazelcast.

the class MigrationManager method onShutdownRequest.

void onShutdownRequest(Address address) {
    if (!partitionStateManager.isInitialized()) {
        sendShutdownOperation(address);
        return;
    }
    ClusterState clusterState = node.getClusterService().getClusterState();
    if (clusterState == ClusterState.FROZEN || clusterState == ClusterState.PASSIVE) {
        sendShutdownOperation(address);
        return;
    }
    if (shutdownRequestedAddresses.add(address)) {
        logger.info("Shutdown request of " + address + " is handled");
        triggerControlTask();
    }
}
Also used : ClusterState(com.hazelcast.cluster.ClusterState)

Aggregations

ClusterState (com.hazelcast.cluster.ClusterState)26 ClusterServiceImpl (com.hazelcast.internal.cluster.impl.ClusterServiceImpl)6 Address (com.hazelcast.nio.Address)6 Node (com.hazelcast.instance.Node)4 ParallelTest (com.hazelcast.test.annotation.ParallelTest)4 QuickTest (com.hazelcast.test.annotation.QuickTest)4 Test (org.junit.Test)4 InternalPartition (com.hazelcast.internal.partition.InternalPartition)3 Version (com.hazelcast.version.Version)3 JsonObject (com.eclipsesource.json.JsonObject)2 HazelcastInstance (com.hazelcast.core.HazelcastInstance)2 HazelcastInstanceNotActiveException (com.hazelcast.core.HazelcastInstanceNotActiveException)2 InternalPartitionService (com.hazelcast.internal.partition.InternalPartitionService)2 ILogger (com.hazelcast.logging.ILogger)2 NodeState (com.hazelcast.monitor.NodeState)2 TargetNotMemberException (com.hazelcast.spi.exception.TargetNotMemberException)2 NodeEngineImpl (com.hazelcast.spi.impl.NodeEngineImpl)2 TransactionException (com.hazelcast.transaction.TransactionException)2 MemberVersion (com.hazelcast.version.MemberVersion)2 ExecutionException (java.util.concurrent.ExecutionException)2