From 45ca978498725ca19530ed51138a252d17e4d676 Mon Sep 17 00:00:00 2001 From: Mark Payne Date: Fri, 29 Apr 2016 16:07:37 -0400 Subject: [PATCH] NIFI-1830: Fixed problems in the merging logic for Drop FlowFile Requests. This closes #394 --- .../manager/impl/WebClusterManager.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/impl/WebClusterManager.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/impl/WebClusterManager.java index 88da5fff55..fbf400b4c5 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/impl/WebClusterManager.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/impl/WebClusterManager.java @@ -2990,9 +2990,18 @@ public class WebClusterManager implements HttpClusterManager, ProtocolHandler, C long droppedSize = 0; DropFlowFileState state = null; + boolean allFinished = true; + String failureReason = null; for (final Map.Entry nodeEntry : dropRequestMap.entrySet()) { final DropRequestDTO nodeDropRequest = nodeEntry.getValue(); + if (!nodeDropRequest.isFinished()) { + allFinished = false; + } + if (nodeDropRequest.getFailureReason() != null) { + failureReason = nodeDropRequest.getFailureReason(); + } + currentCount += nodeDropRequest.getCurrentCount(); currentSize += nodeDropRequest.getCurrentSize(); droppedCount += nodeDropRequest.getDroppedCount(); @@ -3006,7 +3015,7 @@ public class WebClusterManager implements HttpClusterManager, ProtocolHandler, C } final DropFlowFileState nodeState = DropFlowFileState.valueOfDescription(nodeDropRequest.getState()); - if (state == null || state.compareTo(nodeState) > 0) { + if (state == null || state.ordinal() > nodeState.ordinal()) { state = nodeState; } } @@ -3019,6 +3028,14 @@ public class WebClusterManager implements HttpClusterManager, ProtocolHandler, C dropRequest.setDroppedSize(droppedSize); dropRequest.setDropped(FormatUtils.formatCount(droppedCount) + " / " + FormatUtils.formatDataSize(droppedSize)); + dropRequest.setFinished(allFinished); + dropRequest.setFailureReason(failureReason); + if (originalCount == 0) { + dropRequest.setPercentCompleted(allFinished ? 100 : 0); + } else { + dropRequest.setPercentCompleted((int) ((double) droppedCount / (double) originalCount * 100D)); + } + if (!nodeWaiting) { dropRequest.setOriginalCount(originalCount); dropRequest.setOriginalSize(originalSize);