Skip to content

Commit

Permalink
TEZ-4564: TezClient to expose Tez AM host:port
Browse files Browse the repository at this point in the history
  • Loading branch information
abstractdog committed May 16, 2024
1 parent a1fcddb commit cefab38
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tez-api/src/main/java/org/apache/tez/client/FrameworkClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@
public abstract class FrameworkClient {
protected static final Logger LOG = LoggerFactory.getLogger(FrameworkClient.class);

protected String amHost = null;
protected int amPort = -1;

public static FrameworkClient createFrameworkClient(TezConfiguration tezConf) {

boolean isLocal = tezConf.getBoolean(TezConfiguration.TEZ_LOCAL_MODE, TezConfiguration.TEZ_LOCAL_MODE_DEFAULT);
Expand Down Expand Up @@ -94,6 +97,20 @@ public abstract ApplicationId submitApplication(ApplicationSubmissionContext app

public abstract ApplicationReport getApplicationReport(ApplicationId appId) throws YarnException, IOException;

public String getAmHost() {
if (amHost == null) {
throw new IllegalStateException("AM Host is not set when called, please check FrameworkClient implementation");
}
return amHost;
}

public int getAmPort() {
if (amPort == -1) {
throw new IllegalStateException("AM Port is not set when called, please check FrameworkClient implementation");
}
return amPort;
}

public abstract boolean isRunning() throws IOException;

public TezAppMasterStatus getAMStatus(Configuration conf, ApplicationId appId,
Expand Down
8 changes: 8 additions & 0 deletions tez-api/src/main/java/org/apache/tez/client/TezClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -1286,4 +1286,12 @@ public static ApplicationId appIdfromString(String appIdStr) {
+ appIdStr, n);
}
}

public String getAmHost() {
return frameworkClient.getAmHost();
}

public int getAmPort() {
return frameworkClient.getAmPort();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ public ApplicationReport getApplicationReport(ApplicationId appId) throws YarnEx
throw new ApplicationNotFoundException("YARN reports no state for application "
+ appId);
}
this.amHost = report.getHost();
this.amPort = report.getRpcPort();
return report;
}

Expand Down
3 changes: 3 additions & 0 deletions tez-dag/src/main/java/org/apache/tez/client/LocalClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,9 @@ public ApplicationReport getApplicationReport(ApplicationId appId) {
report.setProgress(dagAppMaster.getProgress());
report.setAMRMToken(null);

this.amHost = dagAppMaster.getAppNMHost();
this.amPort = dagAppMaster.getRpcPort();

return report;
}

Expand Down

0 comments on commit cefab38

Please sign in to comment.