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 27, 2024
1 parent 30e9cdb commit 868b2a2
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ public abstract ApplicationId submitApplication(ApplicationSubmissionContext app

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

public abstract String getAmHost();
public abstract int getAmPort();

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();
}
}
15 changes: 15 additions & 0 deletions tez-api/src/main/java/org/apache/tez/client/TezYarnClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ public class TezYarnClient extends FrameworkClient {

private volatile boolean isRunning;

private String amHost;
private int amPort;

protected TezYarnClient(YarnClient yarnClient) {
this.yarnClient = yarnClient;
}
Expand Down Expand Up @@ -100,11 +103,23 @@ 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;
}

@Override
public boolean isRunning() throws IOException {
return isRunning;
}

@Override
public String getAmHost() {
return amHost;
}

@Override
public int getAmPort() {
return amPort;
}
}
19 changes: 19 additions & 0 deletions tez-api/src/test/java/org/apache/tez/client/TestTezClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,16 @@ protected DAGClientAMProtocolBlockingPB getProxy(Configuration conf, Application
}
return super.getProxy(conf, sessionAppId, ugi);
}

@Override
public String getAmHost() {
return "testhost";
}

@Override
public int getAmPort() {
return 1234;
}
}

TezClientForTest configureAndCreateTezClient() throws YarnException, IOException, ServiceException {
Expand Down Expand Up @@ -1005,4 +1015,13 @@ public void testYarnZkDeprecatedConf() {
//Test that Exception is not thrown by createFinalConfProtoForApp
TezClientUtils.createFinalConfProtoForApp(conf, null);
}

@Test
public void testGetAmHostAndPort() throws Exception {
final TezClientForTest client = configureAndCreateTezClient(new TezConfiguration());

// TezClient exposes AM host and port from the FrameworkClient (now it's a TezYarnClientForTest)
assertEquals("testhost", client.getAmHost());
assertEquals(1234, client.getAmPort());
}
}
15 changes: 15 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 @@ -88,6 +88,8 @@ public class LocalClient extends FrameworkClient {
private TezApiVersionInfo versionInfo = new TezApiVersionInfo();
private volatile Throwable amFailException = null;
private boolean isLocalWithoutNetwork;
private String amHost;
private int amPort;

private static final String localModeDAGSchedulerClassName =
"org.apache.tez.dag.app.dag.impl.DAGSchedulerNaturalOrderControlled";
Expand Down Expand Up @@ -204,6 +206,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 Expand Up @@ -475,4 +480,14 @@ public boolean shutdownSession(Configuration configuration, ApplicationId sessio
}
return super.shutdownSession(configuration, sessionAppId, ugi);
}

@Override
public String getAmHost() {
return amHost;
}

@Override
public int getAmPort() {
return amPort;
}
}

0 comments on commit 868b2a2

Please sign in to comment.