From 1070bd59e284938a5be812d07e4128459b046dbf Mon Sep 17 00:00:00 2001 From: Mark Payne Date: Tue, 19 Jul 2016 15:33:59 -0400 Subject: [PATCH] NIFI-2319: Ensure that when we set cluster node id's and node addresses, that we do so only if they are not already populated --- .../http/endpoints/ComponentStateEndpointMerger.java | 7 +++++-- .../http/endpoints/ListFlowFilesEndpointMerger.java | 6 ++++-- .../http/endpoints/ProvenanceEventEndpointMerger.java | 11 ++++++++--- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/coordination/http/endpoints/ComponentStateEndpointMerger.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/coordination/http/endpoints/ComponentStateEndpointMerger.java index 5ab71c934e5d..3b03ed0b1e31 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/coordination/http/endpoints/ComponentStateEndpointMerger.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/coordination/http/endpoints/ComponentStateEndpointMerger.java @@ -74,8 +74,11 @@ protected void mergeResponses(ComponentStateDTO clientDto, Map dtoMap, Set successfulResponses, Set problematicResponses) { // The request for a Provenance Event is replicated to a single Node. We simply update its cluster node info. - final NodeIdentifier nodeId = successfulResponses.iterator().next().getNodeId(); - clientDto.setClusterNodeId(nodeId.getId()); - clientDto.setClusterNodeAddress(nodeId.getApiAddress() + ":" + nodeId.getApiPort()); + // However, we only do this if the cluster node info isn't set, because if this is replicated across the cluster, + // the cluster coordinator will have already set it, and we will be receiving the response from the cluster + // coordinator. We do not want to overwrite this value on all DTO's with the cluster coordinator's information. + if (clientDto.getClusterNodeId() == null || clientDto.getClusterNodeAddress() == null) { + final NodeIdentifier nodeId = successfulResponses.iterator().next().getNodeId(); + clientDto.setClusterNodeId(nodeId.getId()); + clientDto.setClusterNodeAddress(nodeId.getApiAddress() + ":" + nodeId.getApiPort()); + } } }