YARN为了实现多个状态机的对象,控制ResourceManager中间RMAppImpl、RMApp-AttemptImpl、RMContainerImpl和RMNodeImpl,NodeManager中的ApplicationImpl、ContainerImpl和LocalizedResource,MRAppMaster中的JobImpl、TaskImpl和TaskAttemptImpl等。
为了便于用户查看这些状态机的状态变化以及相关事件。YARN提供了一个状态机可视化工具。详细操作过程例如以下。
步骤1 将状态机转化为graphviz(.gv)格式的文件。在源码根文件夹下运行编译命令例如以下:
mvn compile -Pvisualize
经过该步骤后。本地文件夹中生成了ResourceManager.gv、NodeManager.gv和MapReduce.gv三个graphviz格式的文件。NodeManager.gv文件里LocalizedResource状态机部分内容例如以下:subgraph cluster_LocalizedResource { label="LocalizedResource" "LocalizedResource.FAILED" [ label = FAILED ]; "LocalizedResource.DOWNLOADING" [ label = DOWNLOADING ]; "LocalizedResource.DOWNLOADING" -> "LocalizedResource.DOWNLOADING" [ label = "REQUEST, RELEASE" ]; "LocalizedResource.DOWNLOADING" -> "LocalizedResource.FAILED" [ label = "LOCALIZATION_FAILED" ]; "LocalizedResource.DOWNLOADING" -> "LocalizedResource.LOCALIZED" [ label = "LOCALIZED" ]; "LocalizedResource.INIT" [ label = INIT ]; "LocalizedResource.INIT" -> "LocalizedResource.DOWNLOADING" [ label = "REQUEST" ]; "LocalizedResource.LOCALIZED" [ label = LOCALIZED ]; "LocalizedResource.LOCALIZED" -> "LocalizedResource.LOCALIZED" [ label = "REQUEST, RELEASE" ]; }
步骤2 使用可视化包graphviz中的相关命令生成状态机图,Shell命令详细例如以下:
dot -Tpng NodeManager.gv > NodeManager.png
假设尚未安装graphviz包,操作该步骤之前先要安装该包,cent os安装命令例如以下:sudo yum install graphviz
打开NodeManager.png。例如以下图所看到的(为了便于展示。分拆成了两个图):
版权声明:本文博主原创文章,博客,未经同意不得转载。