atlas-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From shweth...@apache.org
Subject incubator-atlas git commit: ATLAS-296 IllegalArgumentException during hive HiveHookIT integration tests (tbeerbower via shwethags)
Date Wed, 11 Nov 2015 12:01:25 GMT
Repository: incubator-atlas
Updated Branches:
  refs/heads/master 6f421e997 -> 5bc6f6bdb


ATLAS-296 IllegalArgumentException during hive HiveHookIT integration tests (tbeerbower via
shwethags)


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

Branch: refs/heads/master
Commit: 5bc6f6bdba7d904db371b28f542c75d8f2e5c544
Parents: 6f421e9
Author: Shwetha GS <sshivalingamurthy@hortonworks.com>
Authored: Wed Nov 11 17:31:16 2015 +0530
Committer: Shwetha GS <sshivalingamurthy@hortonworks.com>
Committed: Wed Nov 11 17:31:16 2015 +0530

----------------------------------------------------------------------
 .../NotificationEntityChangeListener.java       | 32 +++++++++++++++++---
 release-log.txt                                 |  1 +
 .../apache/atlas/typesystem/Referenceable.java  | 19 ++++++------
 3 files changed, 38 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/5bc6f6bd/notification/src/main/java/org/apache/atlas/notification/entity/NotificationEntityChangeListener.java
----------------------------------------------------------------------
diff --git a/notification/src/main/java/org/apache/atlas/notification/entity/NotificationEntityChangeListener.java
b/notification/src/main/java/org/apache/atlas/notification/entity/NotificationEntityChangeListener.java
index a660bf9..23a6d69 100644
--- a/notification/src/main/java/org/apache/atlas/notification/entity/NotificationEntityChangeListener.java
+++ b/notification/src/main/java/org/apache/atlas/notification/entity/NotificationEntityChangeListener.java
@@ -18,14 +18,22 @@
 package org.apache.atlas.notification.entity;
 
 import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonParser;
+import com.google.gson.JsonSerializationContext;
+import com.google.gson.JsonSerializer;
 import org.apache.atlas.AtlasException;
 import org.apache.atlas.listener.EntityChangeListener;
 import org.apache.atlas.notification.NotificationInterface;
+import org.apache.atlas.typesystem.IReferenceableInstance;
 import org.apache.atlas.typesystem.IStruct;
 import org.apache.atlas.typesystem.ITypedReferenceableInstance;
 import org.apache.atlas.typesystem.Referenceable;
+import org.apache.atlas.typesystem.json.InstanceSerialization;
 import org.apache.atlas.typesystem.types.TypeSystem;
 
+import java.lang.reflect.Type;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.LinkedList;
@@ -36,9 +44,11 @@ import java.util.List;
  */
 public class NotificationEntityChangeListener implements EntityChangeListener {
 
+    private static final Gson GSON = new GsonBuilder().
+        registerTypeAdapter(Referenceable.class, new ReferencableSerializer()).create();
+
     private final NotificationInterface notificationInterface;
     private final TypeSystem typeSystem;
-    private final Gson gson = new Gson();
 
 
     // ----- Constructors ------------------------------------------------------
@@ -78,23 +88,37 @@ public class NotificationEntityChangeListener implements EntityChangeListener
{
     }
 
 
-    // ----- helper methods ----------------------------------------------------
+    // ----- helper methods -------------------------------------------------
 
     // send notification of entity change
     private void notifyOfEntityEvent(Collection<ITypedReferenceableInstance> entityDefinitions,
                                      EntityNotification.OperationType operationType) throws
AtlasException {
         List<String> messages = new LinkedList<>();
 
-        for (ITypedReferenceableInstance entityDefinition : entityDefinitions) {
+        for (IReferenceableInstance entityDefinition : entityDefinitions) {
             Referenceable entity = new Referenceable(entityDefinition);
 
             EntityNotificationImpl notification =
                     new EntityNotificationImpl(entity, operationType, typeSystem);
 
-            messages.add(gson.toJson(notification));
+            messages.add(GSON.toJson(notification));
         }
 
         notificationInterface.send(NotificationInterface.NotificationType.ENTITIES,
                 messages.toArray(new String[messages.size()]));
     }
+
+
+    // ----- inner class : ReferencableSerializer ---------------------------
+
+    private static class ReferencableSerializer implements JsonSerializer<Referenceable>
 {
+
+        public static final JsonParser JSON_PARSER = new JsonParser();
+
+        @Override
+        public JsonElement serialize(Referenceable referenceable, Type type,
+                                     JsonSerializationContext jsonSerializationContext) {
+            return JSON_PARSER.parse(InstanceSerialization.toJson(referenceable, true)).getAsJsonObject();
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/5bc6f6bd/release-log.txt
----------------------------------------------------------------------
diff --git a/release-log.txt b/release-log.txt
index c70df12..adeef31 100644
--- a/release-log.txt
+++ b/release-log.txt
@@ -9,6 +9,7 @@ ATLAS-54 Rename configs in hive hook (shwethags)
 ATLAS-3 Mixed Index creation fails with Date types (sumasai via shwethags)
 
 ALL CHANGES:
+ATLAS-296 IllegalArgumentException during hive HiveHookIT integration tests (tbeerbower via
shwethags)
 ATLAS-158 Provide Atlas Entity Change Notification (tbeerbower via shwethags)
 ATALS-238 atlas_start.py- the Atlas server won’t restart after improper shutdown(ndjouri
via sumasai)
 ATLAS-293 UI Requires Internet Access For UI Facelift (darshankumar89 via shwethags)

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/5bc6f6bd/typesystem/src/main/java/org/apache/atlas/typesystem/Referenceable.java
----------------------------------------------------------------------
diff --git a/typesystem/src/main/java/org/apache/atlas/typesystem/Referenceable.java b/typesystem/src/main/java/org/apache/atlas/typesystem/Referenceable.java
index 6102427..aaf0aa4 100755
--- a/typesystem/src/main/java/org/apache/atlas/typesystem/Referenceable.java
+++ b/typesystem/src/main/java/org/apache/atlas/typesystem/Referenceable.java
@@ -42,7 +42,7 @@ public class Referenceable extends Struct implements IReferenceableInstance
{
         super(typeName);
         id = new Id(typeName);
         this.traitNames = ImmutableList.copyOf(traitNames);
-        ImmutableMap.Builder<String, IStruct> b = new ImmutableMap.Builder<String,
IStruct>();
+        ImmutableMap.Builder<String, IStruct> b = new ImmutableMap.Builder<>();
         for (String t : traitNames) {
             b.put(t, new Struct(t));
         }
@@ -65,9 +65,9 @@ public class Referenceable extends Struct implements IReferenceableInstance
{
 
     /**
      * Not public - only use during deserialization
-     * @param guid
-     * @param typeName
-     * @param values
+     * @param guid      the unique id
+     * @param typeName  the type name
+     * @param values    the entity attribute values
      */
     @InterfaceAudience.Private
     public Referenceable(String guid, String typeName, Map<String, Object> values,
List<String> _traitNames,
@@ -79,13 +79,13 @@ public class Referenceable extends Struct implements IReferenceableInstance
{
     }
 
     /**
-     * Construct a Referenceable from the given ITypedReferenceableInstance.
+     * Construct a Referenceable from the given IReferenceableInstance.
      *
-     * @param instance  the typed referenceable instance to copy
+     * @param instance  the referenceable instance to copy
      *
      * @throws AtlasException if the referenceable can not be created
      */
-    public Referenceable(ITypedReferenceableInstance instance) throws AtlasException {
+    public Referenceable(IReferenceableInstance instance) throws AtlasException {
         this(instance.getId()._getId(), instance.getTypeName(), instance.getValuesMap(),
instance.getTraits(),
             getTraits(instance));
     }
@@ -114,11 +114,10 @@ public class Referenceable extends Struct implements IReferenceableInstance
{
         return traits.get(typeName);
     }
 
-    private static Map<String, IStruct> getTraits(ITypedReferenceableInstance instance)
{
+    private static Map<String, IStruct> getTraits(IReferenceableInstance instance)
throws AtlasException {
         Map<String, IStruct> traits = new HashMap<>();
-
         for (String traitName : instance.getTraits() ) {
-            traits.put(traitName, instance.getTrait(traitName));
+            traits.put(traitName, new Struct(traitName, instance.getTrait(traitName).getValuesMap()));
         }
         return traits;
     }


Mime
View raw message