Search in sources :

Example 31 with Referenceable

use of org.apache.atlas.typesystem.Referenceable in project incubator-atlas by apache.

the class FalconBridge method fillHDFSDataSet.

private static List<Referenceable> fillHDFSDataSet(final String pathUri, final String clusterName) {
    List<Referenceable> entities = new ArrayList<>();
    Referenceable ref = new Referenceable(HiveMetaStoreBridge.HDFS_PATH);
    ref.set("path", pathUri);
    //        Path path = new Path(pathUri);
    //        ref.set("name", path.getName());
    //TODO - Fix after ATLAS-542 to shorter Name
    Path path = new Path(pathUri);
    ref.set(AtlasClient.NAME, Path.getPathWithoutSchemeAndAuthority(path).toString().toLowerCase());
    ref.set(AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, pathUri);
    ref.set(AtlasConstants.CLUSTER_NAME_ATTRIBUTE, clusterName);
    entities.add(ref);
    return entities;
}
Also used : Path(org.apache.hadoop.fs.Path) Referenceable(org.apache.atlas.typesystem.Referenceable) ArrayList(java.util.ArrayList)

Example 32 with Referenceable

use of org.apache.atlas.typesystem.Referenceable in project incubator-atlas by apache.

the class FalconHookIT method assertFeedAttributes.

private void assertFeedAttributes(String feedId) throws Exception {
    Referenceable feedEntity = atlasClient.getEntity(feedId);
    assertEquals(feedEntity.get(AtlasClient.OWNER), "testuser");
    assertEquals(feedEntity.get(FalconBridge.FREQUENCY), "hours(1)");
    assertEquals(feedEntity.get(AtlasClient.DESCRIPTION), "test input");
}
Also used : Referenceable(org.apache.atlas.typesystem.Referenceable)

Example 33 with Referenceable

use of org.apache.atlas.typesystem.Referenceable in project incubator-atlas by apache.

the class FalconHookIT method verifyFeedLineage.

private void verifyFeedLineage(String feedName, String clusterName, String feedId, String dbName, String tableName) throws Exception {
    //verify that lineage from hive table to falcon feed is created
    String processId = assertEntityIsRegistered(FalconDataTypes.FALCON_FEED_CREATION.getName(), AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, FalconBridge.getFeedQualifiedName(feedName, clusterName));
    Referenceable processEntity = atlasClient.getEntity(processId);
    assertEquals(((List<Id>) processEntity.get("outputs")).get(0).getId()._getId(), feedId);
    String inputId = ((List<Id>) processEntity.get("inputs")).get(0).getId()._getId();
    Referenceable tableEntity = atlasClient.getEntity(inputId);
    assertEquals(tableEntity.getTypeName(), HiveDataTypes.HIVE_TABLE.getName());
    assertEquals(tableEntity.get(AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME), HiveMetaStoreBridge.getTableQualifiedName(clusterName, dbName, tableName));
}
Also used : Referenceable(org.apache.atlas.typesystem.Referenceable) List(java.util.List) Id(org.apache.atlas.typesystem.persistence.Id)

Example 34 with Referenceable

use of org.apache.atlas.typesystem.Referenceable in project incubator-atlas by apache.

the class FalconBridge method createFeedEntity.

private static Referenceable createFeedEntity(Feed feed, Referenceable clusterReferenceable) {
    LOG.info("Creating feed dataset: {}", feed.getName());
    Referenceable feedEntity = new Referenceable(FalconDataTypes.FALCON_FEED.getName());
    feedEntity.set(AtlasClient.NAME, feed.getName());
    feedEntity.set(AtlasClient.DESCRIPTION, feed.getDescription());
    String feedQualifiedName = getFeedQualifiedName(feed.getName(), (String) clusterReferenceable.get(AtlasClient.NAME));
    feedEntity.set(AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, feedQualifiedName);
    feedEntity.set(FalconBridge.FREQUENCY, feed.getFrequency().toString());
    feedEntity.set(FalconBridge.STOREDIN, clusterReferenceable);
    if (feed.getACL() != null) {
        feedEntity.set(AtlasClient.OWNER, feed.getACL().getOwner());
    }
    if (StringUtils.isNotEmpty(feed.getTags())) {
        feedEntity.set(FalconBridge.TAGS, EventUtil.convertKeyValueStringToMap(feed.getTags()));
    }
    if (feed.getGroups() != null) {
        feedEntity.set(FalconBridge.GROUPS, feed.getGroups());
    }
    return feedEntity;
}
Also used : Referenceable(org.apache.atlas.typesystem.Referenceable)

Example 35 with Referenceable

use of org.apache.atlas.typesystem.Referenceable in project incubator-atlas by apache.

the class GraphBackedMetadataRepositoryDeleteTestBase method createDbTableGraph.

private void createDbTableGraph(String dbName, String tableName) throws Exception {
    Referenceable databaseInstance = new Referenceable(TestUtils.DATABASE_TYPE);
    databaseInstance.set("name", dbName);
    databaseInstance.set("description", "foo database");
    ClassType dbType = typeSystem.getDataType(ClassType.class, TestUtils.DATABASE_TYPE);
    ITypedReferenceableInstance db = dbType.convert(databaseInstance, Multiplicity.REQUIRED);
    Referenceable tableInstance = new Referenceable(TestUtils.TABLE_TYPE, TestUtils.CLASSIFICATION);
    tableInstance.set("name", tableName);
    tableInstance.set("description", "bar table");
    tableInstance.set("type", "managed");
    Struct traitInstance = (Struct) tableInstance.getTrait(TestUtils.CLASSIFICATION);
    traitInstance.set("tag", "foundation_etl");
    // enum
    tableInstance.set("tableType", 1);
    tableInstance.set("database", databaseInstance);
    ArrayList<Referenceable> columns = new ArrayList<>();
    for (int index = 0; index < 5; index++) {
        Referenceable columnInstance = new Referenceable("column_type");
        final String name = "column_" + index;
        columnInstance.set("name", name);
        columnInstance.set("type", "string");
        columns.add(columnInstance);
    }
    tableInstance.set("columns", columns);
    ClassType tableType = typeSystem.getDataType(ClassType.class, TestUtils.TABLE_TYPE);
    ITypedReferenceableInstance table = tableType.convert(tableInstance, Multiplicity.REQUIRED);
    repositoryService.createEntities(db, table);
}
Also used : Referenceable(org.apache.atlas.typesystem.Referenceable) ITypedReferenceableInstance(org.apache.atlas.typesystem.ITypedReferenceableInstance) ArrayList(java.util.ArrayList) ITypedStruct(org.apache.atlas.typesystem.ITypedStruct) IStruct(org.apache.atlas.typesystem.IStruct) Struct(org.apache.atlas.typesystem.Struct)

Aggregations

Referenceable (org.apache.atlas.typesystem.Referenceable)235 Test (org.testng.annotations.Test)114 Id (org.apache.atlas.typesystem.persistence.Id)50 ArrayList (java.util.ArrayList)45 List (java.util.List)25 Struct (org.apache.atlas.typesystem.Struct)25 HashMap (java.util.HashMap)24 BeforeTest (org.testng.annotations.BeforeTest)24 ITypedReferenceableInstance (org.apache.atlas.typesystem.ITypedReferenceableInstance)22 AfterTest (org.testng.annotations.AfterTest)22 HookNotification (org.apache.atlas.notification.hook.HookNotification)20 IStruct (org.apache.atlas.typesystem.IStruct)18 ClassType (org.apache.atlas.typesystem.types.ClassType)16 JSONObject (org.codehaus.jettison.json.JSONObject)16 ImmutableList (com.google.common.collect.ImmutableList)15 AtlasServiceException (org.apache.atlas.AtlasServiceException)14 TraitType (org.apache.atlas.typesystem.types.TraitType)12 WriteEntity (org.apache.hadoop.hive.ql.hooks.WriteEntity)12 Date (java.util.Date)11 AtlasException (org.apache.atlas.AtlasException)11