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 2018/03/23 22:14:39 UTC

atlas git commit: ATLAS-2491: Hive hook using V2 notifications (#2) (Cherry picked from commit ae23e78369ce765c5353923754374bbd74c1bd47)

Repository: atlas
Updated Branches:
  refs/heads/branch-0.8 5273ab69d -> 4e27bf086


ATLAS-2491: Hive hook using V2 notifications (#2)
(Cherry picked from commit ae23e78369ce765c5353923754374bbd74c1bd47)


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

Branch: refs/heads/branch-0.8
Commit: 4e27bf0866312e914be384c637c2e3e87b89c62e
Parents: 5273ab6
Author: Madhan Neethiraj <ma...@apache.org>
Authored: Wed Mar 21 12:36:45 2018 -0700
Committer: Madhan Neethiraj <ma...@apache.org>
Committed: Fri Mar 23 15:14:13 2018 -0700

----------------------------------------------------------------------
 .../apache/atlas/hive/hook/events/AlterDatabase.java  | 10 +++++++---
 .../org/apache/atlas/hive/hook/events/AlterTable.java | 10 +++++++---
 .../apache/atlas/hive/hook/events/BaseHiveEvent.java  |  1 +
 .../apache/atlas/hive/hook/events/CreateDatabase.java | 12 +++++++++---
 .../apache/atlas/hive/hook/events/CreateTable.java    | 10 +++++++---
 .../apache/atlas/hive/hook/events/DropDatabase.java   | 14 +++++++++++---
 .../org/apache/atlas/hive/hook/events/DropTable.java  | 14 +++++++++++---
 7 files changed, 53 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/atlas/blob/4e27bf08/addons/hive-bridge/src/main/java/org/apache/atlas/hive/hook/events/AlterDatabase.java
----------------------------------------------------------------------
diff --git a/addons/hive-bridge/src/main/java/org/apache/atlas/hive/hook/events/AlterDatabase.java b/addons/hive-bridge/src/main/java/org/apache/atlas/hive/hook/events/AlterDatabase.java
index b0f11c4..1cc31a4 100644
--- a/addons/hive-bridge/src/main/java/org/apache/atlas/hive/hook/events/AlterDatabase.java
+++ b/addons/hive-bridge/src/main/java/org/apache/atlas/hive/hook/events/AlterDatabase.java
@@ -22,6 +22,7 @@ import org.apache.atlas.hive.hook.AtlasHiveHookContext;
 import org.apache.atlas.model.instance.AtlasEntity.AtlasEntitiesWithExtInfo;
 import org.apache.atlas.notification.hook.HookNotification.EntityUpdateRequestV2;
 import org.apache.atlas.notification.hook.HookNotification.HookNotificationMessage;
+import org.apache.commons.collections.CollectionUtils;
 
 import java.util.Collections;
 import java.util.List;
@@ -33,9 +34,12 @@ public class AlterDatabase extends CreateDatabase {
 
     @Override
     public List<HookNotificationMessage> getNotificationMessages() throws Exception {
-        AtlasEntitiesWithExtInfo      entities     = getEntities();
-        HookNotificationMessage       notification = new EntityUpdateRequestV2(getUserName(), entities);
-        List<HookNotificationMessage> ret          = Collections.singletonList(notification);
+        List<HookNotificationMessage> ret      = null;
+        AtlasEntitiesWithExtInfo      entities = getEntities();
+
+        if (entities != null && CollectionUtils.isNotEmpty(entities.getEntities())) {
+            ret = Collections.singletonList(new EntityUpdateRequestV2(getUserName(), entities));
+        }
 
         return ret;
     }

http://git-wip-us.apache.org/repos/asf/atlas/blob/4e27bf08/addons/hive-bridge/src/main/java/org/apache/atlas/hive/hook/events/AlterTable.java
----------------------------------------------------------------------
diff --git a/addons/hive-bridge/src/main/java/org/apache/atlas/hive/hook/events/AlterTable.java b/addons/hive-bridge/src/main/java/org/apache/atlas/hive/hook/events/AlterTable.java
index 3d7e3af..2943c73 100644
--- a/addons/hive-bridge/src/main/java/org/apache/atlas/hive/hook/events/AlterTable.java
+++ b/addons/hive-bridge/src/main/java/org/apache/atlas/hive/hook/events/AlterTable.java
@@ -22,6 +22,7 @@ import org.apache.atlas.hive.hook.AtlasHiveHookContext;
 import org.apache.atlas.model.instance.AtlasEntity.AtlasEntitiesWithExtInfo;
 import org.apache.atlas.notification.hook.HookNotification.EntityUpdateRequestV2;
 import org.apache.atlas.notification.hook.HookNotification.HookNotificationMessage;
+import org.apache.commons.collections.CollectionUtils;
 
 import java.util.Collections;
 import java.util.List;
@@ -33,9 +34,12 @@ public class AlterTable extends CreateTable {
 
     @Override
     public List<HookNotificationMessage> getNotificationMessages() throws Exception {
-        AtlasEntitiesWithExtInfo      entities     = getEntities();
-        HookNotificationMessage       notification = new EntityUpdateRequestV2(getUserName(), entities);
-        List<HookNotificationMessage> ret          = Collections.singletonList(notification);
+        List<HookNotificationMessage> ret      = null;
+        AtlasEntitiesWithExtInfo      entities = getEntities();
+
+        if (entities != null && CollectionUtils.isNotEmpty(entities.getEntities())) {
+            ret = Collections.singletonList(new EntityUpdateRequestV2(getUserName(), entities));
+        }
 
         return ret;
     }

http://git-wip-us.apache.org/repos/asf/atlas/blob/4e27bf08/addons/hive-bridge/src/main/java/org/apache/atlas/hive/hook/events/BaseHiveEvent.java
----------------------------------------------------------------------
diff --git a/addons/hive-bridge/src/main/java/org/apache/atlas/hive/hook/events/BaseHiveEvent.java b/addons/hive-bridge/src/main/java/org/apache/atlas/hive/hook/events/BaseHiveEvent.java
index 47de783..2a29bcd 100644
--- a/addons/hive-bridge/src/main/java/org/apache/atlas/hive/hook/events/BaseHiveEvent.java
+++ b/addons/hive-bridge/src/main/java/org/apache/atlas/hive/hook/events/BaseHiveEvent.java
@@ -796,6 +796,7 @@ public abstract class BaseHiveEvent {
             case ALTERTABLE_RENAMECOL:
             case ALTERVIEW_PROPERTIES:
             case ALTERVIEW_RENAME:
+            case ALTERVIEW_AS:
                 return true;
         }
 

http://git-wip-us.apache.org/repos/asf/atlas/blob/4e27bf08/addons/hive-bridge/src/main/java/org/apache/atlas/hive/hook/events/CreateDatabase.java
----------------------------------------------------------------------
diff --git a/addons/hive-bridge/src/main/java/org/apache/atlas/hive/hook/events/CreateDatabase.java b/addons/hive-bridge/src/main/java/org/apache/atlas/hive/hook/events/CreateDatabase.java
index d5df9e7..d694299 100644
--- a/addons/hive-bridge/src/main/java/org/apache/atlas/hive/hook/events/CreateDatabase.java
+++ b/addons/hive-bridge/src/main/java/org/apache/atlas/hive/hook/events/CreateDatabase.java
@@ -21,8 +21,11 @@ package org.apache.atlas.hive.hook.events;
 import org.apache.atlas.hive.hook.AtlasHiveHookContext;
 import org.apache.atlas.model.instance.AtlasEntity;
 import org.apache.atlas.model.instance.AtlasEntity.AtlasEntitiesWithExtInfo;
+import org.apache.atlas.model.instance.AtlasObjectId;
+import org.apache.atlas.notification.hook.HookNotification;
 import org.apache.atlas.notification.hook.HookNotification.EntityCreateRequestV2;
 import org.apache.atlas.notification.hook.HookNotification.HookNotificationMessage;
+import org.apache.commons.collections.CollectionUtils;
 import org.apache.hadoop.hive.metastore.api.Database;
 import org.apache.hadoop.hive.ql.hooks.Entity;
 import org.slf4j.Logger;
@@ -40,9 +43,12 @@ public class CreateDatabase extends BaseHiveEvent {
 
     @Override
     public List<HookNotificationMessage> getNotificationMessages() throws Exception {
-        AtlasEntitiesWithExtInfo      entities     = getEntities();
-        HookNotificationMessage       notification = new EntityCreateRequestV2(getUserName(), entities);
-        List<HookNotificationMessage> ret          = Collections.singletonList(notification);
+        List<HookNotificationMessage> ret      = null;
+        AtlasEntitiesWithExtInfo      entities = getEntities();
+
+        if (entities != null && CollectionUtils.isNotEmpty(entities.getEntities())) {
+            ret = Collections.singletonList(new EntityCreateRequestV2(getUserName(), entities));
+        }
 
         return ret;
     }

http://git-wip-us.apache.org/repos/asf/atlas/blob/4e27bf08/addons/hive-bridge/src/main/java/org/apache/atlas/hive/hook/events/CreateTable.java
----------------------------------------------------------------------
diff --git a/addons/hive-bridge/src/main/java/org/apache/atlas/hive/hook/events/CreateTable.java b/addons/hive-bridge/src/main/java/org/apache/atlas/hive/hook/events/CreateTable.java
index 142f591..2afaf9f 100644
--- a/addons/hive-bridge/src/main/java/org/apache/atlas/hive/hook/events/CreateTable.java
+++ b/addons/hive-bridge/src/main/java/org/apache/atlas/hive/hook/events/CreateTable.java
@@ -23,6 +23,7 @@ import org.apache.atlas.model.instance.AtlasEntity;
 import org.apache.atlas.model.instance.AtlasEntity.AtlasEntitiesWithExtInfo;
 import org.apache.atlas.notification.hook.HookNotification.EntityCreateRequestV2;
 import org.apache.atlas.notification.hook.HookNotification.HookNotificationMessage;
+import org.apache.commons.collections.CollectionUtils;
 import org.apache.hadoop.hive.metastore.TableType;
 import org.apache.hadoop.hive.metastore.api.Database;
 import org.apache.hadoop.hive.ql.hooks.Entity;
@@ -42,9 +43,12 @@ public class CreateTable extends BaseHiveEvent {
 
     @Override
     public List<HookNotificationMessage> getNotificationMessages() throws Exception {
-        AtlasEntitiesWithExtInfo      entities     = getEntities();
-        HookNotificationMessage       notification = new EntityCreateRequestV2(getUserName(), entities);
-        List<HookNotificationMessage> ret          = Collections.singletonList(notification);
+        List<HookNotificationMessage> ret      = null;
+        AtlasEntitiesWithExtInfo      entities = getEntities();
+
+        if (entities != null && CollectionUtils.isNotEmpty(entities.getEntities())) {
+            ret = Collections.singletonList(new EntityCreateRequestV2(getUserName(), entities));
+        }
 
         return ret;
     }

http://git-wip-us.apache.org/repos/asf/atlas/blob/4e27bf08/addons/hive-bridge/src/main/java/org/apache/atlas/hive/hook/events/DropDatabase.java
----------------------------------------------------------------------
diff --git a/addons/hive-bridge/src/main/java/org/apache/atlas/hive/hook/events/DropDatabase.java b/addons/hive-bridge/src/main/java/org/apache/atlas/hive/hook/events/DropDatabase.java
index 33a998c..435cea7 100644
--- a/addons/hive-bridge/src/main/java/org/apache/atlas/hive/hook/events/DropDatabase.java
+++ b/addons/hive-bridge/src/main/java/org/apache/atlas/hive/hook/events/DropDatabase.java
@@ -22,6 +22,7 @@ import org.apache.atlas.hive.hook.AtlasHiveHookContext;
 import org.apache.atlas.model.instance.AtlasObjectId;
 import org.apache.atlas.notification.hook.HookNotification.EntityDeleteRequestV2;
 import org.apache.atlas.notification.hook.HookNotification.HookNotificationMessage;
+import org.apache.commons.collections.CollectionUtils;
 import org.apache.hadoop.hive.ql.hooks.Entity;
 
 import java.util.ArrayList;
@@ -35,9 +36,16 @@ public class DropDatabase extends BaseHiveEvent {
 
     @Override
     public List<HookNotificationMessage> getNotificationMessages() throws Exception {
-        List<AtlasObjectId>           entities     = getEntities();
-        HookNotificationMessage       notification = new EntityDeleteRequestV2(getUserName(), entities);
-        List<HookNotificationMessage> ret          = Collections.singletonList(notification);
+        List<HookNotificationMessage> ret      = null;
+        List<AtlasObjectId>           entities = getEntities();
+
+        if (entities != null && CollectionUtils.isNotEmpty(entities)) {
+            ret = new ArrayList<>(entities.size());
+
+            for (AtlasObjectId entity : entities) {
+                ret.add(new EntityDeleteRequestV2(getUserName(), Collections.singletonList(entity)));
+            }
+        }
 
         return ret;
     }

http://git-wip-us.apache.org/repos/asf/atlas/blob/4e27bf08/addons/hive-bridge/src/main/java/org/apache/atlas/hive/hook/events/DropTable.java
----------------------------------------------------------------------
diff --git a/addons/hive-bridge/src/main/java/org/apache/atlas/hive/hook/events/DropTable.java b/addons/hive-bridge/src/main/java/org/apache/atlas/hive/hook/events/DropTable.java
index 6862f53..65efa46 100644
--- a/addons/hive-bridge/src/main/java/org/apache/atlas/hive/hook/events/DropTable.java
+++ b/addons/hive-bridge/src/main/java/org/apache/atlas/hive/hook/events/DropTable.java
@@ -22,6 +22,7 @@ import org.apache.atlas.hive.hook.AtlasHiveHookContext;
 import org.apache.atlas.model.instance.AtlasObjectId;
 import org.apache.atlas.notification.hook.HookNotification.EntityDeleteRequestV2;
 import org.apache.atlas.notification.hook.HookNotification.HookNotificationMessage;
+import org.apache.commons.collections.CollectionUtils;
 import org.apache.hadoop.hive.ql.hooks.Entity;
 
 import java.util.ArrayList;
@@ -35,9 +36,16 @@ public class DropTable extends BaseHiveEvent {
 
     @Override
     public List<HookNotificationMessage> getNotificationMessages() throws Exception {
-        List<AtlasObjectId>           entities     = getEntities();
-        HookNotificationMessage       notification = new EntityDeleteRequestV2(getUserName(), entities);
-        List<HookNotificationMessage> ret          = Collections.singletonList(notification);
+        List<HookNotificationMessage> ret      = null;
+        List<AtlasObjectId>           entities = getEntities();
+
+        if (entities != null && CollectionUtils.isNotEmpty(entities)) {
+            ret = new ArrayList<>(entities.size());
+
+            for (AtlasObjectId entity : entities) {
+                ret.add(new EntityDeleteRequestV2(getUserName(), Collections.singletonList(entity)));
+            }
+        }
 
         return ret;
     }