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();
}
}
}
}
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);
}
}
}
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);
}
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();
}
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();
}
}
Aggregations