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 2017/01/04 09:47:18 UTC
incubator-atlas git commit: ATLAS-1417: HIveHook: synchronous
execution fails to notify
Repository: incubator-atlas
Updated Branches:
refs/heads/master 6145bf481 -> c99117308
ATLAS-1417: HIveHook: synchronous execution fails to notify
Signed-off-by: Madhan Neethiraj <ma...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/incubator-atlas/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-atlas/commit/c9911730
Tree: http://git-wip-us.apache.org/repos/asf/incubator-atlas/tree/c9911730
Diff: http://git-wip-us.apache.org/repos/asf/incubator-atlas/diff/c9911730
Branch: refs/heads/master
Commit: c99117308509efac5bc937f1de102d65de27db2b
Parents: 6145bf4
Author: Suma Shivaprasad <su...@gmail.com>
Authored: Wed Jan 4 01:46:58 2017 -0800
Committer: Madhan Neethiraj <ma...@apache.org>
Committed: Wed Jan 4 01:46:58 2017 -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/c9911730/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 143241f..2b256d0 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
@@ -196,16 +196,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);
}
@@ -217,14 +208,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 {