ijokarumawak commented on a change in pull request #3647: NIFI-6530 - HTTP 
SiteToSite server returns 201 in case no data is ava…
URL: https://github.com/apache/nifi/pull/3647#discussion_r313307594
 
 

 ##########
 File path: 
nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/DataTransferResource.java
 ##########
 @@ -205,9 +207,17 @@ public Response createPortTransaction(
         final int transportProtocolVersion = 
validationResult.transportProtocolVersion;
 
         try {
-            // Execute handshake.
-            initiateServerProtocol(req, peer, transportProtocolVersion);
+            HttpFlowFileServerProtocol serverProtocol = 
initiateServerProtocol(req, peer, transportProtocolVersion);
+            if (PORT_TYPE_OUTPUT.equals(portType)) {
+                List<Connection> connectionList = 
serverProtocol.getPort().getIncomingConnections();
+                if (connectionList.stream().allMatch(c -> 
c.getFlowFileQueue().isEmpty())) {
+                    // Transaction could be created, but there is nothing to 
transfer. Just return 200.
+                    logger.debug("Output port has no flowfiles to transfer, 
returning 200");
 
 Review comment:
   Also, we don't want to penalize a peer at a client in this case, because if 
we penalize, the peer will not be used for a certain period of time and that 
will adds some latency for the next data transfer.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to