use of com.hazelcast.cluster.Address in project hazelcast by hazelcast.
the class ClusterJoinManager method ensureValidConfiguration.
private boolean ensureValidConfiguration(JoinMessage joinMessage) {
Address address = joinMessage.getAddress();
try {
if (isValidJoinMessage(joinMessage)) {
return true;
}
logger.warning(format("Received an invalid join request from %s, cause: members part of different cluster", address));
nodeEngine.getOperationService().send(new ClusterMismatchOp(), address);
} catch (ConfigMismatchException e) {
logger.warning(format("Received an invalid join request from %s, cause: %s", address, e.getMessage()));
OperationService operationService = nodeEngine.getOperationService();
operationService.send(new ConfigMismatchOp(e.getMessage()), address);
}
return false;
}
use of com.hazelcast.cluster.Address in project hazelcast by hazelcast.
the class ClusterJoinManager method handleJoinRequest.
/**
* Handle a {@link JoinRequestOp}. If this node is not master, reply with a {@link MasterResponseOp} to let the
* joining node know the current master. Otherwise, if no other join is in progress, execute the {@link JoinRequest}
*
* @param joinRequest the join request
* @param connection the connection to the joining node
* @see JoinRequestOp
*/
public void handleJoinRequest(JoinRequest joinRequest, ServerConnection connection) {
if (!ensureNodeIsReady()) {
return;
}
if (!ensureValidConfiguration(joinRequest)) {
return;
}
Address target = joinRequest.getAddress();
boolean isRequestFromCurrentMaster = target.equals(clusterService.getMasterAddress());
// because master can somehow dropped its connection and wants to join back
if (!clusterService.isMaster() && !isRequestFromCurrentMaster) {
sendMasterAnswer(target);
return;
}
if (joinInProgress) {
if (logger.isFineEnabled()) {
logger.fine(format("Join or membership claim is in progress, cannot handle join request from %s at the moment", target));
}
return;
}
executeJoinRequest(joinRequest, connection);
}
use of com.hazelcast.cluster.Address 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.Address in project hazelcast by hazelcast.
the class ClusterServiceImpl method resetLocalMemberUuid.
private void resetLocalMemberUuid() {
assert lock.isHeldByCurrentThread() : "Called without holding cluster service lock!";
assert !isJoined() : "Cannot reset local member UUID when joined.";
Map<EndpointQualifier, Address> addressMap = localMember.getAddressMap();
UUID newUuid = UuidUtil.newUnsecureUUID();
logger.warning("Resetting local member UUID. Previous: " + localMember.getUuid() + ", new: " + newUuid);
node.setThisUuid(newUuid);
localMember = new MemberImpl.Builder(addressMap).version(localMember.getVersion()).localMember(true).uuid(newUuid).attributes(localMember.getAttributes()).liteMember(localMember.isLiteMember()).memberListJoinVersion(localMember.getMemberListJoinVersion()).instance(node.hazelcastInstance).build();
node.loggingService.setThisMember(localMember);
node.getLocalAddressRegistry().setLocalUuid(newUuid);
}
use of com.hazelcast.cluster.Address 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);
}
Aggregations