use of com.hazelcast.internal.partition.PartitionRuntimeState in project hazelcast by hazelcast.
the class ClusterJoinManager method checkIfJoinRequestFromAnExistingMember.
private boolean checkIfJoinRequestFromAnExistingMember(JoinMessage joinMessage, Connection connection) {
Address target = joinMessage.getAddress();
MemberImpl member = clusterService.getMember(target);
if (member == null) {
return checkIfUsingAnExistingMemberUuid(joinMessage);
}
if (joinMessage.getUuid().equals(member.getUuid())) {
sendMasterAnswer(target);
if (node.isMaster()) {
if (logger.isFineEnabled()) {
logger.fine(format("Ignoring join request, member already exists: %s", joinMessage));
}
// send members update back to node trying to join again...
Operation[] postJoinOps = nodeEngine.getPostJoinOperations();
boolean isPostJoinOperation = postJoinOps != null && postJoinOps.length > 0;
PostJoinOperation postJoinOp = isPostJoinOperation ? new PostJoinOperation(postJoinOps) : null;
PartitionRuntimeState partitionRuntimeState = node.getPartitionService().createPartitionState();
List<MemberInfo> memberInfos = createMemberInfoList(clusterService.getMemberImpls());
Operation operation = new FinalizeJoinOperation(member.getUuid(), memberInfos, postJoinOp, clusterClock.getClusterTime(), clusterService.getClusterId(), clusterClock.getClusterStartTime(), clusterStateManager.getState(), clusterService.getClusterVersion(), partitionRuntimeState, false);
nodeEngine.getOperationService().send(operation, target);
}
return true;
}
// and wants to join back, so drop old member and process join request if this node becomes master
if (node.isMaster() || target.equals(node.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.doRemoveAddress(target, msg, false);
Connection existing = node.connectionManager.getConnection(target);
if (existing != connection) {
if (existing != null) {
existing.close(msg, null);
}
node.connectionManager.registerConnection(target, connection);
}
return false;
}
return true;
}
use of com.hazelcast.internal.partition.PartitionRuntimeState in project hazelcast by hazelcast.
the class MigrationManager method commitMigrationToDestination.
private boolean commitMigrationToDestination(Address destination, MigrationInfo migration) {
assert migration != null : "No migrations to commit! destination=" + destination;
if (node.getThisAddress().equals(destination)) {
if (logger.isFinestEnabled()) {
logger.finest("Shortcutting migration commit, since destination is master. -> " + migration);
}
return true;
}
MemberImpl member = node.getClusterService().getMember(destination);
if (member == null) {
logger.warning("Destination " + destination + " is not member anymore");
return false;
}
try {
if (logger.isFinestEnabled()) {
logger.finest("Sending commit operation to " + destination + " for " + migration);
}
PartitionRuntimeState partitionState = partitionService.createMigrationCommitPartitionState(migration);
String destinationUuid = member.getUuid();
MigrationCommitOperation operation = new MigrationCommitOperation(partitionState, destinationUuid);
Future<Boolean> future = nodeEngine.getOperationService().createInvocationBuilder(SERVICE_NAME, operation, destination).setTryCount(Integer.MAX_VALUE).setCallTimeout(Long.MAX_VALUE).invoke();
boolean result = future.get();
if (logger.isFinestEnabled()) {
logger.finest("Migration commit result " + result + " from " + destination + " for " + migration);
}
return result;
} catch (Throwable t) {
logMigrationCommitFailure(destination, migration, t);
}
return false;
}
use of com.hazelcast.internal.partition.PartitionRuntimeState in project hazelcast by hazelcast.
the class PartitionStateOperation method readInternal.
@Override
protected void readInternal(ObjectDataInput in) throws IOException {
super.readInternal(in);
partitionState = new PartitionRuntimeState();
partitionState.readData(in);
sync = in.readBoolean();
}
use of com.hazelcast.internal.partition.PartitionRuntimeState in project hazelcast by hazelcast.
the class MigrationCommitOperation method readInternal.
@Override
protected void readInternal(ObjectDataInput in) throws IOException {
super.readInternal(in);
expectedMemberUuid = in.readUTF();
partitionState = new PartitionRuntimeState();
partitionState.readData(in);
}
use of com.hazelcast.internal.partition.PartitionRuntimeState 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;
}
Aggregations