You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by GitBox <gi...@apache.org> on 2021/04/21 22:29:51 UTC

[GitHub] [nifi] exceptionfactory opened a new pull request #5020: NIFI-8435 Added Kudu Client Worker Count property

exceptionfactory opened a new pull request #5020:
URL: https://github.com/apache/nifi/pull/5020


   #### Description of PR
   
   NIFI-8435 Adds the `Kudu Client Worker Count` property to `PutKudu` with a default value that matches the value used in `KuduClient`.  The property sets both the worker count property for `KuduClient` as well the maximum pool size for the `ThreadPoolExecutor` that `KuduClient` uses to configure the internal Netty `NioEventLoopGroup`.  This maximum pool size ensures that the thread pool cannot continue to grow unbounded in certain edge case scenarios.  The custom `ThreadFactory` also names client threads using the Processor Identifier to assist with runtime troubleshooting.
   
   Updates also include refactoring processing methods to ensure that the `KuduSession` is always closed after each `onTrigger` invocation.  Under the previous implementation, the Processor called `KuduSession.close()` when remaining buffered records were found.  `PutKudu` is also annotated with `SystemResource.MEMORY` to indicate that multiple instances increase memory usage based on pooled byte buffering present in Netty version 4.
   
   In order to streamline the review of the contribution we ask you
   to ensure the following steps have been taken:
   
   ### For all changes:
   - [X] Is there a JIRA ticket associated with this PR? Is it referenced 
        in the commit message?
   
   - [X] Does your PR title start with **NIFI-XXXX** where XXXX is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character.
   
   - [X] Has your PR been rebased against the latest commit within the target branch (typically `main`)?
   
   - [X] Is your initial contribution a single, squashed commit? _Additional commits in response to PR reviewer feedback should be made on this branch and pushed to allow change tracking. Do not `squash` or use `--force` when pushing to allow for clean monitoring of changes._
   
   ### For code changes:
   - [X] Have you ensured that the full suite of tests is executed via `mvn -Pcontrib-check clean install` at the root `nifi` folder?
   - [X] Have you written or updated unit tests to verify your changes?
   - [X] Have you verified that the full build is successful on JDK 8?
   - [X] Have you verified that the full build is successful on JDK 11?
   - [ ] If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under [ASF 2.0](http://www.apache.org/legal/resolved.html#category-a)? 
   - [ ] If applicable, have you updated the `LICENSE` file, including the main `LICENSE` file under `nifi-assembly`?
   - [ ] If applicable, have you updated the `NOTICE` file, including the main `NOTICE` file found under `nifi-assembly`?
   - [X] If adding new Properties, have you added `.displayName` in addition to .name (programmatic access) for each of the new properties?
   
   ### For documentation related changes:
   - [X] Have you ensured that format looks appropriate for the output in which it is rendered?
   
   ### Note:
   Please ensure that once the PR is submitted, you check GitHub Actions CI for build issues and submit an update to your PR as soon as possible.
   


-- 
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:
users@infra.apache.org



[GitHub] [nifi] asfgit closed pull request #5020: NIFI-8435 Added Kudu Client Worker Count property

Posted by GitBox <gi...@apache.org>.
asfgit closed pull request #5020:
URL: https://github.com/apache/nifi/pull/5020


   


-- 
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:
users@infra.apache.org



[GitHub] [nifi] granthenke commented on a change in pull request #5020: NIFI-8435 Added Kudu Client Worker Count property

Posted by GitBox <gi...@apache.org>.
granthenke commented on a change in pull request #5020:
URL: https://github.com/apache/nifi/pull/5020#discussion_r618059261



##########
File path: nifi-nar-bundles/nifi-kudu-bundle/nifi-kudu-processors/src/main/java/org/apache/nifi/processors/kudu/AbstractKuduProcessor.java
##########
@@ -184,10 +200,25 @@ protected KuduClient buildClient(final ProcessContext context) {
         final String masters = context.getProperty(KUDU_MASTERS).evaluateAttributeExpressions().getValue();
         final int operationTimeout = context.getProperty(KUDU_OPERATION_TIMEOUT_MS).evaluateAttributeExpressions().asTimePeriod(TimeUnit.MILLISECONDS).intValue();
         final int adminOperationTimeout = context.getProperty(KUDU_KEEP_ALIVE_PERIOD_TIMEOUT_MS).evaluateAttributeExpressions().asTimePeriod(TimeUnit.MILLISECONDS).intValue();
+        final int workerCount = context.getProperty(WORKER_COUNT).asInteger();
+
+        // Create Executor following approach of Executors.newCachedThreadPool() using worker count as maximum pool size
+        final int corePoolSize = 0;
+        final long threadKeepAliveTime = 60;
+        final Executor nioExecutor = new ThreadPoolExecutor(

Review comment:
       Is this required vs just setting the workerCount on the client? IIUC the client uses an unbound cached threadpool, but the NioEventLoopGroup will never user more than workerCount threads. 

##########
File path: nifi-nar-bundles/nifi-kudu-bundle/nifi-kudu-processors/src/main/java/org/apache/nifi/processors/kudu/AbstractKuduProcessor.java
##########
@@ -184,10 +200,25 @@ protected KuduClient buildClient(final ProcessContext context) {
         final String masters = context.getProperty(KUDU_MASTERS).evaluateAttributeExpressions().getValue();
         final int operationTimeout = context.getProperty(KUDU_OPERATION_TIMEOUT_MS).evaluateAttributeExpressions().asTimePeriod(TimeUnit.MILLISECONDS).intValue();
         final int adminOperationTimeout = context.getProperty(KUDU_KEEP_ALIVE_PERIOD_TIMEOUT_MS).evaluateAttributeExpressions().asTimePeriod(TimeUnit.MILLISECONDS).intValue();
+        final int workerCount = context.getProperty(WORKER_COUNT).asInteger();
+
+        // Create Executor following approach of Executors.newCachedThreadPool() using worker count as maximum pool size
+        final int corePoolSize = 0;
+        final long threadKeepAliveTime = 60;
+        final Executor nioExecutor = new ThreadPoolExecutor(
+                corePoolSize,
+                workerCount,
+                threadKeepAliveTime,
+                TimeUnit.SECONDS,
+                new SynchronousQueue<>(),
+                new ClientThreadFactory(getIdentifier())
+        );
 
         return new KuduClient.KuduClientBuilder(masters)
                 .defaultOperationTimeoutMs(operationTimeout)
-                .defaultSocketReadTimeoutMs(adminOperationTimeout)
+                .defaultAdminOperationTimeoutMs(adminOperationTimeout)

Review comment:
       This code looks suspect to me it's called adminOperationTimeout but the property is called KUDU_KEEP_ALIVE_PERIOD_TIMEOUT_MS. Not sure what this is and it probably should be cleaned up, but maybe in a seperate change.

##########
File path: nifi-nar-bundles/nifi-kudu-bundle/nifi-kudu-processors/src/main/java/org/apache/nifi/processors/kudu/PutKudu.java
##########
@@ -342,38 +346,73 @@ public void onTrigger(final ProcessContext context, final ProcessSession session
 
         final KerberosUser user = getKerberosUser();
         if (user == null) {
-            executeOnKuduClient(kuduClient -> trigger(context, session, flowFiles, kuduClient));
+            executeOnKuduClient(kuduClient -> processFlowFiles(context, session, flowFiles, kuduClient));
             return;
         }
 
         final PrivilegedExceptionAction<Void> privilegedAction = () -> {
-            executeOnKuduClient(kuduClient -> trigger(context, session, flowFiles, kuduClient));
+            executeOnKuduClient(kuduClient -> processFlowFiles(context, session, flowFiles, kuduClient));
             return null;
         };
 
         final KerberosAction<Void> action = new KerberosAction<>(user, privilegedAction, getLogger());
         action.execute();
     }
 
-    private void trigger(final ProcessContext context, final ProcessSession session, final List<FlowFile> flowFiles, KuduClient kuduClient) throws ProcessException {
-        final RecordReaderFactory recordReaderFactory = context.getProperty(RECORD_READER).asControllerService(RecordReaderFactory.class);
+    private void processFlowFiles(final ProcessContext context, final ProcessSession session, final List<FlowFile> flowFiles, final KuduClient kuduClient) {
+        final Map<FlowFile, Integer> processedRecords = new HashMap<>();
+        final Map<FlowFile, Object> flowFileFailures = new HashMap<>();
+        final Map<Operation, FlowFile> operationFlowFileMap = new HashMap<>();
+        final List<RowError> pendingRowErrors = new ArrayList<>();
 
         final KuduSession kuduSession = createKuduSession(kuduClient);
+        try {
+            processFlowFiles(flowFiles,
+                    processedRecords,
+                    flowFileFailures,
+                    operationFlowFileMap,
+                    pendingRowErrors,
+                    session,
+                    context,
+                    kuduClient,
+                    kuduSession);
+        } finally {
+            try {
+                flushKuduSession(kuduSession, true, pendingRowErrors);
+            } catch (final KuduException|RuntimeException e) {
+                getLogger().error("KuduSession.close() Failed", e);
+            }
+        }
 
-        final Map<FlowFile, Integer> numRecords = new HashMap<>();
-        final Map<FlowFile, Object> flowFileFailures = new HashMap<>();
-        final Map<Operation, FlowFile> operationFlowFileMap = new HashMap<>();
+        if (isRollbackOnFailure() && (!pendingRowErrors.isEmpty() || !flowFileFailures.isEmpty())) {
+            logFailures(pendingRowErrors, operationFlowFileMap);
+            session.rollback();
+            context.yield();
+        } else {
+            transferFlowFiles(flowFiles, processedRecords, flowFileFailures, operationFlowFileMap, pendingRowErrors, session);
+        }
+    }
 
-        int numBuffered = 0;
+    private void processFlowFiles(final List<FlowFile> flowFiles,

Review comment:
       Maybe use a different name than processFlowFiles or change the name of the above processFlowFiles?




-- 
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:
users@infra.apache.org



[GitHub] [nifi] granthenke commented on a change in pull request #5020: NIFI-8435 Added Kudu Client Worker Count property

Posted by GitBox <gi...@apache.org>.
granthenke commented on a change in pull request #5020:
URL: https://github.com/apache/nifi/pull/5020#discussion_r618639929



##########
File path: nifi-nar-bundles/nifi-kudu-bundle/nifi-kudu-processors/src/main/java/org/apache/nifi/processors/kudu/AbstractKuduProcessor.java
##########
@@ -184,10 +200,25 @@ protected KuduClient buildClient(final ProcessContext context) {
         final String masters = context.getProperty(KUDU_MASTERS).evaluateAttributeExpressions().getValue();
         final int operationTimeout = context.getProperty(KUDU_OPERATION_TIMEOUT_MS).evaluateAttributeExpressions().asTimePeriod(TimeUnit.MILLISECONDS).intValue();
         final int adminOperationTimeout = context.getProperty(KUDU_KEEP_ALIVE_PERIOD_TIMEOUT_MS).evaluateAttributeExpressions().asTimePeriod(TimeUnit.MILLISECONDS).intValue();
+        final int workerCount = context.getProperty(WORKER_COUNT).asInteger();
+
+        // Create Executor following approach of Executors.newCachedThreadPool() using worker count as maximum pool size
+        final int corePoolSize = 0;
+        final long threadKeepAliveTime = 60;
+        final Executor nioExecutor = new ThreadPoolExecutor(

Review comment:
       That makes sense. Thanks for clarifying. 




-- 
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:
users@infra.apache.org



[GitHub] [nifi] exceptionfactory commented on a change in pull request #5020: NIFI-8435 Added Kudu Client Worker Count property

Posted by GitBox <gi...@apache.org>.
exceptionfactory commented on a change in pull request #5020:
URL: https://github.com/apache/nifi/pull/5020#discussion_r618375958



##########
File path: nifi-nar-bundles/nifi-kudu-bundle/nifi-kudu-processors/src/main/java/org/apache/nifi/processors/kudu/AbstractKuduProcessor.java
##########
@@ -184,10 +200,25 @@ protected KuduClient buildClient(final ProcessContext context) {
         final String masters = context.getProperty(KUDU_MASTERS).evaluateAttributeExpressions().getValue();
         final int operationTimeout = context.getProperty(KUDU_OPERATION_TIMEOUT_MS).evaluateAttributeExpressions().asTimePeriod(TimeUnit.MILLISECONDS).intValue();
         final int adminOperationTimeout = context.getProperty(KUDU_KEEP_ALIVE_PERIOD_TIMEOUT_MS).evaluateAttributeExpressions().asTimePeriod(TimeUnit.MILLISECONDS).intValue();
+        final int workerCount = context.getProperty(WORKER_COUNT).asInteger();
+
+        // Create Executor following approach of Executors.newCachedThreadPool() using worker count as maximum pool size
+        final int corePoolSize = 0;
+        final long threadKeepAliveTime = 60;
+        final Executor nioExecutor = new ThreadPoolExecutor(
+                corePoolSize,
+                workerCount,
+                threadKeepAliveTime,
+                TimeUnit.SECONDS,
+                new SynchronousQueue<>(),
+                new ClientThreadFactory(getIdentifier())
+        );
 
         return new KuduClient.KuduClientBuilder(masters)
                 .defaultOperationTimeoutMs(operationTimeout)
-                .defaultSocketReadTimeoutMs(adminOperationTimeout)
+                .defaultAdminOperationTimeoutMs(adminOperationTimeout)

Review comment:
       The `defaultSocketReadTimeoutMs()` setting is deprecated in version 1.14, and the existing variable name `adminOperationTimeout` seemed to be a good match for the `defaultAdminOperationTimeoutMs()` setting.  However, the processor property name and description do not seem to match up as described.  Do you think `defaultAdminOperationTimeoutMs()` should be set using the `operationTimeout` value instead?




-- 
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:
users@infra.apache.org



[GitHub] [nifi] exceptionfactory commented on a change in pull request #5020: NIFI-8435 Added Kudu Client Worker Count property

Posted by GitBox <gi...@apache.org>.
exceptionfactory commented on a change in pull request #5020:
URL: https://github.com/apache/nifi/pull/5020#discussion_r618601572



##########
File path: nifi-nar-bundles/nifi-kudu-bundle/nifi-kudu-processors/src/main/java/org/apache/nifi/processors/kudu/PutKudu.java
##########
@@ -342,38 +346,73 @@ public void onTrigger(final ProcessContext context, final ProcessSession session
 
         final KerberosUser user = getKerberosUser();
         if (user == null) {
-            executeOnKuduClient(kuduClient -> trigger(context, session, flowFiles, kuduClient));
+            executeOnKuduClient(kuduClient -> processFlowFiles(context, session, flowFiles, kuduClient));
             return;
         }
 
         final PrivilegedExceptionAction<Void> privilegedAction = () -> {
-            executeOnKuduClient(kuduClient -> trigger(context, session, flowFiles, kuduClient));
+            executeOnKuduClient(kuduClient -> processFlowFiles(context, session, flowFiles, kuduClient));
             return null;
         };
 
         final KerberosAction<Void> action = new KerberosAction<>(user, privilegedAction, getLogger());
         action.execute();
     }
 
-    private void trigger(final ProcessContext context, final ProcessSession session, final List<FlowFile> flowFiles, KuduClient kuduClient) throws ProcessException {
-        final RecordReaderFactory recordReaderFactory = context.getProperty(RECORD_READER).asControllerService(RecordReaderFactory.class);
+    private void processFlowFiles(final ProcessContext context, final ProcessSession session, final List<FlowFile> flowFiles, final KuduClient kuduClient) {
+        final Map<FlowFile, Integer> processedRecords = new HashMap<>();
+        final Map<FlowFile, Object> flowFileFailures = new HashMap<>();
+        final Map<Operation, FlowFile> operationFlowFileMap = new HashMap<>();
+        final List<RowError> pendingRowErrors = new ArrayList<>();
 
         final KuduSession kuduSession = createKuduSession(kuduClient);
+        try {
+            processFlowFiles(flowFiles,
+                    processedRecords,
+                    flowFileFailures,
+                    operationFlowFileMap,
+                    pendingRowErrors,
+                    session,
+                    context,
+                    kuduClient,
+                    kuduSession);
+        } finally {
+            try {
+                flushKuduSession(kuduSession, true, pendingRowErrors);
+            } catch (final KuduException|RuntimeException e) {
+                getLogger().error("KuduSession.close() Failed", e);
+            }
+        }
 
-        final Map<FlowFile, Integer> numRecords = new HashMap<>();
-        final Map<FlowFile, Object> flowFileFailures = new HashMap<>();
-        final Map<Operation, FlowFile> operationFlowFileMap = new HashMap<>();
+        if (isRollbackOnFailure() && (!pendingRowErrors.isEmpty() || !flowFileFailures.isEmpty())) {
+            logFailures(pendingRowErrors, operationFlowFileMap);
+            session.rollback();
+            context.yield();
+        } else {
+            transferFlowFiles(flowFiles, processedRecords, flowFileFailures, operationFlowFileMap, pendingRowErrors, session);
+        }
+    }
 
-        int numBuffered = 0;
+    private void processFlowFiles(final List<FlowFile> flowFiles,

Review comment:
       Updated to processRecords, thanks!




-- 
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:
users@infra.apache.org



[GitHub] [nifi] exceptionfactory commented on a change in pull request #5020: NIFI-8435 Added Kudu Client Worker Count property

Posted by GitBox <gi...@apache.org>.
exceptionfactory commented on a change in pull request #5020:
URL: https://github.com/apache/nifi/pull/5020#discussion_r618371556



##########
File path: nifi-nar-bundles/nifi-kudu-bundle/nifi-kudu-processors/src/main/java/org/apache/nifi/processors/kudu/AbstractKuduProcessor.java
##########
@@ -184,10 +200,25 @@ protected KuduClient buildClient(final ProcessContext context) {
         final String masters = context.getProperty(KUDU_MASTERS).evaluateAttributeExpressions().getValue();
         final int operationTimeout = context.getProperty(KUDU_OPERATION_TIMEOUT_MS).evaluateAttributeExpressions().asTimePeriod(TimeUnit.MILLISECONDS).intValue();
         final int adminOperationTimeout = context.getProperty(KUDU_KEEP_ALIVE_PERIOD_TIMEOUT_MS).evaluateAttributeExpressions().asTimePeriod(TimeUnit.MILLISECONDS).intValue();
+        final int workerCount = context.getProperty(WORKER_COUNT).asInteger();
+
+        // Create Executor following approach of Executors.newCachedThreadPool() using worker count as maximum pool size
+        final int corePoolSize = 0;
+        final long threadKeepAliveTime = 60;
+        final Executor nioExecutor = new ThreadPoolExecutor(

Review comment:
       Technically it isn't required as you mentioned.  However, creating the ThreadPoolExecutor instance with a custom ThreadFactory allows for created Threads to be named using the Processor Identifier.  This is useful when troubleshooting multiple instances of PutKudu in a single VM, otherwise there can be multiple threads with the same name, such as `kudu-nio-0`.




-- 
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:
users@infra.apache.org



[GitHub] [nifi] exceptionfactory commented on a change in pull request #5020: NIFI-8435 Added Kudu Client Worker Count property

Posted by GitBox <gi...@apache.org>.
exceptionfactory commented on a change in pull request #5020:
URL: https://github.com/apache/nifi/pull/5020#discussion_r618628897



##########
File path: nifi-nar-bundles/nifi-kudu-bundle/nifi-kudu-processors/src/main/java/org/apache/nifi/processors/kudu/AbstractKuduProcessor.java
##########
@@ -184,10 +200,25 @@ protected KuduClient buildClient(final ProcessContext context) {
         final String masters = context.getProperty(KUDU_MASTERS).evaluateAttributeExpressions().getValue();
         final int operationTimeout = context.getProperty(KUDU_OPERATION_TIMEOUT_MS).evaluateAttributeExpressions().asTimePeriod(TimeUnit.MILLISECONDS).intValue();
         final int adminOperationTimeout = context.getProperty(KUDU_KEEP_ALIVE_PERIOD_TIMEOUT_MS).evaluateAttributeExpressions().asTimePeriod(TimeUnit.MILLISECONDS).intValue();
+        final int workerCount = context.getProperty(WORKER_COUNT).asInteger();
+
+        // Create Executor following approach of Executors.newCachedThreadPool() using worker count as maximum pool size
+        final int corePoolSize = 0;
+        final long threadKeepAliveTime = 60;
+        final Executor nioExecutor = new ThreadPoolExecutor(
+                corePoolSize,
+                workerCount,
+                threadKeepAliveTime,
+                TimeUnit.SECONDS,
+                new SynchronousQueue<>(),
+                new ClientThreadFactory(getIdentifier())
+        );
 
         return new KuduClient.KuduClientBuilder(masters)
                 .defaultOperationTimeoutMs(operationTimeout)
-                .defaultSocketReadTimeoutMs(adminOperationTimeout)
+                .defaultAdminOperationTimeoutMs(adminOperationTimeout)

Review comment:
       Reverted the change for now, something that can be addressed separately.




-- 
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:
users@infra.apache.org



[GitHub] [nifi] exceptionfactory commented on a change in pull request #5020: NIFI-8435 Added Kudu Client Worker Count property

Posted by GitBox <gi...@apache.org>.
exceptionfactory commented on a change in pull request #5020:
URL: https://github.com/apache/nifi/pull/5020#discussion_r618379123



##########
File path: nifi-nar-bundles/nifi-kudu-bundle/nifi-kudu-processors/src/main/java/org/apache/nifi/processors/kudu/PutKudu.java
##########
@@ -342,38 +346,73 @@ public void onTrigger(final ProcessContext context, final ProcessSession session
 
         final KerberosUser user = getKerberosUser();
         if (user == null) {
-            executeOnKuduClient(kuduClient -> trigger(context, session, flowFiles, kuduClient));
+            executeOnKuduClient(kuduClient -> processFlowFiles(context, session, flowFiles, kuduClient));
             return;
         }
 
         final PrivilegedExceptionAction<Void> privilegedAction = () -> {
-            executeOnKuduClient(kuduClient -> trigger(context, session, flowFiles, kuduClient));
+            executeOnKuduClient(kuduClient -> processFlowFiles(context, session, flowFiles, kuduClient));
             return null;
         };
 
         final KerberosAction<Void> action = new KerberosAction<>(user, privilegedAction, getLogger());
         action.execute();
     }
 
-    private void trigger(final ProcessContext context, final ProcessSession session, final List<FlowFile> flowFiles, KuduClient kuduClient) throws ProcessException {
-        final RecordReaderFactory recordReaderFactory = context.getProperty(RECORD_READER).asControllerService(RecordReaderFactory.class);
+    private void processFlowFiles(final ProcessContext context, final ProcessSession session, final List<FlowFile> flowFiles, final KuduClient kuduClient) {
+        final Map<FlowFile, Integer> processedRecords = new HashMap<>();
+        final Map<FlowFile, Object> flowFileFailures = new HashMap<>();
+        final Map<Operation, FlowFile> operationFlowFileMap = new HashMap<>();
+        final List<RowError> pendingRowErrors = new ArrayList<>();
 
         final KuduSession kuduSession = createKuduSession(kuduClient);
+        try {
+            processFlowFiles(flowFiles,
+                    processedRecords,
+                    flowFileFailures,
+                    operationFlowFileMap,
+                    pendingRowErrors,
+                    session,
+                    context,
+                    kuduClient,
+                    kuduSession);
+        } finally {
+            try {
+                flushKuduSession(kuduSession, true, pendingRowErrors);
+            } catch (final KuduException|RuntimeException e) {
+                getLogger().error("KuduSession.close() Failed", e);
+            }
+        }
 
-        final Map<FlowFile, Integer> numRecords = new HashMap<>();
-        final Map<FlowFile, Object> flowFileFailures = new HashMap<>();
-        final Map<Operation, FlowFile> operationFlowFileMap = new HashMap<>();
+        if (isRollbackOnFailure() && (!pendingRowErrors.isEmpty() || !flowFileFailures.isEmpty())) {
+            logFailures(pendingRowErrors, operationFlowFileMap);
+            session.rollback();
+            context.yield();
+        } else {
+            transferFlowFiles(flowFiles, processedRecords, flowFileFailures, operationFlowFileMap, pendingRowErrors, session);
+        }
+    }
 
-        int numBuffered = 0;
+    private void processFlowFiles(final List<FlowFile> flowFiles,

Review comment:
       That seems reasonable, how about `processFlowFileRecords`?




-- 
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:
users@infra.apache.org