use of com.hazelcast.cluster.impl.MemberImpl in project hazelcast by hazelcast.
the class MapPublisherCreateMessageTask method call.
@Override
protected Object call() throws Exception {
ClusterService clusterService = clientEngine.getClusterService();
Collection<MemberImpl> members = clusterService.getMemberImpls();
List<Future> futures = new ArrayList<Future>(members.size());
createInvocations(members, futures);
return fetchMapSnapshotFrom(futures);
}
use of com.hazelcast.cluster.impl.MemberImpl in project hazelcast by hazelcast.
the class ClusterJoinManager method checkIfJoinRequestFromAnExistingMember.
@SuppressWarnings("checkstyle:cyclomaticcomplexity")
private boolean checkIfJoinRequestFromAnExistingMember(JoinMessage joinMessage, ServerConnection connection) {
Address targetAddress = joinMessage.getAddress();
MemberImpl member = clusterService.getMember(targetAddress);
if (member == null) {
return checkIfUsingAnExistingMemberUuid(joinMessage);
}
if (joinMessage.getUuid().equals(member.getUuid())) {
sendMasterAnswer(targetAddress);
if (clusterService.isMaster() && !isMastershipClaimInProgress()) {
if (logger.isFineEnabled()) {
logger.fine(format("Ignoring join request, member already exists: %s", joinMessage));
}
// send members update back to node trying to join again...
boolean deferPartitionProcessing = isMemberRestartingWithPersistence(member.getAttributes());
OnJoinOp preJoinOp = preparePreJoinOps();
OnJoinOp postJoinOp = preparePostJoinOp();
PartitionRuntimeState partitionRuntimeState = node.getPartitionService().createPartitionState();
Operation op = new FinalizeJoinOp(member.getUuid(), clusterService.getMembershipManager().getMembersView(), preJoinOp, postJoinOp, clusterClock.getClusterTime(), clusterService.getClusterId(), clusterClock.getClusterStartTime(), clusterStateManager.getState(), clusterService.getClusterVersion(), partitionRuntimeState, deferPartitionProcessing);
op.setCallerUuid(clusterService.getThisUuid());
invokeClusterOp(op, targetAddress);
}
return true;
}
// after I suspect from the target.
if (clusterService.isMaster() || targetAddress.equals(clusterService.getMasterAddress())) {
String msg = format("New join request has been received from an existing endpoint %s." + " Removing old member and processing join request...", member);
logger.warning(msg);
clusterService.suspectMember(member, msg, false);
ServerConnection existing = node.getServer().getConnectionManager(MEMBER).get(targetAddress);
if (existing != connection) {
if (existing != null) {
existing.close(msg, null);
}
node.getServer().getConnectionManager(MEMBER).register(targetAddress, joinMessage.getUuid(), connection);
}
}
return true;
}
use of com.hazelcast.cluster.impl.MemberImpl in project hazelcast by hazelcast.
the class ClusterServiceImpl method suspectAddressIfNotConnected.
public void suspectAddressIfNotConnected(Address address) {
lock.lock();
try {
MemberImpl member = getMember(address);
if (member == null) {
if (logger.isFineEnabled()) {
logger.fine("Cannot suspect " + address + ", since it's not a member.");
}
return;
}
Connection conn = node.getServer().getConnectionManager(MEMBER).get(address);
if (conn != null && conn.isAlive()) {
if (logger.isFineEnabled()) {
logger.fine("Cannot suspect " + member + ", since there's a live connection -> " + conn);
}
return;
}
suspectMember(member, "No connection", false);
} finally {
lock.unlock();
}
}
use of com.hazelcast.cluster.impl.MemberImpl in project hazelcast by hazelcast.
the class ClusterServiceImpl method getMasterMember.
private MemberImpl getMasterMember() {
MemberImpl master;
lock.lock();
try {
Address masterAddress = getMasterAddress();
if (masterAddress == null) {
throw new IllegalStateException("Master is not known yet!");
}
master = getMember(masterAddress);
} finally {
lock.unlock();
}
return master;
}
use of com.hazelcast.cluster.impl.MemberImpl in project hazelcast by hazelcast.
the class PartialDisconnectionHandler method update.
/**
* Updates the disconnected members set for the given member if the given
* timestamp is greater than the highest observed timestamp.
*
* @return true if the internal disconnected members set is updated.
*/
boolean update(MemberImpl member, long timestamp, Collection<MemberImpl> disconnectedMembers) {
if (timestamp < lastUpdated) {
return false;
}
Set<MemberImpl> currentDisconnectedMembers = disconnections.get(member);
if (currentDisconnectedMembers == null) {
if (disconnectedMembers.isEmpty()) {
return false;
}
currentDisconnectedMembers = new HashSet<>();
disconnections.put(member, currentDisconnectedMembers);
}
boolean updated = false;
for (MemberImpl disconnectedMember : disconnectedMembers) {
if (currentDisconnectedMembers.add(disconnectedMember) && !disconnections.getOrDefault(disconnectedMember, emptySet()).contains(member)) {
lastUpdated = timestamp;
updated = true;
}
}
if (currentDisconnectedMembers.retainAll(disconnectedMembers)) {
lastUpdated = timestamp;
updated = true;
}
if (currentDisconnectedMembers.isEmpty()) {
disconnections.remove(member);
}
return updated;
}
Aggregations