天天看點

[Apache Atlas] Atlas 架構設計及源代碼簡單分析

Apache Atlas 架構設計及源代碼分析, 以Hive建庫為例,分析中繼資料采集的主體流程

[Apache Atlas] Atlas 架構設計及源代碼簡單分析

Atlas 支援多資料源接入:Hive、HBase、Storm等

Atlas 中定義了一些中繼資料類型

Entity 是基于類型的具體實作

針對模型定義屬性

AtlasAttributeDef 屬性字段:

isComposite - 是否複合

isIndexable - 是否索引

isUnique - 是否唯一

multiplicity - 訓示此屬性是(必需的/可選的/還是可以是多值)的

Referenceable

This type represents all entities that can be searched for using a unique attribute called qualifiedName.

以Hive元資訊采集為例分析采集過程:

import-hive.sh

上面是調用過程:

importTables -> importTable --> registerInstances

通過Http Post 的請求将庫表資料更新至Atlas

atlasClientV2有很多Http接口

Atlas HTTP 用戶端API:

[Apache Atlas] Atlas 架構設計及源代碼簡單分析

<code>HiveHook implements ExecuteWithHookContext</code>

ExecuteWithHookContext is a new interface that the Pre/Post Execute Hook can run with the HookContext.

實作run()方法來對Hive 相關事件做處理

Hive相關事件:

以create database 為例分析流程:

主要:

擷取實體資訊, 傳遞Hook message的類型、操作使用者

notifyEntities 可以看出其他元件HBase、impala也會調用該方法進行消息的發送

[Apache Atlas] Atlas 架構設計及源代碼簡單分析

消息通知架構:

資料寫入Kafka中:

根據NotificationType寫入指定topic 中:

資料主要寫入兩個Topic中: ATLAS_ENTITIES、ATLAS_HOOK

ATLAS_HOOK是寫入Hook事件消息, 建立庫的事件中繼資料資訊會寫入該Topic中

如何唯一确定一個庫:

dbName@clusterName 确定唯一性

一個基于Hive hook 實作Impala 中繼資料重新整理的用例:

AutoRefreshImpala:https://github.com/Observe-secretly/AutoRefreshImpala

[1] Apache Atlas – Data Governance and Metadata framework for Hadoop

[2] Apache Atlas 源碼

本文作者: chaplinthink, 關注領域:大資料、基礎架構、系統設計, 一個熱愛學習、分享的大資料工程師

繼續閱讀