了解altas 的血缘关系的作用
在数据治理环节,需要对表进行溯源,或者对字段进行溯源,简单说 多个表组成一个表时,可以追溯到表中的字段来自具体的哪个表,以后数据进行变动可以通过血缘关系图形直观看出,如下图
altas的安装部署
本人并没有实践过,这点请参考网上的资料
了解官方API
链接: http://atlas.apache.org/api/v2/index.html.推荐
链接: http://atlas.apache.org/api/v2/application.wadl.
这里详细讲解一下 / v2 / lineage / {guid} 这个接口,
这里可以看出我们需要一个guid,那么guid怎么获取呢?且域名端口号是什么?完整url:http://{部署的ip}:21000/api/atlas/v2/lineage/{guid}
guid是一个唯一的id,那么我想尝试调用一下不需要参数的接口试试,比如:http://ip:21000/api/atlas/v2/search/basic?query=gdyinfo_new&typeName=hive_table,查询hive_table中的gdyinfo_new 这个表的信息,返回得到结果: 通过调用其他接口,我发现了guid,说明这个guid就是gdyinfo_new的唯一标识,然后我们再回到之前的lineage,把这个guid传进去,这不就是说 我能通过这个接口对这个表进行追溯嘛哈哈哈。
话不多说 我们赶紧试一下,http://ip:21000/api/atlas/v2/lineage/6fa88134-ab3e-4db9-8907-947e4fc17b88(这里atlas会自动跳转到登录页面,需要验证才能调用,我是通过浏览器调用的,先登录,java和postman方法移步至链接:
https://blog.csdn.net/qq_43185247/article/details/116200436?spm=1001.2014.3001.5502
确实能够调用接口了,返回了一组json数据,我把他保存了下来分析一下:
{ "baseEntityGuid":"01d12e5f-1ef5-46a8-ac13-29be71e8f78e",
"lineageDirection":"BOTH","lineageDepth":3,
"guidEntityMap":{
"5a676b74-e058-4e81-bcf8-42d73f4c1729":
{"typeName":"rdbms_table",
"attributes":
{"owner":"root",
"createTime":1577687198000,
"qualifiedName":"testdb.p_people@mysql://192.168.1.1:3306",
"name":"p_people1",
"description":"MySQL数据库表:testdb.p_people"},
"guid":"5a676b74-e058-4e81-bcf8-42d73f4c1729",
"status":"ACTIVE",
"displayText":"p_people",
"classificationNames":[],
"meaningNames":[],
"meanings":[]},
"2e7c70e1-5a8a-4430-859f-c46d267e33fd":
{"typeName":"hive_table",
"attributes":
{"owner":"hdfs",
"createTime":1578981817000,
"qualifiedName":"testdb.p_people@primary",
"name":"p_people2"},
"guid":"2e7c70e1-5a8a-4430-859f-c46d267e33fd",
"status":"ACTIVE",
"displayText":"p_people",
"classificationNames":["people"],
"meaningNames":[],"meanings":[]},
"2b65eb7f-596e-48f0-a94d-240e56a4da93":
{"typeName":"Process",
"attributes":
{"owner":"root",
"qualifiedName":"people@process@mysql://192.168.1.1:3306",
"name":"peopleProcess",
"description":"people Process"},
"guid":"2b65eb7f-596e-48f0-a94d-240e56a4da93",
"status":"ACTIVE",
"displayText":"peopleProcess",
"classificationNames":[],
"meaningNames":[],
"meanings":[]},
"01d12e5f-1ef5-46a8-ac13-29be71e8f78e":
{"typeName":"hive_process",
"attributes":
{"qualifiedName":
"testdb.p_people_tmp2@primary:1588921268000",
"name":"create table p_people_tmp2 as select peopleid,peopletype,credentialtype,credentialno,peoplename,gender,nation from p_people"},
"guid":"01d12e5f-1ef5-46a8-ac13-29be71e8f78e",
"status":"ACTIVE",
"displayText":"create table p_people_tmp2 as select peopleid,peopletype,credentialtype,credentialno,peoplename,gender,nation from p_people",
"classificationNames":["people"],
"meaningNames":[],
"meanings":[]},
"a4ccceb2-a52c-46a2-b4fd-27d26b8aad3f":
{"typeName":"hive_table",
"attributes":
{"owner":"hive",
"createTime":1588921268000,
"qualifiedName":"testdb.p_people_tmp2@primary",
"name":"p_people_tmp2"},
"guid":"a4ccceb2-a52c-46a2-b4fd-27d26b8aad3f",
"status":"ACTIVE",
"displayText":"p_people_tmp2",
"classificationNames":["people"],
"meaningNames":[],
"meanings":[]}},
"relations":[
{ "fromEntityId":"01d12e5f-1ef5-46a8-ac13-29be71e8f78e", //create table
"toEntityId":"a4ccceb2-a52c-46a2-b4fd-27d26b8aad3f", //p_people_tmp2
"relationshipId":"148cc83d-5b67-4174-91e4-767509483e13"},
{ "fromEntityId":"2e7c70e1-5a8a-4430-859f-c46d267e33fd", //p_people2
"toEntityId":"01d12e5f-1ef5-46a8-ac13-29be71e8f78e", // //create table
"relationshipId":"eb768346-d32a-40f9-bf04-d23abbcc3221"},
{ "fromEntityId":"2b65eb7f-596e-48f0-a94d-240e56a4da93", //peopleProcess
"toEntityId":"2e7c70e1-5a8a-4430-859f-c46d267e33fd", //p_people2
"relationshipId":"bea47efd-2645-4d8a-ba6b-8f4ef9bb7316"},
{ "fromEntityId":"5a676b74-e058-4e81-bcf8-42d73f4c1729", //p_people1
"toEntityId":"2b65eb7f-596e-48f0-a94d-240e56a4da93", //peopleProcess
"relationshipId":"517db5b7-f537-4e66-97f1-33c2863fb440"}]}
通过分析这个json,我发现了两个重要的地方,这里结合给出的血缘图比较直观!
发现每一个guid下有一个name,对应着上图一个步骤,ralations描述了它们之间的联系,这不就串起来了嘛,那么我要怎么把这个关系用图形表达出来呢?
了解apache echars
altas源码并不是用的这种方式,貌似是用的图数据库,我也在测试这种方式是否可行。
链接: https://echarts.apache.org/zh/index.html.
大家可以了解一下,比较容易上手。
我在示例图上找到了关系图,然后对代码进行对应调整,这是不是跟atlas的血缘关系类似了,后续再考虑其他问题,比如图标,代码如下,可直接贴上测试。文章来源:https://www.toymoban.com/news/detail-400424.html
option = {
title: {
text: 'Graph 简单示例'
},
tooltip: {},
animationDurationUpdate: 1500,
animationEasingUpdate: 'quinticInOut',
series: [
{
type: 'graph',
layout: 'none',
xAxisIndex : 0, //x轴坐标 有多种坐标系轴坐标选项
yAxisIndex : 0, //y轴坐标
symbolSize: 50,
roam: true,
label: {
show: true
},
edgeSymbol: ['circle', 'arrow'],
edgeSymbolSize: [4, 10],
edgeLabel: {
fontSize: 20
},
data: [ {
name: 'p_people1',
x:0,
y: 0
}, {
name: 'p_people2',
x:-50,
y:50
}, {
name: 'peopleProcess',
x:-50,
y:-50
},{
name: 'create table',
x: 50,
y: 0
},{
name: 'p_people_tmp2',
x: 50,
y: 0
},],
// links: [],
links: [{
source: 'create table',
target: 'p_people_tmp2',
label: {
// show: true
},
lineStyle: {
curveness: -0.2
}
}, {
source: 'p_people2',
target: 'create table',
lineStyle: {
curveness: 0
}
}, {
source: 'peopleProcess',
target: 'p_people2',
lineStyle: {
curveness: 0.2
}
}, {
source: 'p_people1',
target: 'peopleProcess',
lineStyle: {
curveness: 0
}
}],
lineStyle: {
opacity: 0.9,
width: 2,
}
}
]
};
基本的雏形已经出来了,浏览器调用接口,再用echars 实现图形化,最后再强调一次,调用接口需要权限,已经测试过java代码和postman,请参考:链接:
https://blog.csdn.net/qq_43185247/article/details/116200436?spm=1001.2014.3001.5502
感谢,第二次写博客文章来源地址https://www.toymoban.com/news/detail-400424.html
到了这里,关于了解apache atlas的血缘关系的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!