Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,16 @@ object YarnJob extends Logging {
@VisibleForTesting
private[yarn] def buildEnvironment(config: Config, yarnConfig: YarnConfig,
jobConfig: JobConfig): Map[String, String] = {
val coordinatorSystemConfig = CoordinatorStreamUtil.buildCoordinatorStreamConfig(config)
val envMapBuilder = Map.newBuilder[String, String]
envMapBuilder += ShellCommandConfig.ENV_COORDINATOR_SYSTEM_CONFIG ->
Util.envVarEscape(SamzaObjectMapper.getObjectMapper.writeValueAsString(coordinatorSystemConfig))
if (jobConfig.getConfigLoaderFactory.isPresent) {
envMapBuilder += ShellCommandConfig.ENV_SUBMISSION_CONFIG ->
Util.envVarEscape(SamzaObjectMapper.getObjectMapper.writeValueAsString(config))
} else {
// TODO SAMZA-2432: Clean this up once SAMZA-2405 is completed when legacy flow is removed.
val coordinatorSystemConfig = CoordinatorStreamUtil.buildCoordinatorStreamConfig(config)
envMapBuilder += ShellCommandConfig.ENV_COORDINATOR_SYSTEM_CONFIG ->
Util.envVarEscape(SamzaObjectMapper.getObjectMapper.writeValueAsString(coordinatorSystemConfig))
}
envMapBuilder += ShellCommandConfig.ENV_JAVA_OPTS -> Util.envVarEscape(yarnConfig.getAmOpts)
val clusterBasedJobCoordinatorDependencyIsolationEnabled =
jobConfig.getClusterBasedJobCoordinatorDependencyIsolationEnabled
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,24 @@ public void testBuildEnvironmentWithAMJavaHome() throws IOException {
assertEquals(expected, JavaConverters.mapAsJavaMapConverter(
YarnJob$.MODULE$.buildEnvironment(config, new YarnConfig(config), new JobConfig(config))).asJava());
}

@Test
public void testBuildJobSubmissionEnvironment() throws IOException {
Config config = new MapConfig(new ImmutableMap.Builder<String, String>()
.put(JobConfig.JOB_NAME, "jobName")
.put(JobConfig.JOB_ID, "jobId")
.put(JobConfig.CONFIG_LOADER_FACTORY, "org.apache.samza.config.loaders.PropertiesConfigLoaderFactory")
.put(YarnConfig.AM_JVM_OPTIONS, "")
.put(JobConfig.CLUSTER_BASED_JOB_COORDINATOR_DEPENDENCY_ISOLATION_ENABLED, "true")
.build());
String expectedSubmissionConfig = Util.envVarEscape(SamzaObjectMapper.getObjectMapper()
.writeValueAsString(config));
Map<String, String> expected = ImmutableMap.of(
ShellCommandConfig.ENV_SUBMISSION_CONFIG(), expectedSubmissionConfig,
ShellCommandConfig.ENV_JAVA_OPTS(), "",
ShellCommandConfig.ENV_CLUSTER_BASED_JOB_COORDINATOR_DEPENDENCY_ISOLATION_ENABLED(), "true",
ShellCommandConfig.ENV_APPLICATION_LIB_DIR(), "./__package/lib");
assertEquals(expected, JavaConverters.mapAsJavaMapConverter(
YarnJob$.MODULE$.buildEnvironment(config, new YarnConfig(config), new JobConfig(config))).asJava());
}
}