NIFI-5672: Do not compare Load Balancing address/port for logical equivalence of Node Identifiers. Added more details to logging of Node Identifiers

This closes #3054
This commit is contained in:
Mark Payne 2018-10-09 12:19:24 -04:00 committed by Matt Gilman
parent 77edddd988
commit 9dfc6683ee
No known key found for this signature in database
GPG Key ID: DF61EC19432AEE37
2 changed files with 20 additions and 15 deletions

View File

@ -23,6 +23,7 @@ import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import java.util.Collections;
import java.util.HashSet;
import java.util.Objects;
import java.util.Set;
/**
@ -254,24 +255,21 @@ public class NodeIdentifier {
if (other == null) {
return false;
}
if ((this.apiAddress == null) ? (other.apiAddress != null) : !this.apiAddress.equals(other.apiAddress)) {
if (other == this) {
return true;
}
if (!Objects.equals(apiAddress, other.apiAddress)) {
return false;
}
if (this.apiPort != other.apiPort) {
return false;
}
if ((this.socketAddress == null) ? (other.socketAddress != null) : !this.socketAddress.equals(other.socketAddress)) {
if (!Objects.equals(socketAddress, other.socketAddress)) {
return false;
}
if (this.socketPort != other.socketPort) {
return false;
}
if (!this.loadBalanceAddress.equals(other.loadBalanceAddress)) {
return false;
}
if (this.loadBalancePort != other.loadBalancePort) {
return false;
}
return true;
}
@ -288,4 +286,10 @@ public class NodeIdentifier {
return apiAddress + ":" + apiPort;
}
public String getFullDescription() {
return "NodeIdentifier[UUID=" + id + ", API Address = " + apiAddress + ":" + apiPort + ", Cluster Socket Address = " + socketAddress + ":" + socketPort
+ ", Load Balance Address = " + loadBalanceAddress + ":" + loadBalancePort + ", Site-to-Site Raw Address = " + siteToSiteAddress + ":" + siteToSitePort
+ ", Site-to-Site HTTP Address = " + apiAddress + ":" + siteToSiteHttpApiPort + ", Site-to-Site Secure = " + siteToSiteSecure + ", Node Identities = " + nodeIdentities + "]";
}
}

View File

@ -174,8 +174,8 @@ public class NodeClusterCoordinator implements ClusterCoordinator, ProtocolHandl
if (localNodeId == null) {
localNodeId = nodeId;
} else {
logger.warn("When recovering state, determined that tgwo Node Identifiers claim to be the local Node Identifier: {} and {}. Will ignore both of these and wait until " +
"connecting to cluster to determine which Node Identiifer is the local Node Identifier", localNodeId, nodeId);
logger.warn("When recovering state, determined that two Node Identifiers claim to be the local Node Identifier: {} and {}. Will ignore both of these and wait until " +
"connecting to cluster to determine which Node Identiifer is the local Node Identifier", localNodeId.getFullDescription(), nodeId.getFullDescription());
localNodeId = null;
}
}
@ -1029,19 +1029,20 @@ public class NodeClusterCoordinator implements ClusterCoordinator, ProtocolHandl
if (existingStatus == null) {
// there is no node with that ID
resolvedNodeId = proposedIdentifier;
logger.debug("No existing node with ID {}; resolved node ID is as-proposed", proposedIdentifier.getId());
logger.debug("No existing node with ID {}; resolved node ID is as-proposed", proposedIdentifier.getFullDescription());
onNodeAdded(resolvedNodeId, true);
} else if (existingStatus.getNodeIdentifier().logicallyEquals(proposedIdentifier)) {
// there is a node with that ID but it's the same node.
resolvedNodeId = proposedIdentifier;
logger.debug("No existing node with ID {}; resolved node ID is as-proposed", proposedIdentifier.getId());
logger.debug("A node already exists with ID {} and is logically equivalent; resolved node ID is as-proposed: {}", proposedIdentifier.getId(), proposedIdentifier.getFullDescription());
} else {
// there is a node with that ID and it's a different node
resolvedNodeId = new NodeIdentifier(UUID.randomUUID().toString(), proposedIdentifier.getApiAddress(), proposedIdentifier.getApiPort(),
proposedIdentifier.getSocketAddress(), proposedIdentifier.getSocketPort(), proposedIdentifier.getSiteToSiteAddress(),
proposedIdentifier.getSiteToSitePort(), proposedIdentifier.getSiteToSiteHttpApiPort(), proposedIdentifier.isSiteToSiteSecure());
proposedIdentifier.getSocketAddress(), proposedIdentifier.getSocketPort(), proposedIdentifier.getLoadBalanceAddress(), proposedIdentifier.getLoadBalancePort(),
proposedIdentifier.getSiteToSiteAddress(), proposedIdentifier.getSiteToSitePort(), proposedIdentifier.getSiteToSiteHttpApiPort(), proposedIdentifier.isSiteToSiteSecure());
logger.debug("A node already exists with ID {}. Proposed Node Identifier was {}; existing Node Identifier is {}; Resolved Node Identifier is {}",
proposedIdentifier.getId(), proposedIdentifier, getNodeIdentifier(proposedIdentifier.getId()), resolvedNodeId);
proposedIdentifier.getId(), proposedIdentifier.getFullDescription(), getNodeIdentifier(proposedIdentifier.getId()).getFullDescription(), resolvedNodeId.getFullDescription());
}
return resolvedNodeId;