Commit 435fe3fb by Madhan Neethiraj

ATLAS-2251: Remove TypeSystem and related implementation, to avoid unncessary…

ATLAS-2251: Remove TypeSystem and related implementation, to avoid unncessary duplicate of type details in cache
parent 0abf84ca
...@@ -48,11 +48,6 @@ ...@@ -48,11 +48,6 @@
<dependency> <dependency>
<groupId>org.apache.atlas</groupId> <groupId>org.apache.atlas</groupId>
<artifactId>atlas-typesystem</artifactId>
</dependency>
<dependency>
<groupId>org.apache.atlas</groupId>
<artifactId>atlas-client-v1</artifactId> <artifactId>atlas-client-v1</artifactId>
</dependency> </dependency>
...@@ -100,13 +95,6 @@ ...@@ -100,13 +95,6 @@
<type>pom</type> <type>pom</type>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>org.apache.atlas</groupId>
<artifactId>atlas-typesystem</artifactId>
<classifier>tests</classifier>
<scope>test</scope>
</dependency>
</dependencies> </dependencies>
<profiles> <profiles>
...@@ -141,21 +129,6 @@ ...@@ -141,21 +129,6 @@
<version>${project.version}</version> <version>${project.version}</version>
</artifactItem> </artifactItem>
<artifactItem> <artifactItem>
<groupId>org.json4s</groupId>
<artifactId>json4s-native_${scala.binary.version}</artifactId>
<version>${json.version}</version>
</artifactItem>
<artifactItem>
<groupId>org.json4s</groupId>
<artifactId>json4s-core_${scala.binary.version}</artifactId>
<version>${json.version}</version>
</artifactItem>
<artifactItem>
<groupId>org.json4s</groupId>
<artifactId>json4s-ast_${scala.binary.version}</artifactId>
<version>${json.version}</version>
</artifactItem>
<artifactItem>
<groupId>${project.groupId}</groupId> <groupId>${project.groupId}</groupId>
<artifactId>atlas-client-common</artifactId> <artifactId>atlas-client-common</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
...@@ -172,11 +145,6 @@ ...@@ -172,11 +145,6 @@
</artifactItem> </artifactItem>
<artifactItem> <artifactItem>
<groupId>${project.groupId}</groupId> <groupId>${project.groupId}</groupId>
<artifactId>atlas-typesystem</artifactId>
<version>${project.version}</version>
</artifactItem>
<artifactItem>
<groupId>${project.groupId}</groupId>
<artifactId>atlas-intg</artifactId> <artifactId>atlas-intg</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
</artifactItem> </artifactItem>
...@@ -196,28 +164,8 @@ ...@@ -196,28 +164,8 @@
<version>${project.version}</version> <version>${project.version}</version>
</artifactItem> </artifactItem>
<artifactItem> <artifactItem>
<groupId>org.scala-lang</groupId>
<artifactId>scala-compiler</artifactId>
<version>${scala.version}</version>
</artifactItem>
<artifactItem>
<groupId>org.scala-lang</groupId>
<artifactId>scala-reflect</artifactId>
<version>${scala.version}</version>
</artifactItem>
<artifactItem>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>${scala.version}</version>
</artifactItem>
<artifactItem>
<groupId>org.scala-lang</groupId>
<artifactId>scalap</artifactId>
<version>${scala.version}</version>
</artifactItem>
<artifactItem>
<groupId>org.apache.kafka</groupId> <groupId>org.apache.kafka</groupId>
<artifactId>kafka_${scala.binary.version}</artifactId> <artifactId>kafka_${kafka.scala.binary.version}</artifactId>
<version>${kafka.version}</version> <version>${kafka.version}</version>
</artifactItem> </artifactItem>
<artifactItem> <artifactItem>
...@@ -225,11 +173,6 @@ ...@@ -225,11 +173,6 @@
<artifactId>kafka-clients</artifactId> <artifactId>kafka-clients</artifactId>
<version>${kafka.version}</version> <version>${kafka.version}</version>
</artifactItem> </artifactItem>
<artifactItem>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>${gson.version}</version>
</artifactItem>
</artifactItems> </artifactItems>
</configuration> </configuration>
</execution> </execution>
...@@ -302,7 +245,7 @@ ...@@ -302,7 +245,7 @@
</systemProperty> </systemProperty>
<systemProperty> <systemProperty>
<key>atlas.conf</key> <key>atlas.conf</key>
<value>${project.build.directory}/../../../typesystem/target/test-classes</value> <value>${project.build.directory}/../../../intg/target/test-classes</value>
</systemProperty> </systemProperty>
<systemProperty> <systemProperty>
<key>atlas.home</key> <key>atlas.home</key>
......
...@@ -24,7 +24,7 @@ import org.apache.atlas.falcon.Util.EventUtil; ...@@ -24,7 +24,7 @@ import org.apache.atlas.falcon.Util.EventUtil;
import org.apache.atlas.falcon.model.FalconDataTypes; import org.apache.atlas.falcon.model.FalconDataTypes;
import org.apache.atlas.hive.bridge.HiveMetaStoreBridge; import org.apache.atlas.hive.bridge.HiveMetaStoreBridge;
import org.apache.atlas.hive.model.HiveDataTypes; import org.apache.atlas.hive.model.HiveDataTypes;
import org.apache.atlas.typesystem.Referenceable; import org.apache.atlas.v1.model.instance.Referenceable;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.falcon.FalconException; import org.apache.falcon.FalconException;
...@@ -204,8 +204,6 @@ public class FalconBridge { ...@@ -204,8 +204,6 @@ public class FalconBridge {
* *
* @param process process entity * @param process process entity
* @param falconStore config store * @param falconStore config store
* @param user falcon user
* @param timestamp timestamp of entity
* @return process instance reference * @return process instance reference
* *
* @throws FalconException if retrieving from the configuration store fail * @throws FalconException if retrieving from the configuration store fail
......
...@@ -25,8 +25,9 @@ import org.apache.atlas.falcon.event.FalconEvent; ...@@ -25,8 +25,9 @@ import org.apache.atlas.falcon.event.FalconEvent;
import org.apache.atlas.falcon.publisher.FalconEventPublisher; import org.apache.atlas.falcon.publisher.FalconEventPublisher;
import org.apache.atlas.hook.AtlasHook; import org.apache.atlas.hook.AtlasHook;
import org.apache.atlas.kafka.NotificationProvider; import org.apache.atlas.kafka.NotificationProvider;
import org.apache.atlas.notification.hook.HookNotification; import org.apache.atlas.model.notification.HookNotification;
import org.apache.atlas.typesystem.Referenceable; import org.apache.atlas.v1.model.instance.Referenceable;
import org.apache.atlas.v1.model.notification.HookNotificationV1.EntityCreateRequest;
import org.apache.falcon.FalconException; import org.apache.falcon.FalconException;
import org.apache.falcon.entity.store.ConfigurationStore; import org.apache.falcon.entity.store.ConfigurationStore;
import org.apache.falcon.entity.v0.feed.Feed; import org.apache.falcon.entity.v0.feed.Feed;
...@@ -151,14 +152,14 @@ public class FalconHook extends AtlasHook implements FalconEventPublisher { ...@@ -151,14 +152,14 @@ public class FalconHook extends AtlasHook implements FalconEventPublisher {
private void fireAndForget(FalconEvent event) throws FalconException, URISyntaxException { private void fireAndForget(FalconEvent event) throws FalconException, URISyntaxException {
LOG.info("Entered Atlas hook for Falcon hook operation {}", event.getOperation()); LOG.info("Entered Atlas hook for Falcon hook operation {}", event.getOperation());
List<HookNotification.HookNotificationMessage> messages = new ArrayList<>(); List<HookNotification> messages = new ArrayList<>();
Operation op = getOperation(event.getOperation()); Operation op = getOperation(event.getOperation());
String user = getUser(event.getUser()); String user = getUser(event.getUser());
LOG.info("fireAndForget user:{}", user); LOG.info("fireAndForget user:{}", user);
switch (op) { switch (op) {
case ADD: case ADD:
messages.add(new HookNotification.EntityCreateRequest(user, createEntities(event, user))); messages.add(new EntityCreateRequest(user, createEntities(event, user)));
break; break;
} }
......
...@@ -26,9 +26,9 @@ import org.apache.atlas.falcon.bridge.FalconBridge; ...@@ -26,9 +26,9 @@ import org.apache.atlas.falcon.bridge.FalconBridge;
import org.apache.atlas.falcon.model.FalconDataTypes; import org.apache.atlas.falcon.model.FalconDataTypes;
import org.apache.atlas.hive.bridge.HiveMetaStoreBridge; import org.apache.atlas.hive.bridge.HiveMetaStoreBridge;
import org.apache.atlas.hive.model.HiveDataTypes; import org.apache.atlas.hive.model.HiveDataTypes;
import org.apache.atlas.typesystem.Referenceable; import org.apache.atlas.v1.model.instance.Id;
import org.apache.atlas.typesystem.persistence.Id; import org.apache.atlas.v1.model.instance.Referenceable;
import org.apache.atlas.typesystem.types.TypeUtils; import org.apache.atlas.v1.typesystem.types.utils.TypesUtil;
import org.apache.atlas.utils.AuthenticationUtil; import org.apache.atlas.utils.AuthenticationUtil;
import org.apache.atlas.utils.ParamChecker; import org.apache.atlas.utils.ParamChecker;
import org.apache.commons.configuration.Configuration; import org.apache.commons.configuration.Configuration;
...@@ -162,7 +162,7 @@ public class FalconHookIT { ...@@ -162,7 +162,7 @@ public class FalconHookIT {
AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, cluster.getName()); AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, cluster.getName());
} }
private TypeUtils.Pair<String, Feed> getHDFSFeed(String feedResource, String clusterName) throws Exception { private TypesUtil.Pair<String, Feed> getHDFSFeed(String feedResource, String clusterName) throws Exception {
Feed feed = loadEntity(EntityType.FEED, feedResource, "feed" + random()); Feed feed = loadEntity(EntityType.FEED, feedResource, "feed" + random());
org.apache.falcon.entity.v0.feed.Cluster feedCluster = feed.getClusters().getClusters().get(0); org.apache.falcon.entity.v0.feed.Cluster feedCluster = feed.getClusters().getClusters().get(0);
feedCluster.setName(clusterName); feedCluster.setName(clusterName);
...@@ -174,9 +174,9 @@ public class FalconHookIT { ...@@ -174,9 +174,9 @@ public class FalconHookIT {
AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME,
FalconBridge.getFeedQualifiedName(feed.getName(), clusterName)); FalconBridge.getFeedQualifiedName(feed.getName(), clusterName));
Referenceable processEntity = atlasClient.getEntity(processId); Referenceable processEntity = atlasClient.getEntity(processId);
assertEquals(((List<Id>)processEntity.get("outputs")).get(0).getId()._getId(), feedId); assertEquals(((List<Id>)processEntity.get("outputs")).get(0).getId(), feedId);
String inputId = ((List<Id>) processEntity.get("inputs")).get(0).getId()._getId(); String inputId = ((List<Id>) processEntity.get("inputs")).get(0).getId();
Referenceable pathEntity = atlasClient.getEntity(inputId); Referenceable pathEntity = atlasClient.getEntity(inputId);
assertEquals(pathEntity.getTypeName(), HiveMetaStoreBridge.HDFS_PATH); assertEquals(pathEntity.getTypeName(), HiveMetaStoreBridge.HDFS_PATH);
...@@ -185,7 +185,7 @@ public class FalconHookIT { ...@@ -185,7 +185,7 @@ public class FalconHookIT {
assertEquals(pathEntity.get(AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME), assertEquals(pathEntity.get(AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME),
FalconBridge.normalize(dataLocation.getPath())); FalconBridge.normalize(dataLocation.getPath()));
return TypeUtils.Pair.of(feedId, feed); return TypesUtil.Pair.of(feedId, feed);
} }
private Feed getTableFeed(String feedResource, String clusterName) throws Exception { private Feed getTableFeed(String feedResource, String clusterName) throws Exception {
...@@ -236,9 +236,9 @@ public class FalconHookIT { ...@@ -236,9 +236,9 @@ public class FalconHookIT {
AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME,
FalconBridge.getFeedQualifiedName(feedName, clusterName)); FalconBridge.getFeedQualifiedName(feedName, clusterName));
Referenceable processEntity = atlasClient.getEntity(processId); Referenceable processEntity = atlasClient.getEntity(processId);
assertEquals(((List<Id>)processEntity.get("outputs")).get(0).getId()._getId(), feedId); assertEquals(((List<Id>)processEntity.get("outputs")).get(0).getId(), feedId);
String inputId = ((List<Id>) processEntity.get("inputs")).get(0).getId()._getId(); String inputId = ((List<Id>) processEntity.get("inputs")).get(0).getId();
Referenceable tableEntity = atlasClient.getEntity(inputId); Referenceable tableEntity = atlasClient.getEntity(inputId);
assertEquals(tableEntity.getTypeName(), HiveDataTypes.HIVE_TABLE.getName()); assertEquals(tableEntity.getTypeName(), HiveDataTypes.HIVE_TABLE.getName());
assertEquals(tableEntity.get(AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME), assertEquals(tableEntity.get(AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME),
...@@ -280,7 +280,7 @@ public class FalconHookIT { ...@@ -280,7 +280,7 @@ public class FalconHookIT {
Cluster cluster = loadEntity(EntityType.CLUSTER, CLUSTER_RESOURCE, "cluster" + random()); Cluster cluster = loadEntity(EntityType.CLUSTER, CLUSTER_RESOURCE, "cluster" + random());
STORE.publish(EntityType.CLUSTER, cluster); STORE.publish(EntityType.CLUSTER, cluster);
TypeUtils.Pair<String, Feed> result = getHDFSFeed(FEED_HDFS_RESOURCE, cluster.getName()); TypesUtil.Pair<String, Feed> result = getHDFSFeed(FEED_HDFS_RESOURCE, cluster.getName());
Feed infeed = result.right; Feed infeed = result.right;
String infeedId = result.left; String infeedId = result.left;
......
...@@ -124,13 +124,6 @@ ...@@ -124,13 +124,6 @@
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.atlas</groupId>
<artifactId>atlas-typesystem</artifactId>
<classifier>tests</classifier>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.hbase</groupId> <groupId>org.apache.hbase</groupId>
<artifactId>hbase-server</artifactId> <artifactId>hbase-server</artifactId>
<version>${hbase.version}</version> <version>${hbase.version}</version>
...@@ -186,42 +179,6 @@ ...@@ -186,42 +179,6 @@
<id>dist</id> <id>dist</id>
<build> <build>
<plugins> <plugins>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>3.2.0</version>
<executions>
<execution>
<id>scala-compile-first</id>
<phase>process-resources</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>scala-test-compile-first</id>
<phase>process-test-resources</phase>
<goals>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
<configuration>
<scalaVersion>${scala.version}</scalaVersion>
<recompileMode>incremental</recompileMode>
<useZincServer>true</useZincServer>
<source>1.7</source>
<target>1.7</target>
<args>
<arg>-unchecked</arg>
<arg>-deprecation</arg>
<arg>-feature</arg>
</args>
<jvmArgs>
<jvmArg>-Xmx512m</jvmArg>
</jvmArgs>
</configuration>
</plugin>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId> <artifactId>maven-dependency-plugin</artifactId>
...@@ -244,21 +201,6 @@ ...@@ -244,21 +201,6 @@
<version>${project.version}</version> <version>${project.version}</version>
</artifactItem> </artifactItem>
<artifactItem> <artifactItem>
<groupId>org.json4s</groupId>
<artifactId>json4s-native_${scala.binary.version}</artifactId>
<version>${json.version}</version>
</artifactItem>
<artifactItem>
<groupId>org.json4s</groupId>
<artifactId>json4s-core_${scala.binary.version}</artifactId>
<version>${json.version}</version>
</artifactItem>
<artifactItem>
<groupId>org.json4s</groupId>
<artifactId>json4s-ast_${scala.binary.version}</artifactId>
<version>${json.version}</version>
</artifactItem>
<artifactItem>
<groupId>${project.groupId}</groupId> <groupId>${project.groupId}</groupId>
<artifactId>atlas-client-v1</artifactId> <artifactId>atlas-client-v1</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
...@@ -275,11 +217,6 @@ ...@@ -275,11 +217,6 @@
</artifactItem> </artifactItem>
<artifactItem> <artifactItem>
<groupId>${project.groupId}</groupId> <groupId>${project.groupId}</groupId>
<artifactId>atlas-typesystem</artifactId>
<version>${project.version}</version>
</artifactItem>
<artifactItem>
<groupId>${project.groupId}</groupId>
<artifactId>atlas-notification</artifactId> <artifactId>atlas-notification</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
</artifactItem> </artifactItem>
...@@ -294,33 +231,8 @@ ...@@ -294,33 +231,8 @@
<version>${project.version}</version> <version>${project.version}</version>
</artifactItem> </artifactItem>
<artifactItem> <artifactItem>
<groupId>org.scala-lang</groupId>
<artifactId>scala-compiler</artifactId>
<version>${scala.version}</version>
</artifactItem>
<artifactItem>
<groupId>org.scala-lang</groupId>
<artifactId>scala-reflect</artifactId>
<version>${scala.version}</version>
</artifactItem>
<artifactItem>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>${scala.version}</version>
</artifactItem>
<artifactItem>
<groupId>org.scala-lang</groupId>
<artifactId>scalap</artifactId>
<version>${scala.version}</version>
</artifactItem>
<artifactItem>
<groupId>com.google.inject.extensions</groupId>
<artifactId>guice-multibindings</artifactId>
<version>${guice.version}</version>
</artifactItem>
<artifactItem>
<groupId>org.apache.kafka</groupId> <groupId>org.apache.kafka</groupId>
<artifactId>kafka_${scala.binary.version}</artifactId> <artifactId>kafka_${kafka.scala.binary.version}</artifactId>
<version>${kafka.version}</version> <version>${kafka.version}</version>
</artifactItem> </artifactItem>
<artifactItem> <artifactItem>
...@@ -328,11 +240,6 @@ ...@@ -328,11 +240,6 @@
<artifactId>kafka-clients</artifactId> <artifactId>kafka-clients</artifactId>
<version>${kafka.version}</version> <version>${kafka.version}</version>
</artifactItem> </artifactItem>
<artifactItem>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>${gson.version}</version>
</artifactItem>
</artifactItems> </artifactItems>
</configuration> </configuration>
</execution> </execution>
...@@ -406,7 +313,7 @@ ...@@ -406,7 +313,7 @@
</systemProperty> </systemProperty>
<systemProperty> <systemProperty>
<key>atlas.conf</key> <key>atlas.conf</key>
<value>${project.build.directory}/../../../typesystem/target/test-classes</value> <value>${project.build.directory}/../../../intg/target/test-classes</value>
</systemProperty> </systemProperty>
<systemProperty> <systemProperty>
<key>atlas.home</key> <key>atlas.home</key>
......
...@@ -23,8 +23,11 @@ import org.apache.atlas.AtlasConstants; ...@@ -23,8 +23,11 @@ import org.apache.atlas.AtlasConstants;
import org.apache.atlas.hbase.model.HBaseOperationContext; import org.apache.atlas.hbase.model.HBaseOperationContext;
import org.apache.atlas.hbase.model.HBaseDataTypes; import org.apache.atlas.hbase.model.HBaseDataTypes;
import org.apache.atlas.hook.AtlasHook; import org.apache.atlas.hook.AtlasHook;
import org.apache.atlas.notification.hook.HookNotification; import org.apache.atlas.model.notification.HookNotification;
import org.apache.atlas.typesystem.Referenceable; import org.apache.atlas.v1.model.instance.Referenceable;
import org.apache.atlas.v1.model.notification.HookNotificationV1.EntityCreateRequest;
import org.apache.atlas.v1.model.notification.HookNotificationV1.EntityDeleteRequest;
import org.apache.atlas.v1.model.notification.HookNotificationV1.EntityUpdateRequest;
import org.apache.commons.configuration.Configuration; import org.apache.commons.configuration.Configuration;
import org.apache.hadoop.hbase.HTableDescriptor; import org.apache.hadoop.hbase.HTableDescriptor;
import org.apache.hadoop.hbase.HColumnDescriptor; import org.apache.hadoop.hbase.HColumnDescriptor;
...@@ -219,13 +222,13 @@ public class HBaseAtlasHook extends AtlasHook { ...@@ -219,13 +222,13 @@ public class HBaseAtlasHook extends AtlasHook {
case CREATE_NAMESPACE: case CREATE_NAMESPACE:
LOG.info("Create NameSpace {}", nameSpaceRef.get(REFERENCEABLE_ATTRIBUTE_NAME)); LOG.info("Create NameSpace {}", nameSpaceRef.get(REFERENCEABLE_ATTRIBUTE_NAME));
hbaseOperationContext.addMessage(new HookNotification.EntityCreateRequest(hbaseOperationContext.getUser(), nameSpaceRef)); hbaseOperationContext.addMessage(new EntityCreateRequest(hbaseOperationContext.getUser(), nameSpaceRef));
break; break;
case ALTER_NAMESPACE: case ALTER_NAMESPACE:
LOG.info("Modify NameSpace {}", nameSpaceRef.get(REFERENCEABLE_ATTRIBUTE_NAME)); LOG.info("Modify NameSpace {}", nameSpaceRef.get(REFERENCEABLE_ATTRIBUTE_NAME));
hbaseOperationContext.addMessage(new HookNotification.EntityUpdateRequest(hbaseOperationContext.getUser(), nameSpaceRef)); hbaseOperationContext.addMessage(new EntityUpdateRequest(hbaseOperationContext.getUser(), nameSpaceRef));
break; break;
} }
} }
...@@ -235,10 +238,10 @@ public class HBaseAtlasHook extends AtlasHook { ...@@ -235,10 +238,10 @@ public class HBaseAtlasHook extends AtlasHook {
LOG.info("Delete NameSpace {}", nameSpaceQualifiedName); LOG.info("Delete NameSpace {}", nameSpaceQualifiedName);
hbaseOperationContext.addMessage(new HookNotification.EntityDeleteRequest(hbaseOperationContext.getUser(), hbaseOperationContext.addMessage(new EntityDeleteRequest(hbaseOperationContext.getUser(),
HBaseDataTypes.HBASE_NAMESPACE.getName(), HBaseDataTypes.HBASE_NAMESPACE.getName(),
REFERENCEABLE_ATTRIBUTE_NAME, REFERENCEABLE_ATTRIBUTE_NAME,
nameSpaceQualifiedName)); nameSpaceQualifiedName));
} }
private void createOrUpdateTableInstance(HBaseOperationContext hbaseOperationContext) { private void createOrUpdateTableInstance(HBaseOperationContext hbaseOperationContext) {
...@@ -252,13 +255,13 @@ public class HBaseAtlasHook extends AtlasHook { ...@@ -252,13 +255,13 @@ public class HBaseAtlasHook extends AtlasHook {
case CREATE_TABLE: case CREATE_TABLE:
LOG.info("Create Table {}", tableRef.get(REFERENCEABLE_ATTRIBUTE_NAME)); LOG.info("Create Table {}", tableRef.get(REFERENCEABLE_ATTRIBUTE_NAME));
hbaseOperationContext.addMessage(new HookNotification.EntityCreateRequest(hbaseOperationContext.getUser(), nameSpaceRef, tableRef)); hbaseOperationContext.addMessage(new EntityCreateRequest(hbaseOperationContext.getUser(), nameSpaceRef, tableRef));
break; break;
case ALTER_TABLE: case ALTER_TABLE:
LOG.info("Modify Table {}", tableRef.get(REFERENCEABLE_ATTRIBUTE_NAME)); LOG.info("Modify Table {}", tableRef.get(REFERENCEABLE_ATTRIBUTE_NAME));
hbaseOperationContext.addMessage(new HookNotification.EntityUpdateRequest(hbaseOperationContext.getUser(), nameSpaceRef, tableRef)); hbaseOperationContext.addMessage(new EntityUpdateRequest(hbaseOperationContext.getUser(), nameSpaceRef, tableRef));
break; break;
} }
} }
...@@ -276,10 +279,10 @@ public class HBaseAtlasHook extends AtlasHook { ...@@ -276,10 +279,10 @@ public class HBaseAtlasHook extends AtlasHook {
LOG.info("Delete Table {}", tableQualifiedName); LOG.info("Delete Table {}", tableQualifiedName);
hbaseOperationContext.addMessage(new HookNotification.EntityDeleteRequest(hbaseOperationContext.getUser(), hbaseOperationContext.addMessage(new EntityDeleteRequest(hbaseOperationContext.getUser(),
HBaseDataTypes.HBASE_TABLE.getName(), HBaseDataTypes.HBASE_TABLE.getName(),
REFERENCEABLE_ATTRIBUTE_NAME, REFERENCEABLE_ATTRIBUTE_NAME,
tableQualifiedName)); tableQualifiedName));
} }
private void createOrUpdateColumnFamilyInstance(HBaseOperationContext hbaseOperationContext) { private void createOrUpdateColumnFamilyInstance(HBaseOperationContext hbaseOperationContext) {
...@@ -291,13 +294,13 @@ public class HBaseAtlasHook extends AtlasHook { ...@@ -291,13 +294,13 @@ public class HBaseAtlasHook extends AtlasHook {
case CREATE_COLUMN_FAMILY: case CREATE_COLUMN_FAMILY:
LOG.info("Create ColumnFamily {}", columnFamilyRef.get(REFERENCEABLE_ATTRIBUTE_NAME)); LOG.info("Create ColumnFamily {}", columnFamilyRef.get(REFERENCEABLE_ATTRIBUTE_NAME));
hbaseOperationContext.addMessage(new HookNotification.EntityCreateRequest(hbaseOperationContext.getUser(), nameSpaceRef, tableRef, columnFamilyRef)); hbaseOperationContext.addMessage(new EntityCreateRequest(hbaseOperationContext.getUser(), nameSpaceRef, tableRef, columnFamilyRef));
break; break;
case ALTER_COLUMN_FAMILY: case ALTER_COLUMN_FAMILY:
LOG.info("Alter ColumnFamily {}", columnFamilyRef.get(REFERENCEABLE_ATTRIBUTE_NAME)); LOG.info("Alter ColumnFamily {}", columnFamilyRef.get(REFERENCEABLE_ATTRIBUTE_NAME));
hbaseOperationContext.addMessage(new HookNotification.EntityUpdateRequest(hbaseOperationContext.getUser(), nameSpaceRef, tableRef, columnFamilyRef)); hbaseOperationContext.addMessage(new EntityUpdateRequest(hbaseOperationContext.getUser(), nameSpaceRef, tableRef, columnFamilyRef));
break; break;
} }
} }
...@@ -316,10 +319,10 @@ public class HBaseAtlasHook extends AtlasHook { ...@@ -316,10 +319,10 @@ public class HBaseAtlasHook extends AtlasHook {
LOG.info("Delete ColumnFamily {}", columnFamilyQualifiedName); LOG.info("Delete ColumnFamily {}", columnFamilyQualifiedName);
hbaseOperationContext.addMessage(new HookNotification.EntityDeleteRequest(hbaseOperationContext.getUser(), hbaseOperationContext.addMessage(new EntityDeleteRequest(hbaseOperationContext.getUser(),
HBaseDataTypes.HBASE_COLUMN_FAMILY.getName(), HBaseDataTypes.HBASE_COLUMN_FAMILY.getName(),
REFERENCEABLE_ATTRIBUTE_NAME, REFERENCEABLE_ATTRIBUTE_NAME,
columnFamilyQualifiedName)); columnFamilyQualifiedName));
} }
...@@ -491,7 +494,7 @@ public class HBaseAtlasHook extends AtlasHook { ...@@ -491,7 +494,7 @@ public class HBaseAtlasHook extends AtlasHook {
LOG.debug("==> HBaseAtlasHook.notifyAsPrivilegedAction({})", hbaseOperationContext); LOG.debug("==> HBaseAtlasHook.notifyAsPrivilegedAction({})", hbaseOperationContext);
} }
final List<HookNotification.HookNotificationMessage> messages = hbaseOperationContext.getMessages(); final List<HookNotification> messages = hbaseOperationContext.getMessages();
try { try {
...@@ -534,7 +537,7 @@ public class HBaseAtlasHook extends AtlasHook { ...@@ -534,7 +537,7 @@ public class HBaseAtlasHook extends AtlasHook {
* *
* @param messages hook notification messages * @param messages hook notification messages
*/ */
protected void notifyEntities(List<HookNotification.HookNotificationMessage> messages) { protected void notifyEntities(List<HookNotification> messages) {
final int maxRetries = atlasProperties.getInt(HOOK_NUM_RETRIES, 3); final int maxRetries = atlasProperties.getInt(HOOK_NUM_RETRIES, 3);
notifyEntities(messages, maxRetries); notifyEntities(messages, maxRetries);
} }
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
package org.apache.atlas.hbase.model; package org.apache.atlas.hbase.model;
import org.apache.atlas.hbase.bridge.HBaseAtlasHook; import org.apache.atlas.hbase.bridge.HBaseAtlasHook;
import org.apache.atlas.notification.hook.HookNotification; import org.apache.atlas.model.notification.HookNotification;
import org.apache.hadoop.hbase.NamespaceDescriptor; import org.apache.hadoop.hbase.NamespaceDescriptor;
import org.apache.hadoop.hbase.HTableDescriptor; import org.apache.hadoop.hbase.HTableDescriptor;
import org.apache.hadoop.hbase.HColumnDescriptor; import org.apache.hadoop.hbase.HColumnDescriptor;
...@@ -74,7 +74,7 @@ public class HBaseOperationContext { ...@@ -74,7 +74,7 @@ public class HBaseOperationContext {
this(null, nameSpace, null, tableName, null, hColumnDescriptor, columnFamily, operation, ugi, user, owner, hbaseConf); this(null, nameSpace, null, tableName, null, hColumnDescriptor, columnFamily, operation, ugi, user, owner, hbaseConf);
} }
private List<HookNotification.HookNotificationMessage> messages = new ArrayList<>(); private List<HookNotification> messages = new ArrayList<>();
public UserGroupInformation getUgi() { public UserGroupInformation getUgi() {
return ugi; return ugi;
...@@ -120,7 +120,7 @@ public class HBaseOperationContext { ...@@ -120,7 +120,7 @@ public class HBaseOperationContext {
return columnFamily; return columnFamily;
} }
public void addMessage(HookNotification.HookNotificationMessage message) { public void addMessage(HookNotification message) {
messages.add(message); messages.add(message);
} }
...@@ -128,7 +128,7 @@ public class HBaseOperationContext { ...@@ -128,7 +128,7 @@ public class HBaseOperationContext {
return owner; return owner;
} }
public List<HookNotification.HookNotificationMessage> getMessages() { public List<HookNotification> getMessages() {
return messages; return messages;
} }
......
...@@ -22,7 +22,7 @@ import org.apache.atlas.ApplicationProperties; ...@@ -22,7 +22,7 @@ import org.apache.atlas.ApplicationProperties;
import org.apache.atlas.AtlasClient; import org.apache.atlas.AtlasClient;
import org.apache.atlas.hbase.bridge.HBaseAtlasHook; import org.apache.atlas.hbase.bridge.HBaseAtlasHook;
import org.apache.atlas.hbase.model.HBaseDataTypes; import org.apache.atlas.hbase.model.HBaseDataTypes;
import org.apache.atlas.typesystem.Referenceable; import org.apache.atlas.v1.model.instance.Referenceable;
import org.apache.atlas.utils.AuthenticationUtil; import org.apache.atlas.utils.AuthenticationUtil;
import org.apache.atlas.utils.ParamChecker; import org.apache.atlas.utils.ParamChecker;
import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.conf.Configuration;
......
...@@ -45,11 +45,6 @@ ...@@ -45,11 +45,6 @@
<!-- apache atlas core dependencies --> <!-- apache atlas core dependencies -->
<dependency> <dependency>
<groupId>org.apache.atlas</groupId> <groupId>org.apache.atlas</groupId>
<artifactId>atlas-typesystem</artifactId>
</dependency>
<dependency>
<groupId>org.apache.atlas</groupId>
<artifactId>atlas-client-v1</artifactId> <artifactId>atlas-client-v1</artifactId>
</dependency> </dependency>
...@@ -83,72 +78,11 @@ ...@@ -83,72 +78,11 @@
<artifactId>atlas-repository</artifactId> <artifactId>atlas-repository</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>org.apache.atlas</groupId>
<artifactId>atlas-typesystem</artifactId>
<classifier>tests</classifier>
<scope>test</scope>
</dependency>
</dependencies> </dependencies>
<build> <build>
<plugins> <plugins>
<plugin> <plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>3.2.0</version>
<executions>
<execution>
<id>scala-compile-first</id>
<phase>process-resources</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>scala-test-compile-first</id>
<phase>process-test-resources</phase>
<goals>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
<configuration>
<scalaVersion>${scala.version}</scalaVersion>
<recompileMode>incremental</recompileMode>
<useZincServer>true</useZincServer>
<source>1.7</source>
<target>1.7</target>
<args>
<arg>-unchecked</arg>
<arg>-deprecation</arg>
<arg>-feature</arg>
</args>
<jvmArgs>
<jvmArg>-Xmx512m</jvmArg>
</jvmArgs>
<!--
<javacArgs>
<javacArg>-source</javacArg>
<javacArg>${java.version}</javacArg>
<javacArg>-target</javacArg>
<javacArg>${java.version}</javacArg>
</javacArgs>
-->
<!-- The following plugin is required to use quasiquotes in Scala 2.10 and is used
by Spark SQL for code generation. -->
<!--<compilerPlugins>
<compilerPlugin>
<groupId>org.scalamacros</groupId>
<artifactId>paradise_${scala.version}</artifactId>
<version>${scala.macros.version}</version>
</compilerPlugin>
</compilerPlugins>-->
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId> <artifactId>maven-site-plugin</artifactId>
<dependencies> <dependencies>
......
...@@ -95,11 +95,6 @@ ...@@ -95,11 +95,6 @@
<dependency> <dependency>
<groupId>org.apache.atlas</groupId> <groupId>org.apache.atlas</groupId>
<artifactId>atlas-typesystem</artifactId>
</dependency>
<dependency>
<groupId>org.apache.atlas</groupId>
<artifactId>atlas-client-v1</artifactId> <artifactId>atlas-client-v1</artifactId>
</dependency> </dependency>
...@@ -156,7 +151,7 @@ ...@@ -156,7 +151,7 @@
<dependency> <dependency>
<groupId>org.apache.atlas</groupId> <groupId>org.apache.atlas</groupId>
<artifactId>atlas-typesystem</artifactId> <artifactId>atlas-intg</artifactId>
<classifier>tests</classifier> <classifier>tests</classifier>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
...@@ -189,21 +184,6 @@ ...@@ -189,21 +184,6 @@
<version>${project.version}</version> <version>${project.version}</version>
</artifactItem> </artifactItem>
<artifactItem> <artifactItem>
<groupId>org.json4s</groupId>
<artifactId>json4s-native_${scala.binary.version}</artifactId>
<version>${json.version}</version>
</artifactItem>
<artifactItem>
<groupId>org.json4s</groupId>
<artifactId>json4s-core_${scala.binary.version}</artifactId>
<version>${json.version}</version>
</artifactItem>
<artifactItem>
<groupId>org.json4s</groupId>
<artifactId>json4s-ast_${scala.binary.version}</artifactId>
<version>${json.version}</version>
</artifactItem>
<artifactItem>
<groupId>${project.groupId}</groupId> <groupId>${project.groupId}</groupId>
<artifactId>atlas-client-common</artifactId> <artifactId>atlas-client-common</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
...@@ -220,11 +200,6 @@ ...@@ -220,11 +200,6 @@
</artifactItem> </artifactItem>
<artifactItem> <artifactItem>
<groupId>${project.groupId}</groupId> <groupId>${project.groupId}</groupId>
<artifactId>atlas-typesystem</artifactId>
<version>${project.version}</version>
</artifactItem>
<artifactItem>
<groupId>${project.groupId}</groupId>
<artifactId>atlas-intg</artifactId> <artifactId>atlas-intg</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
</artifactItem> </artifactItem>
...@@ -244,28 +219,8 @@ ...@@ -244,28 +219,8 @@
<version>${project.version}</version> <version>${project.version}</version>
</artifactItem> </artifactItem>
<artifactItem> <artifactItem>
<groupId>org.scala-lang</groupId>
<artifactId>scala-compiler</artifactId>
<version>${scala.version}</version>
</artifactItem>
<artifactItem>
<groupId>org.scala-lang</groupId>
<artifactId>scala-reflect</artifactId>
<version>${scala.version}</version>
</artifactItem>
<artifactItem>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>${scala.version}</version>
</artifactItem>
<artifactItem>
<groupId>org.scala-lang</groupId>
<artifactId>scalap</artifactId>
<version>${scala.version}</version>
</artifactItem>
<artifactItem>
<groupId>org.apache.kafka</groupId> <groupId>org.apache.kafka</groupId>
<artifactId>kafka_${scala.binary.version}</artifactId> <artifactId>kafka_${kafka.scala.binary.version}</artifactId>
<version>${kafka.version}</version> <version>${kafka.version}</version>
</artifactItem> </artifactItem>
<artifactItem> <artifactItem>
...@@ -273,11 +228,6 @@ ...@@ -273,11 +228,6 @@
<artifactId>kafka-clients</artifactId> <artifactId>kafka-clients</artifactId>
<version>${kafka.version}</version> <version>${kafka.version}</version>
</artifactItem> </artifactItem>
<artifactItem>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>${gson.version}</version>
</artifactItem>
</artifactItems> </artifactItems>
</configuration> </configuration>
</execution> </execution>
...@@ -351,7 +301,7 @@ ...@@ -351,7 +301,7 @@
</systemProperty> </systemProperty>
<systemProperty> <systemProperty>
<key>atlas.conf</key> <key>atlas.conf</key>
<value>${project.build.directory}/../../../typesystem/target/test-classes</value> <value>${project.build.directory}/../../../intg/target/test-classes</value>
</systemProperty> </systemProperty>
<systemProperty> <systemProperty>
<key>atlas.home</key> <key>atlas.home</key>
......
...@@ -20,7 +20,7 @@ package org.apache.atlas.hive.bridge; ...@@ -20,7 +20,7 @@ package org.apache.atlas.hive.bridge;
import org.apache.atlas.AtlasClient; import org.apache.atlas.AtlasClient;
import org.apache.atlas.hive.model.HiveDataTypes; import org.apache.atlas.hive.model.HiveDataTypes;
import org.apache.atlas.typesystem.Referenceable; import org.apache.atlas.v1.model.instance.Referenceable;
import org.apache.hadoop.hive.ql.hooks.LineageInfo; import org.apache.hadoop.hive.ql.hooks.LineageInfo;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
......
...@@ -27,10 +27,10 @@ import org.apache.atlas.AtlasServiceException; ...@@ -27,10 +27,10 @@ import org.apache.atlas.AtlasServiceException;
import org.apache.atlas.hive.hook.HiveHook; import org.apache.atlas.hive.hook.HiveHook;
import org.apache.atlas.hive.model.HiveDataTypes; import org.apache.atlas.hive.model.HiveDataTypes;
import org.apache.atlas.hook.AtlasHookException; import org.apache.atlas.hook.AtlasHookException;
import org.apache.atlas.typesystem.Referenceable; import org.apache.atlas.v1.model.instance.Id;
import org.apache.atlas.typesystem.Struct; import org.apache.atlas.v1.model.instance.Referenceable;
import org.apache.atlas.typesystem.json.InstanceSerialization; import org.apache.atlas.v1.model.instance.Struct;
import org.apache.atlas.typesystem.persistence.Id; import org.apache.atlas.type.AtlasType;
import org.apache.atlas.utils.AuthenticationUtil; import org.apache.atlas.utils.AuthenticationUtil;
import org.apache.commons.cli.BasicParser; import org.apache.commons.cli.BasicParser;
import org.apache.commons.cli.CommandLine; import org.apache.commons.cli.CommandLine;
...@@ -170,7 +170,7 @@ public class HiveMetaStoreBridge { ...@@ -170,7 +170,7 @@ public class HiveMetaStoreBridge {
dbRef = createDBInstance(db); dbRef = createDBInstance(db);
dbRef = registerInstance(dbRef); dbRef = registerInstance(dbRef);
} else { } else {
LOG.info("Database {} is already registered with id {}. Updating it.", databaseName, dbRef.getId().id); LOG.info("Database {} is already registered with id {}. Updating it.", databaseName, dbRef.getId().getId());
dbRef = createOrUpdateDBInstance(db, dbRef); dbRef = createOrUpdateDBInstance(db, dbRef);
updateInstance(dbRef); updateInstance(dbRef);
} }
...@@ -208,7 +208,7 @@ public class HiveMetaStoreBridge { ...@@ -208,7 +208,7 @@ public class HiveMetaStoreBridge {
String typeName = referenceable.getTypeName(); String typeName = referenceable.getTypeName();
LOG.debug("creating instance of type {}", typeName); LOG.debug("creating instance of type {}", typeName);
String entityJSON = InstanceSerialization.toJson(referenceable, true); String entityJSON = AtlasType.toV1Json(referenceable);
LOG.debug("Submitting new entity {} = {}", referenceable.getTypeName(), entityJSON); LOG.debug("Submitting new entity {} = {}", referenceable.getTypeName(), entityJSON);
List<String> guids = getAtlasClient().createEntity(entityJSON); List<String> guids = getAtlasClient().createEntity(entityJSON);
LOG.debug("created instance for type {}, guid: {}", typeName, guids); LOG.debug("created instance for type {}, guid: {}", typeName, guids);
...@@ -506,7 +506,7 @@ public class HiveMetaStoreBridge { ...@@ -506,7 +506,7 @@ public class HiveMetaStoreBridge {
tableReference = registerInstance(tableReference); tableReference = registerInstance(tableReference);
} else { } else {
LOG.info("Table {}.{} is already registered with id {}. Updating entity.", dbName, tableName, LOG.info("Table {}.{} is already registered with id {}. Updating entity.", dbName, tableName,
tableReference.getId().id); tableReference.getId().getId());
tableReference = createOrUpdateTableInstance(dbReference, tableReference, table); tableReference = createOrUpdateTableInstance(dbReference, tableReference, table);
updateInstance(tableReference); updateInstance(tableReference);
} }
...@@ -520,10 +520,10 @@ public class HiveMetaStoreBridge { ...@@ -520,10 +520,10 @@ public class HiveMetaStoreBridge {
String typeName = referenceable.getTypeName(); String typeName = referenceable.getTypeName();
LOG.debug("updating instance of type {}", typeName); LOG.debug("updating instance of type {}", typeName);
String entityJSON = InstanceSerialization.toJson(referenceable, true); String entityJSON = AtlasType.toV1Json(referenceable);
LOG.debug("Updating entity {} = {}", referenceable.getTypeName(), entityJSON); LOG.debug("Updating entity {} = {}", referenceable.getTypeName(), entityJSON);
atlasClient.updateEntity(referenceable.getId().id, referenceable); atlasClient.updateEntity(referenceable.getId().getId(), referenceable);
} }
public Referenceable fillStorageDesc(StorageDescriptor storageDesc, String tableQualifiedName, public Referenceable fillStorageDesc(StorageDescriptor storageDesc, String tableQualifiedName,
......
...@@ -28,8 +28,11 @@ import org.apache.atlas.hive.bridge.HiveMetaStoreBridge; ...@@ -28,8 +28,11 @@ import org.apache.atlas.hive.bridge.HiveMetaStoreBridge;
import org.apache.atlas.hive.model.HiveDataTypes; import org.apache.atlas.hive.model.HiveDataTypes;
import org.apache.atlas.hook.AtlasHook; import org.apache.atlas.hook.AtlasHook;
import org.apache.atlas.hook.AtlasHookException; import org.apache.atlas.hook.AtlasHookException;
import org.apache.atlas.notification.hook.HookNotification; import org.apache.atlas.model.notification.HookNotification;
import org.apache.atlas.typesystem.Referenceable; import org.apache.atlas.v1.model.instance.Referenceable;
import org.apache.atlas.v1.model.notification.HookNotificationV1.EntityDeleteRequest;
import org.apache.atlas.v1.model.notification.HookNotificationV1.EntityPartialUpdateRequest;
import org.apache.atlas.v1.model.notification.HookNotificationV1.EntityUpdateRequest;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.tuple.Pair; import org.apache.commons.lang3.tuple.Pair;
import org.apache.hadoop.fs.Path; import org.apache.hadoop.fs.Path;
...@@ -331,7 +334,7 @@ public class HiveHook extends AtlasHook implements ExecuteWithHookContext { ...@@ -331,7 +334,7 @@ public class HiveHook extends AtlasHook implements ExecuteWithHookContext {
final String tblQualifiedName = HiveMetaStoreBridge.getTableQualifiedName(dgiBridge.getClusterName(), output.getTable()); final String tblQualifiedName = HiveMetaStoreBridge.getTableQualifiedName(dgiBridge.getClusterName(), output.getTable());
LOG.info("Deleting table {} ", tblQualifiedName); LOG.info("Deleting table {} ", tblQualifiedName);
event.addMessage( event.addMessage(
new HookNotification.EntityDeleteRequest(event.getUser(), new EntityDeleteRequest(event.getUser(),
HiveDataTypes.HIVE_TABLE.getName(), HiveDataTypes.HIVE_TABLE.getName(),
AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME,
tblQualifiedName)); tblQualifiedName));
...@@ -350,7 +353,7 @@ public class HiveHook extends AtlasHook implements ExecuteWithHookContext { ...@@ -350,7 +353,7 @@ public class HiveHook extends AtlasHook implements ExecuteWithHookContext {
} else if (Type.DATABASE.equals(output.getType())) { } else if (Type.DATABASE.equals(output.getType())) {
final String dbQualifiedName = HiveMetaStoreBridge.getDBQualifiedName(dgiBridge.getClusterName(), output.getDatabase().getName()); final String dbQualifiedName = HiveMetaStoreBridge.getDBQualifiedName(dgiBridge.getClusterName(), output.getDatabase().getName());
event.addMessage( event.addMessage(
new HookNotification.EntityDeleteRequest(event.getUser(), new EntityDeleteRequest(event.getUser(),
HiveDataTypes.HIVE_DB.getName(), HiveDataTypes.HIVE_DB.getName(),
AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME,
dbQualifiedName)); dbQualifiedName));
...@@ -412,7 +415,7 @@ public class HiveHook extends AtlasHook implements ExecuteWithHookContext { ...@@ -412,7 +415,7 @@ public class HiveHook extends AtlasHook implements ExecuteWithHookContext {
Referenceable newColEntity = new Referenceable(HiveDataTypes.HIVE_COLUMN.getName()); Referenceable newColEntity = new Referenceable(HiveDataTypes.HIVE_COLUMN.getName());
newColEntity.set(AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, newColumnQFName); newColEntity.set(AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, newColumnQFName);
event.addMessage(new HookNotification.EntityPartialUpdateRequest(event.getUser(), event.addMessage(new EntityPartialUpdateRequest(event.getUser(),
HiveDataTypes.HIVE_COLUMN.getName(), AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, HiveDataTypes.HIVE_COLUMN.getName(), AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME,
oldColumnQFName, newColEntity)); oldColumnQFName, newColEntity));
} }
...@@ -481,7 +484,7 @@ public class HiveHook extends AtlasHook implements ExecuteWithHookContext { ...@@ -481,7 +484,7 @@ public class HiveHook extends AtlasHook implements ExecuteWithHookContext {
ArrayList<String> alias_list = new ArrayList<>(); ArrayList<String> alias_list = new ArrayList<>();
alias_list.add(oldTable.getTableName().toLowerCase()); alias_list.add(oldTable.getTableName().toLowerCase());
newEntity.set(HiveMetaStoreBridge.TABLE_ALIAS_LIST, alias_list); newEntity.set(HiveMetaStoreBridge.TABLE_ALIAS_LIST, alias_list);
event.addMessage(new HookNotification.EntityPartialUpdateRequest(event.getUser(), event.addMessage(new EntityPartialUpdateRequest(event.getUser(),
HiveDataTypes.HIVE_TABLE.getName(), AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, HiveDataTypes.HIVE_TABLE.getName(), AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME,
oldTableQFName, newEntity)); oldTableQFName, newEntity));
...@@ -499,7 +502,7 @@ public class HiveHook extends AtlasHook implements ExecuteWithHookContext { ...@@ -499,7 +502,7 @@ public class HiveHook extends AtlasHook implements ExecuteWithHookContext {
Referenceable newColEntity = new Referenceable(HiveDataTypes.HIVE_COLUMN.getName()); Referenceable newColEntity = new Referenceable(HiveDataTypes.HIVE_COLUMN.getName());
///Only QF Name changes ///Only QF Name changes
newColEntity.set(AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, newColumnQFName); newColEntity.set(AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, newColumnQFName);
event.addMessage(new HookNotification.EntityPartialUpdateRequest(event.getUser(), event.addMessage(new EntityPartialUpdateRequest(event.getUser(),
HiveDataTypes.HIVE_COLUMN.getName(), AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, HiveDataTypes.HIVE_COLUMN.getName(), AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME,
oldColumnQFName, newColEntity)); oldColumnQFName, newColEntity));
newColEntities.add(newColEntity); newColEntities.add(newColEntity);
...@@ -518,7 +521,7 @@ public class HiveHook extends AtlasHook implements ExecuteWithHookContext { ...@@ -518,7 +521,7 @@ public class HiveHook extends AtlasHook implements ExecuteWithHookContext {
final Referenceable newSDEntity = new Referenceable(HiveDataTypes.HIVE_STORAGEDESC.getName()); final Referenceable newSDEntity = new Referenceable(HiveDataTypes.HIVE_STORAGEDESC.getName());
newSDEntity.set(AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, newSDQFName); newSDEntity.set(AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, newSDQFName);
event.addMessage(new HookNotification.EntityPartialUpdateRequest(event.getUser(), event.addMessage(new EntityPartialUpdateRequest(event.getUser(),
HiveDataTypes.HIVE_STORAGEDESC.getName(), AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, HiveDataTypes.HIVE_STORAGEDESC.getName(), AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME,
oldSDQFName, newSDEntity)); oldSDQFName, newSDEntity));
...@@ -593,7 +596,7 @@ public class HiveHook extends AtlasHook implements ExecuteWithHookContext { ...@@ -593,7 +596,7 @@ public class HiveHook extends AtlasHook implements ExecuteWithHookContext {
} }
if (!entities.isEmpty()) { if (!entities.isEmpty()) {
event.addMessage(new HookNotification.EntityUpdateRequest(event.getUser(), entities)); event.addMessage(new EntityUpdateRequest(event.getUser(), entities));
} }
return result; return result;
...@@ -719,7 +722,7 @@ public class HiveHook extends AtlasHook implements ExecuteWithHookContext { ...@@ -719,7 +722,7 @@ public class HiveHook extends AtlasHook implements ExecuteWithHookContext {
private void addEntityUpdateNotificationMessagess(final HiveEventContext event, final Collection<Referenceable> entities) { private void addEntityUpdateNotificationMessagess(final HiveEventContext event, final Collection<Referenceable> entities) {
// process each entity as separate message to avoid running into OOM errors // process each entity as separate message to avoid running into OOM errors
for (Referenceable entity : entities) { for (Referenceable entity : entities) {
event.addMessage(new HookNotification.EntityUpdateRequest(event.getUser(), entity)); event.addMessage(new EntityUpdateRequest(event.getUser(), entity));
} }
} }
...@@ -1089,7 +1092,7 @@ public class HiveHook extends AtlasHook implements ExecuteWithHookContext { ...@@ -1089,7 +1092,7 @@ public class HiveHook extends AtlasHook implements ExecuteWithHookContext {
public Map<String, List<ColumnLineageUtils.HiveColumnLineageInfo>> lineageInfo; public Map<String, List<ColumnLineageUtils.HiveColumnLineageInfo>> lineageInfo;
private List<HookNotification.HookNotificationMessage> messages = new ArrayList<>(); private List<HookNotification> messages = new ArrayList<>();
public void setInputs(Set<ReadEntity> inputs) { public void setInputs(Set<ReadEntity> inputs) {
this.inputs = inputs; this.inputs = inputs;
...@@ -1172,11 +1175,11 @@ public class HiveHook extends AtlasHook implements ExecuteWithHookContext { ...@@ -1172,11 +1175,11 @@ public class HiveHook extends AtlasHook implements ExecuteWithHookContext {
return queryStartTime; return queryStartTime;
} }
public void addMessage(HookNotification.HookNotificationMessage message) { public void addMessage(HookNotification message) {
messages.add(message); messages.add(message);
} }
public List<HookNotification.HookNotificationMessage> getMessages() { public List<HookNotification> getMessages() {
return messages; return messages;
} }
} }
......
...@@ -23,8 +23,8 @@ import org.apache.atlas.AtlasClient; ...@@ -23,8 +23,8 @@ import org.apache.atlas.AtlasClient;
import org.apache.atlas.hive.bridge.HiveMetaStoreBridge; import org.apache.atlas.hive.bridge.HiveMetaStoreBridge;
import org.apache.atlas.hive.hook.HiveHookIT; import org.apache.atlas.hive.hook.HiveHookIT;
import org.apache.atlas.hive.model.HiveDataTypes; import org.apache.atlas.hive.model.HiveDataTypes;
import org.apache.atlas.typesystem.Referenceable; import org.apache.atlas.v1.model.instance.Referenceable;
import org.apache.atlas.typesystem.persistence.Id; import org.apache.atlas.v1.model.instance.Id;
import org.apache.atlas.utils.AuthenticationUtil; import org.apache.atlas.utils.AuthenticationUtil;
import org.apache.atlas.utils.ParamChecker; import org.apache.atlas.utils.ParamChecker;
import org.apache.commons.configuration.Configuration; import org.apache.commons.configuration.Configuration;
......
...@@ -21,7 +21,7 @@ package org.apache.atlas.hive.bridge; ...@@ -21,7 +21,7 @@ package org.apache.atlas.hive.bridge;
import org.apache.atlas.AtlasClient; import org.apache.atlas.AtlasClient;
import org.apache.atlas.AtlasServiceException; import org.apache.atlas.AtlasServiceException;
import org.apache.atlas.hive.model.HiveDataTypes; import org.apache.atlas.hive.model.HiveDataTypes;
import org.apache.atlas.typesystem.Referenceable; import org.apache.atlas.v1.model.instance.Referenceable;
import org.apache.hadoop.fs.Path; import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hive.metastore.TableType; import org.apache.hadoop.hive.metastore.TableType;
import org.apache.hadoop.hive.metastore.api.Database; import org.apache.hadoop.hive.metastore.api.Database;
...@@ -38,8 +38,8 @@ import org.mockito.MockitoAnnotations; ...@@ -38,8 +38,8 @@ import org.mockito.MockitoAnnotations;
import org.testng.Assert; import org.testng.Assert;
import org.testng.annotations.BeforeMethod; import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import scala.actors.threadpool.Arrays;
import java.util.Arrays;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
......
...@@ -21,8 +21,8 @@ package org.apache.atlas.hive.bridge; ...@@ -21,8 +21,8 @@ package org.apache.atlas.hive.bridge;
import org.apache.atlas.AtlasClient; import org.apache.atlas.AtlasClient;
import org.apache.atlas.hive.HiveITBase; import org.apache.atlas.hive.HiveITBase;
import org.apache.atlas.hive.model.HiveDataTypes; import org.apache.atlas.hive.model.HiveDataTypes;
import org.apache.atlas.typesystem.Referenceable; import org.apache.atlas.v1.model.instance.Referenceable;
import org.apache.atlas.typesystem.persistence.Id; import org.apache.atlas.v1.model.instance.Id;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import java.util.List; import java.util.List;
...@@ -50,7 +50,7 @@ public class HiveMetastoreBridgeIT extends HiveITBase { ...@@ -50,7 +50,7 @@ public class HiveMetastoreBridgeIT extends HiveITBase {
List<Id> outputs = (List<Id>) processReference.get(OUTPUTS); List<Id> outputs = (List<Id>) processReference.get(OUTPUTS);
assertEquals(outputs.size(), 1); assertEquals(outputs.size(), 1);
assertEquals(outputs.get(0).getId()._getId(), tableId); assertEquals(outputs.get(0).getId(), tableId);
int tableCount = atlasClient.listEntities(HiveDataTypes.HIVE_TABLE.getName()).size(); int tableCount = atlasClient.listEntities(HiveDataTypes.HIVE_TABLE.getName()).size();
...@@ -84,6 +84,6 @@ public class HiveMetastoreBridgeIT extends HiveITBase { ...@@ -84,6 +84,6 @@ public class HiveMetastoreBridgeIT extends HiveITBase {
getTableProcessQualifiedName(DEFAULT_DB, tableName), null); getTableProcessQualifiedName(DEFAULT_DB, tableName), null);
List<Id> outputs = (List<Id>) atlasClient.getEntity(processId).get(OUTPUTS); List<Id> outputs = (List<Id>) atlasClient.getEntity(processId).get(OUTPUTS);
assertEquals(outputs.size(), 1); assertEquals(outputs.size(), 1);
assertEquals(outputs.get(0).getId()._getId(), tableId); assertEquals(outputs.get(0).getId(), tableId);
} }
} }
...@@ -19,18 +19,16 @@ ...@@ -19,18 +19,16 @@
package org.apache.atlas.hive.hook; package org.apache.atlas.hive.hook;
import com.google.common.base.Joiner; import com.google.common.base.Joiner;
import com.google.common.collect.ImmutableList;
import com.sun.jersey.api.client.ClientResponse; import com.sun.jersey.api.client.ClientResponse;
import org.apache.atlas.AtlasClient; import org.apache.atlas.AtlasClient;
import org.apache.atlas.AtlasServiceException; import org.apache.atlas.AtlasServiceException;
import org.apache.atlas.hive.HiveITBase; import org.apache.atlas.hive.HiveITBase;
import org.apache.atlas.hive.bridge.HiveMetaStoreBridge; import org.apache.atlas.hive.bridge.HiveMetaStoreBridge;
import org.apache.atlas.hive.model.HiveDataTypes; import org.apache.atlas.hive.model.HiveDataTypes;
import org.apache.atlas.typesystem.Referenceable; import org.apache.atlas.model.typedef.AtlasBaseTypeDef;
import org.apache.atlas.typesystem.Struct; import org.apache.atlas.v1.model.instance.Id;
import org.apache.atlas.typesystem.persistence.Id; import org.apache.atlas.v1.model.instance.Struct;
import org.apache.atlas.typesystem.types.TypeSystem; import org.apache.atlas.v1.model.instance.Referenceable;
import org.apache.commons.lang.RandomStringUtils;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.apache.hadoop.fs.Path; import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hive.metastore.TableType; import org.apache.hadoop.hive.metastore.TableType;
...@@ -182,7 +180,7 @@ public class HiveHookIT extends HiveITBase { ...@@ -182,7 +180,7 @@ public class HiveHookIT extends HiveITBase {
private void verifyTimestamps(Referenceable ref, String property, long expectedTime) throws ParseException { private void verifyTimestamps(Referenceable ref, String property, long expectedTime) throws ParseException {
//Verify timestamps. //Verify timestamps.
String createTimeStr = (String) ref.get(property); String createTimeStr = (String) ref.get(property);
Date createDate = TypeSystem.getInstance().getDateFormat().parse(createTimeStr); Date createDate = AtlasBaseTypeDef.DATE_FORMATTER.parse(createTimeStr);
Assert.assertNotNull(createTimeStr); Assert.assertNotNull(createTimeStr);
if (expectedTime > 0) { if (expectedTime > 0) {
...@@ -1262,7 +1260,7 @@ public class HiveHookIT extends HiveITBase { ...@@ -1262,7 +1260,7 @@ public class HiveHookIT extends HiveITBase {
String guid2 = assertColumnIsRegistered(HiveMetaStoreBridge.getColumnQualifiedName(tbqn, "id_new")); String guid2 = assertColumnIsRegistered(HiveMetaStoreBridge.getColumnQualifiedName(tbqn, "id_new"));
assertEquals(guid2, guid); assertEquals(guid2, guid);
assertTrue(atlasClient.getEntity(guid2).getTraits().contains(trait)); assertTrue(atlasClient.getEntity(guid2).getTraitNames().contains(trait));
} }
@Test @Test
...@@ -1349,15 +1347,15 @@ public class HiveHookIT extends HiveITBase { ...@@ -1349,15 +1347,15 @@ public class HiveHookIT extends HiveITBase {
@Test @Test
public void testAlterTableBucketingClusterSort() throws Exception { public void testAlterTableBucketingClusterSort() throws Exception {
String tableName = createTable(); String tableName = createTable();
ImmutableList<String> cols = ImmutableList.of("id"); List<String> cols = Collections.singletonList("id");
runBucketSortQuery(tableName, 5, cols, cols); runBucketSortQuery(tableName, 5, cols, cols);
cols = ImmutableList.of("id", NAME); cols = Arrays.asList("id", NAME);
runBucketSortQuery(tableName, 2, cols, cols); runBucketSortQuery(tableName, 2, cols, cols);
} }
private void runBucketSortQuery(String tableName, final int numBuckets, final ImmutableList<String> bucketCols, private void runBucketSortQuery(String tableName, final int numBuckets, final List<String> bucketCols,
final ImmutableList<String> sortCols) throws Exception { final List<String> sortCols) throws Exception {
final String fmtQuery = "alter table %s CLUSTERED BY (%s) SORTED BY (%s) INTO %s BUCKETS"; final String fmtQuery = "alter table %s CLUSTERED BY (%s) SORTED BY (%s) INTO %s BUCKETS";
String query = String.format(fmtQuery, tableName, stripListBrackets(bucketCols.toString()), String query = String.format(fmtQuery, tableName, stripListBrackets(bucketCols.toString()),
stripListBrackets(sortCols.toString()), numBuckets); stripListBrackets(sortCols.toString()), numBuckets);
...@@ -1375,8 +1373,8 @@ public class HiveHookIT extends HiveITBase { ...@@ -1375,8 +1373,8 @@ public class HiveHookIT extends HiveITBase {
} }
private void verifyBucketSortingProperties(Referenceable tableRef, int numBuckets, private void verifyBucketSortingProperties(Referenceable tableRef, int numBuckets,
ImmutableList<String> bucketColNames, List<String> bucketColNames,
ImmutableList<String> sortcolNames) throws Exception { List<String> sortcolNames) throws Exception {
Referenceable sdRef = (Referenceable) tableRef.get(HiveMetaStoreBridge.STORAGE_DESC); Referenceable sdRef = (Referenceable) tableRef.get(HiveMetaStoreBridge.STORAGE_DESC);
Assert.assertEquals(((scala.math.BigInt) sdRef.get(HiveMetaStoreBridge.STORAGE_NUM_BUCKETS)).intValue(), Assert.assertEquals(((scala.math.BigInt) sdRef.get(HiveMetaStoreBridge.STORAGE_NUM_BUCKETS)).intValue(),
numBuckets); numBuckets);
......
...@@ -94,11 +94,6 @@ ...@@ -94,11 +94,6 @@
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency>
<groupId>org.apache.atlas</groupId>
<artifactId>atlas-typesystem</artifactId>
</dependency>
<dependency> <dependency>
<groupId>org.apache.atlas</groupId> <groupId>org.apache.atlas</groupId>
<artifactId>atlas-client-v1</artifactId> <artifactId>atlas-client-v1</artifactId>
...@@ -155,13 +150,6 @@ ...@@ -155,13 +150,6 @@
<type>pom</type> <type>pom</type>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>org.apache.atlas</groupId>
<artifactId>atlas-typesystem</artifactId>
<classifier>tests</classifier>
<scope>test</scope>
</dependency>
</dependencies> </dependencies>
<profiles> <profiles>
...@@ -206,21 +194,6 @@ ...@@ -206,21 +194,6 @@
<version>${project.version}</version> <version>${project.version}</version>
</artifactItem> </artifactItem>
<artifactItem> <artifactItem>
<groupId>org.json4s</groupId>
<artifactId>json4s-native_${scala.binary.version}</artifactId>
<version>${json.version}</version>
</artifactItem>
<artifactItem>
<groupId>org.json4s</groupId>
<artifactId>json4s-core_${scala.binary.version}</artifactId>
<version>${json.version}</version>
</artifactItem>
<artifactItem>
<groupId>org.json4s</groupId>
<artifactId>json4s-ast_${scala.binary.version}</artifactId>
<version>${json.version}</version>
</artifactItem>
<artifactItem>
<groupId>${project.groupId}</groupId> <groupId>${project.groupId}</groupId>
<artifactId>atlas-client-common</artifactId> <artifactId>atlas-client-common</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
...@@ -237,11 +210,6 @@ ...@@ -237,11 +210,6 @@
</artifactItem> </artifactItem>
<artifactItem> <artifactItem>
<groupId>${project.groupId}</groupId> <groupId>${project.groupId}</groupId>
<artifactId>atlas-typesystem</artifactId>
<version>${project.version}</version>
</artifactItem>
<artifactItem>
<groupId>${project.groupId}</groupId>
<artifactId>atlas-intg</artifactId> <artifactId>atlas-intg</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
</artifactItem> </artifactItem>
...@@ -256,28 +224,8 @@ ...@@ -256,28 +224,8 @@
<version>${project.version}</version> <version>${project.version}</version>
</artifactItem> </artifactItem>
<artifactItem> <artifactItem>
<groupId>org.scala-lang</groupId>
<artifactId>scala-compiler</artifactId>
<version>${scala.version}</version>
</artifactItem>
<artifactItem>
<groupId>org.scala-lang</groupId>
<artifactId>scala-reflect</artifactId>
<version>${scala.version}</version>
</artifactItem>
<artifactItem>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>${scala.version}</version>
</artifactItem>
<artifactItem>
<groupId>org.scala-lang</groupId>
<artifactId>scalap</artifactId>
<version>${scala.version}</version>
</artifactItem>
<artifactItem>
<groupId>org.apache.kafka</groupId> <groupId>org.apache.kafka</groupId>
<artifactId>kafka_${scala.binary.version}</artifactId> <artifactId>kafka_${kafka.scala.binary.version}</artifactId>
<version>${kafka.version}</version> <version>${kafka.version}</version>
</artifactItem> </artifactItem>
<artifactItem> <artifactItem>
...@@ -285,11 +233,6 @@ ...@@ -285,11 +233,6 @@
<artifactId>kafka-clients</artifactId> <artifactId>kafka-clients</artifactId>
<version>${kafka.version}</version> <version>${kafka.version}</version>
</artifactItem> </artifactItem>
<artifactItem>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>${gson.version}</version>
</artifactItem>
</artifactItems> </artifactItems>
</configuration> </configuration>
</execution> </execution>
...@@ -363,7 +306,7 @@ ...@@ -363,7 +306,7 @@
</systemProperty> </systemProperty>
<systemProperty> <systemProperty>
<key>atlas.conf</key> <key>atlas.conf</key>
<value>${project.build.directory}/../../../typesystem/target/test-classes</value> <value>${project.build.directory}/../../../intg/target/test-classes</value>
</systemProperty> </systemProperty>
<systemProperty> <systemProperty>
<key>atlas.home</key> <key>atlas.home</key>
......
...@@ -26,9 +26,10 @@ import org.apache.atlas.hive.bridge.HiveMetaStoreBridge; ...@@ -26,9 +26,10 @@ import org.apache.atlas.hive.bridge.HiveMetaStoreBridge;
import org.apache.atlas.hive.model.HiveDataTypes; import org.apache.atlas.hive.model.HiveDataTypes;
import org.apache.atlas.hook.AtlasHook; import org.apache.atlas.hook.AtlasHook;
import org.apache.atlas.hook.AtlasHookException; import org.apache.atlas.hook.AtlasHookException;
import org.apache.atlas.notification.hook.HookNotification; import org.apache.atlas.model.notification.HookNotification;
import org.apache.atlas.v1.model.instance.Referenceable;
import org.apache.atlas.v1.model.notification.HookNotificationV1.EntityCreateRequest;
import org.apache.atlas.sqoop.model.SqoopDataTypes; import org.apache.atlas.sqoop.model.SqoopDataTypes;
import org.apache.atlas.typesystem.Referenceable;
import org.apache.commons.configuration.Configuration; import org.apache.commons.configuration.Configuration;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.sqoop.SqoopJobDataPublisher; import org.apache.sqoop.SqoopJobDataPublisher;
...@@ -185,8 +186,8 @@ public class SqoopHook extends SqoopJobDataPublisher { ...@@ -185,8 +186,8 @@ public class SqoopHook extends SqoopJobDataPublisher {
Referenceable procRef = createSqoopProcessInstance(dbStoreRef, hiveTableRef, data, clusterName); Referenceable procRef = createSqoopProcessInstance(dbStoreRef, hiveTableRef, data, clusterName);
int maxRetries = atlasProperties.getInt(HOOK_NUM_RETRIES, 3); int maxRetries = atlasProperties.getInt(HOOK_NUM_RETRIES, 3);
HookNotification.HookNotificationMessage message = HookNotification message =
new HookNotification.EntityCreateRequest(AtlasHook.getUser(), dbStoreRef, dbRef, hiveTableRef, procRef); new EntityCreateRequest(AtlasHook.getUser(), dbStoreRef, dbRef, hiveTableRef, procRef);
AtlasHook.notifyEntities(Arrays.asList(message), maxRetries); AtlasHook.notifyEntities(Arrays.asList(message), maxRetries);
} }
catch(Exception e) { catch(Exception e) {
......
...@@ -38,11 +38,6 @@ ...@@ -38,11 +38,6 @@
<!-- apache atlas core dependencies --> <!-- apache atlas core dependencies -->
<dependency> <dependency>
<groupId>org.apache.atlas</groupId> <groupId>org.apache.atlas</groupId>
<artifactId>atlas-typesystem</artifactId>
</dependency>
<dependency>
<groupId>org.apache.atlas</groupId>
<artifactId>atlas-client-v1</artifactId> <artifactId>atlas-client-v1</artifactId>
</dependency> </dependency>
...@@ -124,13 +119,6 @@ ...@@ -124,13 +119,6 @@
<type>war</type> <type>war</type>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>org.apache.atlas</groupId>
<artifactId>atlas-typesystem</artifactId>
<classifier>tests</classifier>
<scope>test</scope>
</dependency>
</dependencies> </dependencies>
<profiles> <profiles>
...@@ -160,21 +148,6 @@ ...@@ -160,21 +148,6 @@
<version>${project.version}</version> <version>${project.version}</version>
</artifactItem> </artifactItem>
<artifactItem> <artifactItem>
<groupId>org.json4s</groupId>
<artifactId>json4s-native_${scala.binary.version}</artifactId>
<version>${json.version}</version>
</artifactItem>
<artifactItem>
<groupId>org.json4s</groupId>
<artifactId>json4s-core_${scala.binary.version}</artifactId>
<version>${json.version}</version>
</artifactItem>
<artifactItem>
<groupId>org.json4s</groupId>
<artifactId>json4s-ast_${scala.binary.version}</artifactId>
<version>${json.version}</version>
</artifactItem>
<artifactItem>
<groupId>${project.groupId}</groupId> <groupId>${project.groupId}</groupId>
<artifactId>atlas-client-common</artifactId> <artifactId>atlas-client-common</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
...@@ -191,11 +164,6 @@ ...@@ -191,11 +164,6 @@
</artifactItem> </artifactItem>
<artifactItem> <artifactItem>
<groupId>${project.groupId}</groupId> <groupId>${project.groupId}</groupId>
<artifactId>atlas-typesystem</artifactId>
<version>${project.version}</version>
</artifactItem>
<artifactItem>
<groupId>${project.groupId}</groupId>
<artifactId>hive-bridge</artifactId> <artifactId>hive-bridge</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
</artifactItem> </artifactItem>
...@@ -220,28 +188,8 @@ ...@@ -220,28 +188,8 @@
<version>${project.version}</version> <version>${project.version}</version>
</artifactItem> </artifactItem>
<artifactItem> <artifactItem>
<groupId>org.scala-lang</groupId>
<artifactId>scala-compiler</artifactId>
<version>${scala.version}</version>
</artifactItem>
<artifactItem>
<groupId>org.scala-lang</groupId>
<artifactId>scala-reflect</artifactId>
<version>${scala.version}</version>
</artifactItem>
<artifactItem>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>${scala.version}</version>
</artifactItem>
<artifactItem>
<groupId>org.scala-lang</groupId>
<artifactId>scalap</artifactId>
<version>${scala.version}</version>
</artifactItem>
<artifactItem>
<groupId>org.apache.kafka</groupId> <groupId>org.apache.kafka</groupId>
<artifactId>kafka_${scala.binary.version}</artifactId> <artifactId>kafka_${kafka.scala.binary.version}</artifactId>
<version>${kafka.version}</version> <version>${kafka.version}</version>
</artifactItem> </artifactItem>
<artifactItem> <artifactItem>
...@@ -300,11 +248,6 @@ ...@@ -300,11 +248,6 @@
<version>${hadoop.version}</version> <version>${hadoop.version}</version>
</artifactItem> </artifactItem>
<artifactItem> <artifactItem>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>${gson.version}</version>
</artifactItem>
<artifactItem>
<groupId>log4j</groupId> <groupId>log4j</groupId>
<artifactId>log4j</artifactId> <artifactId>log4j</artifactId>
<version>${log4j.version}</version> <version>${log4j.version}</version>
...@@ -347,60 +290,6 @@ ...@@ -347,60 +290,6 @@
<build> <build>
<plugins> <plugins>
<plugin> <plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>3.2.0</version>
<executions>
<execution>
<id>scala-compile-first</id>
<phase>process-resources</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>scala-test-compile-first</id>
<phase>process-test-resources</phase>
<goals>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
<configuration>
<scalaVersion>${scala.version}</scalaVersion>
<recompileMode>incremental</recompileMode>
<useZincServer>true</useZincServer>
<source>1.7</source>
<target>1.7</target>
<args>
<arg>-unchecked</arg>
<arg>-deprecation</arg>
<arg>-feature</arg>
</args>
<jvmArgs>
<jvmArg>-Xmx512m</jvmArg>
</jvmArgs>
<!--
<javacArgs>
<javacArg>-source</javacArg>
<javacArg>${java.version}</javacArg>
<javacArg>-target</javacArg>
<javacArg>${java.version}</javacArg>
</javacArgs>
-->
<!-- The following plugin is required to use quasiquotes in Scala 2.10 and is used
by Spark SQL for code generation. -->
<!--<compilerPlugins>
<compilerPlugin>
<groupId>org.scalamacros</groupId>
<artifactId>paradise_${scala.version}</artifactId>
<version>${scala.macros.version}</version>
</compilerPlugin>
</compilerPlugins>-->
</configuration>
</plugin>
<plugin>
<groupId>org.eclipse.jetty</groupId> <groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId> <artifactId>jetty-maven-plugin</artifactId>
<configuration> <configuration>
...@@ -437,7 +326,7 @@ ...@@ -437,7 +326,7 @@
</systemProperty> </systemProperty>
<systemProperty> <systemProperty>
<key>atlas.conf</key> <key>atlas.conf</key>
<value>${project.build.directory}/../../../typesystem/target/test-classes</value> <value>${project.build.directory}/../../../intg/target/test-classes</value>
</systemProperty> </systemProperty>
<systemProperty> <systemProperty>
<key>atlas.home</key> <key>atlas.home</key>
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
package org.apache.atlas.storm.hook; package org.apache.atlas.storm.hook;
import org.apache.atlas.v1.model.instance.Referenceable;
import org.apache.storm.ISubmitterHook; import org.apache.storm.ISubmitterHook;
import org.apache.storm.generated.Bolt; import org.apache.storm.generated.Bolt;
import org.apache.storm.generated.SpoutSpec; import org.apache.storm.generated.SpoutSpec;
...@@ -29,7 +30,6 @@ import org.apache.atlas.AtlasConstants; ...@@ -29,7 +30,6 @@ import org.apache.atlas.AtlasConstants;
import org.apache.atlas.hive.bridge.HiveMetaStoreBridge; import org.apache.atlas.hive.bridge.HiveMetaStoreBridge;
import org.apache.atlas.hook.AtlasHook; import org.apache.atlas.hook.AtlasHook;
import org.apache.atlas.storm.model.StormDataTypes; import org.apache.atlas.storm.model.StormDataTypes;
import org.apache.atlas.typesystem.Referenceable;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path; import org.apache.hadoop.fs.Path;
......
...@@ -21,8 +21,8 @@ package org.apache.atlas.storm.hook; ...@@ -21,8 +21,8 @@ package org.apache.atlas.storm.hook;
import org.apache.atlas.ApplicationProperties; import org.apache.atlas.ApplicationProperties;
import org.apache.atlas.AtlasClient; import org.apache.atlas.AtlasClient;
import org.apache.atlas.hive.bridge.HiveMetaStoreBridge; import org.apache.atlas.hive.bridge.HiveMetaStoreBridge;
import org.apache.atlas.v1.model.instance.Referenceable;
import org.apache.atlas.storm.model.StormDataTypes; import org.apache.atlas.storm.model.StormDataTypes;
import org.apache.atlas.typesystem.Referenceable;
import org.apache.atlas.utils.AuthenticationUtil; import org.apache.atlas.utils.AuthenticationUtil;
import org.apache.commons.configuration.Configuration; import org.apache.commons.configuration.Configuration;
import org.apache.storm.ILocalCluster; import org.apache.storm.ILocalCluster;
......
...@@ -42,8 +42,15 @@ ...@@ -42,8 +42,15 @@
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>${guava.version}</version>
</dependency>
<dependency>
<groupId>org.testng</groupId> <groupId>org.testng</groupId>
<artifactId>testng</artifactId> <artifactId>testng</artifactId>
<scope>test</scope>
</dependency> </dependency>
</dependencies> </dependencies>
......
...@@ -31,18 +31,13 @@ ...@@ -31,18 +31,13 @@
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.apache.atlas</groupId> <groupId>org.apache.atlas</groupId>
<artifactId>atlas-typesystem</artifactId>
</dependency>
<dependency>
<groupId>org.apache.atlas</groupId>
<artifactId>atlas-client-common</artifactId> <artifactId>atlas-client-common</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.atlas</groupId> <groupId>org.apache.atlas</groupId>
<artifactId>atlas-typesystem</artifactId> <artifactId>atlas-common</artifactId>
<classifier>tests</classifier> <version>${project.version}</version>
<scope>test</scope>
</dependency> </dependency>
</dependencies> </dependencies>
</project> </project>
...@@ -19,19 +19,16 @@ ...@@ -19,19 +19,16 @@
package org.apache.atlas; package org.apache.atlas;
import com.google.common.annotations.VisibleForTesting; import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.ImmutableSet;
import com.sun.jersey.api.client.WebResource; import com.sun.jersey.api.client.WebResource;
import org.apache.atlas.model.legacy.EntityResult; import org.apache.atlas.model.legacy.EntityResult;
import org.apache.atlas.typesystem.Referenceable; import org.apache.atlas.v1.model.instance.Referenceable;
import org.apache.atlas.typesystem.Struct; import org.apache.atlas.v1.model.instance.Struct;
import org.apache.atlas.typesystem.TypesDef; import org.apache.atlas.v1.model.typedef.AttributeDefinition;
import org.apache.atlas.typesystem.json.InstanceSerialization; import org.apache.atlas.v1.model.typedef.TraitTypeDefinition;
import org.apache.atlas.typesystem.json.TypesSerialization; import org.apache.atlas.v1.model.typedef.TypesDef;
import org.apache.atlas.typesystem.types.AttributeDefinition; import org.apache.atlas.v1.typesystem.types.utils.TypesUtil;
import org.apache.atlas.type.AtlasType;
import org.apache.atlas.typesystem.types.DataTypes; import org.apache.atlas.typesystem.types.DataTypes;
import org.apache.atlas.typesystem.types.HierarchicalTypeDefinition;
import org.apache.atlas.typesystem.types.TraitType;
import org.apache.atlas.typesystem.types.utils.TypesUtil;
import org.apache.commons.configuration.Configuration; import org.apache.commons.configuration.Configuration;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.apache.hadoop.security.UserGroupInformation; import org.apache.hadoop.security.UserGroupInformation;
...@@ -45,10 +42,7 @@ import javax.ws.rs.HttpMethod; ...@@ -45,10 +42,7 @@ import javax.ws.rs.HttpMethod;
import javax.ws.rs.core.Cookie; import javax.ws.rs.core.Cookie;
import javax.ws.rs.core.MultivaluedMap; import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
import java.util.ArrayList; import java.util.*;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
/** /**
* Client for metadata. * Client for metadata.
...@@ -276,7 +270,7 @@ public class AtlasClient extends AtlasBaseClient { ...@@ -276,7 +270,7 @@ public class AtlasClient extends AtlasBaseClient {
* @throws AtlasServiceException * @throws AtlasServiceException
*/ */
public List<String> createType(TypesDef typeDef) throws AtlasServiceException { public List<String> createType(TypesDef typeDef) throws AtlasServiceException {
return createType(TypesSerialization.toJson(typeDef)); return createType(AtlasType.toV1Json(typeDef));
} }
/** /**
...@@ -287,11 +281,11 @@ public class AtlasClient extends AtlasBaseClient { ...@@ -287,11 +281,11 @@ public class AtlasClient extends AtlasBaseClient {
* @return the list of types created * @return the list of types created
* @throws AtlasServiceException * @throws AtlasServiceException
*/ */
public List<String> createTraitType(String traitName, ImmutableSet<String> superTraits, AttributeDefinition... attributeDefinitions) throws AtlasServiceException { public List<String> createTraitType(String traitName, Set<String> superTraits, AttributeDefinition... attributeDefinitions) throws AtlasServiceException {
HierarchicalTypeDefinition<TraitType> piiTrait = TraitTypeDefinition piiTrait =
TypesUtil.createTraitTypeDef(traitName, superTraits, attributeDefinitions); TypesUtil.createTraitTypeDef(traitName, null, superTraits, Arrays.asList(attributeDefinitions));
String traitDefinitionAsJSON = TypesSerialization.toJson(piiTrait, true); String traitDefinitionAsJSON = AtlasType.toV1Json(piiTrait);
LOG.debug("Creating trait type {} {}", traitName, traitDefinitionAsJSON); LOG.debug("Creating trait type {} {}", traitName, traitDefinitionAsJSON);
return createType(traitDefinitionAsJSON); return createType(traitDefinitionAsJSON);
} }
...@@ -332,7 +326,7 @@ public class AtlasClient extends AtlasBaseClient { ...@@ -332,7 +326,7 @@ public class AtlasClient extends AtlasBaseClient {
* @throws AtlasServiceException * @throws AtlasServiceException
*/ */
public List<String> updateType(TypesDef typeDef) throws AtlasServiceException { public List<String> updateType(TypesDef typeDef) throws AtlasServiceException {
return updateType(TypesSerialization.toJson(typeDef)); return updateType(AtlasType.toV1Json(typeDef));
} }
/** /**
...@@ -396,7 +390,7 @@ public class AtlasClient extends AtlasBaseClient { ...@@ -396,7 +390,7 @@ public class AtlasClient extends AtlasBaseClient {
try { try {
JSONObject response = callAPIWithBodyAndParams(API_V1.GET_TYPE, null, typeName); JSONObject response = callAPIWithBodyAndParams(API_V1.GET_TYPE, null, typeName);
String typeJson = response.getString(DEFINITION); String typeJson = response.getString(DEFINITION);
return TypesSerialization.fromJson(typeJson); return AtlasType.fromV1Json(typeJson, TypesDef.class);
} catch (JSONException e) { } catch (JSONException e) {
throw new AtlasServiceException(e); throw new AtlasServiceException(e);
} }
...@@ -442,7 +436,7 @@ public class AtlasClient extends AtlasBaseClient { ...@@ -442,7 +436,7 @@ public class AtlasClient extends AtlasBaseClient {
private JSONArray getEntitiesArray(Collection<Referenceable> entities) { private JSONArray getEntitiesArray(Collection<Referenceable> entities) {
JSONArray entityArray = new JSONArray(entities.size()); JSONArray entityArray = new JSONArray(entities.size());
for (Referenceable entity : entities) { for (Referenceable entity : entities) {
entityArray.put(InstanceSerialization.toJson(entity, true)); entityArray.put(AtlasType.toV1Json(entity));
} }
return entityArray; return entityArray;
} }
...@@ -500,7 +494,7 @@ public class AtlasClient extends AtlasBaseClient { ...@@ -500,7 +494,7 @@ public class AtlasClient extends AtlasBaseClient {
* @param entity entity definition * @param entity entity definition
*/ */
public EntityResult updateEntity(String guid, Referenceable entity) throws AtlasServiceException { public EntityResult updateEntity(String guid, Referenceable entity) throws AtlasServiceException {
String entityJson = InstanceSerialization.toJson(entity, true); String entityJson = AtlasType.toV1Json(entity);
LOG.debug("Updating entity id {} with {}", guid, entityJson); LOG.debug("Updating entity id {} with {}", guid, entityJson);
JSONObject response = callAPIWithBodyAndParams(API_V1.UPDATE_ENTITY_PARTIAL, entityJson, guid); JSONObject response = callAPIWithBodyAndParams(API_V1.UPDATE_ENTITY_PARTIAL, entityJson, guid);
return extractEntityResult(response); return extractEntityResult(response);
...@@ -513,7 +507,7 @@ public class AtlasClient extends AtlasBaseClient { ...@@ -513,7 +507,7 @@ public class AtlasClient extends AtlasBaseClient {
* @param traitDefinition trait definition * @param traitDefinition trait definition
*/ */
public void addTrait(String guid, Struct traitDefinition) throws AtlasServiceException { public void addTrait(String guid, Struct traitDefinition) throws AtlasServiceException {
String traitJson = InstanceSerialization.toJson(traitDefinition, true); String traitJson = AtlasType.toV1Json(traitDefinition);
LOG.debug("Adding trait to entity with id {} {}", guid, traitJson); LOG.debug("Adding trait to entity with id {} {}", guid, traitJson);
callAPIWithBodyAndParams(API_V1.ADD_TRAITS, traitJson, guid, URI_TRAITS); callAPIWithBodyAndParams(API_V1.ADD_TRAITS, traitJson, guid, URI_TRAITS);
} }
...@@ -540,7 +534,7 @@ public class AtlasClient extends AtlasBaseClient { ...@@ -540,7 +534,7 @@ public class AtlasClient extends AtlasBaseClient {
final String uniqueAttributeValue, final String uniqueAttributeValue,
Referenceable entity) throws AtlasServiceException { Referenceable entity) throws AtlasServiceException {
final API api = API_V1.UPDATE_ENTITY_PARTIAL; final API api = API_V1.UPDATE_ENTITY_PARTIAL;
String entityJson = InstanceSerialization.toJson(entity, true); String entityJson = AtlasType.toV1Json(entity);
LOG.debug("Updating entity type: {}, attributeName: {}, attributeValue: {}, entity: {}", entityType, LOG.debug("Updating entity type: {}, attributeName: {}, attributeValue: {}, entity: {}", entityType,
uniqueAttributeName, uniqueAttributeValue, entityJson); uniqueAttributeName, uniqueAttributeValue, entityJson);
JSONObject response = callAPIWithRetries(api, entityJson, new ResourceCreator() { JSONObject response = callAPIWithRetries(api, entityJson, new ResourceCreator() {
...@@ -623,7 +617,7 @@ public class AtlasClient extends AtlasBaseClient { ...@@ -623,7 +617,7 @@ public class AtlasClient extends AtlasBaseClient {
JSONObject jsonResponse = callAPIWithBodyAndParams(API_V1.GET_ENTITY, null, guid); JSONObject jsonResponse = callAPIWithBodyAndParams(API_V1.GET_ENTITY, null, guid);
try { try {
String entityInstanceDefinition = jsonResponse.getString(AtlasClient.DEFINITION); String entityInstanceDefinition = jsonResponse.getString(AtlasClient.DEFINITION);
return InstanceSerialization.fromJsonReferenceable(entityInstanceDefinition, true); return AtlasType.fromV1Json(entityInstanceDefinition, Referenceable.class);
} catch (JSONException e) { } catch (JSONException e) {
throw new AtlasServiceException(API_V1.GET_ENTITY, e); throw new AtlasServiceException(API_V1.GET_ENTITY, e);
} }
...@@ -660,7 +654,7 @@ public class AtlasClient extends AtlasBaseClient { ...@@ -660,7 +654,7 @@ public class AtlasClient extends AtlasBaseClient {
}); });
try { try {
String entityInstanceDefinition = jsonResponse.getString(AtlasClient.DEFINITION); String entityInstanceDefinition = jsonResponse.getString(AtlasClient.DEFINITION);
return InstanceSerialization.fromJsonReferenceable(entityInstanceDefinition, true); return AtlasType.fromV1Json(entityInstanceDefinition, Referenceable.class);
} catch (JSONException e) { } catch (JSONException e) {
throw new AtlasServiceException(api, e); throw new AtlasServiceException(api, e);
} }
...@@ -706,7 +700,7 @@ public class AtlasClient extends AtlasBaseClient { ...@@ -706,7 +700,7 @@ public class AtlasClient extends AtlasBaseClient {
List<JSONObject> traitDefList = extractResults(jsonResponse, AtlasClient.RESULTS, new ExtractOperation<JSONObject, JSONObject>()); List<JSONObject> traitDefList = extractResults(jsonResponse, AtlasClient.RESULTS, new ExtractOperation<JSONObject, JSONObject>());
ArrayList<Struct> traitStructList = new ArrayList<>(); ArrayList<Struct> traitStructList = new ArrayList<>();
for (JSONObject traitDef : traitDefList) { for (JSONObject traitDef : traitDefList) {
Struct traitStruct = InstanceSerialization.fromJsonStruct(traitDef.toString(), true); Struct traitStruct = AtlasType.fromV1Json(traitDef.toString(), Struct.class);
traitStructList.add(traitStruct); traitStructList.add(traitStruct);
} }
return traitStructList; return traitStructList;
...@@ -723,7 +717,7 @@ public class AtlasClient extends AtlasBaseClient { ...@@ -723,7 +717,7 @@ public class AtlasClient extends AtlasBaseClient {
JSONObject jsonResponse = callAPIWithBodyAndParams(API_V1.GET_TRAIT_DEFINITION, null, guid, TRAIT_DEFINITIONS, traitName); JSONObject jsonResponse = callAPIWithBodyAndParams(API_V1.GET_TRAIT_DEFINITION, null, guid, TRAIT_DEFINITIONS, traitName);
try { try {
return InstanceSerialization.fromJsonStruct(jsonResponse.getString(AtlasClient.RESULTS), false); return AtlasType.fromV1Json(jsonResponse.getString(AtlasClient.RESULTS), Struct.class);
} catch (JSONException e) { } catch (JSONException e) {
throw new AtlasServiceException(API_V1.GET_TRAIT_DEFINITION, e); throw new AtlasServiceException(API_V1.GET_TRAIT_DEFINITION, e);
} }
...@@ -782,7 +776,7 @@ public class AtlasClient extends AtlasBaseClient { ...@@ -782,7 +776,7 @@ public class AtlasClient extends AtlasBaseClient {
return extractResults(jsonResponse, AtlasClient.EVENTS, new ExtractOperation<EntityAuditEvent, JSONObject>() { return extractResults(jsonResponse, AtlasClient.EVENTS, new ExtractOperation<EntityAuditEvent, JSONObject>() {
@Override @Override
EntityAuditEvent extractElement(JSONObject element) throws JSONException { EntityAuditEvent extractElement(JSONObject element) throws JSONException {
return SerDe.GSON.fromJson(element.toString(), EntityAuditEvent.class); return AtlasType.fromV1Json(element.toString(), EntityAuditEvent.class);
} }
}); });
......
...@@ -18,8 +18,9 @@ ...@@ -18,8 +18,9 @@
package org.apache.atlas; package org.apache.atlas;
import org.apache.atlas.typesystem.IReferenceableInstance;
import org.apache.atlas.typesystem.json.InstanceSerialization; import org.apache.atlas.v1.model.instance.Referenceable;
import org.apache.atlas.type.AtlasType;
import java.util.Objects; import java.util.Objects;
...@@ -38,13 +39,13 @@ public class EntityAuditEvent { ...@@ -38,13 +39,13 @@ public class EntityAuditEvent {
private EntityAuditAction action; private EntityAuditAction action;
private String details; private String details;
private String eventKey; private String eventKey;
private IReferenceableInstance entityDefinition; private Referenceable entityDefinition;
public EntityAuditEvent() { public EntityAuditEvent() {
} }
public EntityAuditEvent(String entityId, Long ts, String user, EntityAuditAction action, String details, public EntityAuditEvent(String entityId, Long ts, String user, EntityAuditAction action, String details,
IReferenceableInstance entityDefinition) throws AtlasException { Referenceable entityDefinition) throws AtlasException {
this.entityId = entityId; this.entityId = entityId;
this.timestamp = ts; this.timestamp = ts;
this.user = user; this.user = user;
...@@ -74,11 +75,11 @@ public class EntityAuditEvent { ...@@ -74,11 +75,11 @@ public class EntityAuditEvent {
@Override @Override
public String toString() { public String toString() {
return SerDe.GSON.toJson(this); return AtlasType.toV1Json(this);
} }
public static EntityAuditEvent fromString(String eventString) { public static EntityAuditEvent fromString(String eventString) {
return SerDe.GSON.fromJson(eventString, EntityAuditEvent.class); return AtlasType.fromV1Json(eventString, EntityAuditEvent.class);
} }
public String getEntityId() { public String getEntityId() {
...@@ -129,18 +130,18 @@ public class EntityAuditEvent { ...@@ -129,18 +130,18 @@ public class EntityAuditEvent {
this.eventKey = eventKey; this.eventKey = eventKey;
} }
public IReferenceableInstance getEntityDefinition() { public Referenceable getEntityDefinition() {
return entityDefinition; return entityDefinition;
} }
public String getEntityDefinitionString() { public String getEntityDefinitionString() {
if (entityDefinition != null) { if (entityDefinition != null) {
return InstanceSerialization.toJson(entityDefinition, true); return AtlasType.toV1Json(entityDefinition);
} }
return null; return null;
} }
public void setEntityDefinition(String entityDefinition) { public void setEntityDefinition(String entityDefinition) {
this.entityDefinition = InstanceSerialization.fromJsonReferenceable(entityDefinition, true); this.entityDefinition = AtlasType.fromV1Json(entityDefinition, Referenceable.class);
} }
} }
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.atlas;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonParser;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
import org.apache.atlas.typesystem.IReferenceableInstance;
import org.apache.atlas.typesystem.IStruct;
import org.apache.atlas.typesystem.Referenceable;
import org.apache.atlas.typesystem.Struct;
import org.apache.atlas.typesystem.json.InstanceSerialization;
import java.lang.reflect.Type;
@Deprecated
public class SerDe {
public static final Gson GSON = new GsonBuilder().
registerTypeAdapter(IStruct.class, new StructDeserializer()).
registerTypeAdapter(IReferenceableInstance.class, new ReferenceableSerializerDeserializer()).
registerTypeAdapter(Referenceable.class, new ReferenceableSerializerDeserializer()).
create();
/**
* Serde for Struct used by AbstractNotificationConsumer.GSON.
*/
public static final class StructDeserializer implements JsonDeserializer<IStruct>, JsonSerializer<IStruct> {
@Override
public IStruct deserialize(final JsonElement json, final Type type,
final JsonDeserializationContext context) {
return context.deserialize(json, Struct.class);
}
@Override
public JsonElement serialize(IStruct src, Type typeOfSrc, JsonSerializationContext context) {
String instanceJson = InstanceSerialization.toJson(src, true);
return new JsonParser().parse(instanceJson).getAsJsonObject();
}
}
/**
* Serde for Referenceable used by AbstractNotificationConsumer.GSON.
*/
public static final class ReferenceableSerializerDeserializer implements JsonDeserializer<IStruct>,
JsonSerializer<IReferenceableInstance> {
@Override
public IReferenceableInstance deserialize(final JsonElement json, final Type type,
final JsonDeserializationContext context) {
return InstanceSerialization.fromJsonReferenceable(json.toString(), true);
}
@Override
public JsonElement serialize(IReferenceableInstance src, Type typeOfSrc, JsonSerializationContext context) {
String instanceJson = InstanceSerialization.toJson(src, true);
return new JsonParser().parse(instanceJson).getAsJsonObject();
}
}
}
...@@ -22,8 +22,8 @@ import com.sun.jersey.api.client.ClientHandlerException; ...@@ -22,8 +22,8 @@ import com.sun.jersey.api.client.ClientHandlerException;
import com.sun.jersey.api.client.ClientResponse; import com.sun.jersey.api.client.ClientResponse;
import com.sun.jersey.api.client.WebResource; import com.sun.jersey.api.client.WebResource;
import org.apache.atlas.model.legacy.EntityResult; import org.apache.atlas.model.legacy.EntityResult;
import org.apache.atlas.typesystem.Referenceable; import org.apache.atlas.v1.model.instance.Referenceable;
import org.apache.atlas.typesystem.json.InstanceSerialization; import org.apache.atlas.type.AtlasType;
import org.apache.commons.configuration.Configuration; import org.apache.commons.configuration.Configuration;
import org.apache.hadoop.security.UserGroupInformation; import org.apache.hadoop.security.UserGroupInformation;
import org.codehaus.jettison.json.JSONObject; import org.codehaus.jettison.json.JSONObject;
...@@ -99,7 +99,7 @@ public class AtlasClientTest { ...@@ -99,7 +99,7 @@ public class AtlasClientTest {
JSONObject jsonResponse = new JSONObject(new EntityResult(Arrays.asList("id"), null, null).toString()); JSONObject jsonResponse = new JSONObject(new EntityResult(Arrays.asList("id"), null, null).toString());
when(response.getEntity(String.class)).thenReturn(jsonResponse.toString()); when(response.getEntity(String.class)).thenReturn(jsonResponse.toString());
when(response.getLength()).thenReturn(jsonResponse.length()); when(response.getLength()).thenReturn(jsonResponse.length());
String entityJson = InstanceSerialization.toJson(new Referenceable("type"), true); String entityJson = AtlasType.toV1Json(new Referenceable("type"));
when(builder.method(anyString(), Matchers.<Class>any(), anyString())).thenReturn(response); when(builder.method(anyString(), Matchers.<Class>any(), anyString())).thenReturn(response);
List<String> ids = atlasClient.createEntity(entityJson); List<String> ids = atlasClient.createEntity(entityJson);
......
...@@ -39,16 +39,22 @@ ...@@ -39,16 +39,22 @@
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.mockito</groupId> <groupId>com.google.guava</groupId>
<artifactId>mockito-all</artifactId> <artifactId>guava</artifactId>
<scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.sun.jersey.contribs</groupId> <groupId>com.sun.jersey.contribs</groupId>
<artifactId>jersey-multipart</artifactId> <artifactId>jersey-multipart</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testng</groupId> <groupId>org.testng</groupId>
<artifactId>testng</artifactId> <artifactId>testng</artifactId>
<scope>test</scope> <scope>test</scope>
......
...@@ -76,6 +76,7 @@ ...@@ -76,6 +76,7 @@
<groupId>com.google.guava</groupId> <groupId>com.google.guava</groupId>
<artifactId>guava</artifactId> <artifactId>guava</artifactId>
<version>${guava.version}</version> <version>${guava.version}</version>
<scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
......
...@@ -104,6 +104,13 @@ public final class Constants { ...@@ -104,6 +104,13 @@ public final class Constants {
public static final String MAX_FULLTEXT_QUERY_STR_LENGTH = "atlas.graph.fulltext-max-query-str-length"; public static final String MAX_FULLTEXT_QUERY_STR_LENGTH = "atlas.graph.fulltext-max-query-str-length";
public static final String MAX_DSL_QUERY_STR_LENGTH = "atlas.graph.dsl-max-query-str-length"; public static final String MAX_DSL_QUERY_STR_LENGTH = "atlas.graph.dsl-max-query-str-length";
public static final String ATTRIBUTE_NAME_GUID = "guid";
public static final String ATTRIBUTE_NAME_TYPENAME = "typeName";
public static final String ATTRIBUTE_NAME_SUPERTYPENAMES = "superTypeNames";
public static final String ATTRIBUTE_NAME_STATE = "state";
public static final String ATTRIBUTE_NAME_VERSION = "version";
public static final String TEMP_STRUCT_NAME_PREFIX = "__tempQueryResultStruct";
private Constants() { private Constants() {
} }
......
...@@ -32,10 +32,14 @@ ...@@ -32,10 +32,14 @@
<packaging>jar</packaging> <packaging>jar</packaging>
<dependencies> <dependencies>
<dependency>
<groupId>org.apache.atlas</groupId>
<artifactId>atlas-common</artifactId>
</dependency>
<dependency> <dependency>
<groupId>org.apache.atlas</groupId> <groupId>org.apache.atlas</groupId>
<artifactId>atlas-typesystem</artifactId> <artifactId>atlas-intg</artifactId>
</dependency> </dependency>
<dependency> <dependency>
......
...@@ -27,7 +27,7 @@ import javax.script.ScriptException; ...@@ -27,7 +27,7 @@ import javax.script.ScriptException;
import org.apache.atlas.exception.AtlasBaseException; import org.apache.atlas.exception.AtlasBaseException;
import org.apache.atlas.groovy.GroovyExpression; import org.apache.atlas.groovy.GroovyExpression;
import org.apache.atlas.typesystem.types.IDataType; import org.apache.atlas.type.AtlasType;
/** /**
* Represents a graph. * Represents a graph.
...@@ -110,7 +110,6 @@ public interface AtlasGraph<V, E> { ...@@ -110,7 +110,6 @@ public interface AtlasGraph<V, E> {
* Gets the names of the indexes on edges * Gets the names of the indexes on edges
* type. * type.
* *
* @param type
* @return * @return
*/ */
Set<String> getEdgeIndexKeys(); Set<String> getEdgeIndexKeys();
...@@ -120,7 +119,6 @@ public interface AtlasGraph<V, E> { ...@@ -120,7 +119,6 @@ public interface AtlasGraph<V, E> {
* Gets the names of the indexes on vertices. * Gets the names of the indexes on vertices.
* type. * type.
* *
* @param type
* @return * @return
*/ */
Set<String> getVertexIndexKeys(); Set<String> getVertexIndexKeys();
...@@ -218,11 +216,11 @@ public interface AtlasGraph<V, E> { ...@@ -218,11 +216,11 @@ public interface AtlasGraph<V, E> {
* convert property values from the value that is stored in the graph * convert property values from the value that is stored in the graph
* to the value/type that the user expects to get back. * to the value/type that the user expects to get back.
* *
* @param expr - gremlin expr that represents the persistent property value * @param valueExpr - gremlin expr that represents the persistent property value
* @param type * @param type
* @return * @return
*/ */
GroovyExpression generatePersisentToLogicalConversionExpression(GroovyExpression valueExpr, IDataType<?> type); GroovyExpression generatePersisentToLogicalConversionExpression(GroovyExpression valueExpr, AtlasType type);
/** /**
* Indicates whether or not stored values with the specified type need to be converted * Indicates whether or not stored values with the specified type need to be converted
...@@ -234,7 +232,7 @@ public interface AtlasGraph<V, E> { ...@@ -234,7 +232,7 @@ public interface AtlasGraph<V, E> {
* gremlin expression with the converted value. In addition, this cause the gremlin * gremlin expression with the converted value. In addition, this cause the gremlin
* 'filter' step to be used to compare the values instead of a 'has' step. * 'filter' step to be used to compare the values instead of a 'has' step.
*/ */
boolean isPropertyValueConversionNeeded(IDataType<?> type); boolean isPropertyValueConversionNeeded(AtlasType type);
/** /**
* Gets the version of Gremlin that this graph uses. * Gets the version of Gremlin that this graph uses.
...@@ -286,7 +284,7 @@ public interface AtlasGraph<V, E> { ...@@ -286,7 +284,7 @@ public interface AtlasGraph<V, E> {
/** /**
* Executes a Gremlin script, returns an object with the result. * Executes a Gremlin script, returns an object with the result.
* *
* @param gremlinQuery * @param query
* @param isPath whether this is a path query * @param isPath whether this is a path query
* *
* @return the result from executing the script * @return the result from executing the script
......
...@@ -34,6 +34,12 @@ under the License. --> ...@@ -34,6 +34,12 @@ under the License. -->
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>${guava.version}</version>
</dependency>
<dependency>
<groupId>org.testng</groupId> <groupId>org.testng</groupId>
<artifactId>testng</artifactId> <artifactId>testng</artifactId>
<version>6.9.4</version> <version>6.9.4</version>
......
...@@ -21,6 +21,7 @@ import com.google.common.base.Function; ...@@ -21,6 +21,7 @@ import com.google.common.base.Function;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import org.apache.atlas.type.AtlasType;
import org.janusgraph.core.Cardinality; import org.janusgraph.core.Cardinality;
import org.janusgraph.core.PropertyKey; import org.janusgraph.core.PropertyKey;
import org.janusgraph.core.SchemaViolationException; import org.janusgraph.core.SchemaViolationException;
...@@ -42,7 +43,6 @@ import org.apache.atlas.repository.graphdb.AtlasVertex; ...@@ -42,7 +43,6 @@ import org.apache.atlas.repository.graphdb.AtlasVertex;
import org.apache.atlas.repository.graphdb.GremlinVersion; import org.apache.atlas.repository.graphdb.GremlinVersion;
import org.apache.atlas.repository.graphdb.janus.query.AtlasJanusGraphQuery; import org.apache.atlas.repository.graphdb.janus.query.AtlasJanusGraphQuery;
import org.apache.atlas.repository.graphdb.utils.IteratorToIterableAdapter; import org.apache.atlas.repository.graphdb.utils.IteratorToIterableAdapter;
import org.apache.atlas.typesystem.types.IDataType;
import org.apache.tinkerpop.gremlin.groovy.CompilerCustomizerProvider; import org.apache.tinkerpop.gremlin.groovy.CompilerCustomizerProvider;
import org.apache.tinkerpop.gremlin.groovy.DefaultImportCustomizerProvider; import org.apache.tinkerpop.gremlin.groovy.DefaultImportCustomizerProvider;
import org.apache.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngine; import org.apache.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngine;
...@@ -359,13 +359,13 @@ public class AtlasJanusGraph implements AtlasGraph<AtlasJanusVertex, AtlasJanusE ...@@ -359,13 +359,13 @@ public class AtlasJanusGraph implements AtlasGraph<AtlasJanusVertex, AtlasJanusE
} }
@Override @Override
public GroovyExpression generatePersisentToLogicalConversionExpression(GroovyExpression expr, IDataType<?> type) { public GroovyExpression generatePersisentToLogicalConversionExpression(GroovyExpression expr, AtlasType type) {
//nothing special needed, value is stored in required type //nothing special needed, value is stored in required type
return expr; return expr;
} }
@Override @Override
public boolean isPropertyValueConversionNeeded(IDataType<?> type) { public boolean isPropertyValueConversionNeeded(AtlasType type) {
return false; return false;
} }
......
...@@ -45,7 +45,7 @@ import org.apache.atlas.repository.graphdb.AtlasVertex; ...@@ -45,7 +45,7 @@ import org.apache.atlas.repository.graphdb.AtlasVertex;
import org.apache.atlas.repository.graphdb.GremlinVersion; import org.apache.atlas.repository.graphdb.GremlinVersion;
import org.apache.atlas.repository.graphdb.titan0.query.Titan0GraphQuery; import org.apache.atlas.repository.graphdb.titan0.query.Titan0GraphQuery;
import org.apache.atlas.repository.graphdb.utils.IteratorToIterableAdapter; import org.apache.atlas.repository.graphdb.utils.IteratorToIterableAdapter;
import org.apache.atlas.typesystem.types.IDataType; import org.apache.atlas.type.AtlasType;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
...@@ -348,14 +348,14 @@ public class Titan0Graph implements AtlasGraph<Titan0Vertex, Titan0Edge> { ...@@ -348,14 +348,14 @@ public class Titan0Graph implements AtlasGraph<Titan0Vertex, Titan0Edge> {
} }
@Override @Override
public GroovyExpression generatePersisentToLogicalConversionExpression(GroovyExpression expr, IDataType<?> type) { public GroovyExpression generatePersisentToLogicalConversionExpression(GroovyExpression expr, AtlasType type) {
//nothing special needed, value is stored in required type //nothing special needed, value is stored in required type
return expr; return expr;
} }
@Override @Override
public boolean isPropertyValueConversionNeeded(IDataType<?> type) { public boolean isPropertyValueConversionNeeded(AtlasType type) {
return false; return false;
} }
......
...@@ -42,7 +42,7 @@ import org.apache.atlas.repository.graphdb.AtlasVertex; ...@@ -42,7 +42,7 @@ import org.apache.atlas.repository.graphdb.AtlasVertex;
import org.apache.atlas.repository.graphdb.GremlinVersion; import org.apache.atlas.repository.graphdb.GremlinVersion;
import org.apache.atlas.repository.graphdb.titan1.query.Titan1GraphQuery; import org.apache.atlas.repository.graphdb.titan1.query.Titan1GraphQuery;
import org.apache.atlas.repository.graphdb.utils.IteratorToIterableAdapter; import org.apache.atlas.repository.graphdb.utils.IteratorToIterableAdapter;
import org.apache.atlas.typesystem.types.IDataType; import org.apache.atlas.type.AtlasType;
import org.apache.tinkerpop.gremlin.groovy.CompilerCustomizerProvider; import org.apache.tinkerpop.gremlin.groovy.CompilerCustomizerProvider;
import org.apache.tinkerpop.gremlin.groovy.DefaultImportCustomizerProvider; import org.apache.tinkerpop.gremlin.groovy.DefaultImportCustomizerProvider;
import org.apache.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngine; import org.apache.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngine;
...@@ -359,13 +359,13 @@ public class Titan1Graph implements AtlasGraph<Titan1Vertex, Titan1Edge> { ...@@ -359,13 +359,13 @@ public class Titan1Graph implements AtlasGraph<Titan1Vertex, Titan1Edge> {
} }
@Override @Override
public GroovyExpression generatePersisentToLogicalConversionExpression(GroovyExpression expr, IDataType<?> type) { public GroovyExpression generatePersisentToLogicalConversionExpression(GroovyExpression expr, AtlasType type) {
//nothing special needed, value is stored in required type //nothing special needed, value is stored in required type
return expr; return expr;
} }
@Override @Override
public boolean isPropertyValueConversionNeeded(IDataType<?> type) { public boolean isPropertyValueConversionNeeded(AtlasType type) {
return false; return false;
} }
......
...@@ -36,11 +36,6 @@ ...@@ -36,11 +36,6 @@
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</dependency>
<dependency>
<groupId>org.apache.hadoop</groupId> <groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-common</artifactId> <artifactId>hadoop-common</artifactId>
</dependency> </dependency>
...@@ -58,20 +53,23 @@ ...@@ -58,20 +53,23 @@
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
<dependency>
<groupId>org.testng</groupId> <groupId>org.testng</groupId>
<artifactId>testng</artifactId> <artifactId>testng</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework</groupId> <groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId> <artifactId>spring-context</artifactId>
<version>${spring.version}</version> <version>${spring.version}</version>
</dependency> </dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>${guava.version}</version>
<scope>test</scope>
</dependency>
</dependencies> </dependencies>
<build> <build>
...@@ -88,6 +86,14 @@ ...@@ -88,6 +86,14 @@
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins> </plugins>
</build> </build>
</project> </project>
...@@ -16,23 +16,37 @@ ...@@ -16,23 +16,37 @@
* limitations under the License. * limitations under the License.
*/ */
package org.apache.atlas.notification; package org.apache.atlas.model.notification;
import org.apache.atlas.AtlasConfiguration; import org.apache.atlas.AtlasConfiguration;
import org.apache.commons.codec.binary.Base64; import org.apache.commons.codec.binary.Base64;
import org.apache.commons.codec.binary.StringUtils; import org.apache.commons.codec.binary.StringUtils;
import org.apache.commons.compress.utils.IOUtils; import org.apache.commons.compress.utils.IOUtils;
import org.codehaus.jackson.annotate.JsonAutoDetect;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.map.annotate.JsonSerialize;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.IOException; import java.io.IOException;
import java.util.zip.GZIPInputStream; import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream; import java.util.zip.GZIPOutputStream;
import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.NONE;
import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.PUBLIC_ONLY;
@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
@JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown=true)
@XmlRootElement
@XmlAccessorType(XmlAccessType.PROPERTY)
public class AtlasNotificationBaseMessage { public class AtlasNotificationBaseMessage {
private static final Logger LOG = LoggerFactory.getLogger(AtlasNotificationBaseMessage.class); private static final Logger LOG = LoggerFactory.getLogger(AtlasNotificationBaseMessage.class);
......
...@@ -16,14 +16,28 @@ ...@@ -16,14 +16,28 @@
* limitations under the License. * limitations under the License.
*/ */
package org.apache.atlas.notification; package org.apache.atlas.model.notification;
import org.joda.time.DateTimeZone; import org.codehaus.jackson.annotate.JsonAutoDetect;
import org.joda.time.Instant; import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.map.annotate.JsonSerialize;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import java.util.Date;
import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.NONE;
import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.PUBLIC_ONLY;
/** /**
* Represents a notification message that is associated with a version. * Represents a notification message that is associated with a version.
*/ */
@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
@JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown=true)
@XmlRootElement
@XmlAccessorType(XmlAccessType.PROPERTY)
public class AtlasNotificationMessage<T> extends AtlasNotificationBaseMessage { public class AtlasNotificationMessage<T> extends AtlasNotificationBaseMessage {
private String msgSourceIP; private String msgSourceIP;
private String msgCreatedBy; private String msgCreatedBy;
...@@ -32,17 +46,13 @@ public class AtlasNotificationMessage<T> extends AtlasNotificationBaseMessage { ...@@ -32,17 +46,13 @@ public class AtlasNotificationMessage<T> extends AtlasNotificationBaseMessage {
/** /**
* The actual message. * The actual message.
*/ */
private final T message; private T message;
// ----- Constructors ---------------------------------------------------- // ----- Constructors ----------------------------------------------------
public AtlasNotificationMessage() {
}
/**
* Create a notification message.
*
* @param version the message version
* @param message the actual message
*/
public AtlasNotificationMessage(MessageVersion version, T message) { public AtlasNotificationMessage(MessageVersion version, T message) {
this(version, message, null, null); this(version, message, null, null);
} }
...@@ -52,7 +62,7 @@ public class AtlasNotificationMessage<T> extends AtlasNotificationBaseMessage { ...@@ -52,7 +62,7 @@ public class AtlasNotificationMessage<T> extends AtlasNotificationBaseMessage {
this.msgSourceIP = msgSourceIP; this.msgSourceIP = msgSourceIP;
this.msgCreatedBy = createdBy; this.msgCreatedBy = createdBy;
this.msgCreationTime = Instant.now().toDateTime(DateTimeZone.UTC).getMillis(); this.msgCreationTime = (new Date()).getTime();
this.message = message; this.message = message;
} }
...@@ -84,4 +94,8 @@ public class AtlasNotificationMessage<T> extends AtlasNotificationBaseMessage { ...@@ -84,4 +94,8 @@ public class AtlasNotificationMessage<T> extends AtlasNotificationBaseMessage {
public T getMessage() { public T getMessage() {
return message; return message;
} }
public void setMessage(T message) {
this.message = message;
}
} }
...@@ -16,42 +16,58 @@ ...@@ -16,42 +16,58 @@
* limitations under the License. * limitations under the License.
*/ */
package org.apache.atlas.notification; package org.apache.atlas.model.notification;
import org.codehaus.jackson.annotate.JsonAutoDetect;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.map.annotate.JsonSerialize;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.NONE;
import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.PUBLIC_ONLY;
@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
@JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown=true)
@XmlRootElement
@XmlAccessorType(XmlAccessType.PROPERTY)
public class AtlasNotificationStringMessage extends AtlasNotificationBaseMessage { public class AtlasNotificationStringMessage extends AtlasNotificationBaseMessage {
private String message = null; private String message = null;
public AtlasNotificationStringMessage() { public AtlasNotificationStringMessage() {
super(AbstractNotification.CURRENT_MESSAGE_VERSION); super(MessageVersion.CURRENT_VERSION);
} }
public AtlasNotificationStringMessage(String message) { public AtlasNotificationStringMessage(String message) {
super(AbstractNotification.CURRENT_MESSAGE_VERSION); super(MessageVersion.CURRENT_VERSION);
this.message = message; this.message = message;
} }
public AtlasNotificationStringMessage(String message, String msgId, CompressionKind compressionKind) { public AtlasNotificationStringMessage(String message, String msgId, CompressionKind compressionKind) {
super(AbstractNotification.CURRENT_MESSAGE_VERSION, msgId, compressionKind); super(MessageVersion.CURRENT_VERSION, msgId, compressionKind);
this.message = message; this.message = message;
} }
public AtlasNotificationStringMessage(String message, String msgId, CompressionKind compressionKind, int msgSplitIdx, int msgSplitCount) { public AtlasNotificationStringMessage(String message, String msgId, CompressionKind compressionKind, int msgSplitIdx, int msgSplitCount) {
super(AbstractNotification.CURRENT_MESSAGE_VERSION, msgId, compressionKind, msgSplitIdx, msgSplitCount); super(MessageVersion.CURRENT_VERSION, msgId, compressionKind, msgSplitIdx, msgSplitCount);
this.message = message; this.message = message;
} }
public AtlasNotificationStringMessage(byte[] encodedBytes, String msgId, CompressionKind compressionKind) { public AtlasNotificationStringMessage(byte[] encodedBytes, String msgId, CompressionKind compressionKind) {
super(AbstractNotification.CURRENT_MESSAGE_VERSION, msgId, compressionKind); super(MessageVersion.CURRENT_VERSION, msgId, compressionKind);
this.message = AtlasNotificationBaseMessage.getStringUtf8(encodedBytes); this.message = AtlasNotificationBaseMessage.getStringUtf8(encodedBytes);
} }
public AtlasNotificationStringMessage(byte[] encodedBytes, int offset, int length, String msgId, CompressionKind compressionKind, int msgSplitIdx, int msgSplitCount) { public AtlasNotificationStringMessage(byte[] encodedBytes, int offset, int length, String msgId, CompressionKind compressionKind, int msgSplitIdx, int msgSplitCount) {
super(AbstractNotification.CURRENT_MESSAGE_VERSION, msgId, compressionKind, msgSplitIdx, msgSplitCount); super(MessageVersion.CURRENT_VERSION, msgId, compressionKind, msgSplitIdx, msgSplitCount);
this.message = new String(encodedBytes, offset, length); this.message = new String(encodedBytes, offset, length);
} }
......
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.atlas.model.notification;
import org.codehaus.jackson.annotate.JsonAutoDetect;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.map.annotate.JsonSerialize;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import java.io.Serializable;
import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.NONE;
import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.PUBLIC_ONLY;
/**
* Base type of hook message.
*/
@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
@JsonSerialize(include=JsonSerialize.Inclusion.ALWAYS)
@JsonIgnoreProperties(ignoreUnknown=true)
@XmlRootElement
@XmlAccessorType(XmlAccessType.PROPERTY)
public class EntityNotification implements Serializable {
private static final long serialVersionUID = 1L;
/**
* Type of the hook message.
*/
public enum EntityNotificationType {
ENTITY_NOTIFICATION_V1
}
protected EntityNotificationType type;
public EntityNotification() {
this.type = EntityNotificationType.ENTITY_NOTIFICATION_V1;
}
public EntityNotification(EntityNotificationType type) {
this.type = type;
}
public EntityNotificationType getType() {
return type;
}
public void setType(EntityNotificationType type) {
this.type = type;
}
public void normalize() { }
@Override
public String toString() {
return toString(new StringBuilder()).toString();
}
public StringBuilder toString(StringBuilder sb) {
if (sb == null) {
sb = new StringBuilder();
}
sb.append("EntityNotification{");
sb.append("type=").append(type);
sb.append("}");
return sb;
}
}
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.atlas.model.notification;
import org.apache.commons.lang.StringUtils;
import org.codehaus.jackson.annotate.JsonAutoDetect;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.map.annotate.JsonSerialize;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import java.io.Serializable;
import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.NONE;
import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.PUBLIC_ONLY;
/**
* Base type of hook message.
*/
@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
@JsonSerialize(include=JsonSerialize.Inclusion.ALWAYS)
@JsonIgnoreProperties(ignoreUnknown=true)
@XmlRootElement
@XmlAccessorType(XmlAccessType.PROPERTY)
public class HookNotification implements Serializable {
private static final long serialVersionUID = 1L;
public static final String UNKNOW_USER = "UNKNOWN";
/**
* Type of the hook message.
*/
public enum HookNotificationType {
TYPE_CREATE, TYPE_UPDATE, ENTITY_CREATE, ENTITY_PARTIAL_UPDATE, ENTITY_FULL_UPDATE, ENTITY_DELETE
}
protected HookNotificationType type;
protected String user;
public HookNotification() {
}
public HookNotification(HookNotificationType type, String user) {
this.type = type;
this.user = user;
}
public HookNotificationType getType() {
return type;
}
public void setType(HookNotificationType type) {
this.type = type;
}
public String getUser() {
if (StringUtils.isEmpty(user)) {
return UNKNOW_USER;
}
return user;
}
public void setUser(String user) {
this.user = user;
}
public void normalize() { }
@Override
public String toString() {
return toString(new StringBuilder()).toString();
}
public StringBuilder toString(StringBuilder sb) {
if (sb == null) {
sb = new StringBuilder();
}
sb.append("HookNotification{");
sb.append("type=").append(type);
sb.append(", user=").append(user);
sb.append("}");
return sb;
}
}
...@@ -16,15 +16,33 @@ ...@@ -16,15 +16,33 @@
* limitations under the License. * limitations under the License.
*/ */
package org.apache.atlas.notification; package org.apache.atlas.model.notification;
import org.codehaus.jackson.annotate.JsonAutoDetect;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.map.annotate.JsonSerialize;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.NONE;
import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.PUBLIC_ONLY;
/** /**
* Represents the version of a notification message. * Represents the version of a notification message.
*/ */
public class MessageVersion implements Comparable<MessageVersion> { @JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
@JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown=true)
@XmlRootElement
@XmlAccessorType(XmlAccessType.PROPERTY)
public class MessageVersion implements Comparable<MessageVersion>, Serializable {
private static final long serialVersionUID = 1L;
/** /**
* Used for message with no version (old format). * Used for message with no version (old format).
*/ */
...@@ -33,10 +51,13 @@ public class MessageVersion implements Comparable<MessageVersion> { ...@@ -33,10 +51,13 @@ public class MessageVersion implements Comparable<MessageVersion> {
public static final MessageVersion CURRENT_VERSION = VERSION_1; public static final MessageVersion CURRENT_VERSION = VERSION_1;
private final String version; private String version;
// ----- Constructors ---------------------------------------------------- // ----- Constructors ----------------------------------------------------
public MessageVersion() {
this.version = CURRENT_VERSION.version;
}
/** /**
* Create a message version. * Create a message version.
...@@ -53,6 +74,14 @@ public class MessageVersion implements Comparable<MessageVersion> { ...@@ -53,6 +74,14 @@ public class MessageVersion implements Comparable<MessageVersion> {
} }
} }
public String getVersion() {
return version;
}
public void setVersion(String version) {
this.version = version;
}
// ----- Comparable ------------------------------------------------------ // ----- Comparable ------------------------------------------------------
...@@ -113,7 +142,7 @@ public class MessageVersion implements Comparable<MessageVersion> { ...@@ -113,7 +142,7 @@ public class MessageVersion implements Comparable<MessageVersion> {
* *
* @return the version parts array * @return the version parts array
*/ */
protected Integer[] getVersionParts() { public Integer[] getVersionParts() {
String[] sParts = version.split("\\."); String[] sParts = version.split("\\.");
ArrayList<Integer> iParts = new ArrayList<>(); ArrayList<Integer> iParts = new ArrayList<>();
...@@ -135,7 +164,7 @@ public class MessageVersion implements Comparable<MessageVersion> { ...@@ -135,7 +164,7 @@ public class MessageVersion implements Comparable<MessageVersion> {
return iParts.toArray(new Integer[iParts.size()]); return iParts.toArray(new Integer[iParts.size()]);
} }
private Integer getVersionPart(Integer[] versionParts, int i) { public Integer getVersionPart(Integer[] versionParts, int i) {
return i < versionParts.length ? versionParts[i] : 0; return i < versionParts.length ? versionParts[i] : 0;
} }
} }
...@@ -20,25 +20,56 @@ package org.apache.atlas.type; ...@@ -20,25 +20,56 @@ package org.apache.atlas.type;
import org.apache.atlas.exception.AtlasBaseException; import org.apache.atlas.exception.AtlasBaseException;
import org.apache.atlas.model.TypeCategory; import org.apache.atlas.model.TypeCategory;
import org.apache.atlas.model.notification.EntityNotification;
import org.apache.atlas.model.notification.EntityNotification.EntityNotificationType;
import org.apache.atlas.model.notification.HookNotification;
import org.apache.atlas.model.notification.HookNotification.HookNotificationType;
import org.apache.atlas.model.typedef.AtlasBaseTypeDef; import org.apache.atlas.model.typedef.AtlasBaseTypeDef;
import org.codehaus.jackson.map.DeserializationConfig; import org.apache.atlas.v1.model.notification.EntityNotificationV1;
import org.codehaus.jackson.map.ObjectMapper; import org.apache.atlas.v1.model.notification.HookNotificationV1.EntityCreateRequest;
import org.apache.atlas.v1.model.notification.HookNotificationV1.EntityDeleteRequest;
import org.apache.atlas.v1.model.notification.HookNotificationV1.EntityPartialUpdateRequest;
import org.apache.atlas.v1.model.notification.HookNotificationV1.EntityUpdateRequest;
import org.apache.atlas.v1.model.notification.HookNotificationV1.TypeRequest;
import org.codehaus.jackson.*;
import org.codehaus.jackson.map.*;
import org.codehaus.jackson.map.module.SimpleModule;
import org.codehaus.jackson.node.ObjectNode;
import org.codehaus.jackson.type.TypeReference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException; import java.io.IOException;
import java.text.ParseException;
import java.util.Date;
import java.util.List; import java.util.List;
/** /**
* base class that declares interface for all Atlas types. * base class that declares interface for all Atlas types.
*/ */
public abstract class AtlasType { public abstract class AtlasType {
private static final Logger LOG = LoggerFactory.getLogger(AtlasStructType.class);
private static final ObjectMapper mapper = new ObjectMapper() private static final ObjectMapper mapper = new ObjectMapper()
.configure(DeserializationConfig.Feature.USE_BIG_DECIMAL_FOR_FLOATS, true); .configure(DeserializationConfig.Feature.USE_BIG_DECIMAL_FOR_FLOATS, true);
private static final ObjectMapper mapperV1 = new ObjectMapper()
.configure(DeserializationConfig.Feature.USE_BIG_DECIMAL_FOR_FLOATS, true);
static {
SimpleModule atlasSerDeModule = new SimpleModule("AtlasSerDe", new Version(1, 0, 0, null));
atlasSerDeModule.addSerializer(Date.class, new DateSerializer());
atlasSerDeModule.addDeserializer(Date.class, new DateDeserializer());
atlasSerDeModule.addDeserializer(HookNotification.class, new HookNotificationDeserializer());
atlasSerDeModule.addDeserializer(EntityNotification.class, new EntityNotificationDeserializer());
mapperV1.registerModule(atlasSerDeModule);
}
private final String typeName; private final String typeName;
private final TypeCategory typeCategory; private final TypeCategory typeCategory;
...@@ -109,6 +140,8 @@ public abstract class AtlasType { ...@@ -109,6 +140,8 @@ public abstract class AtlasType {
try { try {
ret = mapper.writeValueAsString(obj); ret = mapper.writeValueAsString(obj);
}catch (IOException e){ }catch (IOException e){
LOG.error("AtlasType.toJson()", e);
ret = null; ret = null;
} }
return ret; return ret;
...@@ -119,8 +152,134 @@ public abstract class AtlasType { ...@@ -119,8 +152,134 @@ public abstract class AtlasType {
try { try {
ret = mapper.readValue(jsonStr, type); ret = mapper.readValue(jsonStr, type);
}catch (IOException e){ }catch (IOException e){
LOG.error("AtlasType.fromJson()", e);
ret = null; ret = null;
} }
return ret; return ret;
} }
public static String toV1Json(Object obj) {
String ret;
try {
ret = mapperV1.writeValueAsString(obj);
}catch (IOException e){
LOG.error("AtlasType.toV1Json()", e);
ret = null;
}
return ret;
}
public static <T> T fromV1Json(String jsonStr, Class<T> type) {
T ret;
try {
ret = mapperV1.readValue(jsonStr, type);
}catch (IOException e){
LOG.error("AtlasType.fromV1Json()", e);
ret = null;
}
return ret;
}
public static <T> T fromV1Json(String jsonStr, TypeReference<T> type) {
T ret;
try {
ret = mapperV1.readValue(jsonStr, type);
}catch (IOException e){
LOG.error("AtlasType.toV1Json()", e);
ret = null;
}
return ret;
}
static class DateSerializer extends JsonSerializer<Date> {
@Override
public void serialize(Date value, JsonGenerator jgen, SerializerProvider provider) throws IOException {
if (value != null) {
jgen.writeString(AtlasBaseTypeDef.DATE_FORMATTER.format(value));
}
}
}
static class DateDeserializer extends JsonDeserializer<Date> {
@Override
public Date deserialize(JsonParser parser, DeserializationContext context) throws IOException {
Date ret = null;
String value = parser.readValueAs(String.class);
if (value != null) {
try {
ret = AtlasBaseTypeDef.DATE_FORMATTER.parse(value);
} catch (ParseException excp) {
}
}
return ret;
}
}
static class HookNotificationDeserializer extends JsonDeserializer<HookNotification> {
@Override
public HookNotification deserialize(JsonParser parser, DeserializationContext context) throws IOException {
HookNotification ret = null;
ObjectMapper mapper = (ObjectMapper) parser.getCodec();
ObjectNode root = (ObjectNode) mapper.readTree(parser);
JsonNode typeNode = root != null ? root.get("type") : null;
String strType = typeNode != null ? typeNode.asText() : null;
HookNotificationType notificationType = strType != null ? HookNotificationType.valueOf(strType) : null;
if (notificationType != null) {
switch (notificationType) {
case TYPE_CREATE:
case TYPE_UPDATE:
ret = mapper.readValue(root, TypeRequest.class);
break;
case ENTITY_CREATE:
ret = mapper.readValue(root, EntityCreateRequest.class);
break;
case ENTITY_PARTIAL_UPDATE:
ret = mapper.readValue(root, EntityPartialUpdateRequest.class);
break;
case ENTITY_FULL_UPDATE:
ret = mapper.readValue(root, EntityUpdateRequest.class);
break;
case ENTITY_DELETE:
ret = mapper.readValue(root, EntityDeleteRequest.class);
break;
}
}
return ret;
}
}
static class EntityNotificationDeserializer extends JsonDeserializer<EntityNotification> {
@Override
public EntityNotification deserialize(JsonParser parser, DeserializationContext context) throws IOException {
EntityNotification ret = null;
ObjectMapper mapper = (ObjectMapper) parser.getCodec();
ObjectNode root = (ObjectNode) mapper.readTree(parser);
JsonNode typeNode = root != null ? root.get("type") : null;
String strType = typeNode != null ? typeNode.asText() : null;
EntityNotificationType notificationType = strType != null ? EntityNotificationType.valueOf(strType) : EntityNotificationType.ENTITY_NOTIFICATION_V1;
if (root != null) {
switch (notificationType) {
case ENTITY_NOTIFICATION_V1:
ret = mapper.readValue(root, EntityNotificationV1.class);
break;
}
}
return ret;
}
}
} }
...@@ -846,8 +846,8 @@ public class AtlasTypeRegistry { ...@@ -846,8 +846,8 @@ public class AtlasTypeRegistry {
boolean alreadyLockedByCurrentThread = typeRegistryUpdateLock.isHeldByCurrentThread(); boolean alreadyLockedByCurrentThread = typeRegistryUpdateLock.isHeldByCurrentThread();
if (!alreadyLockedByCurrentThread) { if (!alreadyLockedByCurrentThread) {
if (LOG.isDebugEnabled()) { if (lockedByThread != null) {
LOG.debug("lockTypeRegistryForUpdate(): waiting for lock to be released by thread {}", lockedByThread); LOG.info("lockTypeRegistryForUpdate(): waiting for lock to be released by thread {}", lockedByThread);
} }
} else { } else {
LOG.warn("lockTypeRegistryForUpdate(): already locked. currentLockCount={}", LOG.warn("lockTypeRegistryForUpdate(): already locked. currentLockCount={}",
......
...@@ -6,9 +6,9 @@ ...@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the * to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance * "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at * with the License. You may obtain a copy of the License at
* <p/> * <p>
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* <p/> * <p>
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
...@@ -16,12 +16,20 @@ ...@@ -16,12 +16,20 @@
* limitations under the License. * limitations under the License.
*/ */
package org.apache.atlas.typesystem.exception; package org.apache.atlas.typesystem.types;
import org.apache.atlas.AtlasException; /*
* this enum must be in package org.apache.atlas.typesystem.types, since vertex property in GraphDB has reference to this type
public class TypeExistsException extends AtlasException { */
public TypeExistsException(String message) { public class DataTypes {
super(message); public enum TypeCategory {
PRIMITIVE,
ENUM,
ARRAY,
MAP,
STRUCT,
TRAIT,
CLASS,
RELATIONSHIP
} }
} }
\ No newline at end of file
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.atlas.v1.model.instance;
import org.codehaus.jackson.annotate.JsonAutoDetect;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.map.annotate.JsonSerialize;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import java.io.Serializable;
import java.util.Date;
import java.util.Map;
import java.util.Objects;
import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.NONE;
import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.PUBLIC_ONLY;
@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
@JsonSerialize(include=JsonSerialize.Inclusion.ALWAYS)
@JsonIgnoreProperties(ignoreUnknown=true)
@XmlRootElement
@XmlAccessorType(XmlAccessType.PROPERTY)
public class AtlasSystemAttributes implements Serializable {
private static final long serialVersionUID = 1L;
private String createdBy;
private String modifiedBy;
private Date createdTime;
private Date modifiedTime;
public AtlasSystemAttributes() {
}
public AtlasSystemAttributes(AtlasSystemAttributes that) {
if (that != null) {
this.createdBy = that.createdBy;
this.modifiedBy = that.modifiedBy;
this.createdTime = that.createdTime;
this.modifiedTime = that.modifiedTime;
}
}
public AtlasSystemAttributes(String createdBy, String modifiedBy, Date createdTime, Date modifiedTime){
this.createdBy = createdBy;
this.modifiedBy = modifiedBy;
this.createdTime = createdTime;
this.modifiedTime = modifiedTime;
}
public AtlasSystemAttributes(Map<String, Object> map) {
this();
if (map != null) {
this.createdBy = Id.asString(map.get("createdBy"));
this.modifiedBy = Id.asString(map.get("modifiedBy"));
this.createdTime = Id.asDate(map.get("createdTime"));
this.modifiedTime = Id.asDate(map.get("modifiedTime"));
}
}
public String getCreatedBy(){
return createdBy;
}
public void setCreatedBy(String createdBy) {
this.createdBy = createdBy;
}
public String getModifiedBy(){
return modifiedBy;
}
public void setModifiedBy(String modifiedBy) {
this.modifiedBy = modifiedBy;
}
public Date getCreatedTime(){
return createdTime;
}
public void setCreatedTime(Date createdTime) {
this.createdTime = createdTime;
}
public Date getModifiedTime(){
return modifiedTime;
}
public void setModifiedTime(Date modifiedTime) {
this.modifiedTime = modifiedTime;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
AtlasSystemAttributes obj = (AtlasSystemAttributes) o;
return Objects.equals(createdBy, obj.createdBy) &&
Objects.equals(modifiedBy, obj.modifiedBy) &&
Objects.equals(createdTime, obj.createdTime) &&
Objects.equals(modifiedTime, obj.modifiedTime);
}
@Override
public int hashCode() {
return Objects.hash(createdBy, modifiedBy, createdTime, modifiedTime);
}
@Override
public String toString() {
return toString(new StringBuilder()).toString();
}
public StringBuilder toString(StringBuilder sb) {
if (sb == null) {
sb = new StringBuilder();
}
sb.append("AtlasSystemAttributes{")
.append("createdBy=").append(createdBy)
.append(", modifiedBy=").append(modifiedBy)
.append(", createdTime=").append(createdTime)
.append(", modifiedTime=").append(modifiedTime)
.append("}");
return sb;
}
}
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.atlas.v1.model.instance;
import org.apache.atlas.model.typedef.AtlasBaseTypeDef;
import org.codehaus.jackson.annotate.JsonAutoDetect;
import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.map.annotate.JsonSerialize;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import java.io.Serializable;
import java.text.ParseException;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.atomic.AtomicLong;
import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.NONE;
import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.PUBLIC_ONLY;
@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
@JsonSerialize(include=JsonSerialize.Inclusion.ALWAYS)
@JsonIgnoreProperties(ignoreUnknown=true)
@XmlRootElement
@XmlAccessorType(XmlAccessType.PROPERTY)
public class Id implements Serializable {
private static final long serialVersionUID = 1L;
@JsonIgnore
private static AtomicLong s_nextId = new AtomicLong(System.nanoTime());
public static final String JSON_CLASS_ID = "org.apache.atlas.typesystem.json.InstanceSerialization$_Id";
public enum EntityState { ACTIVE, DELETED }
private String id;
private String typeName;
private int version;
private EntityState state;
public Id() {
}
public Id(Id that) {
if (that != null) {
this.id = that.id;
this.typeName = that.typeName;
this.version = that.version;
this.state = that.state;
}
}
public Id(String typeName) {
this("" + nextNegativeLong(), 0, typeName);
}
public Id(String id, int version, String typeName) {
this(id, version, typeName, null);
}
public Id(long id, int version, String typeName) {
this(id, version, typeName, null);
}
public Id(long id, int version, String typeName, String state) {
this("" + id, version, typeName, state);
}
public Id(String id, int version, String typeName, String state) {
this.id = id;
this.typeName = typeName;
this.version = version;
this.state = state == null ? EntityState.ACTIVE : EntityState.valueOf(state.toUpperCase());
}
public Id(Map<String, Object> map) {
this();
if (map != null) {
this.id = Id.asString(map.get("id"));
this.typeName = Id.asString(map.get("typeName"));
this.version = Id.asInt(map.get("id"));
this.state = Id.asEntityState(map.get("state"));
}
}
// for serialization backward compatibility
public String getJsonClass() {
return JSON_CLASS_ID;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getTypeName() {
return typeName;
}
public void setTypeName(String typeName) {
this.typeName = typeName;
}
public int getVersion() {
return version;
}
public void setVersion(int version) {
this.version = version;
}
public EntityState getState() {
return state;
}
public void setState(EntityState state) {
this.state = state;
}
@JsonIgnore
public String _getId() {
return id;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
Id obj = (Id) o;
return version == obj.version &&
Objects.equals(id, obj.id) &&
Objects.equals(typeName, obj.typeName) &&
Objects.equals(state, obj.state);
}
@Override
public int hashCode() {
return Objects.hash(id, typeName, version, state);
}
@Override
public String toString() {
return asString(new StringBuilder()).toString();
}
public StringBuilder asString(StringBuilder sb) {
if (sb == null) {
sb = new StringBuilder();
}
sb.append("Id{")
.append("id=").append(id)
.append(", typeName=").append(typeName)
.append(", version=").append(version)
.append(", state=").append(state)
.append("}");
return sb;
}
private static long nextNegativeLong() {
long ret = s_nextId.getAndDecrement();
if (ret > 0) {
ret *= -1;
} else if (ret == 0) {
ret = Long.MIN_VALUE;
}
return ret;
}
static String asString(Object val) {
return val == null ? null : val.toString();
}
static int asInt(Object val) {
if (val != null) {
if (val instanceof Number) {
return ((Number)val).intValue();
}
try {
return Integer.parseInt(val.toString());
} catch (NumberFormatException excp) {
// ignore
}
}
return 0;
}
static Date asDate(Object val) {
if (val != null) {
if (val instanceof Date) {
return (Date) val;
} else if (val instanceof Number) {
return new Date(((Number)val).longValue());
}
try {
return AtlasBaseTypeDef.DATE_FORMATTER.parse(val.toString());
} catch (ParseException excp) {
// ignore
}
}
return null;
}
static EntityState asEntityState(Object val) {
if (val != null) {
if (val instanceof EntityState) {
return (EntityState) val;
}
try {
return EntityState.valueOf(val.toString());
} catch (Exception excp) {
// ignore
}
}
return EntityState.ACTIVE;
}
static Map asMap(Object val) {
return (val instanceof Map) ? ((Map) val) : null;
}
static List asList(Object val) {
return (val instanceof List) ? ((List) val) : null;
}
}
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.atlas.v1.model.instance;
import org.apache.atlas.model.typedef.AtlasBaseTypeDef;
import org.apache.commons.collections.MapUtils;
import org.codehaus.jackson.annotate.JsonAutoDetect;
import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.map.annotate.JsonFilter;
import org.codehaus.jackson.map.annotate.JsonSerialize;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.NONE;
import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.PUBLIC_ONLY;
@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
@JsonSerialize(include=JsonSerialize.Inclusion.ALWAYS)
@JsonIgnoreProperties(ignoreUnknown=true)
@XmlRootElement
@XmlAccessorType(XmlAccessType.PROPERTY)
public class Referenceable extends Struct implements Serializable {
private static final long serialVersionUID = 1L;
public static final String JSON_CLASS_REFERENCE = "org.apache.atlas.typesystem.json.InstanceSerialization$_Reference";
private Id id;
private Map<String, Struct> traits = new HashMap<>();
private List<String> traitNames = new ArrayList<>();
private AtlasSystemAttributes systemAttributes;
public Referenceable() {
super();
}
public Referenceable(Referenceable that) {
super(that);
if (that != null) {
this.id = new Id(that.id);
if (that.traits != null) {
this.traits.putAll(that.traits);
}
if (that.traitNames != null) {
this.traitNames.addAll(that.traitNames);
}
this.systemAttributes = new AtlasSystemAttributes(that.systemAttributes);
}
}
public Referenceable(String typeName, String... traitNames) {
super(typeName);
this.id = new Id(typeName);
this.systemAttributes = null;
if (traitNames != null) {
for (String traitName : traitNames) {
this.traitNames.add(traitName);
this.traits.put(traitName, new Struct(traitName));
}
}
}
public Referenceable(String typeName, Map<String, Object> values) {
this(new Id(typeName), typeName, values, null, null);
}
public Referenceable(String guid, String typeName, Map<String, Object> values) {
this(new Id(guid, 0, typeName), typeName, values, null, null, null);
}
public Referenceable(String guid, String typeName, Map<String, Object> values, AtlasSystemAttributes systemAttributes) {
this(new Id(guid, 0, typeName), typeName, values, systemAttributes, null, null);
}
public Referenceable(String guid, String typeName, Map<String, Object> values, AtlasSystemAttributes systemAttributes, List<String> traitNames, Map<String, Struct> traits) {
this(new Id(guid, 0, typeName), typeName, values, systemAttributes, traitNames, traits);
}
public Referenceable(String guid, String typeName, Map<String, Object> values, List<String> traitNames, Map<String, Struct> traits) {
this(new Id(guid, 0, typeName), typeName, values, null, traitNames, traits);
}
public Referenceable(Id id, String typeName, Map<String, Object> values, List<String> traitNames, Map<String, Struct> traits) {
this(id, typeName, values, null, traitNames, traits);
}
public Referenceable(Id id, String typeName, Map<String, Object> values, AtlasSystemAttributes systemAttributes, List<String> traitNames, Map<String, Struct> traits) {
super(typeName, values);
this.id = id;
this.systemAttributes = systemAttributes;
if (traitNames != null) {
this.traitNames = traitNames;
}
if (traits != null) {
this.traits = traits;
}
}
public Referenceable(Map<String, Object> map) {
super(map);
if (map != null) {
this.id = new Id((Map)map.get("id"));
this.traitNames = Id.asList(map.get("traitNames"));
this.systemAttributes = new AtlasSystemAttributes((Map) map.get("systemAttributes"));
Map traits = Id.asMap(map.get("traits"));
if (MapUtils.isNotEmpty(traits)) {
this.traits = new HashMap<>(traits.size());
for (Object key : traits.keySet()) {
this.traits.put(Id.asString(key), new Struct(Id.asMap(traits.get(key))));
}
}
}
}
// for serialization backward compatibility
public String getJsonClass() {
return JSON_CLASS_REFERENCE;
}
public Id getId() {
return id;
}
public void setId(Id id) {
this.id = id;
}
public Map<String, Struct> getTraits() {
return traits;
}
public void setTraits(Map<String, Struct> traits) {
this.traits = traits;
}
public List<String> getTraitNames() {
return traitNames;
}
public void setTraitNames(List<String> traitNames) {
this.traitNames = traitNames;
}
public AtlasSystemAttributes getSystemAttributes() {
return systemAttributes;
}
public void setSystemAttributes(AtlasSystemAttributes systemAttributes) {
this.systemAttributes = systemAttributes;
}
@JsonIgnore
public Struct getTrait(String name) {
return traits != null ? traits.get(name) : null;
}
@JsonIgnore
public String toShortString() {
return String.format("entity[type=%s guid=%s]", getTypeName(), id._getId());
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || o.getClass() != getClass()) {
return false;
}
Referenceable obj = (Referenceable)o;
return Objects.equals(id, obj.id) &&
Objects.equals(traits, obj.traits) &&
Objects.equals(traitNames, obj.traitNames) &&
Objects.equals(systemAttributes, obj.systemAttributes);
}
@Override
public int hashCode() {
return Objects.hash(id, traits, traitNames, systemAttributes);
}
@Override
public StringBuilder toString(StringBuilder sb) {
if (sb == null) {
sb = new StringBuilder();
}
sb.append("Referenceable{");
super.toString(sb);
sb.append(", id=");
if (id != null) {
id.asString(sb);
}
sb.append(", triats={");
AtlasBaseTypeDef.dumpObjects(this.traits, sb);
sb.append("}, traitNames=[");
AtlasBaseTypeDef.dumpObjects(traitNames, sb);
sb.append("], systemAttributes=");
if (systemAttributes != null) {
systemAttributes.toString(sb);
}
sb.append("}");
return sb;
}
}
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.atlas.v1.model.instance;
import org.apache.atlas.model.typedef.AtlasBaseTypeDef;
import org.apache.commons.collections.MapUtils;
import org.codehaus.jackson.annotate.JsonAutoDetect;
import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.map.annotate.JsonSerialize;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import java.io.Serializable;
import java.util.*;
import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.NONE;
import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.PUBLIC_ONLY;
@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
@JsonSerialize(include=JsonSerialize.Inclusion.ALWAYS)
@JsonIgnoreProperties(ignoreUnknown=true)
@XmlRootElement
@XmlAccessorType(XmlAccessType.PROPERTY)
public class Struct implements Serializable {
private static final long serialVersionUID = 1L;
public static final String JSON_CLASS_STRUCT = "org.apache.atlas.typesystem.json.InstanceSerialization$_Struct";
private String typeName;
private Map<String, Object> values;
public Struct() {
}
public Struct(Struct that) {
if (that != null) {
this.typeName = that.typeName;
if (that.values != null) {
this.values = new HashMap<>(that.values);
}
}
}
public Struct(String typeName) {
this(typeName, null);
}
public Struct(String typeName, Map<String, Object> values) {
this.typeName = typeName;
this.values = values;
}
public Struct(Map<String, Object> map) {
this();
if (map != null) {
this.typeName = Id.asString(map.get("typeName"));
this.values = Id.asMap(map.get("values"));
this.normailze();
}
}
// for serialization backward compatibility
public String getJsonClass() {
return JSON_CLASS_STRUCT;
}
public String getTypeName() {
return typeName;
}
public void setTypeName(String typeName) {
this.typeName = typeName;
}
public Map<String, Object> getValues() {
return values;
}
public void setValues(Map<String, Object> values) {
this.values = values;
}
@JsonIgnore
public Map<String, Object> getValuesMap() {
return values;
}
@JsonIgnore
public void set(String attrName, Object attrValue) {
if (values == null) {
values = new HashMap<>();
}
values.put(attrName, attrValue);
}
@JsonIgnore
public Object get(String attrName) {
return values != null ? values.get(attrName) : null;
}
@JsonIgnore
public void setNull(String attrName) {
if (values != null) {
values.remove(attrName);
}
}
public void normailze() {
if (MapUtils.isEmpty(values)) {
return;
}
for (Map.Entry<String, Object> entry : values.entrySet()) {
entry.setValue(normalizeAttributeValue(entry.getValue()));
}
}
private Object normalizeAttributeValue(Object value) {
if (value instanceof Map) {
Map mapValue = (Map) value;
String jsonClass = (String)mapValue.get("jsonClass");
if (jsonClass != null) {
if (Id.JSON_CLASS_ID.equals(jsonClass)) {
value = new Id(mapValue);
} else if (Struct.JSON_CLASS_STRUCT.equals(jsonClass)) {
value = new Struct(mapValue);
} else if (Referenceable.JSON_CLASS_REFERENCE.equals(jsonClass)) {
value = new Referenceable(mapValue);
}
}
} else if (value instanceof List) {
List<Object> listValue = (List) value;
List<Object> normalizedValue = new ArrayList<>(listValue.size());
for (Object val : listValue) {
normalizedValue.add(normalizeAttributeValue(val));
}
value = normalizedValue;
}
return value;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || o.getClass() != getClass()) {
return false;
}
Struct obj = (Struct)o;
return Objects.equals(typeName, obj.typeName) &&
Objects.equals(values, obj.values);
}
@Override
public int hashCode() {
return Objects.hash(typeName, values);
}
@Override
public String toString() {
return toString(new StringBuilder()).toString();
}
public StringBuilder toString(StringBuilder sb) {
if (sb == null) {
sb = new StringBuilder();
}
sb.append("Struct{");
sb.append("typeName=").append(typeName);
sb.append(", values={");
AtlasBaseTypeDef.dumpObjects(values, sb);
sb.append("}");
sb.append("}");
return sb;
}
}
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.atlas.v1.model.lineage;
import org.codehaus.jackson.annotate.JsonAutoDetect;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.map.annotate.JsonSerialize;
import java.util.Objects;
import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.NONE;
import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.PUBLIC_ONLY;
@JsonAutoDetect(getterVisibility = PUBLIC_ONLY, setterVisibility = PUBLIC_ONLY, fieldVisibility = NONE)
@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class DataSetLineageResponse extends LineageResponse {
private String tableName;
public DataSetLineageResponse() {
}
public DataSetLineageResponse(final DataSetLineageResponse other) {
super(other);
this.tableName = other.tableName;
}
public String getTableName() {
return tableName;
}
public void setTableName(final String tableName) {
this.tableName = tableName;
}
@Override
public boolean equals(final Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
if (!super.equals(o)) return false;
final DataSetLineageResponse that = (DataSetLineageResponse) o;
return Objects.equals(tableName, that.tableName);
}
@Override
public int hashCode() {
return Objects.hash(super.hashCode(), tableName);
}
}
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.atlas.v1.model.lineage;
import org.apache.atlas.v1.model.instance.Struct;
import org.codehaus.jackson.annotate.JsonAutoDetect;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.map.annotate.JsonSerialize;
import java.util.Objects;
import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.NONE;
import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.PUBLIC_ONLY;
@JsonAutoDetect(getterVisibility = PUBLIC_ONLY, setterVisibility = PUBLIC_ONLY, fieldVisibility = NONE)
@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class LineageResponse {
private String requestId;
private Struct results;
public LineageResponse() {
}
public LineageResponse(final LineageResponse other) {
this.requestId = other.requestId;
this.results = other.results;
}
public Struct getResults() {
return results;
}
public void setResults(final Struct results) {
this.results = results;
}
public String getRequestId() {
return requestId;
}
public void setRequestId(final String requestId) {
this.requestId = requestId;
}
@Override
public boolean equals(final Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
final LineageResponse that = (LineageResponse) o;
return Objects.equals(requestId, that.requestId) &&
Objects.equals(results, that.results);
}
@Override
public int hashCode() {
return Objects.hash(requestId, results);
}
}
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.atlas.v1.model.lineage;
import org.apache.atlas.v1.model.typedef.ClassTypeDefinition;
import org.codehaus.jackson.annotate.JsonAutoDetect;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.map.annotate.JsonSerialize;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.NONE;
import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.PUBLIC_ONLY;
@JsonAutoDetect(getterVisibility = PUBLIC_ONLY, setterVisibility = PUBLIC_ONLY, fieldVisibility = NONE)
@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class SchemaResponse {
private String requestId;
private String tableName;
private SchemaDetails results;
public SchemaResponse() {
}
public String getTableName() {
return tableName;
}
public void setTableName(final String tableName) {
this.tableName = tableName;
}
public String getRequestId() {
return requestId;
}
public void setRequestId(final String requestId) {
this.requestId = requestId;
}
public SchemaDetails getResults() {
return results;
}
public void setResults(final SchemaDetails results) {
this.results = results;
}
/**
* Represents the column schema for a given hive table
*/
@JsonAutoDetect(getterVisibility = PUBLIC_ONLY, setterVisibility = PUBLIC_ONLY, fieldVisibility = NONE)
@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public static class SchemaDetails {
private ClassTypeDefinition dataType; // Data type of the (hive) columns
private List<Map<String, Object>> rows; // Column instances for the given table
public SchemaDetails() {
}
public SchemaDetails(final SchemaDetails other) {
this.dataType = other.dataType;
this.rows = other.rows;
}
public ClassTypeDefinition getDataType() {
return dataType;
}
public void setDataType(final ClassTypeDefinition dataType) {
this.dataType = dataType;
}
public List<Map<String, Object>> getRows() {
return rows;
}
public void setRows(final List<Map<String, Object>> rows) {
this.rows = rows;
}
@Override
public boolean equals(final Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
final SchemaDetails that = (SchemaDetails) o;
return Objects.equals(dataType, that.dataType) &&
Objects.equals(rows, that.rows);
}
@Override
public int hashCode() {
return Objects.hash(dataType, rows);
}
}
}
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.atlas.v1.model.notification;
import org.apache.atlas.model.notification.EntityNotification;
import org.apache.atlas.model.typedef.AtlasBaseTypeDef;
import org.apache.atlas.v1.model.instance.Referenceable;
import org.apache.atlas.v1.model.instance.Struct;
import org.apache.atlas.type.AtlasClassificationType;
import org.apache.atlas.type.AtlasTypeRegistry;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
import org.codehaus.jackson.annotate.JsonAutoDetect;
import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.map.annotate.JsonSerialize;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import java.io.Serializable;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.NONE;
import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.PUBLIC_ONLY;
/**
* Entity notification
*/
@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
@JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown=true)
@XmlRootElement
@XmlAccessorType(XmlAccessType.PROPERTY)
public class EntityNotificationV1 extends EntityNotification implements Serializable {
private static final long serialVersionUID = 1L;
public enum OperationType {
ENTITY_CREATE,
ENTITY_UPDATE,
ENTITY_DELETE,
TRAIT_ADD,
TRAIT_DELETE,
TRAIT_UPDATE
}
private Referenceable entity;
private OperationType operationType;
private List<Struct> traits;
// ----- Constructors ------------------------------------------------------
/**
* No-arg constructor for serialization.
*/
public EntityNotificationV1() {
}
/**
* Construct an EntityNotificationV1.
*
* @param entity the entity subject of the notification
* @param operationType the type of operation that caused the notification
* @param traits the traits for the given entity
*/
public EntityNotificationV1(Referenceable entity, OperationType operationType, List<Struct> traits) {
this.entity = entity;
this.operationType = operationType;
this.traits = traits;
}
/**
* Construct an EntityNotificationV1.
*
* @param entity the entity subject of the notification
* @param operationType the type of operation that caused the notification
* @param typeRegistry the Atlas type system
*/
public EntityNotificationV1(Referenceable entity, OperationType operationType, AtlasTypeRegistry typeRegistry) {
this(entity, operationType, getAllTraits(entity, typeRegistry));
}
public Referenceable getEntity() {
return entity;
}
public void setEntity(Referenceable entity) {
this.entity = entity;
}
public OperationType getOperationType() {
return operationType;
}
public void setOperationType(OperationType operationType) {
this.operationType = operationType;
}
public List<Struct> getTraits() {
return traits;
}
public void setTraits(List<Struct> traits) {
this.traits = traits;
}
@JsonIgnore
public List<Struct> getAllTraits() {
return traits;
}
public void normalize() {
super.normalize();
if (entity != null) {
entity.normailze();
}
if (traits != null) {
for (Struct trait : traits) {
if (trait != null) {
trait.normailze();
}
}
}
}
// ----- Object overrides --------------------------------------------------
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
EntityNotificationV1 that = (EntityNotificationV1) o;
return Objects.equals(entity, that.entity) &&
operationType == that.operationType &&
Objects.equals(traits, that.traits);
}
@Override
public int hashCode() {
return Objects.hash(entity, operationType, traits);
}
@Override
public StringBuilder toString(StringBuilder sb) {
if (sb == null) {
sb = new StringBuilder();
}
sb.append("EntityNotificationV1{");
super.toString(sb);
sb.append(", entity=");
if (entity != null) {
entity.toString(sb);
} else {
sb.append(entity);
}
sb.append(", operationType=").append(operationType);
sb.append(", traits=[");
AtlasBaseTypeDef.dumpObjects(traits, sb);
sb.append("]");
sb.append("}");
return sb;
}
// ----- helper methods ----------------------------------------------------
private static List<Struct> getAllTraits(Referenceable entityDefinition, AtlasTypeRegistry typeRegistry) {
List<Struct> ret = new LinkedList<>();
for (String traitName : entityDefinition.getTraitNames()) {
Struct trait = entityDefinition.getTrait(traitName);
AtlasClassificationType traitType = typeRegistry.getClassificationTypeByName(traitName);
Set<String> superTypeNames = traitType != null ? traitType.getAllSuperTypes() : null;
ret.add(trait);
if (CollectionUtils.isNotEmpty(superTypeNames)) {
for (String superTypeName : superTypeNames) {
Struct superTypeTrait = new Struct(superTypeName);
if (MapUtils.isNotEmpty(trait.getValues())) {
AtlasClassificationType superType = typeRegistry.getClassificationTypeByName(superTypeName);
if (superType != null && MapUtils.isNotEmpty(superType.getAllAttributes())) {
Map<String, Object> superTypeTraitAttributes = new HashMap<>();
for (Map.Entry<String, Object> attrEntry : trait.getValues().entrySet()) {
String attrName = attrEntry.getKey();
if (superType.getAllAttributes().containsKey(attrName)) {
superTypeTraitAttributes.put(attrName, attrEntry.getValue());
}
}
superTypeTrait.setValues(superTypeTraitAttributes);
}
}
ret.add(superTypeTrait);
}
}
}
return ret;
}
}
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.atlas.v1.model.typedef;
import org.codehaus.jackson.annotate.JsonAutoDetect;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.map.annotate.JsonSerialize;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import java.io.Serializable;
import java.util.Objects;
import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.NONE;
import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.PUBLIC_ONLY;
@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
@JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown=true)
@XmlRootElement
@XmlAccessorType(XmlAccessType.PROPERTY)
public class AttributeDefinition implements Serializable {
private static final long serialVersionUID = 1L;
private String name;
private String dataTypeName;
private Multiplicity multiplicity;
private boolean isComposite; // A composite is the one whose lifecycle is dependent on the enclosing type and is not just a reference
private boolean isUnique;
private boolean isIndexable;
private String reverseAttributeName; // If this is a reference attribute, then the name of the attribute on the Class that this refers to.
private String defaultValue;
private String description;
public AttributeDefinition() {
}
public AttributeDefinition(String name, String dataTypeName, Multiplicity multiplicity) {
this(name, dataTypeName, multiplicity, false, false, true, null);
}
public AttributeDefinition(String name, String dataTypeName, Multiplicity multiplicity, boolean isComposite,
String reverseAttributeName) {
this(name, dataTypeName, multiplicity, isComposite, false, false, reverseAttributeName);
}
public AttributeDefinition(String name, String dataTypeName, Multiplicity multiplicity, boolean isComposite, boolean isUnique, boolean isIndexable, String reverseAttributeName) {
this.name = name;
this.dataTypeName = dataTypeName;
this.multiplicity = multiplicity;
this.isComposite = isComposite;
this.isUnique = isUnique;
this.isIndexable = isIndexable;
this.reverseAttributeName = reverseAttributeName;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDataTypeName() {
return dataTypeName;
}
public void setDataTypeName(String dataTypeName) {
this.dataTypeName = dataTypeName;
}
public Multiplicity getMultiplicity() {
return multiplicity;
}
public void setMultiplicity(Multiplicity multiplicity) {
this.multiplicity = multiplicity;
}
public boolean getIsComposite() {
return isComposite;
}
public void setIsComposite(boolean isComposite) {
this.isComposite = isComposite;
}
public boolean getIsUnique() {
return isUnique;
}
public void setIsUnique(boolean isUnique) {
this.isUnique = isUnique;
}
public boolean getIsIndexable() {
return isIndexable;
}
public void setIsIndexable(boolean isIndexable) {
this.isIndexable = isIndexable;
}
public String getReverseAttributeName() {
return reverseAttributeName;
}
public void setReverseAttributeName(String reverseAttributeName) {
this.reverseAttributeName = reverseAttributeName;
}
public String getDefaultValue() {
return defaultValue;
}
public void setDefaultValue(final String defaultValue) {
this.defaultValue = defaultValue;
}
public String getDescription() {
return description;
}
public void setDescription(final String description) {
this.description = description;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
AttributeDefinition that = (AttributeDefinition) o;
return isComposite == that.isComposite &&
isUnique == that.isUnique &&
isIndexable == that.isIndexable &&
Objects.equals(name, that.name) &&
Objects.equals(dataTypeName, that.dataTypeName) &&
Objects.equals(multiplicity, that.multiplicity) &&
Objects.equals(defaultValue, that.defaultValue) &&
Objects.equals(description, that.description) &&
Objects.equals(reverseAttributeName, that.reverseAttributeName);
}
@Override
public int hashCode() {
return Objects.hash(name, dataTypeName, multiplicity, isComposite, isUnique, isIndexable,
reverseAttributeName, defaultValue, description);
}
}
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.atlas.v1.model.typedef;
import org.codehaus.jackson.annotate.JsonAutoDetect;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.map.annotate.JsonSerialize;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import java.io.Serializable;
import java.util.List;
import java.util.Set;
import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.NONE;
import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.PUBLIC_ONLY;
@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
@JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown=true)
@XmlRootElement
@XmlAccessorType(XmlAccessType.PROPERTY)
public class ClassTypeDefinition extends HierarchicalTypeDefinition implements Serializable {
private static final long serialVersionUID = 1L;
private static final String META_TYPE_NAME = "org.apache.atlas.typesystem.types.ClassType";
public ClassTypeDefinition() {
}
public ClassTypeDefinition(String typeName, String typeDescription, String typeVersion, List<AttributeDefinition> attributeDefinitions, Set<String> superTypes) {
super(typeName, typeDescription, typeVersion, attributeDefinitions, META_TYPE_NAME, superTypes);
}
@Override
public String getHierarchicalMetaTypeName() {
return META_TYPE_NAME;
}
}
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.atlas.v1.model.typedef;
import org.codehaus.jackson.annotate.JsonAutoDetect;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.map.annotate.JsonSerialize;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import java.io.Serializable;
import java.util.List;
import java.util.Objects;
import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.NONE;
import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.PUBLIC_ONLY;
@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
@JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown=true)
@XmlRootElement
@XmlAccessorType(XmlAccessType.PROPERTY)
public class EnumTypeDefinition implements Serializable {
private static final long serialVersionUID = 1L;
private String name;
private String description;
private String version;
private List<EnumValue> enumValues;
public EnumTypeDefinition() {
}
public EnumTypeDefinition(String name, String description, String version, List<EnumValue> enumValues) {
this.name = name;
this.description = description;
this.version = version;
this.enumValues = enumValues;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getVersion() {
return version;
}
public void setVersion(String version) {
this.version = version;
}
public List<EnumValue> getEnumValues() {
return enumValues;
}
public void setEnumValues(List<EnumValue> enumValues) {
this.enumValues = enumValues;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
EnumTypeDefinition that = (EnumTypeDefinition) o;
return Objects.equals(name, that.name) &&
Objects.equals(description, that.description) &&
Objects.equals(version, that.version) &&
Objects.equals(enumValues, that.enumValues);
}
@Override
public int hashCode() {
return Objects.hash(name, description, version, enumValues);
}
@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
@JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown=true)
@XmlRootElement
@XmlAccessorType(XmlAccessType.PROPERTY)
public static class EnumValue implements Serializable {
private static final long serialVersionUID = 1L;
private String value;
private int ordinal;
public EnumValue() {
}
public EnumValue(String value, int ordinal) {
this.value = value;
this.ordinal = ordinal;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public int getOrdinal() {
return ordinal;
}
public void setOrdinal(int ordinal) {
this.ordinal = ordinal;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
EnumValue that = (EnumValue) o;
return ordinal == that.ordinal &&
Objects.equals(value, that.value);
}
@Override
public int hashCode() {
return Objects.hash(value, ordinal);
}
}
}
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.atlas.v1.model.typedef;
import org.codehaus.jackson.annotate.JsonAutoDetect;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.map.annotate.JsonSerialize;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import java.io.Serializable;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.NONE;
import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.PUBLIC_ONLY;
@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
@JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown=true)
@XmlRootElement
@XmlAccessorType(XmlAccessType.PROPERTY)
public class HierarchicalTypeDefinition extends StructTypeDefinition implements Serializable {
private static final long serialVersionUID = 1L;
private String hierarchicalMetaTypeName = "org.apache.atlas.typesystem.types.TraitType";
private Set<String> superTypes;
public HierarchicalTypeDefinition() {
}
public HierarchicalTypeDefinition(String typeName, String typeDescription, String typeVersion, List<AttributeDefinition> attributeDefinitions, String hierarchicalMetaTypeName, Set<String> superTypes) {
super(typeName, typeDescription, typeVersion, attributeDefinitions);
this.hierarchicalMetaTypeName = hierarchicalMetaTypeName;
this.superTypes = superTypes;
}
public String getHierarchicalMetaTypeName() {
return hierarchicalMetaTypeName;
}
public void setHierarchicalMetaTypeName(String hierarchicalMetaTypeName) {
this.hierarchicalMetaTypeName = hierarchicalMetaTypeName;
}
public Set<String> getSuperTypes() {
return superTypes;
}
public void setSuperTypes(Set<String> superTypes) {
this.superTypes = superTypes;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass() || !super.equals(o)) {
return false;
}
HierarchicalTypeDefinition that = (HierarchicalTypeDefinition) o;
return Objects.equals(superTypes, that.superTypes) &&
Objects.equals(hierarchicalMetaTypeName, that.hierarchicalMetaTypeName);
}
@Override
public int hashCode() {
return Objects.hash(super.hashCode(), superTypes, hierarchicalMetaTypeName);
}
}
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.atlas.v1.model.typedef;
import org.codehaus.jackson.JsonGenerator;
import org.codehaus.jackson.JsonParser;
import org.codehaus.jackson.annotate.JsonAutoDetect;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.map.DeserializationContext;
import org.codehaus.jackson.map.JsonDeserializer;
import org.codehaus.jackson.map.JsonSerializer;
import org.codehaus.jackson.map.SerializerProvider;
import org.codehaus.jackson.map.annotate.JsonDeserialize;
import org.codehaus.jackson.map.annotate.JsonSerialize;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import java.io.IOException;
import java.io.Serializable;
import java.util.Objects;
import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.NONE;
import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.PUBLIC_ONLY;
@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
@JsonSerialize(using = Multiplicity.MultiplicitySerializer.class, include=JsonSerialize.Inclusion.NON_NULL)
@JsonDeserialize(using = Multiplicity.MultiplicityDeserializer.class)
@JsonIgnoreProperties(ignoreUnknown=true)
@XmlRootElement
@XmlAccessorType(XmlAccessType.PROPERTY)
public class Multiplicity implements Serializable {
private static final long serialVersionUID = 1L;
public static final Multiplicity OPTIONAL = new Multiplicity(0, 1, false);
public static final Multiplicity REQUIRED = new Multiplicity(1, 1, false);
public static final Multiplicity COLLECTION = new Multiplicity(1, Integer.MAX_VALUE, false);
public static final Multiplicity SET = new Multiplicity(1, Integer.MAX_VALUE, true);
private int lower;
private int upper;
private boolean isUnique;
public Multiplicity() {
this(Multiplicity.REQUIRED);
}
public Multiplicity(Multiplicity copyFrom) {
this(copyFrom.lower, copyFrom.upper, copyFrom.isUnique);
}
public Multiplicity(int lower, int upper, boolean isUnique) {
this.lower = lower;
this.upper = upper;
this.isUnique = isUnique;
}
public int getLower() {
return lower;
}
public void setLower(int lower) {
this.lower = lower;
}
public int getUpper() {
return upper;
}
public void setUpper(int upper) {
this.upper = upper;
}
public boolean getIsUnique() {
return isUnique;
}
public void setIsUnique(boolean isUnique) {
this.isUnique = isUnique;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
Multiplicity that = (Multiplicity) o;
return lower == that.lower &&
upper == that.upper &&
isUnique == that.isUnique;
}
@Override
public int hashCode() {
return Objects.hash(lower, upper, isUnique);
}
static class MultiplicitySerializer extends JsonSerializer<Multiplicity> {
@Override
public void serialize(Multiplicity value, JsonGenerator jgen, SerializerProvider provider) throws IOException {
if (value != null) {
if (value.equals(Multiplicity.REQUIRED)) {
jgen.writeString("required");
} else if (value.equals(Multiplicity.OPTIONAL)) {
jgen.writeString("optional");
} else if (value.equals(Multiplicity.COLLECTION)) {
jgen.writeString("collection");
} else if (value.equals(Multiplicity.SET)) {
jgen.writeString("set");
}
}
}
}
static class MultiplicityDeserializer extends JsonDeserializer<Multiplicity> {
@Override
public Multiplicity deserialize(JsonParser parser, DeserializationContext context) throws IOException {
Multiplicity ret = null;
String value = parser.readValueAs(String.class);
if (value != null) {
if (value.equals("required")) {
ret = new Multiplicity(Multiplicity.REQUIRED);
} else if (value.equals("optional")) {
ret = new Multiplicity(Multiplicity.OPTIONAL);
} else if (value.equals("collection")) {
ret = new Multiplicity(Multiplicity.COLLECTION);
} else if (value.equals("set")) {
ret = new Multiplicity(Multiplicity.SET);
}
}
if (ret == null) {
ret = new Multiplicity();
}
return ret;
}
}
}
...@@ -16,37 +16,52 @@ ...@@ -16,37 +16,52 @@
* limitations under the License. * limitations under the License.
*/ */
package org.apache.atlas.repository.typestore; package org.apache.atlas.v1.model.typedef;
import org.codehaus.jackson.annotate.JsonAutoDetect;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.map.annotate.JsonSerialize;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import java.io.Serializable;
import java.util.List;
import java.util.Objects; import java.util.Objects;
import org.apache.atlas.typesystem.types.DataTypes; import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.NONE;
import org.apache.atlas.typesystem.types.DataTypes.TypeCategory; import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.PUBLIC_ONLY;
/**
* Records the information needed to create a particular type vertex.
*/
public class TypeVertexInfo {
private DataTypes.TypeCategory category; @JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
private String typeName; @JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
private String typeDescription; @JsonIgnoreProperties(ignoreUnknown=true)
@XmlRootElement
@XmlAccessorType(XmlAccessType.PROPERTY)
public class StructTypeDefinition implements Serializable {
private static final long serialVersionUID = 1L;
public TypeVertexInfo(TypeCategory category, String typeName, String typeDescription) { private String typeName;
super(); private String typeDescription;
this.category = category; private String typeVersion;
this.typeName = typeName; private List<AttributeDefinition> attributeDefinitions;
this.typeDescription = typeDescription;
public StructTypeDefinition() {
} }
public DataTypes.TypeCategory getCategory() { public StructTypeDefinition(String typeName, String typeDescription, List<AttributeDefinition> attributeDefinitions) {
return category; this(typeName, typeDescription, "1.0", attributeDefinitions);
} }
public void setCategory(DataTypes.TypeCategory category) { public StructTypeDefinition(String typeName, String typeDescription, String typeVersion, List<AttributeDefinition> attributeDefinitions) {
this.category = category; this.typeName = typeName;
this.typeDescription = typeDescription;
this.typeVersion = typeVersion;
this.attributeDefinitions = attributeDefinitions;
} }
public String getTypeName() { public String getTypeName() {
return typeName; return typeName;
} }
...@@ -63,32 +78,42 @@ public class TypeVertexInfo { ...@@ -63,32 +78,42 @@ public class TypeVertexInfo {
this.typeDescription = typeDescription; this.typeDescription = typeDescription;
} }
@Override public String getTypeVersion() {
public int hashCode() { return typeVersion;
return Objects.hash(category, typeName);
} }
@Override public void setTypeVersion(String typeVersion) {
public boolean equals(Object obj) { this.typeVersion = typeVersion;
}
if (this == obj) { public List<AttributeDefinition> getAttributeDefinitions() {
return true; return attributeDefinitions;
} }
if (getClass() != obj.getClass()) { public void setAttributeDefinitions(List<AttributeDefinition> attributeDefinitions) {
return false; this.attributeDefinitions = attributeDefinitions;
} }
TypeVertexInfo other = (TypeVertexInfo)obj; @Override
if(! Objects.equals(category, other.category)) { public boolean equals(Object o) {
return false; if (this == o) {
return true;
} }
if(! Objects.equals(typeName, other.typeName)) { if (o == null || getClass() != o.getClass()) {
return false; return false;
} }
return true; StructTypeDefinition that = (StructTypeDefinition) o;
return Objects.equals(typeName, that.typeName) &&
Objects.equals(typeDescription, that.typeDescription) &&
Objects.equals(typeVersion, that.typeVersion) &&
Objects.equals(attributeDefinitions, that.attributeDefinitions);
} }
} @Override
\ No newline at end of file public int hashCode() {
return Objects.hash(typeName, typeDescription, typeVersion, attributeDefinitions);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment