增加ContainerManager

This commit is contained in:
LingZhaoHui 2024-08-04 00:08:15 +08:00
parent c9a5063b58
commit 92378a2d28
Signed by: zeekling
GPG Key ID: D96E4E75267CA2CC

View File

@ -92,3 +92,52 @@ app.handle(new ApplicationContainerInitEvent(container));
此状态会重新拉起所有的Container。 此状态会重新拉起所有的Container。
# 启动Containers
## 获取NMToken
在Container启动之前需要获取NMToken,可以通过下面命令获取一般情况下获取第一个NMTokenIdentifier类型的Token。
```java
Set<TokenIdentifier> 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事件处理