Apache Atlas删除元数据实体
Apache Atlas删除元数据实体
数据删除的模式
在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);
删除实体API
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);