Search in sources :

Example 61 with AtlasObjectId

use of org.apache.atlas.model.instance.AtlasObjectId in project atlas by apache.

the class ImpalaLineageToolIT method testCreateTableAsSelectWithCommentSpacesFromFile.

/**
 * This tests is based on extra comment and spaces adding to create table as select query
 * 1) ImpalaLineageTool can parse one lineage file that contains "create   table   as   select" command lineage,
 *    there is table vertex with createTime.
 * 2) Lineage is sent to Atlas
 * 3) Atlas can get this lineage from Atlas
 */
@Test
public void testCreateTableAsSelectWithCommentSpacesFromFile() throws Exception {
    String IMPALA = dir + "impalaCreateTableAsSelectWithCommentSpaces.json";
    String IMPALA_WAL = dir + "WALimpala.wal";
    ImpalaLineageHook impalaLineageHook = new ImpalaLineageHook();
    // create database and tables to simulate Impala behavior that Impala updates metadata
    // to HMS and HMSHook sends the metadata to Atlas, which has to happen before
    // Atlas can handle lineage notification
    String dbName = "db_9";
    createDatabase(dbName);
    String sourceTableName = "table_1";
    createTable(dbName, sourceTableName, "(id string, count int)", false);
    String targetTableName = "table_2";
    createTable(dbName, targetTableName, "(count int, id string)", false);
    // process lineage record, and send corresponding notification to Atlas
    String[] args = new String[] { "-d", "./", "-p", "impala" };
    ImpalaLineageTool toolInstance = new ImpalaLineageTool(args);
    toolInstance.importHImpalaEntities(impalaLineageHook, IMPALA, IMPALA_WAL);
    // verify the process is saved in Atlas
    // the value is from info in IMPALA_4.
    String createTime = new Long(TABLE_CREATE_TIME * 1000).toString();
    String processQFName = dbName + "." + targetTableName + AtlasImpalaHookContext.QNAME_SEP_METADATA_NAMESPACE + CLUSTER_NAME + AtlasImpalaHookContext.QNAME_SEP_PROCESS + createTime;
    processQFName = processQFName.toLowerCase();
    String queryString = "create   /* Test */   table " + dbName + "." + targetTableName + "   as /* Test */ select count, id from " + dbName + "." + sourceTableName;
    AtlasEntity processEntity1 = validateProcess(processQFName, queryString);
    AtlasEntity processExecutionEntity1 = validateProcessExecution(processEntity1, queryString);
    AtlasObjectId process1 = toAtlasObjectId(processExecutionEntity1.getRelationshipAttribute(BaseImpalaEvent.ATTRIBUTE_PROCESS));
    Assert.assertEquals(process1.getGuid(), processEntity1.getGuid());
    Assert.assertEquals(numberOfProcessExecutions(processEntity1), 1);
    String guid = assertTableIsRegistered(dbName, targetTableName);
    AtlasEntity entity = atlasClientV2.getEntityByGuid(guid).getEntity();
    List ddlQueries = (List) entity.getRelationshipAttribute(ATTRIBUTE_DDL_QUERIES);
    assertNotNull(ddlQueries);
    assertEquals(ddlQueries.size(), 1);
}
Also used : AtlasEntity(org.apache.atlas.model.instance.AtlasEntity) ImpalaLineageHook(org.apache.atlas.impala.hook.ImpalaLineageHook) AtlasObjectId(org.apache.atlas.model.instance.AtlasObjectId) ArrayList(java.util.ArrayList) List(java.util.List) Test(org.testng.annotations.Test)

Example 62 with AtlasObjectId

use of org.apache.atlas.model.instance.AtlasObjectId in project atlas by apache.

the class AtlasServerService method updateEntitiesWithServer.

@GraphTransaction
public void updateEntitiesWithServer(AtlasServer server, List<String> entityGuids, String attributeName) throws AtlasBaseException {
    if (server != null && StringUtils.isEmpty(server.getGuid())) {
        return;
    }
    AtlasObjectId objectId = getObjectId(server);
    for (String guid : entityGuids) {
        AtlasEntity.AtlasEntityWithExtInfo entityWithExtInfo = entityStore.getById(guid, false, false);
        updateAttribute(entityWithExtInfo, attributeName, objectId);
    }
}
Also used : AtlasEntity(org.apache.atlas.model.instance.AtlasEntity) AtlasObjectId(org.apache.atlas.model.instance.AtlasObjectId) GraphTransaction(org.apache.atlas.annotation.GraphTransaction)

Example 63 with AtlasObjectId

use of org.apache.atlas.model.instance.AtlasObjectId in project atlas by apache.

the class AtlasGlossaryCategoryDTO method toEntity.

@Override
public AtlasEntity toEntity(final AtlasGlossaryCategory obj) throws AtlasBaseException {
    if (LOG.isDebugEnabled()) {
        LOG.debug("==> AtlasGlossaryCategoryDTO.toEntity()", obj);
    }
    Objects.requireNonNull(obj, "atlasGlossaryCategory");
    Objects.requireNonNull(obj.getQualifiedName(), "atlasGlossaryCategory qualifiedName must be specified");
    Objects.requireNonNull(obj.getAnchor(), "atlasGlossaryCategory anchor must be specified");
    AtlasEntity ret = getDefaultAtlasEntity(obj);
    ret.setAttribute("qualifiedName", obj.getQualifiedName());
    ret.setAttribute("name", obj.getName());
    ret.setAttribute("shortDescription", obj.getShortDescription());
    ret.setAttribute("longDescription", obj.getLongDescription());
    ret.setAttribute("anchor", new AtlasObjectId(obj.getAnchor().getGlossaryGuid()));
    ret.setAttribute("additionalAttributes", obj.getAdditionalAttributes());
    if (LOG.isDebugEnabled()) {
        LOG.debug("<== AtlasGlossaryCategoryDTO.toEntity() : {}", ret);
    }
    return ret;
}
Also used : AtlasEntity(org.apache.atlas.model.instance.AtlasEntity) AtlasObjectId(org.apache.atlas.model.instance.AtlasObjectId)

Example 64 with AtlasObjectId

use of org.apache.atlas.model.instance.AtlasObjectId in project atlas by apache.

the class StartEntityFetchByExportRequest method get.

public List<AtlasObjectId> get(AtlasExportRequest exportRequest) {
    List<AtlasObjectId> list = new ArrayList<>();
    for (AtlasObjectId objectId : exportRequest.getItemsToExport()) {
        List<String> guids = get(exportRequest, objectId);
        if (guids.isEmpty()) {
            continue;
        }
        objectId.setGuid(guids.get(0));
        list.add(objectId);
    }
    return list;
}
Also used : ArrayList(java.util.ArrayList) AtlasObjectId(org.apache.atlas.model.instance.AtlasObjectId)

Example 65 with AtlasObjectId

use of org.apache.atlas.model.instance.AtlasObjectId in project atlas by apache.

the class ExportServiceTest method getRequestForFullFetch.

private AtlasExportRequest getRequestForFullFetch() {
    AtlasExportRequest request = new AtlasExportRequest();
    List<AtlasObjectId> itemsToExport = new ArrayList<>();
    itemsToExport.add(new AtlasObjectId("hive_db", "qualifiedName", "default@cl1"));
    request.setItemsToExport(itemsToExport);
    return request;
}
Also used : AtlasExportRequest(org.apache.atlas.model.impexp.AtlasExportRequest) ArrayList(java.util.ArrayList) AtlasObjectId(org.apache.atlas.model.instance.AtlasObjectId)

Aggregations

AtlasObjectId (org.apache.atlas.model.instance.AtlasObjectId)255 AtlasEntity (org.apache.atlas.model.instance.AtlasEntity)124 Test (org.testng.annotations.Test)70 ArrayList (java.util.ArrayList)69 Map (java.util.Map)47 EntityMutationResponse (org.apache.atlas.model.instance.EntityMutationResponse)44 AtlasEntityHeader (org.apache.atlas.model.instance.AtlasEntityHeader)41 AtlasEntityType (org.apache.atlas.type.AtlasEntityType)41 HashMap (java.util.HashMap)40 AtlasVertex (org.apache.atlas.repository.graphdb.AtlasVertex)38 List (java.util.List)36 AtlasEntityWithExtInfo (org.apache.atlas.model.instance.AtlasEntity.AtlasEntityWithExtInfo)33 AtlasBaseException (org.apache.atlas.exception.AtlasBaseException)32 BeforeTest (org.testng.annotations.BeforeTest)32 AtlasEntitiesWithExtInfo (org.apache.atlas.model.instance.AtlasEntity.AtlasEntitiesWithExtInfo)29 AtlasTypeUtil.getAtlasObjectId (org.apache.atlas.type.AtlasTypeUtil.getAtlasObjectId)24 AtlasStruct (org.apache.atlas.model.instance.AtlasStruct)22 AtlasExportRequest (org.apache.atlas.model.impexp.AtlasExportRequest)14 AtlasEdge (org.apache.atlas.repository.graphdb.AtlasEdge)13 AtlasType (org.apache.atlas.type.AtlasType)11