From 92378a2d2808b102dee0e08d5480490b8d0d6d51 Mon Sep 17 00:00:00 2001 From: zeekling Date: Sun, 4 Aug 2024 00:08:15 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0ContainerManager?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- yarn/containerManager.md | 49 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/yarn/containerManager.md b/yarn/containerManager.md index a39f10c..34e6acd 100644 --- a/yarn/containerManager.md +++ b/yarn/containerManager.md @@ -92,3 +92,52 @@ app.handle(new ApplicationContainerInitEvent(container)); 此状态会重新拉起所有的Container。 +# 启动Containers + +## 获取NMToken + +在Container启动之前需要获取NMToken,可以通过下面命令获取,一般情况下获取第一个NMTokenIdentifier类型的Token。 + +```java +Set tokenIdentifiers = remoteUgi.getTokenIdentifiers(); +``` + +## 开始启动Container + +启动之前需要做的就是初始化ContainerImpl信息,方便后续启动Container。 + +```java +Container container = + new ContainerImpl(getConfig(), this.dispatcher, + launchContext, credentials, metrics, containerTokenIdentifier, + context, containerStartTime); + +``` + +如果是第一次启动(满足条件:`!context.getApplications().containsKey(applicationID))`,也就是AM,会通过下面命令触发作业的启动: + +```java +context.getNMStateStore().storeApplication(applicationID, + buildAppProto(applicationID, user, credentials, appAcls, + logAggregationContext, flowContext)); +dispatcher.getEventHandler().handle(new ApplicationInitEvent( + applicationID, appAcls, logAggregationContext)); +``` + +满足下面条件则是恢复Application: + +`containerTokenIdentifier.getContainerType() == ContainerType.APPLICATION_MASTER && context.getApplications().containsKey(applicationID))` + +启动Container主要是触发Container的Init事件: + +```java +this.context.getNMStateStore().storeContainer(containerId, + containerTokenIdentifier.getVersion(), containerStartTime, request); +dispatcher.getEventHandler().handle( + new ApplicationContainerInitEvent(container)); +``` + +## Container事件处理 + + +