You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by mc...@apache.org on 2015/11/02 14:59:47 UTC

nifi git commit: NIFI-730: - Updating logic now that original is guaranteed to be non null. - Always reporting 100% once the drop request has completed.

Repository: nifi
Updated Branches:
  refs/heads/NIFI-730 f5727cfb0 -> 5a04021dd


NIFI-730:
- Updating logic now that original is guaranteed to be non null.
- Always reporting 100% once the drop request has completed.

Project: http://git-wip-us.apache.org/repos/asf/nifi/repo
Commit: http://git-wip-us.apache.org/repos/asf/nifi/commit/5a04021d
Tree: http://git-wip-us.apache.org/repos/asf/nifi/tree/5a04021d
Diff: http://git-wip-us.apache.org/repos/asf/nifi/diff/5a04021d

Branch: refs/heads/NIFI-730
Commit: 5a04021dd7a61cc7c76b24405288713116bcd682
Parents: f5727cf
Author: Matt Gilman <ma...@gmail.com>
Authored: Mon Nov 2 08:59:11 2015 -0500
Committer: Matt Gilman <ma...@gmail.com>
Committed: Mon Nov 2 08:59:11 2015 -0500

----------------------------------------------------------------------
 .../org/apache/nifi/web/api/dto/DtoFactory.java | 22 +++++++++++---------
 1 file changed, 12 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/nifi/blob/5a04021d/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/dto/DtoFactory.java
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/dto/DtoFactory.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/dto/DtoFactory.java
index d34242d..5d437cf 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/dto/DtoFactory.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/dto/DtoFactory.java
@@ -296,6 +296,10 @@ public final class DtoFactory {
         return new PositionDTO(position.getX(), position.getY());
     }
 
+    private boolean isDropRequestComplete(final DropFlowFileState state) {
+        return DropFlowFileState.COMPLETE.equals(state) || DropFlowFileState.CANCELED.equals(state) || DropFlowFileState.FAILURE.equals(state);
+    }
+
     /**
      * Creates a DropRequestDTO from the specified flow file status.
      *
@@ -309,9 +313,7 @@ public final class DtoFactory {
         dto.setLastUpdated(new Date(dropRequest.getLastUpdated()));
         dto.setState(dropRequest.getState().toString());
         dto.setFailureReason(dropRequest.getFailureReason());
-        dto.setFinished(DropFlowFileState.COMPLETE.equals(dropRequest.getState())
-                || DropFlowFileState.CANCELED.equals(dropRequest.getState())
-                || DropFlowFileState.FAILURE.equals(dropRequest.getState()));
+        dto.setFinished(isDropRequestComplete(dropRequest.getState()));
 
         final QueueSize dropped = dropRequest.getDroppedSize();
         dto.setDroppedCount(dropped.getObjectCount());
@@ -323,15 +325,15 @@ public final class DtoFactory {
         dto.setCurrentSize(current.getByteCount());
         dto.setCurrent(FormatUtils.formatCount(current.getObjectCount()) + " / " + FormatUtils.formatDataSize(current.getByteCount()));
 
-        if (dropRequest.getOriginalSize() != null) {
-            final QueueSize original = dropRequest.getOriginalSize();
-            dto.setOriginalCount(original.getObjectCount());
-            dto.setOriginalSize(original.getByteCount());
-            dto.setOriginal(FormatUtils.formatCount(original.getObjectCount()) + " / " + FormatUtils.formatDataSize(original.getByteCount()));
+        final QueueSize original = dropRequest.getOriginalSize();
+        dto.setOriginalCount(original.getObjectCount());
+        dto.setOriginalSize(original.getByteCount());
+        dto.setOriginal(FormatUtils.formatCount(original.getObjectCount()) + " / " + FormatUtils.formatDataSize(original.getByteCount()));
 
-            dto.setPercentCompleted((dropped.getObjectCount() * 100) / original.getObjectCount());
+        if (isDropRequestComplete(dropRequest.getState())) {
+            dto.setPercentCompleted(100);
         } else {
-            dto.setPercentCompleted(0);
+            dto.setPercentCompleted((dropped.getObjectCount() * 100) / original.getObjectCount());
         }
 
         return dto;