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

Attach more readable info to task executor's thread #650

Merged
merged 1 commit into from
Mar 7, 2022
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 @@ -96,6 +96,7 @@ public class ApplicationMaster {
* Metadata + History Server related variables
*/
private String appIdString;
private String applicationName;
private FileSystem resourceFs; // FileSystem used to access resources for the job, like jars and zips
private FileSystem historyFs; // FileSystem used to write history-related files like config and events.
// In some HDFS setups, operators may wish to write history files to a different
Expand Down Expand Up @@ -283,6 +284,9 @@ private boolean init(String[] args) {
TonyConfigurationKeys.DEFAULT_FRAMEWORK_NAME).toUpperCase();
amRuntimeAdapter = FrameworkRuntimeProvider.getAMAdapter(frameworkType);

applicationName = tonyConf.get(TonyConfigurationKeys.APPLICATION_NAME,
TonyConfigurationKeys.DEFAULT_APPLICATION_NAME);

if (!amRuntimeAdapter.validateAndUpdateConfig(tonyConf)) {
LOG.error("Invalid TonY conf.");
return false;
Expand Down Expand Up @@ -1191,7 +1195,7 @@ public void run() {
containerLaunchEnv.put(Constants.SESSION_ID, String.valueOf(session.sessionId));

List<CharSequence> arguments = new ArrayList<>(5);
arguments.add(session.getTaskCommand());
arguments.add(session.getTaskCommand(appIdString, applicationName, jobName, taskIndex));
arguments.add("1>" + ApplicationConstants.LOG_DIR_EXPANSION_VAR + "/stdout");
arguments.add("2>" + ApplicationConstants.LOG_DIR_EXPANSION_VAR + "/stderr");
List<String> commands = ImmutableList.of(String.join(" ", arguments));
Expand Down
20 changes: 18 additions & 2 deletions tony-core/src/main/java/com/linkedin/tony/TonySession.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,22 @@ public enum TaskType {
TASK_TYPE_CHIEF, TASK_TYPE_PARAMETER_SERVER, TASK_TYPE_OTHERS
}

public String getTaskCommand() {
@VisibleForTesting
public String getTaskCommand(String appIdString, String applicationName, String taskName, String taskIndex) {
StringBuilder cmd = new StringBuilder();
cmd.append("$JAVA_HOME/bin/java ")
.append(jvmArgs)
.append(" com.linkedin.tony.TaskExecutor");
.append(" com.linkedin.tony.TaskExecutor ")
.append(" appId=")
.append(appIdString)
.append(" ")
.append(" appName=")
.append(applicationName)
.append(" ")
.append(" task=")
.append(taskName)
.append(":")
.append(taskIndex);
return cmd.toString();
}

Expand Down Expand Up @@ -680,4 +691,9 @@ public void makeTaskTypeUntracked(String taskType) {
untrackedList.add(taskType);
tonyConf.set(UNTRACKED_JOBTYPES, StringUtils.join(untrackedList, ","));
}

/** Only for test cases. */
protected void setJvmArgs(String jvmArgs) {
this.jvmArgs = jvmArgs;
}
}
11 changes: 11 additions & 0 deletions tony-core/src/test/java/com/linkedin/tony/TestTonySession.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,15 @@ public void testTaskComparable() {
Assert.assertEquals(ps1.compareTo(samePs1), 0);
Assert.assertEquals(worker1.compareTo(sameWorker1), 0);
}

@Test
public void testGetTaskCommand() {
Configuration tonyConf = new Configuration(false);
TonySession session = new TonySession.Builder().setTonyConf(tonyConf).build();
session.setJvmArgs("");

String commandline = session.getTaskCommand("application_1645363183601_0001", "tony_tensorflow", "ps", "1");
Assert.assertEquals(commandline, "$JAVA_HOME/bin/java com.linkedin.tony.TaskExecutor "
+ "appId=application_1645363183601_0001 appName=tony_tensorflow task=ps:1");
}
}