Search in sources :

Example 6 with Id

use of org.apache.atlas.v1.model.instance.Id in project atlas by apache.

the class EntityNotificationIT method testDeleteEntity.

public void testDeleteEntity() throws Exception {
    final String tableName = "table-" + randomString();
    final String dbName = "db-" + randomString();
    final Referenceable HiveDBInstance = createHiveDBInstanceBuiltIn(dbName);
    final Id dbId = createInstance(HiveDBInstance);
    final Referenceable tableInstance = createHiveTableInstanceBuiltIn(dbName, tableName, dbId);
    final Id tableId = createInstance(tableInstance);
    final String guid = tableId._getId();
    waitForNotification(notificationConsumer, MAX_WAIT_TIME, newNotificationPredicate(OperationType.ENTITY_CREATE, HIVE_TABLE_TYPE_BUILTIN, guid));
    final String name = (String) tableInstance.get(AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME);
    atlasClientV1.deleteEntity(HIVE_TABLE_TYPE_BUILTIN, AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, name);
    waitForNotification(notificationConsumer, MAX_WAIT_TIME, newNotificationPredicate(OperationType.ENTITY_DELETE, HIVE_TABLE_TYPE_BUILTIN, guid));
}
Also used : Referenceable(org.apache.atlas.v1.model.instance.Referenceable) Id(org.apache.atlas.v1.model.instance.Id)

Example 7 with Id

use of org.apache.atlas.v1.model.instance.Id in project atlas by apache.

the class QuickStartIT method testViewIsAdded.

@Test
public void testViewIsAdded() throws AtlasServiceException {
    Referenceable view = atlasClientV1.getEntity(QuickStart.VIEW_TYPE, AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, QuickStart.PRODUCT_DIM_VIEW);
    assertEquals(QuickStart.PRODUCT_DIM_VIEW, view.get(AtlasClient.NAME));
    Id productDimId = getTable(QuickStart.PRODUCT_DIM_TABLE).getId();
    Id inputTableId = ((List<Id>) view.get(QuickStart.INPUT_TABLES_ATTRIBUTE)).get(0);
    assertEquals(productDimId, inputTableId);
}
Also used : Referenceable(org.apache.atlas.v1.model.instance.Referenceable) List(java.util.List) Id(org.apache.atlas.v1.model.instance.Id) Test(org.testng.annotations.Test)

Example 8 with Id

use of org.apache.atlas.v1.model.instance.Id in project atlas by apache.

the class QuickStartIT method testProcessIsAdded.

@Test
public void testProcessIsAdded() throws AtlasServiceException {
    Referenceable loadProcess = atlasClientV1.getEntity(QuickStart.LOAD_PROCESS_TYPE, AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, QuickStart.LOAD_SALES_DAILY_PROCESS);
    assertEquals(QuickStart.LOAD_SALES_DAILY_PROCESS, loadProcess.get(AtlasClient.NAME));
    assertEquals(QuickStart.LOAD_SALES_DAILY_PROCESS_DESCRIPTION, loadProcess.get("description"));
    List<Id> inputs = (List<Id>) loadProcess.get(QuickStart.INPUTS_ATTRIBUTE);
    List<Id> outputs = (List<Id>) loadProcess.get(QuickStart.OUTPUTS_ATTRIBUTE);
    assertEquals(2, inputs.size());
    String salesFactTableId = getTableId(QuickStart.SALES_FACT_TABLE);
    String timeDimTableId = getTableId(QuickStart.TIME_DIM_TABLE);
    String salesFactDailyMVId = getTableId(QuickStart.SALES_FACT_DAILY_MV_TABLE);
    assertEquals(salesFactTableId, inputs.get(0)._getId());
    assertEquals(timeDimTableId, inputs.get(1)._getId());
    assertEquals(salesFactDailyMVId, outputs.get(0)._getId());
}
Also used : Referenceable(org.apache.atlas.v1.model.instance.Referenceable) List(java.util.List) Id(org.apache.atlas.v1.model.instance.Id) Test(org.testng.annotations.Test)

Example 9 with Id

use of org.apache.atlas.v1.model.instance.Id in project atlas by apache.

the class QuickStart method database.

Id database(String name, String description, String owner, String locationUri, String... traitNames) throws AtlasBaseException {
    try {
        Referenceable referenceable = new Referenceable(DATABASE_TYPE, traitNames);
        referenceable.set("name", name);
        referenceable.set("description", description);
        referenceable.set("owner", owner);
        referenceable.set("locationUri", locationUri);
        referenceable.set("createTime", System.currentTimeMillis());
        return createInstance(referenceable);
    } catch (Exception e) {
        throw new AtlasBaseException(AtlasErrorCode.QUICK_START, e, String.format("%s database entity creation failed", name));
    }
}
Also used : AtlasBaseException(org.apache.atlas.exception.AtlasBaseException) Referenceable(org.apache.atlas.v1.model.instance.Referenceable) AtlasException(org.apache.atlas.AtlasException) AtlasBaseException(org.apache.atlas.exception.AtlasBaseException)

Example 10 with Id

use of org.apache.atlas.v1.model.instance.Id in project atlas by apache.

the class LineageResource method schema.

/**
 * Returns the schema for the given dataset id.
 *
 * @param guid dataset entity id
 */
@GET
@Path("{guid}/schema")
@Consumes(Servlets.JSON_MEDIA_TYPE)
@Produces(Servlets.JSON_MEDIA_TYPE)
public SchemaResponse schema(@PathParam("guid") String guid) {
    if (LOG.isDebugEnabled()) {
        LOG.debug("==> LineageResource.schema({})", guid);
    }
    AtlasPerfTracer perf = null;
    SchemaResponse ret = new SchemaResponse();
    try {
        if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
            perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "LineageResource.schema(" + guid + ")");
        }
        SchemaResponse.SchemaDetails schemaDetails = atlasLineageService.getSchemaForHiveTableByGuid(guid);
        ret.setRequestId(Servlets.getRequestId());
        ret.setResults(schemaDetails);
        return ret;
    } catch (IllegalArgumentException e) {
        LOG.error("Unable to get schema for entity guid={}", guid, e);
        throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.BAD_REQUEST));
    } catch (WebApplicationException e) {
        LOG.error("Unable to get schema for entity guid={}", guid, e);
        throw e;
    } catch (AtlasBaseException e) {
        LOG.error("Unable to get schema for entity={}", guid, e);
        throw new WebApplicationException(Servlets.getErrorResponse(e, e.getAtlasErrorCode().getHttpCode()));
    } catch (Throwable e) {
        LOG.error("Unable to get schema for entity={}", guid, e);
        throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.INTERNAL_SERVER_ERROR));
    } finally {
        AtlasPerfTracer.log(perf);
        if (LOG.isDebugEnabled()) {
            LOG.debug("<== LineageResource.schema({})", guid);
        }
    }
}
Also used : AtlasBaseException(org.apache.atlas.exception.AtlasBaseException) WebApplicationException(javax.ws.rs.WebApplicationException) AtlasPerfTracer(org.apache.atlas.utils.AtlasPerfTracer) SchemaResponse(org.apache.atlas.v1.model.lineage.SchemaResponse) Path(javax.ws.rs.Path) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Aggregations

Referenceable (org.apache.atlas.v1.model.instance.Referenceable)62 Test (org.testng.annotations.Test)39 Id (org.apache.atlas.v1.model.instance.Id)38 Struct (org.apache.atlas.v1.model.instance.Struct)15 AtlasBaseException (org.apache.atlas.exception.AtlasBaseException)11 List (java.util.List)7 AtlasException (org.apache.atlas.AtlasException)6 AtlasServiceException (org.apache.atlas.AtlasServiceException)6 EntityNotificationV1 (org.apache.atlas.v1.model.notification.EntityNotificationV1)6 EntityResult (org.apache.atlas.model.legacy.EntityResult)5 HashMap (java.util.HashMap)4 AtlasObjectId (org.apache.atlas.model.instance.AtlasObjectId)4 AtlasPerfTracer (org.apache.atlas.utils.AtlasPerfTracer)4 Feed (org.apache.falcon.entity.v0.feed.Feed)4 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)3 Consumes (javax.ws.rs.Consumes)3 GET (javax.ws.rs.GET)3 Path (javax.ws.rs.Path)3 Produces (javax.ws.rs.Produces)3 WebApplicationException (javax.ws.rs.WebApplicationException)3