Smart Storage Management (SSM) 项目是Intel开源的HDFS存储管理系统,致力于提供HDFS数据的智能管理方案。SSM有如下几个重要的功能:
SSM整体架构可分为三部分:
SSM Server基于线程内置不同任务类型的调度器(Scheduler),主要包括:
SSM的整体执行流程可以分为四个步骤:Collect → Learn → Perform → Measure
各个系统的交互图如下所示:
数据库主要维护的信息包括:
(1). SmartService
SSM业务实现服务类,主要包括:
(2). SmartEngine
负责启动所有注入的`SmartService,主要包括:
(3). StatesManager
StatesManager会轮询从NameNode采集指标和事件,
(4). RuleManager
用于管理规则和执行策略,`RuleExecutorPlugin`:规则执行器插件,可扩展不同的管理任务,如小文件处理,EC等;
`RuleExecutor`:策略执行方:
(5). CmdletManager:基于系统CMD脚本方式,真正实现任务执行。策略基于SmartAction执行,SmartAction是Action的基础类,所有的Action都需要运行在cmdlet或web console中。
(6). SmartAgent
执行server下发命令,同时上报对应执行的结果,基于`ActorSystem` 实现的。
SSM是典型的主从架构,Server是主节点,Agent是从节点,基于Actor实现Master/Client之间通信。
由`StatesManager`触发,支持在Runtime运行时进行配置动态加载。
(1). FileAccessEventSource
通过不同方式获取文件访问事件(file access event),默认实现类:`SmartServerAccessEventSource`:
/**
* Get a collector what will produce events from this file access event source.
*/
FileAccessEventCollector getCollector();
/**
* Insert events generated from the Smart client so that the collector can consume.
* The actual implementation of FileAccessEventSource doesn't have to support this.
* @param event The event that generated from Smart client
*/
void insertEventFromSmartClient(FileAccessEvent event);
(2). FileAccessEventCollector
采集器可生产文件访问事件,封装在队列`LinkedBlockingQueue`中,从队列中生产、消费数据;
/**
* Collect file access events occured since last calling of this method.
* @return access events
* @throws IOException
*/
List<FileAccessEvent> collect() throws IOException;
(3). AccessEventFetcher
获取所有的FileAccess Event,每个访问时间放在一个聚合窗口中。
(4). StatesUpdateService
对HDFS组件的事件进行更新处理,则基于实现`HdfsStatesUpdateService`,实现包括:
Init初始化:
Start操作:
(5). RulePlugin
规则插件,管理规则生命周期的调用,主要提供以下方法:
void onAddingNewRule(RuleInfo ruleInfo, TranslateResult tr) throws IOException;
void onNewRuleAdded(RuleInfo ruleInfo, TranslateResult tr);
依赖`StatesManager`,`CmdletManager`,创建时依赖`RuleExecutorPlugin`,规则执行插件:
(1). RuleExecutorPlugin
规则执行插件主要提供以下方法:
/**
* Called just before an RuleExecutor been generated and submitted to
* thread pool for execution. Only called once per instance.
*
* @param ruleInfo
* @param tResult
*/
void onNewRuleExecutor(final RuleInfo ruleInfo, TranslateResult tResult);
/**
* Called just before rule executor begin to execute rule.
*
* @param ruleInfo
* @param tResult
* @return continue this execution if true.
*/
boolean preExecution(final RuleInfo ruleInfo, TranslateResult tResult);
/**
* Called after rule condition checked.
*
* @param objects the result of checking rule condition.
* @return object list that will be used for Cmdlet submission.
*/
List<String> preSubmitCmdlet(final RuleInfo ruleInfo, List<String> objects);
/**
* Called right before the CmdletDescriptor been submitted to CmdletManager.
*
* @param descriptor
* @return the descriptor that will be used to submit to CmdletManager
*/
CmdletDescriptor preSubmitCmdletDescriptor(final RuleInfo ruleInfo, TranslateResult tResult,
CmdletDescriptor descriptor);
/**
* Called when an RuleExecutor exits. Called only once per instance.
*
* @param ruleInfo
*/
void onRuleExecutorExit(final RuleInfo ruleInfo);
已经实现的规则插件包括:
(2). SmartRuleStringParser
将字符串规则转换为规则对象,基于`antlr`进行规则转换,`Lexer`进行分析,`Parser`进行解析,`SmartRuleBaseVisitor`转为对象,最为后`TranslateResult`.
ParseTree tree = parser.ssmrule();
(3). RuleInfoRepo
可以有`RuleInfo`获取,关键方法`launchExecutor`,获取`RuleExecutor`;
(4). RuleManager
规则生命周期管理,关键方法包括:
(5). RuleExecutor
Server实现下发执行的线程,核心类,核心方法`submitCmdlets`,最终由`CmdletManager.submitCmdlet(cmd)` 完成
RuleManager.start
-> RuleExecutor.run()
-> CmdletManager.submitCmdlet
(1). CmdletManager
CMD执行管理,主要包括
(2). CmdletDescriptor
CmdletDescriptor生成对应的`CmdletInfo`和对应的执行`ActionInfo`,核心`ScheduleTask` ,执行方法`scheduleCmdletActions`
CmdletDescriptor
->CmdletInfo
->List<ActionInfo> actionInfos
(3). ActionScheduler
主要提供Action生命周期相关的调度管理方法:
/**
* Called when new action submitted to CmdletManager.
*
* @param cmdletInfo info about the cmdlet which the action belongs to
* @param actionInfo
* @param actionIndex index of the action in cmdlet,
* @return acceptable if true, or discard
* @throws IOException
*/
boolean onSubmit(CmdletInfo cmdletInfo, ActionInfo actionInfo, int actionIndex)
throws IOException;
/**
* Trying to schedule an action for Dispatch.
*
* @param cmdletInfo
* @param actionInfo
* @param cmdlet
* @param action
* @param actionIndex
* @return
*/
ScheduleResult onSchedule(CmdletInfo cmdletInfo, ActionInfo actionInfo,
LaunchCmdlet cmdlet, LaunchAction action, int actionIndex);
/**
* Called after and an Cmdlet get scheduled.
*
* @param actionInfo
* @param result
*/
void postSchedule(CmdletInfo cmdletInfo, ActionInfo actionInfo, int actionIndex,
ScheduleResult result);
/**
* Called just before dispatch for execution.
*
* @param action
*/
void onPreDispatch(LaunchCmdlet cmdlet, LaunchAction action, int actionIndex);
/**
* Called when action finished execution.
*
* @param actionInfo
*/
void onActionFinished(CmdletInfo cmdletInfo, ActionInfo actionInfo, int actionIndex);
Agent执行Server下发的命令,Cmdlet:线程类,调用`SmartAction.run` 执行。
HDFS存储管理系统,对于公司内部的数据平台影响价值可能较小,相比于繁杂的系统搭建维护成本,可以选择更直接的人工运维操作来管理存储系统。而对于商业化数据平台,完善的存储管理系统则具备很高的附加值,大数据平台可以封装了整套存储管理能力,让客户开箱即用,减少客户的运维投入。
SSM系统是少有的HDFS存储管理开源系统,主要以线程模式进行轻量化的运维任务调度,目前该项目已停止维护。虽然,SSM开源实现的整体功能并不完善,且设计比较偏复杂,但可以参考借鉴该设计思想简化出更符合使用场景的存储管理系统。
如图展示参考SSM设计思想,简化实现的存储资源&计算资源管理的轻量级任务引擎架构:
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。