初步學習altas 的血緣關系
- 了解altas 的血緣關系的作用
- altas的安裝部署
- 了解官方API
- 了解apache echars
了解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的血緣關系類似了,后續再考慮其他問題,比如圖示,代碼如下,可直接貼上測驗,
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.uj5u.com/qita/281209.html
標籤:其他
上一篇:01、泛型是什么?——《Android打怪升級之旅》
下一篇:Doris同步多庫多表
