FAQ
Author: thejas
Date: Tue Mar 3 22:09:33 2015
New Revision: 1663805

URL: http://svn.apache.org/r1663805
Log:
HIVE-9779 : ATSHook does not log the end user if doAs=false (it logs the hs2 server user) (Abdelrahman Shettia via Thejas Nair)

Modified:
     hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/hooks/ATSHook.java

Modified: hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/hooks/ATSHook.java
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/hooks/ATSHook.java?rev=1663805&r1=1663804&r2=1663805&view=diff
==============================================================================
--- hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/hooks/ATSHook.java (original)
+++ hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/hooks/ATSHook.java Tue Mar 3 22:09:33 2015
@@ -52,7 +52,7 @@ public class ATSHook implements ExecuteW
    private enum EntityTypes { HIVE_QUERY_ID };
    private enum EventTypes { QUERY_SUBMITTED, QUERY_COMPLETED };
    private enum OtherInfoTypes { QUERY, STATUS, TEZ, MAPRED };
- private enum PrimaryFilterTypes { user, operationid };
+ private enum PrimaryFilterTypes { user, requestuser, operationid };
    private static final int WAIT_TIME = 3;

    public ATSHook() {
@@ -101,9 +101,12 @@ public class ATSHook implements ExecuteW
              String opId = hookContext.getOperationId();
              long queryStartTime = plan.getQueryStartTime();
              String user = hookContext.getUgi().getUserName();
+ String requestuser = hookContext.getUserName();
+ if (hookContext.getUserName() == null ){
+ requestuser = hookContext.getUgi().getUserName() ;
+ }
              int numMrJobs = Utilities.getMRTasks(plan.getRootTasks()).size();
              int numTezJobs = Utilities.getTezTasks(plan.getRootTasks()).size();
-
              if (numMrJobs + numTezJobs <= 0) {
                return; // ignore client only queries
              }
@@ -117,13 +120,13 @@ public class ATSHook implements ExecuteW
                JSONObject explainPlan = explain.getJSONPlan(null, null, rootTasks,
                     plan.getFetchTask(), true, false, false);
                fireAndForget(conf, createPreHookEvent(queryId, query,
- explainPlan, queryStartTime, user, numMrJobs, numTezJobs, opId));
+ explainPlan, queryStartTime, user, requestuser, numMrJobs, numTezJobs, opId));
                break;
              case POST_EXEC_HOOK:
- fireAndForget(conf, createPostHookEvent(queryId, currentTime, user, true, opId));
+ fireAndForget(conf, createPostHookEvent(queryId, currentTime, user, requestuser, true, opId));
                break;
              case ON_FAILURE_HOOK:
- fireAndForget(conf, createPostHookEvent(queryId, currentTime, user, false, opId));
+ fireAndForget(conf, createPostHookEvent(queryId, currentTime, user, requestuser , false, opId));
                break;
              default:
                //ignore
@@ -137,7 +140,7 @@ public class ATSHook implements ExecuteW
    }

    TimelineEntity createPreHookEvent(String queryId, String query, JSONObject explainPlan,
- long startTime, String user, int numMrJobs, int numTezJobs, String opId) throws Exception {
+ long startTime, String user, String requestuser, int numMrJobs, int numTezJobs, String opId) throws Exception {

      JSONObject queryObj = new JSONObject();
      queryObj.put("queryText", query);
@@ -153,6 +156,8 @@ public class ATSHook implements ExecuteW
      atsEntity.setEntityId(queryId);
      atsEntity.setEntityType(EntityTypes.HIVE_QUERY_ID.name());
      atsEntity.addPrimaryFilter(PrimaryFilterTypes.user.name(), user);
+ atsEntity.addPrimaryFilter(PrimaryFilterTypes.requestuser.name(), requestuser);
+
      if (opId != null) {
        atsEntity.addPrimaryFilter(PrimaryFilterTypes.operationid.name(), opId);
      }
@@ -168,7 +173,7 @@ public class ATSHook implements ExecuteW
      return atsEntity;
    }

- TimelineEntity createPostHookEvent(String queryId, long stopTime, String user, boolean success,
+ TimelineEntity createPostHookEvent(String queryId, long stopTime, String user, String requestuser, boolean success,
        String opId) {
      LOG.info("Received post-hook notification for :" + queryId);

@@ -176,6 +181,7 @@ public class ATSHook implements ExecuteW
      atsEntity.setEntityId(queryId);
      atsEntity.setEntityType(EntityTypes.HIVE_QUERY_ID.name());
      atsEntity.addPrimaryFilter(PrimaryFilterTypes.user.name(), user);
+ atsEntity.addPrimaryFilter(PrimaryFilterTypes.requestuser.name(), requestuser);
      if (opId != null) {
        atsEntity.addPrimaryFilter(PrimaryFilterTypes.operationid.name(), opId);
      }

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupcommits @
categorieshive, hadoop
postedMar 3, '15 at 10:09p
activeMar 3, '15 at 10:09p
posts1
users1
websitehive.apache.org

1 user in discussion

Thejas: 1 post

People

Translate

site design / logo © 2021 Grokbase