Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GOBBLIN-1818] initilaize yarn clients in yarn app launcher so that a child class can override the yarn client creation logic #3679

Merged
merged 1 commit into from
Apr 17, 2023
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 @@ -80,7 +80,9 @@ public AzkabanGobblinYarnAppLauncher(String jobId, Properties gobblinProps)

protected GobblinYarnAppLauncher getYarnAppLauncher(Config gobblinConfig)
throws IOException {
return new GobblinYarnAppLauncher(gobblinConfig, this.yarnConfiguration);
GobblinYarnAppLauncher gobblinYarnAppLauncher = new GobblinYarnAppLauncher(gobblinConfig, this.yarnConfiguration);
gobblinYarnAppLauncher.initializeYarnClients(gobblinConfig);
return gobblinYarnAppLauncher;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,10 @@
* this count exceeds the maximum number allowed, it will initiate a shutdown.
* </p>
*
* <p>
* Users of {@link GobblinYarnAppLauncher} need to call {@link #initializeYarnClients} which a child class can override.
* </p>
*
* @author Yinan Li
*/
public class GobblinYarnAppLauncher {
Expand Down Expand Up @@ -260,7 +264,6 @@ public GobblinYarnAppLauncher(Config config, YarnConfiguration yarnConfiguration
YarnHelixUtils.setAdditionalYarnClassPath(config, this.yarnConfiguration);
this.yarnConfiguration.set("fs.automatic.close", "false");
this.originalYarnRMAddress = this.yarnConfiguration.get(GobblinYarnConfigurationKeys.YARN_RESOURCE_MANAGER_ADDRESS);
createPotentialYarnClients(config, this.potentialYarnClients);

this.fs = GobblinClusterUtils.buildFileSystem(config, this.yarnConfiguration);
this.closer.register(this.fs);
Expand Down Expand Up @@ -323,14 +326,14 @@ public GobblinYarnAppLauncher(Config config, YarnConfiguration yarnConfiguration
}
}

protected void createPotentialYarnClients(Config config, Map<String, YarnClient> potentialYarnClients) {
public void initializeYarnClients(Config config) {
Set<String> potentialRMAddresses = new HashSet<>(ConfigUtils.getStringList(config, GobblinYarnConfigurationKeys.OTHER_YARN_RESOURCE_MANAGER_ADDRESSES));
potentialRMAddresses.add(originalYarnRMAddress);
for (String rmAddress : potentialRMAddresses) {
YarnClient tmpYarnClient = YarnClient.createYarnClient();
this.yarnConfiguration.set(GobblinYarnConfigurationKeys.YARN_RESOURCE_MANAGER_ADDRESS, rmAddress);
tmpYarnClient.init(new YarnConfiguration(this.yarnConfiguration));
potentialYarnClients.put(rmAddress, tmpYarnClient);
this.potentialYarnClients.put(rmAddress, tmpYarnClient);
}
}

Expand Down Expand Up @@ -1069,6 +1072,8 @@ static Config addMetricReportingDynamicConfig(Config config, KafkaAvroSchemaRegi
public static void main(String[] args) throws Exception {
final GobblinYarnAppLauncher gobblinYarnAppLauncher =
new GobblinYarnAppLauncher(ConfigFactory.load(), new YarnConfiguration());
gobblinYarnAppLauncher.initializeYarnClients(ConfigFactory.load());

Runtime.getRuntime().addShutdownHook(new Thread() {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ public void setUp() throws Exception {
InstanceType.CONTROLLER, zkConnectionString);

this.gobblinYarnAppLauncher = new GobblinYarnAppLauncher(this.config, clusterConf);
this.gobblinYarnAppLauncher.initializeYarnClients(this.config);

this.configManagedHelix = ConfigFactory.parseURL(url)
.withValue("gobblin.cluster.zk.connection.string",
Expand All @@ -213,6 +214,7 @@ public void setUp() throws Exception {
InstanceType.PARTICIPANT, zkConnectionString);

this.gobblinYarnAppLauncherManagedHelix = new GobblinYarnAppLauncher(this.configManagedHelix, clusterConf);
this.gobblinYarnAppLauncherManagedHelix.initializeYarnClients(this.configManagedHelix);
}

@Test
Expand Down