Apache Atlas类型系统与Rest API

本文深入解析了Atlas类型系统的基本概念,包括Type、Entity和Attribute,以及如何使用REST API进行数据资产的管理和检索。涵盖了类型检索、实体操作、全文检索及数据血缘查询等功能。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

概述

类型系统Type System是Atlas最核心的组件之一,用户可以通过类型系统对数据资产进行分类、定义,然后用Ingest/Export组件添加元数据或输出元数据变化。对外,其他系统可以通过REST API或Kafka Message与Atlas进行集成。

这里,总结Atlas 类型系统与Rest API。

Atlas 类型系统

Type

Type(类型)在Atlas中代表了一类数据,如hdfs_path Type,hive_db Type,hive_table Type,hive_column Type。Type,简单理解,可理解成Java 面向对象中的类Class,定义了一类数据。

Entity

Entity(实体)是某个Type(类型)的Instance(实例)。类似面向对象中某一Class的具体Object。

举例:

  1. Hive有一个default数据库,则在Atlas中,该库default将是hive_db类型的一个Entity。
  2. Hive在default数据库中有一个表叫customers,则在Atlas中,该表customers将是hive_table类型的一个Entity。
  3. Hive在default数据库customers表中有一个列叫user_name,则在Atlas中,该列user_name将是hive_column类型的一个Entity。

Atlas WebUI中可根据某一Type类型Search一类Entity。

注意: 每一个Entity都有一个GUID。在Atlas WebUI中,点击某个Entity,在浏览器URL框中即可看到该GUID。

Attribute

类型系统中,Type和Entity都是有属性的。Attribute定义了Type和Entity的具体属性。

除此之外,Atlas内部还自带了一些预定义类型,如Referenceable Type,Asset Type,Infrastructure Type,DataSet Type,Process Type等。

Atlas Rest API

总结部分Rest API,其他API查看Atlas官网Atlas Rest API

AdminREST

  1. 查看Atlas Metadata Server节点状态 GET /admin/status
curl -s -u admin:admin "http://node2:21000/api/atlas/admin/status"|jq

ACTIVE:此实例处于活跃状态,可以响应用户请求。
PASSIVE:此实例处于被动状态。它会将收到的任何用户请求重定向到当前ACTIVE实例。
BECOMING_ACTIVE:此实例正在转换为ACTIVE实例,在此状态下无法为用户提供请求服务。
BECOMING_PASSIVE:此实例正在转换为PASSIVE实例,在此状态下无法为用户提供请求服务。

注意:正常情况下,只有一个应该为ACTIVE状态,其他实例均为PASSIVE状态。
  1. 查看Atlas版本和描述 GET /admin/version
curl -s -u admin:admin "http://node2:21000/api/atlas/admin/version"|jq

DiscoveryREST

  1. 基本搜索 GET /v2/search/basic
#查询所有Hive表
curl -s -u admin:admin "http://node2:21000/api/atlas/v2/search/basic?typeName=hive_table"|jq

#查询所有Hive表,且包含某一关键字
curl -s -u admin:admin "http://node2:21000/api/atlas/v2/search/basic?query=dim_channel&typeName=hive_table"|jq
  1. DSL 搜索 GET /v2/search/dsl
#DSL方式查询Hive表
curl -s -u admin:admin "http://node2:21000/api/atlas/v2/search/dsl?typeName=hive_table&query=where%20name%3D%22dim_channel%22"|jq

注意:URL中特殊字符编码。
  1. 全文检索 GET /v2/search/fulltext
#全文检索方式查询
curl -s -u admin:admin "http://node2:21000/api/atlas/v2/search/fulltext?query=where%20name%3D%22dim_channel%22"|jq

TypesREST

  1. 检索所有Type,并返回所有信息 GET /v2/types/typedefs
curl -s -u admin:admin "http://node2:21000/api/atlas/v2/types/typedefs"|jq
  1. 检索所有Type,并返回最少信息 GET /v2/types/typedefs/headers
curl -s -u admin:admin "http://node2:21000/api/atlas/v2/types/typedefs/headers"|jq
如:
{
    "guid": "77edd2dc-cc4e-4980-ae65-b3dd72cf5980",
    "name": "dim_table",
    "category": "CLASSIFICATION"
  },
  {
    "guid": "9d6c9b56-b91b-45f5-9320-d10c67736d05",
    "name": "fact_table",
    "category": "CLASSIFICATION"
  }
.......

EntityREST

  1. 批量根据GUID检索Entity GET /v2/entity/bulk
curl -s -u admin:admin "http://node2:21000/api/atlas/v2/entity/bulk?minExtInfo=yes&guid=bcbc196a-74c1-45ff-ac6f-f749ec8fd9b0"|jq
  1. 获取某个Entity定义 GET /v2/entity/guid/{guid}
curl -s -u admin:admin "http://node2:21000/api/atlas/v2/entity/guid/bcbc196a-74c1-45ff-ac6f-f749ec8fd9b0"|jq
  1. 获取某个Entity的TAG列表 GET /v2/entity/guid/{guid}/classifications
curl -s -u admin:admin "http://node2:21000/api/atlas/v2/entity/guid/bcbc196a-74c1-45ff-ac6f-f749ec8fd9b0/classifications"|jq

LineageREST

  1. 查询某个Entity的Lineage GET /v2/lineage/{guid}
curl -s -u admin:admin "http://node2:21000/api/atlas/v2/lineage/bcbc196a-74c1-45ff-ac6f-f749ec8fd9b0"|jq
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值