pvillard31 commented on a change in pull request #3610: NIFI-6552 Kudu Put
Operations
URL: https://github.com/apache/nifi/pull/3610#discussion_r317066229
##########
File path:
nifi-nar-bundles/nifi-kudu-bundle/nifi-kudu-processors/src/main/java/org/apache/nifi/processors/kudu/PutKudu.java
##########
@@ -213,58 +198,18 @@
return rels;
}
+ protected KerberosUser kerberosUser;
+ protected KuduSession kuduSession;
+ protected String tableName;
@OnScheduled
public void onScheduled(final ProcessContext context) throws IOException,
LoginException {
- final String kuduMasters =
context.getProperty(KUDU_MASTERS).evaluateAttributeExpressions().getValue();
- operationType =
OperationType.valueOf(context.getProperty(INSERT_OPERATION).getValue());
+ tableName =
context.getProperty(TABLE_NAME).evaluateAttributeExpressions().getValue();
batchSize =
context.getProperty(BATCH_SIZE).evaluateAttributeExpressions().asInteger();
ffbatch =
context.getProperty(FLOWFILE_BATCH_SIZE).evaluateAttributeExpressions().asInteger();
flushMode =
SessionConfiguration.FlushMode.valueOf(context.getProperty(FLUSH_MODE).getValue());
-
- getLogger().debug("Setting up Kudu connection...");
- final KerberosCredentialsService credentialsService =
context.getProperty(KERBEROS_CREDENTIALS_SERVICE).asControllerService(KerberosCredentialsService.class);
- kuduClient = createClient(kuduMasters, credentialsService);
- getLogger().debug("Kudu connection successfully initialized");
- }
-
- protected KuduClient createClient(final String masters, final
KerberosCredentialsService credentialsService) throws LoginException {
- if (credentialsService == null) {
- return buildClient(masters);
- }
-
- final String keytab = credentialsService.getKeytab();
- final String principal = credentialsService.getPrincipal();
- kerberosUser = loginKerberosUser(principal, keytab);
-
- final KerberosAction<KuduClient> kerberosAction = new
KerberosAction<>(kerberosUser, () -> buildClient(masters), getLogger());
- return kerberosAction.execute();
- }
-
- protected KuduClient buildClient(final String masters) {
- return new KuduClient.KuduClientBuilder(masters).build();
- }
-
- protected KerberosUser loginKerberosUser(final String principal, final
String keytab) throws LoginException {
- final KerberosUser kerberosUser = new KerberosKeytabUser(principal,
keytab);
- kerberosUser.login();
- return kerberosUser;
- }
-
- @OnStopped
- public final void closeClient() throws KuduException, LoginException {
- try {
- if (kuduClient != null) {
- getLogger().debug("Closing KuduClient");
- kuduClient.close();
- kuduClient = null;
- }
- } finally {
- if (kerberosUser != null) {
- kerberosUser.logout();
- kerberosUser = null;
- }
- }
+ createKuduClient(context);
+ kuduTable = getKuduClient().openTable(tableName);
Review comment:
This is not necessary as we are evaluating the table name L257 based on FFs
attributes (and doing the same on L258).
----------------------------------------------------------------
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