atlas-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mad...@apache.org
Subject incubator-atlas git commit: ATLAS-1417: HIveHook: synchronous execution fails to notify (sumasai)
Date Wed, 28 Dec 2016 01:19:14 GMT
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 <sumasai.shivaprasad@gmail.com>
Authored: Tue Dec 27 17:13:48 2016 -0800
Committer: Madhan Neethiraj <madhan@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 {


Mime
View raw message