use of com.hazelcast.spi.impl.operationservice.Operation 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.spi.impl.operationservice.Operation in project hazelcast by hazelcast.
the class ClusterServiceImpl method sendExplicitSuspicionTrigger.
void sendExplicitSuspicionTrigger(Address triggerTo, MembersViewMetadata endpointMembersViewMetadata) {
if (triggerTo.equals(node.getThisAddress())) {
logger.warning("Cannot send explicit suspicion trigger for " + endpointMembersViewMetadata + " to itself.");
return;
}
int memberListVersion = membershipManager.getMemberListVersion();
Operation op = new TriggerExplicitSuspicionOp(memberListVersion, endpointMembersViewMetadata);
OperationService operationService = nodeEngine.getOperationService();
operationService.send(op, triggerTo);
}
use of com.hazelcast.spi.impl.operationservice.Operation in project hazelcast by hazelcast.
the class ClusterServiceImpl method sendExplicitSuspicion.
void sendExplicitSuspicion(MembersViewMetadata endpointMembersViewMetadata) {
Address endpoint = endpointMembersViewMetadata.getMemberAddress();
if (endpoint.equals(node.getThisAddress())) {
logger.warning("Cannot send explicit suspicion for " + endpointMembersViewMetadata + " to itself.");
return;
}
if (!isJoined()) {
if (logger.isFineEnabled()) {
logger.fine("Cannot send explicit suspicion, not joined yet!");
}
return;
}
Version clusterVersion = getClusterVersion();
assert !clusterVersion.isUnknown() : "Cluster version should not be unknown after join!";
Operation op = new ExplicitSuspicionOp(endpointMembersViewMetadata);
nodeEngine.getOperationService().send(op, endpoint);
}
use of com.hazelcast.spi.impl.operationservice.Operation in project hazelcast by hazelcast.
the class ClusterServiceImpl method shutdownNodesConcurrently.
private void shutdownNodesConcurrently(final long timeoutNanos) {
Operation op = new ShutdownNodeOp();
Collection<Member> members = getMembers(NON_LOCAL_MEMBER_SELECTOR);
long startTimeNanos = Timer.nanos();
logger.info("Sending shut down operations to all members...");
while (Timer.nanosElapsed(startTimeNanos) < timeoutNanos && !members.isEmpty()) {
for (Member member : members) {
nodeEngine.getOperationService().send(op, member.getAddress());
}
try {
Thread.sleep(CLUSTER_SHUTDOWN_SLEEP_DURATION_IN_MILLIS);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
logger.warning("Shutdown sleep interrupted. ", e);
break;
}
members = getMembers(NON_LOCAL_MEMBER_SELECTOR);
}
logger.info("Number of other members remaining: " + getSize(NON_LOCAL_MEMBER_SELECTOR) + ". Shutting down itself.");
HazelcastInstanceImpl hazelcastInstance = node.hazelcastInstance;
hazelcastInstance.getLifecycleService().shutdown();
}
use of com.hazelcast.spi.impl.operationservice.Operation in project hazelcast by hazelcast.
the class ClusterHeartbeatManager method sendHeartbeat.
/**
* Send a {@link HeartbeatOp} to the {@code target}
*
* @param target target Member
*/
private void sendHeartbeat(Member target) {
if (target == null) {
return;
}
try {
MembersViewMetadata membersViewMetadata = clusterService.getMembershipManager().createLocalMembersViewMetadata();
Collection<MemberInfo> suspectedMembers = Collections.emptySet();
if (clusterService.getMembershipManager().isPartialDisconnectionDetectionEnabled() && !clusterService.isMaster() && target.getAddress().equals(clusterService.getMasterAddress())) {
suspectedMembers = clusterService.getMembershipManager().getSuspectedMembers().stream().map(MemberInfo::new).collect(toSet());
}
long clusterTime = clusterClock.getClusterTime();
Operation op = new HeartbeatOp(membersViewMetadata, target.getUuid(), clusterTime, suspectedMembers);
op.setCallerUuid(clusterService.getThisUuid());
node.nodeEngine.getOperationService().send(op, target.getAddress());
} catch (Exception e) {
if (logger.isFineEnabled()) {
logger.fine(format("Error while sending heartbeat -> %s[%s]", e.getClass().getName(), e.getMessage()));
}
}
}
Aggregations