在Apache Atlas中,元数据、元数据类型模型的删除模式分为两种
在Apache Atlas中,元数据导入流程如下:
定义元数据模型(type) -> 依据元数据模型,创建元数据实体(entity) -> 对元数据增删改查操作
所以,如果要删除元数据类型模型(type),则必须删除所有对应的(entity),且软删除无法奏效,需要硬删除;可见,类型系统的定义必须慎重,否则将带来很大麻烦。
Atlas中的删除模式是 物理删除 或 逻辑删除 的重点是配置对应的DeleteHandler;
通过修改atlas-application.properties配置文件的atlas.DeleteHandlerV1.impl变量,设置对应的参数值,来配置删除的模式(软删除或硬删除),然后重启atlas即可。
软删除中,atlas的entity有如下状态:ACTIVE, DELETED, PURGED。
官方注释:Status of the entity - can be active or deleted. Deleted entities are not removed from Atlas store.
atlas-application.properties配置信息如下:
# Delete handler
#
# This allows the default behavior of doing "soft" deletes to be changed.
#
# Allowed Values:
# org.apache.atlas.repository.store.graph.v1.SoftDeleteHandlerV1 - all deletes are "soft" deletes
# org.apache.atlas.repository.store.graph.v1.HardDeleteHandlerV1 - all deletes are "hard" deletes
#
atlas.DeleteHandlerV1.impl=org.apache.atlas.repository.store.graph.v1.HardDeleteHandlerV1
在Apache Atlas中,有没有办法在启用硬删除后删除/清除软删除的实体?
通过如下API即可达到要求:
Http请求方式:
----------------soft delete----------------
curl -iv -u admin:admin -X DELETE http://localhost:21000/api/atlas/v2/entity/guid/88f13750-f2f9-4e31-89f7-06d313fe5d39
---------------- than hard----------------
curl -i -X PUT -H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-u admin:admin 'http://loclahost:21000/api/atlas/admin/purge/' \
-d '["88f13750-f2f9-4e31-89f7-06d313fe5d39"]'
Atlas Client方式:
HashSet<String> set = new HashSet<>();
set.add("2599fead-f70d-447c-a304-46dc64f38485");
set.add("e13cb1eb-889c-4bde-97b8-26fca8792f14");
atlasClientV2.purgeEntitiesByGuids(set);
Atlas Client API
public EntityMutationResponse deleteEntityByGuid(String guid)
public EntityMutationResponse deleteEntityByAttribute(String typeName, Map<String, String> uniqAttributes)
public EntityMutationResponse deleteEntitiesByGuids(List<String> guids)
如果想不改变删除模式,且硬删除实体,则可以调用如下接口
public EntityMutationResponse deleteEntityByGuid(String guid)
atlasClientV2.purgeEntitiesByGuids(guidSet);