overview
INIT_APPLICATION Handle
收到 该 事件通知,Application 保存当前的用户的ACL信息,并通知logHandler,记录用户信息,App进入INITING状态:
app.applicationACLs = initEvent.getApplicationACLs();
app.aclsManager.addApplication(app.getAppId(), app.applicationACLs);
// Inform the logAggregator
app.dispatcher.getEventHandler().handle(
new LogHandlerAppStartedEvent(app.appId, app.user,
app.credentials, ContainerLogsRetentionPolicy.ALL_CONTAINERS,
app.applicationACLs));
LogHandler记录用户信息之后,发送事件通知:APPLICATION_LOG_HANDLING_INITED 到App
this.appOwners.put(appStartedEvent.getApplicationId(),
appStartedEvent.getUser());
this.dispatcher.getEventHandler().handle(
new ApplicationEvent(appStartedEvent.getApplicationId(),
ApplicationEventType.APPLICATION_LOG_HANDLING_INITED));
APPLICATION_LOG_HANDLING_INITED Handle
收到该事件之后,App 发送ApplicationLocalizationEvent 去请求Localization Resource 信息。在请求的resource 返回之前,App一直停留在INITING状态:
app.dispatcher.getEventHandler().handle(
new ApplicationLocalizationEvent(
LocalizationEventType.INIT_APPLICATION_RESOURCES, app));
ResourceLocalizationService收到该事件之后,为前用户初始化LocalResourceTracker对像,并发送:APPLICATION_INITED 通知App:
privateRsrc.putIfAbsent(userName, new LocalResourcesTrackerImpl(userName,
dispatcher, true, super.getConfig()));
if (null != appRsrc.putIfAbsent(
ConverterUtils.toString(app.getAppId()),
new LocalResourcesTrackerImpl(app.getUser(), dispatcher, false, super
.getConfig()))) {
LOG.warn("Initializing application " + app + " already present");
assert false; // TODO: FIXME assert doesn't help
// ^ The condition is benign. Tests should fail and it
// should appear in logs, but it's an internal error
// that should have no effect on applications
}
// 1) Signal container init
//
// This is handled by the ApplicationImpl state machine and allows
// containers to proceed with launching.
dispatcher.getEventHandler().handle(new ApplicationInitedEvent(
app.getAppId()));
APPLICATION_INITED Handle
收到该事件,App将发送INIT_CONTAINER 通知container初始化, App进入Running状态:
// Start all the containers waiting for ApplicationInit
for (Container container : app.containers.values()) {
app.dispatcher.getEventHandler().handle(new ContainerInitEvent(
container.getContainer().getId()));
}
之后App 等待Finish事件,并 执行保存清理工作, 并退出 。