granthenke commented on a change in pull request #3387: NIFI-6009 ScanKudu 
Processor & KuduPut Processor Delete Operation
URL: https://github.com/apache/nifi/pull/3387#discussion_r273568153
 
 

 ##########
 File path: 
nifi-nar-bundles/nifi-kudu-bundle/nifi-kudu-processors/src/main/java/org/apache/nifi/kudu/PutKudu.java
 ##########
 @@ -279,43 +217,56 @@ public void onTrigger(final ProcessContext context, 
final ProcessSession session
         if (flowFiles.isEmpty()) {
             return;
         }
+        final KuduClientService clientService = 
context.getProperty(KUDU_CLIENT_SERVICE).asControllerService(KuduClientService.class);
+        kerberosUser = clientService.getKerberosUser();
 
         final KerberosUser user = kerberosUser;
         if (user == null) {
-            trigger(context, session, flowFiles);
+            trigger(context, session, flowFiles, clientService);
             return;
         }
 
         final PrivilegedExceptionAction<Void> privelegedAction = () -> {
-            trigger(context, session, flowFiles);
+            trigger(context, session, flowFiles, clientService);
             return null;
         };
 
         final KerberosAction<Void> action = new KerberosAction<>(user, 
privelegedAction, getLogger());
         action.execute();
     }
 
-    private void trigger(final ProcessContext context, final ProcessSession 
session, final List<FlowFile> flowFiles) throws ProcessException {
-        final KuduSession kuduSession = getKuduSession(kuduClient);
+    private void trigger(final ProcessContext context, final ProcessSession 
session, final List<FlowFile> flowFiles,  KuduClientService clientService) 
throws ProcessException {
         final RecordReaderFactory recordReaderFactory = 
context.getProperty(RECORD_READER).asControllerService(RecordReaderFactory.class);
 
+        try {
+            kuduTable = clientService.getKuduClient().openTable(tableName);
+        } catch (KuduException e) {
+            e.printStackTrace();
+        }
+
+        final KuduClient kuduClient = clientService.getKuduClient();
+        kuduSession = getKuduSession(kuduClient);
+
         final Map<FlowFile, Integer> numRecords = new HashMap<>();
         final Map<FlowFile, Object> flowFileFailures = new HashMap<>();
         final Map<Operation, FlowFile> operationFlowFileMap = new HashMap<>();
 
         int numBuffered = 0;
         final List<RowError> pendingRowErrors = new ArrayList<>();
         for (FlowFile flowFile : flowFiles) {
+            operationType = 
OperationType.valueOf(context.getProperty(INSERT_OPERATION).evaluateAttributeExpressions(flowFile).getValue());
 
 Review comment:
   Is the idea that a user would have a flow of all INSERTS or all DELETE 
operations? Are there example of other nifi processors that handle different 
operation types? (I am not super familiar with Nifi)

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to