pvary commented on a change in pull request #2865:
URL: https://github.com/apache/hive/pull/2865#discussion_r767584360



##########
File path: ql/src/java/org/apache/hadoop/hive/ql/DriverUtils.java
##########
@@ -171,4 +174,24 @@ public static String getUserFromUGI(DriverContext 
driverContext) throws CommandP
       throw createProcessorException(driverContext, 10, errorMessage, 
ErrorMsg.findSQLState(e.getMessage()), e);
     }
   }
+
+  public static HookContext getHookContext(DriverContext driverContext, 
Context context) {

Review comment:
       Good point.
   Created new `PrivateHookContext` constructor

##########
File path: ql/src/java/org/apache/hadoop/hive/ql/DriverUtils.java
##########
@@ -171,4 +174,24 @@ public static String getUserFromUGI(DriverContext 
driverContext) throws CommandP
       throw createProcessorException(driverContext, 10, errorMessage, 
ErrorMsg.findSQLState(e.getMessage()), e);
     }
   }
+
+  public static HookContext getHookContext(DriverContext driverContext, 
Context context) {
+    String host = "Unknown";
+    try {
+      host = InetAddress.getLocalHost().getHostAddress();
+    } catch (UnknownHostException e) {
+      LOG.warn("Unable to get host", e);

Review comment:
       Ok

##########
File path: ql/src/java/org/apache/hadoop/hive/ql/DriverUtils.java
##########
@@ -171,4 +174,24 @@ public static String getUserFromUGI(DriverContext 
driverContext) throws CommandP
       throw createProcessorException(driverContext, 10, errorMessage, 
ErrorMsg.findSQLState(e.getMessage()), e);
     }
   }
+
+  public static HookContext getHookContext(DriverContext driverContext, 
Context context) {
+    String host = "Unknown";
+    try {
+      host = InetAddress.getLocalHost().getHostAddress();
+    } catch (UnknownHostException e) {
+      LOG.warn("Unable to get host", e);
+    }
+
+    try {
+      return new PrivateHookContext(driverContext.getPlan(), 
driverContext.getQueryState(),
+          context.getPathToCS(), SessionState.get().getUserName(), 
SessionState.get().getUserIpAddress(),
+          host, driverContext.getOperationId(),
+          SessionState.get().getSessionId(), Thread.currentThread().getName(), 
SessionState.get().isHiveServerQuery(),
+          SessionState.getPerfLogger(), driverContext.getQueryInfo(), context);
+    } catch (Exception e) {
+      LOG.warn("Unable to create hook context");
+      return null;

Review comment:
       Ok




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

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to