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

The following examples show how to use org.apache.hadoop.yarn.api.records.ApplicationReport#getApplicationId() . 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: Utils.java    From AthenaX with Apache License 2.0 6 votes vote down vote up
static InstanceInfo extractInstanceInfo(String clusterName, ApplicationReport report) {
  InstanceMetadata md = getMetadata(report.getApplicationTags());
  if (md == null) {
    return null;
  }

  ApplicationResourceUsageReport usage = report.getApplicationResourceUsageReport();
  InstanceStatus stat = new InstanceStatus()
      .allocatedVCores((long) usage.getUsedResources().getVirtualCores())
      .allocatedMB((long) usage.getUsedResources().getMemory())
      .clusterId(clusterName)
      .applicationId(report.getApplicationId().toString())
      .startedTime(report.getStartTime())
      .runningContainers((long) usage.getNumUsedContainers())
      .trackingUrl(report.getTrackingUrl())
      .state(InstanceStatus.StateEnum.fromValue(report.getYarnApplicationState().toString()));
  return new InstanceInfo(clusterName, report.getApplicationId(), md, stat);
}
 
Example 3
Source File: YarnJobValidationTool.java    From samza with Apache License 2.0 6 votes vote down vote up
public ApplicationId validateAppId() throws Exception {
  // fetch only the last created application with the job name and id
  // i.e. get the application with max appId
  ApplicationId appId = null;
  for (ApplicationReport applicationReport : this.client.getApplications()) {
    if (applicationReport.getName().equals(this.jobName)) {
      ApplicationId id = applicationReport.getApplicationId();
      if (appId == null || appId.compareTo(id) < 0) {
        appId = id;
      }
    }
  }
  if (appId != null) {
    log.info("Job lookup success. ApplicationId " + appId.toString());
    return appId;
  } else {
    throw new SamzaException("Job lookup failure " + this.jobName);
  }
}
 
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: YarnClusterDescriptor.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Override
protected ClusterClient<ApplicationId> createYarnClusterClient(
		AbstractYarnClusterDescriptor descriptor,
		int numberTaskManagers,
		int slotsPerTaskManager,
		ApplicationReport report,
		Configuration flinkConfiguration,
		boolean perJobCluster) throws Exception {
	return new RestClusterClient<>(
		flinkConfiguration,
		report.getApplicationId());
}
 
Example 6
Source File: YarnClusterDescriptor.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
protected ClusterClient<ApplicationId> createYarnClusterClient(
		AbstractYarnClusterDescriptor descriptor,
		int numberTaskManagers,
		int slotsPerTaskManager,
		ApplicationReport report,
		Configuration flinkConfiguration,
		boolean perJobCluster) throws Exception {
	return new RestClusterClient<>(
		flinkConfiguration,
		report.getApplicationId());
}
 
Example 7
Source File: YarnJobDescriptor.java    From sylph with Apache License 2.0 5 votes vote down vote up
@Override
protected ClusterClient<ApplicationId> createYarnClusterClient(
        AbstractYarnClusterDescriptor descriptor,
        int numberTaskManagers,
        int slotsPerTaskManager,
        ApplicationReport report,
        Configuration flinkConfiguration,
        boolean perJobCluster)
        throws Exception
{
    return new RestClusterClient<>(flinkConfiguration, report.getApplicationId());
}
 
Example 8
Source File: OlapServerSubmitter.java    From spliceengine with GNU Affero General Public License v3.0 5 votes vote down vote up
private ApplicationId findApplication(YarnClient yarnClient) throws IOException, YarnException {
    List<ApplicationReport> reports = yarnClient.getApplications(Collections.singleton("YARN"),
            EnumSet.of(YarnApplicationState.RUNNING, YarnApplicationState.SUBMITTED, YarnApplicationState.ACCEPTED, YarnApplicationState.NEW, YarnApplicationState.NEW_SAVING));
    for (ApplicationReport ar : reports) {
        if (ar.getName().equals("OlapServer-"+queueName) && ar.getUser().equals(UserGroupInformation.getCurrentUser().getUserName())) {
            LOG.info("Found existing application: " + ar);
            return ar.getApplicationId();
        }
    }
    return null;
}
 
Example 9
Source File: EmrClusterJob.java    From datacollector with Apache License 2.0 4 votes vote down vote up
@Override
public Properties getJobStatus(Properties jobProps) throws IOException {
  EMRJobConfig emrJobConfig = new EMRJobConfig(jobProps);
  Utils.checkNotNull(emrJobConfig.getClusterId(), "EMR Cluster Id");
  String state;
  String message = null;
  DescribeStepResult res = getEmrClient(emrClusterConfig).describeStep(new DescribeStepRequest().withClusterId(
      emrJobConfig.getClusterId()).withStepId(emrJobConfig.getStepId()));
  StepStatus status = res.getStep().getStatus();
  ApplicationId appId = null;
  LOG.debug(Utils.format("Status of step: {} is {}", emrJobConfig.getStepId(), status.getState()));
  if ("PENDING".equals(status.getState())) {
    state = status.getState();
    if (status.getStateChangeReason() != null) {
      message = status.getStateChangeReason().getMessage();
    }
  } else if (!"COMPLETED".equals(status.getState()) && !"RUNNING".equals(status.getState())) {
    state = status.getState();
    if (status.getFailureDetails() != null) {
      message = status.getFailureDetails().getReason();
    }
  } else {
    YarnClient yarnClient = getYarnClient(emrJobConfig.getClusterId(), emrClusterConfig);
    ApplicationReport report = null;
    try {
      for (ApplicationReport applicationReport : yarnClient.getApplications()) {
        if (applicationReport.getName().contains(emrJobConfig.getUniquePrefix())) {
          appId = applicationReport.getApplicationId();
          break;
        }
      }
      if (appId != null) {
        report = yarnClient.getApplicationReport(appId);
      }
    } catch (YarnException ex) {
      throw new IOException("Failed to fetch yarn app report " + ex);
    }
    if (report != null) {
      YarnApplicationState yarnState = report.getYarnApplicationState();
      FinalApplicationStatus finalApplicationStatus = report.getFinalApplicationStatus();
      LOG.info(Utils.format("Application state for app id: {} is {} ", appId, yarnState));
      state = yarnState.name();
      if (YarnApplicationState.FINISHED == yarnState) {
        // override with final application state if yarnState is FINISHED
        state = finalApplicationStatus.name();
      }
      message = report.getDiagnostics();
    } else {
      state = "STARTING"; // a situation where step was in RUNNING but yarn application not yet created.
      message = "Yarn application not yet created";
    }
  }
  EmrState emrJobState = new EmrState();
  emrJobState.setState(state);
  emrJobState.setMessage(message);
  emrJobState.setAppId(appId != null ? appId.toString() : null);
  return emrJobState.toProperties();
}
 
Example 10
Source File: SchedulerApplication.java    From cloudbreak with Apache License 2.0 4 votes vote down vote up
public SchedulerApplication(ApplicationReport appReport, Priority priority) {
    applicationId = appReport.getApplicationId();
    startTime = appReport.getStartTime();
    this.priority = priority;
}
 
Example 11
Source File: RMCommunicator.java    From jumbune with GNU Lesser General Public License v3.0 2 votes vote down vote up
/**
 * Get the Job Id for the given Application Report.
 *
 * @param report the report
 * @return the job id
 */
public JobId getJobId(ApplicationReport report){
	ApplicationId applicationId = report.getApplicationId();
	return MRBuilderUtils.newJobId(applicationId, applicationId.getId());
}