Java Code Examples for org.apache.atlas.model.instance.AtlasEntityHeader#getGuid()

The following examples show how to use org.apache.atlas.model.instance.AtlasEntityHeader#getGuid() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BasicSearchClassificationTest.java    From atlas with Apache License 2.0 6 votes vote down vote up
private void createDimensionTaggedEntityAndDelete() throws AtlasBaseException {
    AtlasEntity entityToDelete = new AtlasEntity(HIVE_TABLE_TYPE);
    entityToDelete.setAttribute("name", "entity to be deleted");
    entityToDelete.setAttribute(AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, "entity.tobedeleted");

    List<AtlasClassification> cls = new ArrayList<>();
    cls.add(new AtlasClassification(DIMENSION_CLASSIFICATION));
    entityToDelete.setClassifications(cls);

    //create entity
    EntityMutationResponse response = entityStore.createOrUpdate(new AtlasEntityStream(new AtlasEntity.AtlasEntitiesWithExtInfo(entityToDelete)), false);
    AtlasEntityHeader entityHeader = response.getCreatedEntities().get(0);
    dimensionTagDeleteGuid = entityHeader.getGuid();

    //delete entity
    entityStore.deleteById(dimensionTagDeleteGuid);
}
 
Example 2
Source File: BasicSearchClassificationTest.java    From atlas with Apache License 2.0 6 votes vote down vote up
private void createDimensionalTaggedEntityWithAttr() throws AtlasBaseException {
    AtlasEntity entityToDelete = new AtlasEntity(HIVE_TABLE_TYPE);
    entityToDelete.setAttribute("name", "Entity1");
    entityToDelete.setAttribute(AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, "entity.one");

    List<AtlasClassification> cls = new ArrayList<>();
    cls.add(new AtlasClassification(DIMENSIONAL_CLASSIFICATION, new HashMap<String, Object>() {{
        put("attr1", "Test");
    }}));
    entityToDelete.setClassifications(cls);

    //create entity
    final EntityMutationResponse response = entityStore.createOrUpdate(new AtlasEntityStream(new AtlasEntity.AtlasEntitiesWithExtInfo(entityToDelete)), false);
    AtlasEntityHeader entityHeader = response.getCreatedEntities().get(0);
    dimensionalTagGuid = entityHeader.getGuid();

}
 
Example 3
Source File: ClassificationAssociator.java    From atlas with Apache License 2.0 5 votes vote down vote up
public String setClassifications(Map<String, AtlasEntityHeader> map) {
    for (AtlasEntityHeader incomingEntityHeader : map.values()) {
        String typeName = incomingEntityHeader.getTypeName();

        AtlasEntityType entityType = typeRegistry.getEntityTypeByName(typeName);
        if (entityType == null) {
            LOG.warn("Entity type: {}: Not found: {}!", typeName, STATUS_SKIPPED);
            summarizeFormat("%s: %s", typeName, STATUS_SKIPPED);
            continue;
        }

        String qualifiedName = getUniqueAttributeName(entityType, incomingEntityHeader);
        if (StringUtils.isEmpty(qualifiedName)) {
            qualifiedName = "<no unique name>";
        }

        AtlasEntityHeader entityToBeChanged = getByUniqueAttributes(entityType, qualifiedName, incomingEntityHeader.getAttributes());
        if (entityToBeChanged == null) {
            summarizeFormat("Entity:%s:%s:[Not found]:%s", entityType.getTypeName(), qualifiedName, STATUS_SKIPPED);
            continue;
        }


        String guid = entityToBeChanged.getGuid();
        Map<String, List<AtlasClassification>> operationListMap = computeChanges(incomingEntityHeader, entityToBeChanged);
        commitChanges(guid, typeName, qualifiedName, operationListMap);
    }

    return getJsonArray(actionSummary);
}
 
Example 4
Source File: AtlasEntityChangeNotifier.java    From atlas with Apache License 2.0 5 votes vote down vote up
private void doFullTextMapping(List<AtlasEntityHeader> entityHeaders) {
    if(AtlasRepositoryConfiguration.isFreeTextSearchEnabled() || !AtlasRepositoryConfiguration.isFullTextSearchEnabled()) {
        return;
    }

    if (CollectionUtils.isEmpty(entityHeaders)) {
        return;
    }

    MetricRecorder metric = RequestContext.get().startMetricRecord("fullTextMapping");

    for (AtlasEntityHeader entityHeader : entityHeaders) {
        if(GraphHelper.isInternalType(entityHeader.getTypeName())) {
            continue;
        }

        String      guid   = entityHeader.getGuid();
        AtlasVertex vertex = AtlasGraphUtilsV2.findByGuid(guid);

        if(vertex == null) {
            continue;
        }

        try {
            String fullText = fullTextMapperV2.getIndexTextForEntity(guid);

            AtlasGraphUtilsV2.setEncodedProperty(vertex, ENTITY_TEXT_PROPERTY_KEY, fullText);
        } catch (AtlasBaseException e) {
            LOG.error("FullText mapping failed for Vertex[ guid = {} ]", guid, e);
        }
    }

    RequestContext.get().endMetricRecord(metric);
}
 
Example 5
Source File: TableReplicationRequestProcessor.java    From atlas with Apache License 2.0 4 votes vote down vote up
private Set<String> getGuidsToDelete(String dbName, List<String> excludeGUIDs, String sourceCluster) throws AtlasBaseException {

        SearchParameters parameters = getSearchParameters(dbName, sourceCluster);
        Set<String> unsafeGUIDs = new HashSet<>();

        final int max = 10000;
        int fetchedSize = 0;
        int i = 0;
        parameters.setLimit(max);

        while (fetchedSize == (max * i)) {
            if (LOG.isDebugEnabled()) {
                LOG.debug("i={}, fetchedSize={}, unsafeGUIDs.size()={}", i, fetchedSize, unsafeGUIDs.size());
            }

            int offset = max * i;
            parameters.setOffset(offset);

            AtlasSearchResult searchResult = discoveryService.searchWithParameters(parameters);

            if (CollectionUtils.isEmpty(searchResult.getEntities())) {
                break;
            } else {
                if (LOG.isDebugEnabled()) {
                    LOG.debug("getGuidsToDelete: {}", searchResult.getApproximateCount());
                }
            }

            String classificationName = String.format(REPLICATED_TAG_NAME, sourceCluster);
            for (AtlasEntityHeader entityHeader : searchResult.getEntities()) {
                if (!entityHeader.getClassificationNames().contains(classificationName)) {
                    continue;
                }

                String guid = entityHeader.getGuid();
                if (!excludeGUIDs.contains(guid)) {
                    unsafeGUIDs.add(guid);
                }
            }
            fetchedSize = searchResult.getEntities().size();
            i++;
        }
        return unsafeGUIDs;
    }
 
Example 6
Source File: AtlasTypeUtil.java    From atlas with Apache License 2.0 4 votes vote down vote up
public static AtlasObjectId getAtlasObjectId(AtlasEntityHeader header) {
    return new AtlasObjectId(header.getGuid(), header.getTypeName());
}
 
Example 7
Source File: RequestContext.java    From atlas with Apache License 2.0 4 votes vote down vote up
public void recordEntityUpdate(AtlasEntityHeader entity) {
    if (entity != null && entity.getGuid() != null && ! entitiesToSkipUpdate.contains(entity.getGuid())) {
        updatedEntities.put(entity.getGuid(), entity);
    }
}
 
Example 8
Source File: RequestContext.java    From atlas with Apache License 2.0 4 votes vote down vote up
public void recordEntityDelete(AtlasEntityHeader entity) {
    if (entity != null && entity.getGuid() != null) {
        deletedEntities.put(entity.getGuid(), entity);
    }
}
 
Example 9
Source File: AtlasTypeUtil.java    From incubator-atlas with Apache License 2.0 4 votes vote down vote up
public static AtlasObjectId getAtlasObjectId(AtlasEntityHeader header) {
    return new AtlasObjectId(header.getGuid(), header.getTypeName());
}