*/
public SpringYarnConfigBuilder() {}
@Override
protected SpringYarnConfigs performBuild() throws Exception {
SpringYarnConfigs config = new SpringYarnConfigs();
// shared objects are created in SpringYarnConfigurerAdapter
YarnConfigBuilder sharedObject = getSharedObject(YarnConfigBuilder.class);
log.info("Existing yarnConfiguration: " + YarnUtils.toString(yarnConfiguration));
Configuration buildConfiguration = getSharedObject(YarnConfigBuilder.class).build();
// TODO: we should find better way to merge configs
Configuration configuration = (yarnConfiguration == null)
? buildConfiguration
: YarnUtils.merge(buildConfiguration, yarnConfiguration);
if (log.isDebugEnabled()) {
log.debug("YarnConfigBuilder shared: " + sharedObject);
log.debug("Existing buildConfiguration: " + YarnUtils.toString(buildConfiguration));
}
log.info("Setting configuration for SpringYarnConfigs: " + YarnUtils.toString(configuration));
config.setConfiguration(configuration);
YarnResourceLocalizerBuilder yarnResourceLocalizerBuilder = getSharedObject(YarnResourceLocalizerBuilder.class);
yarnResourceLocalizerBuilder.configuration(configuration);
ResourceLocalizer localizer = yarnResourceLocalizerBuilder.build();
config.setLocalizer(localizer);
YarnEnvironmentBuilder yarnEnvironmentBuilder = getSharedObject(YarnEnvironmentBuilder.class);
yarnEnvironmentBuilder.configuration(configuration);
Map<String, Map<String, String>> envs = yarnEnvironmentBuilder.build();
Map<String, String> env = envs.get(null);
config.setEnvironment(env);
YarnClientBuilder yarnClientBuilder = getSharedObject(YarnClientBuilder.class);
if (yarnClientBuilder != null) {
yarnClientBuilder.configuration(configuration);
yarnClientBuilder.setResourceLocalizer(localizer);
yarnClientBuilder.setEnvironment(env);
config.setYarnClient(yarnClientBuilder.build());
}
YarnAppmasterBuilder yarnAppmasterBuilder = getSharedObject(YarnAppmasterBuilder.class);
if (yarnAppmasterBuilder != null) {
yarnAppmasterBuilder.configuration(configuration);
yarnAppmasterBuilder.setResourceLocalizer(localizer);
yarnAppmasterBuilder.setEnvironment(env);
yarnAppmasterBuilder.setEnvironments(envs);
config.setYarnAppmaster(yarnAppmasterBuilder.build());
}
YarnContainerBuilder yarnContainerBuilder = getSharedObject(YarnContainerBuilder.class);
if (yarnContainerBuilder != null) {
yarnContainerBuilder.configuration(configuration);
config.setYarnContainer(yarnContainerBuilder.build());
}
return config;
}