jtstorck commented on a change in pull request #4102: NIFI-7025: Adds Kerberos 
Password to Hive/Hive_1_1/Hive3 components
URL: https://github.com/apache/nifi/pull/4102#discussion_r385938030
 
 

 ##########
 File path: 
nifi-nar-bundles/nifi-hive-bundle/nifi-hive-processors/src/main/java/org/apache/nifi/dbcp/hive/HiveConnectionPool.java
 ##########
 @@ -363,6 +379,20 @@ public Connection getConnection() throws ProcessException 
{
                      * the acquisition of a new TGT after the current one has 
expired.
                      * https://issues.apache.org/jira/browse/NIFI-5134
                      */
+                    getLogger().trace("getting UGI instance");
+                    if (kerberosUserReference.get() != null) {
+                        // if there's a KerberosUser associated with this UGI, 
check the TGT and relogin if it is close to expiring
+                        KerberosUser kerberosUser = 
kerberosUserReference.get();
+                        getLogger().debug("kerberosUser is " + kerberosUser);
+                        try {
+                            getLogger().debug("checking TGT on kerberosUser 
[{}]", new Object[] {kerberosUser});
+                            kerberosUser.checkTGTAndRelogin();
+                        } catch (LoginException e) {
+                            throw new ProcessException("Unable to relogin with 
kerberos credentials for " + kerberosUser.getPrincipal(), e);
+                        }
+                    } else {
+                        getLogger().debug("kerberosUser was null, will not 
refresh TGT with KerberosUser");
+                    }
                     ugi.checkTGTAndReloginFromKeytab();
 
 Review comment:
   I moved `ugi.checkTGTAndReloginFromKeytab` into the else block, since 
HiveConnectionPool historically has had to explicitly request the relogin due 
to the Thrift client code not handling that case implicitly.  The call itself 
probably isn't needed, but based on the if/else statement, I think it might be 
safer to keep it inside the else block rather than remove it completely.

----------------------------------------------------------------
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