Search in sources :

Example 21 with Member

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

the class AbstractJoiner method ensureConnectionToAllMembers.

private void ensureConnectionToAllMembers() {
    if (clusterService.isJoined()) {
        logger.fine("Waiting for all connections");
        int connectAllWaitSeconds = node.getProperties().getSeconds(ClusterProperty.CONNECT_ALL_WAIT_SECONDS);
        int checkCount = 0;
        while (checkCount++ < connectAllWaitSeconds) {
            boolean allConnected = true;
            Collection<Member> members = clusterService.getMembers();
            for (Member member : members) {
                if (!member.localMember() && node.getServer().getConnectionManager(MEMBER).getOrConnect(member.getAddress()) == null) {
                    allConnected = false;
                    if (logger.isFineEnabled()) {
                        logger.fine("Not-connected to " + member.getAddress());
                    }
                }
            }
            if (allConnected) {
                break;
            }
            try {
                // noinspection BusyWait
                TimeUnit.SECONDS.sleep(1);
            } catch (InterruptedException ignored) {
                currentThread().interrupt();
            }
        }
    }
}
Also used : Member(com.hazelcast.cluster.Member)

Example 22 with Member

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

the class ClusterHeartbeatManager method heartbeatWhenSlave.

/**
 * Sends heartbeat to each of the cluster members.
 * Checks whether the master member has failed to send a heartbeat (see {@link #maxNoHeartbeatMillis})
 * and removes that master member from cluster, if it fails on heartbeat.
 * <p></p>
 * This method is called on NON-master members.
 */
private void heartbeatWhenSlave(long now) {
    MembershipManager membershipManager = clusterService.getMembershipManager();
    for (Member member : clusterService.getMembers(NON_LOCAL_MEMBER_SELECTOR)) {
        try {
            logIfConnectionToEndpointIsMissing(now, member);
            if (suspectMemberIfNotHeartBeating(now, member)) {
                continue;
            }
            if (membershipManager.isMemberSuspected((MemberImpl) member)) {
                continue;
            }
            pingMemberIfRequired(now, member);
            sendHeartbeat(member);
        } catch (Throwable e) {
            logger.severe(e);
        }
    }
}
Also used : Member(com.hazelcast.cluster.Member)

Example 23 with Member

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

the class ClusterHeartbeatManager method heartbeatWhenMaster.

/**
 * Sends heartbeat to each of the cluster members.
 * Checks whether a member has failed to send a heartbeat in time
 * (see {@link #maxNoHeartbeatMillis})
 * and removes that member from the cluster.
 * <p></p>
 * This method is only called on the master member.
 *
 * @param now the current cluster clock time
 */
private void heartbeatWhenMaster(long now) {
    for (Member member : clusterService.getMembers(NON_LOCAL_MEMBER_SELECTOR)) {
        try {
            logIfConnectionToEndpointIsMissing(now, member);
            if (suspectMemberIfNotHeartBeating(now, member)) {
                continue;
            }
            pingMemberIfRequired(now, member);
            sendHeartbeat(member);
        } catch (Throwable t) {
            logger.severe(t);
        }
    }
    clusterService.getMembershipManager().checkPartialDisconnectivity(now);
}
Also used : Member(com.hazelcast.cluster.Member)

Example 24 with Member

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

the class ClusterStateManager method lockClusterStateOnAllMembers.

private void lockClusterStateOnAllMembers(ClusterStateChange stateChange, NodeEngineImpl nodeEngine, long leaseTime, UUID txnId, Collection<MemberImpl> members, int memberListVersion, long partitionStateStamp) {
    Collection<Future> futures = new ArrayList<>(members.size());
    final Address thisAddress = node.getThisAddress();
    for (Member member : members) {
        Operation op = new LockClusterStateOp(stateChange, thisAddress, txnId, leaseTime, memberListVersion, partitionStateStamp);
        Future future = nodeEngine.getOperationService().invokeOnTarget(SERVICE_NAME, op, member.getAddress());
        futures.add(future);
    }
    StateManagerExceptionHandler exceptionHandler = new StateManagerExceptionHandler(logger);
    waitWithDeadline(futures, leaseTime, TimeUnit.MILLISECONDS, exceptionHandler);
    exceptionHandler.rethrowIfFailed();
}
Also used : Address(com.hazelcast.cluster.Address) LockClusterStateOp(com.hazelcast.internal.cluster.impl.operations.LockClusterStateOp) ArrayList(java.util.ArrayList) Future(java.util.concurrent.Future) Operation(com.hazelcast.spi.impl.operationservice.Operation) Member(com.hazelcast.cluster.Member)

Example 25 with Member

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

the class CRDTReplicationTask method run.

@Override
public void run() {
    if (nodeEngine.getLocalMember().isLiteMember()) {
        return;
    }
    try {
        final Collection<Member> viableTargets = getNonLocalReplicaAddresses();
        if (viableTargets.size() == 0) {
            return;
        }
        final Member[] targets = pickTargets(viableTargets, lastTargetIndex, maxTargets);
        lastTargetIndex = (lastTargetIndex + targets.length) % viableTargets.size();
        for (CRDTReplicationAwareService service : replicationMigrationService.getReplicationServices()) {
            for (Member target : targets) {
                replicate(service, target);
            }
        }
    } finally {
        // we left the interrupt status unchanged while replicating so we clear it here
        Thread.interrupted();
    }
}
Also used : Member(com.hazelcast.cluster.Member)

Aggregations

Member (com.hazelcast.cluster.Member)429 Test (org.junit.Test)210 QuickTest (com.hazelcast.test.annotation.QuickTest)191 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)164 HazelcastInstance (com.hazelcast.core.HazelcastInstance)116 IExecutorService (com.hazelcast.core.IExecutorService)73 Address (com.hazelcast.cluster.Address)62 ArrayList (java.util.ArrayList)55 Future (java.util.concurrent.Future)53 UUID (java.util.UUID)43 Config (com.hazelcast.config.Config)42 CountDownLatch (java.util.concurrent.CountDownLatch)38 Map (java.util.Map)33 HashMap (java.util.HashMap)31 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)28 MultiExecutionCallback (com.hazelcast.core.MultiExecutionCallback)25 List (java.util.List)25 MemberImpl (com.hazelcast.cluster.impl.MemberImpl)24 Operation (com.hazelcast.spi.impl.operationservice.Operation)24 IMap (com.hazelcast.map.IMap)23