nifi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From marka...@apache.org
Subject [1/2] nifi git commit: NIFI-1650: Ensure that we seek to the appropriate offset within the Content Claim when downloading content of a FlowFile
Date Mon, 21 Mar 2016 14:30:41 GMT
Repository: nifi
Updated Branches:
  refs/heads/master 9cde92da1 -> 38c782c30


NIFI-1650: Ensure that we seek to the appropriate offset within the Content Claim when downloading
content of a FlowFile


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

Branch: refs/heads/master
Commit: d3578a7c03835fb55f90fa25856f6cc7ae824994
Parents: 9cde92d
Author: Mark Payne <markap14@hotmail.com>
Authored: Sat Mar 19 11:18:02 2016 -0400
Committer: Mark Payne <markap14@hotmail.com>
Committed: Mon Mar 21 10:30:23 2016 -0400

----------------------------------------------------------------------
 .../org/apache/nifi/controller/FlowController.java     | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/nifi/blob/d3578a7c/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/FlowController.java
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/FlowController.java
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/FlowController.java
index 6d09bf6..c9aaceb 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/FlowController.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/FlowController.java
@@ -158,6 +158,8 @@ import org.apache.nifi.reporting.ReportingInitializationContext;
 import org.apache.nifi.reporting.ReportingTask;
 import org.apache.nifi.reporting.Severity;
 import org.apache.nifi.scheduling.SchedulingStrategy;
+import org.apache.nifi.stream.io.LimitingInputStream;
+import org.apache.nifi.stream.io.StreamUtils;
 import org.apache.nifi.util.FormatUtils;
 import org.apache.nifi.util.NiFiProperties;
 import org.apache.nifi.util.ReflectionUtils;
@@ -3381,7 +3383,7 @@ public class FlowController implements EventAccess, ControllerServiceProvider,
R
         requireNonNull(requestor);
         requireNonNull(requestUri);
 
-        final InputStream stream;
+        InputStream stream;
         final ResourceClaim resourceClaim;
         final ContentClaim contentClaim = flowFile.getContentClaim();
         if (contentClaim == null) {
@@ -3390,6 +3392,12 @@ public class FlowController implements EventAccess, ControllerServiceProvider,
R
         } else {
             resourceClaim = flowFile.getContentClaim().getResourceClaim();
             stream = contentRepository.read(flowFile.getContentClaim());
+            final long contentClaimOffset = flowFile.getContentClaimOffset();
+            if (contentClaimOffset > 0L) {
+                StreamUtils.skip(stream, contentClaimOffset);
+            }
+
+            stream = new LimitingInputStream(stream, flowFile.getSize());
         }
 
         // Register a Provenance Event to indicate that we replayed the data.
@@ -3406,7 +3414,8 @@ public class FlowController implements EventAccess, ControllerServiceProvider,
R
             .setDetails("Download of Content requested by " + requestor + " for " + flowFile);
 
         if (contentClaim != null) {
-            sendEventBuilder.setCurrentContentClaim(resourceClaim.getContainer(), resourceClaim.getSection(),
resourceClaim.getId(), contentClaim.getOffset(), flowFile.getSize());
+            sendEventBuilder.setCurrentContentClaim(resourceClaim.getContainer(), resourceClaim.getSection(),
resourceClaim.getId(),
+                contentClaim.getOffset() + flowFile.getContentClaimOffset(), flowFile.getSize());
         }
 
         final ProvenanceEventRecord sendEvent = sendEventBuilder.build();


Mime
View raw message