You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@atlas.apache.org by ma...@apache.org on 2016/12/28 01:19:14 UTC

incubator-atlas git commit: ATLAS-1417: HIveHook: synchronous execution fails to notify (sumasai)

Repository: incubator-atlas
Updated Branches:
  refs/heads/0.7-incubating dc0b29446 -> a5160017e


ATLAS-1417: HIveHook: synchronous execution fails to notify (sumasai)


Project: http://git-wip-us.apache.org/repos/asf/incubator-atlas/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-atlas/commit/a5160017
Tree: http://git-wip-us.apache.org/repos/asf/incubator-atlas/tree/a5160017
Diff: http://git-wip-us.apache.org/repos/asf/incubator-atlas/diff/a5160017

Branch: refs/heads/0.7-incubating
Commit: a5160017e483be88293f1f851de2a84e115b7a38
Parents: dc0b294
Author: Suma Shivaprasad <su...@gmail.com>
Authored: Tue Dec 27 17:13:48 2016 -0800
Committer: Madhan Neethiraj <ma...@apache.org>
Committed: Tue Dec 27 17:13:48 2016 -0800

----------------------------------------------------------------------
 .../org/apache/atlas/hive/hook/HiveHook.java    | 40 +++++++++++---------
 1 file changed, 23 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/a5160017/addons/hive-bridge/src/main/java/org/apache/atlas/hive/hook/HiveHook.java
----------------------------------------------------------------------
diff --git a/addons/hive-bridge/src/main/java/org/apache/atlas/hive/hook/HiveHook.java b/addons/hive-bridge/src/main/java/org/apache/atlas/hive/hook/HiveHook.java
index 1239551..b223830 100755
--- a/addons/hive-bridge/src/main/java/org/apache/atlas/hive/hook/HiveHook.java
+++ b/addons/hive-bridge/src/main/java/org/apache/atlas/hive/hook/HiveHook.java
@@ -202,16 +202,7 @@ public class HiveHook extends AtlasHook implements ExecuteWithHookContext {
                                 }
                             });
 
-                            //Notify as 'hive' service user in Kerberos mode else will default to the current user - doAs mode
-                            UserGroupInformation realUser = ugi.getRealUser();
-                            if (realUser != null) {
-                                LOG.info("Sending notification for event {} as service user {} ", event.getOperation(), realUser.getShortUserName());
-                                realUser.doAs(notifyAsPrivilegedAction(event));
-                            } else {
-                                //Unsecure or without doAs
-                                LOG.info("Sending notification for event {} as current user {} ", event.getOperation(), ugi.getShortUserName());
-                                ugi.doAs(notifyAsPrivilegedAction(event));
-                            }
+                            notifyAsPrivilegedAction(event);
                         } catch (Throwable e) {
                             LOG.error("Atlas hook failed due to error ", e);
                         }
@@ -223,14 +214,29 @@ public class HiveHook extends AtlasHook implements ExecuteWithHookContext {
         }
     }
 
-    PrivilegedExceptionAction<Object> notifyAsPrivilegedAction(final HiveEventContext event) {
-        return new PrivilegedExceptionAction<Object>() {
-            @Override
-            public Object run() throws Exception {
-                notifyEntities(event.getMessages());
-                return event;
+    void notifyAsPrivilegedAction(final HiveEventContext event) {
+
+        try {
+            PrivilegedExceptionAction<Object> privilegedNotify = new PrivilegedExceptionAction<Object>() {
+                @Override
+                public Object run() throws Exception {
+                    notifyEntities(event.getMessages());
+                    return event;
+                }
+            };
+
+            //Notify as 'hive' service user in doAs mode
+            UserGroupInformation realUser = event.getUgi().getRealUser();
+            if (realUser != null) {
+                LOG.info("Sending notification for event {} as service user {} #messages {} ", event.getOperation(), realUser.getShortUserName(), event.getMessages().size());
+                realUser.doAs(privilegedNotify);
+            } else {
+                LOG.info("Sending notification for event {} as current user {} #messages {} ", event.getOperation(), event.getUgi().getShortUserName(), event.getMessages().size());
+                event.getUgi().doAs(privilegedNotify);
             }
-        };
+        } catch(Throwable e) {
+            LOG.error("Error during notify {} ", event.getOperation(), e);
+        }
     }
 
     private void collect(HiveEventContext event) throws Exception {