Java Code Examples for org.apache.hadoop.yarn.api.records.ApplicationReport#getRpcPort()

The following examples show how to use org.apache.hadoop.yarn.api.records.ApplicationReport#getRpcPort() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: YarnJobDescriptor.java    From sylph with Apache License 2.0 6 votes vote down vote up
public ClusterClient<ApplicationId> deploy(JobGraph jobGraph, boolean detached)
        throws Exception
{
    // this is required because the slots are allocated lazily
    jobGraph.setAllowQueuedScheduling(true);
    //
    ApplicationReport report = startAppMaster(jobGraph);

    Configuration flinkConfiguration = getFlinkConfiguration();

    ClusterEntrypoint.ExecutionMode executionMode = detached ? ClusterEntrypoint.ExecutionMode.DETACHED : ClusterEntrypoint.ExecutionMode.NORMAL;
    flinkConfiguration.setString(ClusterEntrypoint.EXECUTION_MODE, executionMode.toString());
    String host = report.getHost();
    int port = report.getRpcPort();
    flinkConfiguration.setString(JobManagerOptions.ADDRESS, host);
    flinkConfiguration.setInteger(JobManagerOptions.PORT, port);
    flinkConfiguration.setString(RestOptions.ADDRESS, host);
    flinkConfiguration.setInteger(RestOptions.PORT, port);
    return new RestClusterClient<>(flinkConfiguration, report.getApplicationId());
}
 
Example 2
Source File: AppInfo.java    From hadoop with Apache License 2.0 6 votes vote down vote up
public AppInfo(ApplicationReport app) {
  appId = app.getApplicationId().toString();
  if (app.getCurrentApplicationAttemptId() != null) {
    currentAppAttemptId = app.getCurrentApplicationAttemptId().toString();
  }
  user = app.getUser();
  queue = app.getQueue();
  name = app.getName();
  type = app.getApplicationType();
  host = app.getHost();
  rpcPort = app.getRpcPort();
  appState = app.getYarnApplicationState();
  diagnosticsInfo = app.getDiagnostics();
  trackingUrl = app.getTrackingUrl();
  originalTrackingUrl = app.getOriginalTrackingUrl();
  submittedTime = app.getStartTime();
  startedTime = app.getStartTime();
  finishedTime = app.getFinishTime();
  elapsedTime = Times.elapsed(startedTime, finishedTime);
  finalAppStatus = app.getFinalApplicationStatus();
  progress = app.getProgress() * 100; // in percent
  if (app.getApplicationTags() != null && !app.getApplicationTags().isEmpty()) {
    this.applicationTags = CSV_JOINER.join(app.getApplicationTags());
  }
}
 
Example 3
Source File: AppInfo.java    From big-c with Apache License 2.0 6 votes vote down vote up
public AppInfo(ApplicationReport app) {
  appId = app.getApplicationId().toString();
  if (app.getCurrentApplicationAttemptId() != null) {
    currentAppAttemptId = app.getCurrentApplicationAttemptId().toString();
  }
  user = app.getUser();
  queue = app.getQueue();
  name = app.getName();
  type = app.getApplicationType();
  host = app.getHost();
  rpcPort = app.getRpcPort();
  appState = app.getYarnApplicationState();
  diagnosticsInfo = app.getDiagnostics();
  trackingUrl = app.getTrackingUrl();
  originalTrackingUrl = app.getOriginalTrackingUrl();
  submittedTime = app.getStartTime();
  startedTime = app.getStartTime();
  finishedTime = app.getFinishTime();
  elapsedTime = Times.elapsed(startedTime, finishedTime);
  finalAppStatus = app.getFinalApplicationStatus();
  progress = app.getProgress() * 100; // in percent
  if (app.getApplicationTags() != null && !app.getApplicationTags().isEmpty()) {
    this.applicationTags = CSV_JOINER.join(app.getApplicationTags());
  }
}
 
Example 4
Source File: YarnClusterDescriptor.java    From flink with Apache License 2.0 6 votes vote down vote up
private void setClusterEntrypointInfoToConfig(final ApplicationReport report) {
	checkNotNull(report);

	final ApplicationId clusterId = report.getApplicationId();
	final String host = report.getHost();
	final int port = report.getRpcPort();

	LOG.info("Found Web Interface {}:{} of application '{}'.", host, port, clusterId);

	flinkConfiguration.setString(JobManagerOptions.ADDRESS, host);
	flinkConfiguration.setInteger(JobManagerOptions.PORT, port);

	flinkConfiguration.setString(RestOptions.ADDRESS, host);
	flinkConfiguration.setInteger(RestOptions.PORT, port);

	flinkConfiguration.set(YarnConfigOptions.APPLICATION_ID, ConverterUtils.toString(clusterId));
}
 
Example 5
Source File: Client.java    From TensorFlowOnYARN with Apache License 2.0 5 votes vote down vote up
static ClusterSpec getClusterSpec(YarnClient client, ApplicationId appId) throws Exception {
  ClusterSpec clusterSpec = ClusterSpec.empty();
  ApplicationReport report = client.getApplicationReport(appId);
  YarnApplicationState state = report.getYarnApplicationState();
  if (state.equals(YarnApplicationState.RUNNING)) {
    String hostname = report.getHost();
    int port = report.getRpcPort();
    TFApplicationRpc rpc = TFApplicationRpcClient.getInstance(hostname, port);
    String spec = rpc.getClusterSpec();
    if (spec != null) {
      clusterSpec = ClusterSpec.fromJsonString(spec);
    }
  }
  return clusterSpec;
}
 
Example 6
Source File: AbstractYarnClusterDescriptor.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
@Override
public ClusterClient<ApplicationId> retrieve(ApplicationId applicationId) throws ClusterRetrieveException {

	try {
		// check if required Hadoop environment variables are set. If not, warn user
		if (System.getenv("HADOOP_CONF_DIR") == null &&
			System.getenv("YARN_CONF_DIR") == null) {
			LOG.warn("Neither the HADOOP_CONF_DIR nor the YARN_CONF_DIR environment variable is set." +
				"The Flink YARN Client needs one of these to be set to properly load the Hadoop " +
				"configuration for accessing YARN.");
		}

		final ApplicationReport appReport = yarnClient.getApplicationReport(applicationId);

		if (appReport.getFinalApplicationStatus() != FinalApplicationStatus.UNDEFINED) {
			// Flink cluster is not running anymore
			LOG.error("The application {} doesn't run anymore. It has previously completed with final status: {}",
				applicationId, appReport.getFinalApplicationStatus());
			throw new RuntimeException("The Yarn application " + applicationId + " doesn't run anymore.");
		}

		final String host = appReport.getHost();
		final int rpcPort = appReport.getRpcPort();

		LOG.info("Found application JobManager host name '{}' and port '{}' from supplied application id '{}'",
			host, rpcPort, applicationId);

		flinkConfiguration.setString(JobManagerOptions.ADDRESS, host);
		flinkConfiguration.setInteger(JobManagerOptions.PORT, rpcPort);

		flinkConfiguration.setString(RestOptions.ADDRESS, host);
		flinkConfiguration.setInteger(RestOptions.PORT, rpcPort);

		return createYarnClusterClient(
			this,
			-1, // we don't know the number of task managers of a started Flink cluster
			-1, // we don't know how many slots each task manager has for a started Flink cluster
			appReport,
			flinkConfiguration,
			false);
	} catch (Exception e) {
		throw new ClusterRetrieveException("Couldn't retrieve Yarn cluster", e);
	}
}
 
Example 7
Source File: AbstractYarnClusterDescriptor.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public ClusterClient<ApplicationId> retrieve(ApplicationId applicationId) throws ClusterRetrieveException {

	try {
		// check if required Hadoop environment variables are set. If not, warn user
		if (System.getenv("HADOOP_CONF_DIR") == null &&
			System.getenv("YARN_CONF_DIR") == null) {
			LOG.warn("Neither the HADOOP_CONF_DIR nor the YARN_CONF_DIR environment variable is set." +
				"The Flink YARN Client needs one of these to be set to properly load the Hadoop " +
				"configuration for accessing YARN.");
		}

		final ApplicationReport appReport = yarnClient.getApplicationReport(applicationId);

		if (appReport.getFinalApplicationStatus() != FinalApplicationStatus.UNDEFINED) {
			// Flink cluster is not running anymore
			LOG.error("The application {} doesn't run anymore. It has previously completed with final status: {}",
				applicationId, appReport.getFinalApplicationStatus());
			throw new RuntimeException("The Yarn application " + applicationId + " doesn't run anymore.");
		}

		final String host = appReport.getHost();
		final int rpcPort = appReport.getRpcPort();

		LOG.info("Found application JobManager host name '{}' and port '{}' from supplied application id '{}'",
			host, rpcPort, applicationId);

		flinkConfiguration.setString(JobManagerOptions.ADDRESS, host);
		flinkConfiguration.setInteger(JobManagerOptions.PORT, rpcPort);

		flinkConfiguration.setString(RestOptions.ADDRESS, host);
		flinkConfiguration.setInteger(RestOptions.PORT, rpcPort);

		return createYarnClusterClient(
			this,
			-1, // we don't know the number of task managers of a started Flink cluster
			-1, // we don't know how many slots each task manager has for a started Flink cluster
			appReport,
			flinkConfiguration,
			false);
	} catch (Exception e) {
		throw new ClusterRetrieveException("Couldn't retrieve Yarn cluster", e);
	}
}