org.apache.hadoop.yarn.api.records.ApplicationReport Java Examples

The following examples show how to use org.apache.hadoop.yarn.api.records.ApplicationReport. 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: YARNRunner.java    From hadoop with Apache License 2.0 7 votes vote down vote up
private void killUnFinishedApplication(ApplicationId appId)
    throws IOException {
  ApplicationReport application = null;
  try {
    application = resMgrDelegate.getApplicationReport(appId);
  } catch (YarnException e) {
    throw new IOException(e);
  }
  if (application.getYarnApplicationState() == YarnApplicationState.FINISHED
      || application.getYarnApplicationState() == YarnApplicationState.FAILED
      || application.getYarnApplicationState() == YarnApplicationState.KILLED) {
    return;
  }
  killApplication(appId);
}
 
Example #2
Source File: TestApplicationHistoryManagerImpl.java    From hadoop with Apache License 2.0 6 votes vote down vote up
@Test
public void testApplicationReport() throws IOException, YarnException {
  ApplicationId appId = null;
  appId = ApplicationId.newInstance(0, 1);
  writeApplicationStartData(appId);
  writeApplicationFinishData(appId);
  ApplicationAttemptId appAttemptId =
      ApplicationAttemptId.newInstance(appId, 1);
  writeApplicationAttemptStartData(appAttemptId);
  writeApplicationAttemptFinishData(appAttemptId);
  ApplicationReport appReport =
      applicationHistoryManagerImpl.getApplication(appId);
  Assert.assertNotNull(appReport);
  Assert.assertEquals(appId, appReport.getApplicationId());
  Assert.assertEquals(appAttemptId,
    appReport.getCurrentApplicationAttemptId());
  Assert.assertEquals(appAttemptId.toString(), appReport.getHost());
  Assert.assertEquals("test type", appReport.getApplicationType().toString());
  Assert.assertEquals("test queue", appReport.getQueue().toString());
}
 
Example #3
Source File: ApexCli.java    From Bats with Apache License 2.0 6 votes vote down vote up
protected ApplicationReport getApplicationByName(String appName)
{
  if (appName == null) {
    throw new CliException("Invalid application name provided by user");
  }
  List<ApplicationReport> appList = getApplicationList();
  for (ApplicationReport ar : appList) {
    if ((ar.getName().equals(appName)) &&
        (ar.getYarnApplicationState() != YarnApplicationState.KILLED) &&
        (ar.getYarnApplicationState() != YarnApplicationState.FINISHED)) {
      LOG.debug("Application Name: {} Application ID: {} Application State: {}",
          ar.getName(), ar.getApplicationId().toString(), YarnApplicationState.FINISHED);
      return ar;
    }
  }
  return null;
}
 
Example #4
Source File: TestApplicationHistoryManagerImpl.java    From big-c with Apache License 2.0 6 votes vote down vote up
@Test
public void testApplicationReport() throws IOException, YarnException {
  ApplicationId appId = null;
  appId = ApplicationId.newInstance(0, 1);
  writeApplicationStartData(appId);
  writeApplicationFinishData(appId);
  ApplicationAttemptId appAttemptId =
      ApplicationAttemptId.newInstance(appId, 1);
  writeApplicationAttemptStartData(appAttemptId);
  writeApplicationAttemptFinishData(appAttemptId);
  ApplicationReport appReport =
      applicationHistoryManagerImpl.getApplication(appId);
  Assert.assertNotNull(appReport);
  Assert.assertEquals(appId, appReport.getApplicationId());
  Assert.assertEquals(appAttemptId,
    appReport.getCurrentApplicationAttemptId());
  Assert.assertEquals(appAttemptId.toString(), appReport.getHost());
  Assert.assertEquals("test type", appReport.getApplicationType().toString());
  Assert.assertEquals("test queue", appReport.getQueue().toString());
}
 
Example #5
Source File: AppReportConverter.java    From cloudbreak with Apache License 2.0 6 votes vote down vote up
@Override
public AppReportJson convert(ApplicationReport source) {
    AppReportJson json = new AppReportJson();
    json.setAppId(source.getApplicationId().toString());
    json.setStart(source.getStartTime());
    json.setFinish(source.getFinishTime());
    json.setProgress(source.getProgress());
    json.setQueue(source.getQueue());
    json.setUrl(source.getTrackingUrl());
    json.setUser(source.getUser());
    json.setState(source.getYarnApplicationState().name());
    ApplicationResourceUsageReport usageReport = source.getApplicationResourceUsageReport();
    json.setReservedContainers(usageReport.getNumReservedContainers());
    json.setUsedContainers(usageReport.getNumUsedContainers());
    json.setUsedMemory(usageReport.getUsedResources().getMemory());
    json.setUsedVCores(usageReport.getUsedResources().getVirtualCores());
    return json;
}
 
Example #6
Source File: AbstractCliBootYarnClusterTests.java    From spring-cloud-deployer-yarn with Apache License 2.0 6 votes vote down vote up
protected ApplicationInfo waitState(ApplicationId applicationId, long timeout, TimeUnit unit, YarnApplicationState... applicationStates) throws Exception {
	YarnApplicationState state = null;
	ApplicationReport report = null;
	long end = System.currentTimeMillis() + unit.toMillis(timeout);

	// break label for inner loop
	done:
	do {
		report = findApplicationReport(getYarnClient(), applicationId);
		if (report == null) {
			break;
		}
		state = report.getYarnApplicationState();
		for (YarnApplicationState stateCheck : applicationStates) {
			if (state.equals(stateCheck)) {
				break done;
			}
		}
		Thread.sleep(1000);
	} while (System.currentTimeMillis() < end);
	return new ApplicationInfo(applicationId, report);
}
 
Example #7
Source File: TestAHSClient.java    From big-c with Apache License 2.0 6 votes vote down vote up
@Test(timeout = 10000)
public void testGetContainerReport() throws YarnException, IOException {
  Configuration conf = new Configuration();
  final AHSClient client = new MockAHSClient();
  client.init(conf);
  client.start();

  List<ApplicationReport> expectedReports =
      ((MockAHSClient) client).getReports();

  ApplicationId applicationId = ApplicationId.newInstance(1234, 5);
  ApplicationAttemptId appAttemptId =
      ApplicationAttemptId.newInstance(applicationId, 1);
  ContainerId containerId = ContainerId.newContainerId(appAttemptId, 1);
  ContainerReport report = client.getContainerReport(containerId);
  Assert.assertNotNull(report);
  Assert.assertEquals(report.getContainerId().toString(), (ContainerId
    .newContainerId(expectedReports.get(0).getCurrentApplicationAttemptId(), 1))
    .toString());
  client.stop();
}
 
Example #8
Source File: YarnAppLauncherImpl.java    From attic-apex-core with Apache License 2.0 6 votes vote down vote up
protected void shutdownApp(YarnAppHandleImpl app, ShutdownMode shutdownMode) throws LauncherException
{
  if (shutdownMode == ShutdownMode.KILL) {
    try {
      ApplicationId applicationId = app.appId;
      ApplicationReport appReport = app.yarnClient.getApplicationReport(applicationId);
      if (appReport == null) {
        throw new LauncherException("Application " + app.getApplicationId() + " not found");
      }
      app.yarnClient.killApplication(applicationId);
    } catch (YarnException | IOException e) {
      throw Throwables.propagate(e);
    }
  } else {
    throw new UnsupportedOperationException("Orderly shutdown not supported, try kill instead");
  }
}
 
Example #9
Source File: TestApplicatonReport.java    From big-c with Apache License 2.0 6 votes vote down vote up
@Test
public void testApplicationReport() {
  long timestamp = System.currentTimeMillis();
  ApplicationReport appReport1 =
      createApplicationReport(1, 1, timestamp);
  ApplicationReport appReport2 =
      createApplicationReport(1, 1, timestamp);
  ApplicationReport appReport3 =
      createApplicationReport(1, 1, timestamp);
  Assert.assertEquals(appReport1, appReport2);
  Assert.assertEquals(appReport2, appReport3);
  appReport1.setApplicationId(null);
  Assert.assertNull(appReport1.getApplicationId());
  Assert.assertNotSame(appReport1, appReport2);
  appReport2.setCurrentApplicationAttemptId(null);
  Assert.assertNull(appReport2.getCurrentApplicationAttemptId());
  Assert.assertNotSame(appReport2, appReport3);
  Assert.assertNull(appReport1.getAMRMToken());
}
 
Example #10
Source File: ApplicationHistoryManagerOnTimelineStore.java    From hadoop with Apache License 2.0 6 votes vote down vote up
@Override
public Map<ApplicationId, ApplicationReport> getAllApplications()
    throws YarnException, IOException {
  TimelineEntities entities = timelineDataManager.getEntities(
      ApplicationMetricsConstants.ENTITY_TYPE, null, null, null, null,
      null, null, Long.MAX_VALUE, EnumSet.allOf(Field.class),
      UserGroupInformation.getLoginUser());
  Map<ApplicationId, ApplicationReport> apps =
      new LinkedHashMap<ApplicationId, ApplicationReport>();
  if (entities != null && entities.getEntities() != null) {
    for (TimelineEntity entity : entities.getEntities()) {
      try {
        ApplicationReportExt app =
            generateApplicationReport(entity, ApplicationReportField.ALL);
        apps.put(app.appReport.getApplicationId(), app.appReport);
      } catch (Exception e) {
        LOG.error("Error on generating application report for " +
            entity.getEntityId(), e);
      }
    }
  }
  return apps;
}
 
Example #11
Source File: AthenaXYarnClusterDescriptor.java    From AthenaX with Apache License 2.0 6 votes vote down vote up
@Override
protected ClusterClient<ApplicationId> createYarnClusterClient(
    AbstractYarnClusterDescriptor clusterDescriptor,
    int numberTaskManagers,
    int slotPerTaskManager,
    ApplicationReport applicationReport,
    Configuration configuration,
    boolean isNewlyCreatedCluster) throws Exception {
  return new YarnClusterClient(
      clusterDescriptor,
      numberTaskManagers,
      slotPerTaskManager,
      applicationReport,
      configuration,
      isNewlyCreatedCluster);
}
 
Example #12
Source File: ApexCli.java    From attic-apex-core with Apache License 2.0 6 votes vote down vote up
@Override
public void execute(String[] args, ConsoleReader reader) throws Exception
{
  ApplicationReport appReport = currentApp;
  String target = args[1];
  String logLevel = args[2];

  StramAgent.StramUriSpec uriSpec = new StramAgent.StramUriSpec();
  uriSpec = uriSpec.path(StramWebServices.PATH_LOGGERS);
  final JSONObject request = buildRequest(target, logLevel);

  JSONObject response = getResource(uriSpec, appReport, new WebServicesClient.WebServicesHandler<JSONObject>()
  {
    @Override
    public JSONObject process(WebResource.Builder webResource, Class<JSONObject> clazz)
    {
      return webResource.accept(MediaType.APPLICATION_JSON).post(JSONObject.class, request);
    }

  });

  printJson(response);
}
 
Example #13
Source File: TestYarnClient.java    From big-c with Apache License 2.0 6 votes vote down vote up
@Test(timeout = 10000)
public void testGetApplicationAttempt() throws YarnException, IOException {
  Configuration conf = new Configuration();
  final YarnClient client = new MockYarnClient();
  client.init(conf);
  client.start();

  List<ApplicationReport> expectedReports = ((MockYarnClient) client)
      .getReports();

  ApplicationId applicationId = ApplicationId.newInstance(1234, 5);
  ApplicationAttemptId appAttemptId = ApplicationAttemptId.newInstance(
      applicationId, 1);
  ApplicationAttemptReport report = client
      .getApplicationAttemptReport(appAttemptId);
  Assert.assertNotNull(report);
  Assert.assertEquals(report.getApplicationAttemptId().toString(),
      expectedReports.get(0).getCurrentApplicationAttemptId().toString());
  client.stop();
}
 
Example #14
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 #15
Source File: YARNSessionCapacitySchedulerITCase.java    From flink with Apache License 2.0 6 votes vote down vote up
/**
 * Ensures that the YARN application tags were set properly.
 *
 * <p>Since YARN application tags were only added in Hadoop 2.4, but Flink still supports Hadoop 2.3, reflection is
 * required to invoke the methods. If the method does not exist, this test passes.
 */
private void verifyApplicationTags(final ApplicationReport report) throws InvocationTargetException,
	IllegalAccessException {

	final Method applicationTagsMethod;

	Class<ApplicationReport> clazz = ApplicationReport.class;
	try {
		// this method is only supported by Hadoop 2.4.0 onwards
		applicationTagsMethod = clazz.getMethod("getApplicationTags");
	} catch (NoSuchMethodException e) {
		// only verify the tags if the method exists
		return;
	}

	@SuppressWarnings("unchecked")
	Set<String> applicationTags = (Set<String>) applicationTagsMethod.invoke(report);

	assertEquals(Collections.singleton("test-tag"), applicationTags);
}
 
Example #16
Source File: TestYarnClient.java    From hadoop with Apache License 2.0 6 votes vote down vote up
@Test(timeout = 10000)
public void testGetApplicationAttempt() throws YarnException, IOException {
  Configuration conf = new Configuration();
  final YarnClient client = new MockYarnClient();
  client.init(conf);
  client.start();

  List<ApplicationReport> expectedReports = ((MockYarnClient) client)
      .getReports();

  ApplicationId applicationId = ApplicationId.newInstance(1234, 5);
  ApplicationAttemptId appAttemptId = ApplicationAttemptId.newInstance(
      applicationId, 1);
  ApplicationAttemptReport report = client
      .getApplicationAttemptReport(appAttemptId);
  Assert.assertNotNull(report);
  Assert.assertEquals(report.getApplicationAttemptId().toString(),
      expectedReports.get(0).getCurrentApplicationAttemptId().toString());
  client.stop();
}
 
Example #17
Source File: TestClientServiceDelegate.java    From hadoop with Apache License 2.0 6 votes vote down vote up
@Test
public void testHistoryServerNotConfigured() throws Exception {
  //RM doesn't have app report and job History Server is not configured
  ClientServiceDelegate clientServiceDelegate = getClientServiceDelegate(
      null, getRMDelegate());
  JobStatus jobStatus = clientServiceDelegate.getJobStatus(oldJobId);
  Assert.assertEquals("N/A", jobStatus.getUsername());
  Assert.assertEquals(JobStatus.State.PREP, jobStatus.getState());

  //RM has app report and job History Server is not configured
  ResourceMgrDelegate rm = mock(ResourceMgrDelegate.class);
  ApplicationReport applicationReport = getFinishedApplicationReport();
  when(rm.getApplicationReport(jobId.getAppId())).thenReturn(
      applicationReport);

  clientServiceDelegate = getClientServiceDelegate(null, rm);
  jobStatus = clientServiceDelegate.getJobStatus(oldJobId);
  Assert.assertEquals(applicationReport.getUser(), jobStatus.getUsername());
  Assert.assertEquals(JobStatus.State.SUCCEEDED, jobStatus.getState());
}
 
Example #18
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 #19
Source File: TestResourceMgrDelegate.java    From big-c with Apache License 2.0 6 votes vote down vote up
private ApplicationReport getApplicationReport(
    YarnApplicationState yarnApplicationState,
    FinalApplicationStatus finalApplicationStatus) {
  ApplicationReport appReport = Mockito.mock(ApplicationReport.class);
  ApplicationResourceUsageReport appResources = Mockito
      .mock(ApplicationResourceUsageReport.class);
  Mockito.when(appReport.getApplicationId()).thenReturn(
      ApplicationId.newInstance(0, 0));
  Mockito.when(appResources.getNeededResources()).thenReturn(
      Records.newRecord(Resource.class));
  Mockito.when(appResources.getReservedResources()).thenReturn(
      Records.newRecord(Resource.class));
  Mockito.when(appResources.getUsedResources()).thenReturn(
      Records.newRecord(Resource.class));
  Mockito.when(appReport.getApplicationResourceUsageReport()).thenReturn(
      appResources);
  Mockito.when(appReport.getYarnApplicationState()).thenReturn(
      yarnApplicationState);
  Mockito.when(appReport.getFinalApplicationStatus()).thenReturn(
      finalApplicationStatus);

  return appReport;
}
 
Example #20
Source File: ApexCli.java    From attic-apex-core with Apache License 2.0 6 votes vote down vote up
private JSONObject getResource(StramAgent.StramUriSpec uriSpec, ApplicationReport appReport, WebServicesClient.WebServicesHandler handler)
{

  if (appReport == null) {
    throw new CliException("No application selected");
  }

  if (StringUtils.isEmpty(appReport.getTrackingUrl()) || appReport.getFinalApplicationStatus() != FinalApplicationStatus.UNDEFINED) {
    appReport = null;
    throw new CliException("Application terminated");
  }

  WebServicesClient wsClient = new WebServicesClient();
  try {
    return stramAgent.issueStramWebRequest(wsClient, appReport.getApplicationId().toString(), uriSpec, handler);
  } catch (Exception e) {
    // check the application status as above may have failed due application termination etc.
    if (appReport == currentApp) {
      currentApp = assertRunningApp(appReport);
    }
    throw new CliException("Failed to request web service for appid " + appReport.getApplicationId().toString(), e);
  }
}
 
Example #21
Source File: ApplicationHistoryClientService.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@Override
public GetApplicationsResponse
    getApplications(GetApplicationsRequest request) throws YarnException,
        IOException {
  GetApplicationsResponse response =
      GetApplicationsResponse.newInstance(new ArrayList<ApplicationReport>(
        history.getAllApplications().values()));
  return response;
}
 
Example #22
Source File: YarnServiceTest.java    From incubator-gobblin with Apache License 2.0 5 votes vote down vote up
private void startApp() throws Exception {
  // submit a dummy app
  ApplicationSubmissionContext appSubmissionContext =
      yarnClient.createApplication().getApplicationSubmissionContext();
  this.applicationId = appSubmissionContext.getApplicationId();

  ContainerLaunchContext containerLaunchContext =
      BuilderUtils.newContainerLaunchContext(Collections.emptyMap(), Collections.emptyMap(),
          Arrays.asList("sleep", "100"), Collections.emptyMap(), null, Collections.emptyMap());

  // Setup the application submission context
  appSubmissionContext.setApplicationName("TestApp");
  appSubmissionContext.setResource(Resource.newInstance(128, 1));
  appSubmissionContext.setPriority(Priority.newInstance(0));
  appSubmissionContext.setAMContainerSpec(containerLaunchContext);

  this.yarnClient.submitApplication(appSubmissionContext);

  // wait for application to be accepted
  int i;
  RMAppAttempt attempt = null;
  for (i = 0; i < 120; i++) {
    ApplicationReport appReport = yarnClient.getApplicationReport(applicationId);

    if (appReport.getYarnApplicationState() == YarnApplicationState.ACCEPTED) {
      this.applicationAttemptId = appReport.getCurrentApplicationAttemptId();
      attempt = yarnCluster.getResourceManager().getRMContext().getRMApps()
          .get(appReport.getCurrentApplicationAttemptId().getApplicationId()).getCurrentAppAttempt();
      break;
    }
    Thread.sleep(1000);
  }

  Assert.assertTrue(i < 120, "timed out waiting for ACCEPTED state");

  // Set the AM-RM token in the UGI for access during testing
  UserGroupInformation.setLoginUser(UserGroupInformation.createRemoteUser(UserGroupInformation.getCurrentUser()
      .getUserName()));
  UserGroupInformation.getCurrentUser().addToken(attempt.getAMRMToken());
}
 
Example #23
Source File: TestDAGClient.java    From tez with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() throws YarnException, IOException, TezException, ServiceException{

  setUpData();
  
  /////////////// mock //////////////////////
  mockAppId = mock(ApplicationId.class);
  mockAppReport = mock(ApplicationReport.class);
  dagIdStr = "dag_9999_0001_1";
  mockProxy = mock(DAGClientAMProtocolBlockingPB.class);
  // return the response with Counters is the request match the CounterMatcher
  when(mockProxy.getDAGStatus(isNull(RpcController.class), any(GetDAGStatusRequestProto.class)))
    .thenReturn(GetDAGStatusResponseProto.newBuilder().setDagStatus(dagStatusProtoWithoutCounters).build());
  when(mockProxy.getDAGStatus(isNull(RpcController.class), argThat(new DAGCounterRequestMatcher())))
    .thenReturn(GetDAGStatusResponseProto.newBuilder().setDagStatus(dagStatusProtoWithCounters).build());
  
  when(mockProxy.getVertexStatus(isNull(RpcController.class), any(GetVertexStatusRequestProto.class)))
    .thenReturn(GetVertexStatusResponseProto.newBuilder().setVertexStatus(vertexStatusProtoWithoutCounters).build());
  when(mockProxy.getVertexStatus(isNull(RpcController.class), argThat(new VertexCounterRequestMatcher())))
    .thenReturn(GetVertexStatusResponseProto.newBuilder().setVertexStatus(vertexStatusProtoWithCounters).build());

  TezConfiguration tezConf = new TezConfiguration();
  YarnConfiguration yarnConf = new YarnConfiguration(tezConf);
  dagClient = new DAGClientImpl(mockAppId, dagIdStr, tezConf,  yarnConf, null,
      UserGroupInformation.getCurrentUser());
  DAGClientRPCImpl realClient = (DAGClientRPCImpl)((DAGClientImpl)dagClient).getRealClient();
  realClient.appReport = mockAppReport;
  realClient.proxy = mockProxy;
}
 
Example #24
Source File: TestClientRMService.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@Test
public void testGetApplicationReport() throws Exception {
  YarnScheduler yarnScheduler = mock(YarnScheduler.class);
  RMContext rmContext = mock(RMContext.class);
  mockRMContext(yarnScheduler, rmContext);

  ApplicationId appId1 = getApplicationId(1);

  ApplicationACLsManager mockAclsManager = mock(ApplicationACLsManager.class);
  when(
      mockAclsManager.checkAccess(UserGroupInformation.getCurrentUser(),
          ApplicationAccessType.VIEW_APP, null, appId1)).thenReturn(true);

  ClientRMService rmService = new ClientRMService(rmContext, yarnScheduler,
      null, mockAclsManager, null, null);
  try {
    RecordFactory recordFactory = RecordFactoryProvider.getRecordFactory(null);
    GetApplicationReportRequest request = recordFactory
        .newRecordInstance(GetApplicationReportRequest.class);
    request.setApplicationId(appId1);
    GetApplicationReportResponse response = 
        rmService.getApplicationReport(request);
    ApplicationReport report = response.getApplicationReport();
    ApplicationResourceUsageReport usageReport = 
        report.getApplicationResourceUsageReport();
    Assert.assertEquals(10, usageReport.getMemorySeconds());
    Assert.assertEquals(3, usageReport.getVcoreSeconds());
    Assert.assertEquals(3, usageReport.getGcoreSeconds());
  } finally {
    rmService.close();
  }
}
 
Example #25
Source File: TestClientRedirect.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@Override
public GetApplicationReportResponse getApplicationReport(
    GetApplicationReportRequest request) throws IOException {
  ApplicationId applicationId = request.getApplicationId();
  ApplicationReport application = recordFactory
      .newRecordInstance(ApplicationReport.class);
  application.setApplicationId(applicationId);
  application.setFinalApplicationStatus(FinalApplicationStatus.UNDEFINED);
  if (amRunning) {
    application.setYarnApplicationState(YarnApplicationState.RUNNING);
  } else if (amRestarting) {
    application.setYarnApplicationState(YarnApplicationState.SUBMITTED);
  } else {
    application.setYarnApplicationState(YarnApplicationState.FINISHED);
    application.setFinalApplicationStatus(FinalApplicationStatus.SUCCEEDED);
  }
  String[] split = AMHOSTADDRESS.split(":");
  application.setHost(split[0]);
  application.setRpcPort(Integer.parseInt(split[1]));
  application.setUser("TestClientRedirect-user");
  application.setName("N/A");
  application.setQueue("N/A");
  application.setStartTime(0);
  application.setFinishTime(0);
  application.setTrackingUrl("N/A");
  application.setDiagnostics("N/A");

  GetApplicationReportResponse response = recordFactory
      .newRecordInstance(GetApplicationReportResponse.class);
  response.setApplicationReport(application);
  return response;
}
 
Example #26
Source File: FlinkYarnSessionCli.java    From flink with Apache License 2.0 5 votes vote down vote up
private void tryRetrieveAndLogApplicationReport(YarnClient yarnClient, ApplicationId yarnApplicationId) {
	ApplicationReport applicationReport;

	try {
		applicationReport = yarnClient.getApplicationReport(yarnApplicationId);
	} catch (YarnException | IOException e) {
		LOG.info("Could not log the final application report.", e);
		applicationReport = null;
	}

	if (applicationReport != null) {
		logApplicationReport(applicationReport);
	}
}
 
Example #27
Source File: TezClientUtils.java    From incubator-tez with Apache License 2.0 5 votes vote down vote up
static DAGClientAMProtocolBlockingPB getSessionAMProxy(YarnClient yarnClient,
    Configuration conf,
    ApplicationId applicationId) throws TezException, IOException {
  ApplicationReport appReport;
  try {
    appReport = yarnClient.getApplicationReport(
        applicationId);

    if(appReport == null) {
      throw new TezUncheckedException("Could not retrieve application report"
          + " from YARN, applicationId=" + applicationId);
    }
    YarnApplicationState appState = appReport.getYarnApplicationState();
    if(appState != YarnApplicationState.RUNNING) {
      if (appState == YarnApplicationState.FINISHED
          || appState == YarnApplicationState.KILLED
          || appState == YarnApplicationState.FAILED) {
        throw new SessionNotRunning("Application not running"
            + ", applicationId=" + applicationId
            + ", yarnApplicationState=" + appReport.getYarnApplicationState()
            + ", finalApplicationStatus="
            + appReport.getFinalApplicationStatus()
            + ", trackingUrl=" + appReport.getTrackingUrl());
      }
      return null;
    }
  } catch (YarnException e) {
    throw new TezException(e);
  }
  return getAMProxy(conf, appReport.getHost(),
      appReport.getRpcPort(), appReport.getClientToAMToken());
}
 
Example #28
Source File: YarnTestBase.java    From flink with Apache License 2.0 5 votes vote down vote up
protected ApplicationReport getOnlyApplicationReport() throws IOException, YarnException {
	final YarnClient yarnClient = getYarnClient();
	checkState(yarnClient != null);

	final List<ApplicationReport> apps = yarnClient.getApplications(EnumSet.of(YarnApplicationState.RUNNING));
	assertEquals(1, apps.size()); // Only one running
	return apps.get(0);
}
 
Example #29
Source File: TestYarnClient.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Override
public List<ApplicationReport> getApplications(
    Set<String> applicationTypes, EnumSet<YarnApplicationState> applicationStates)
    throws YarnException, IOException {
  when(mockAppResponse.getApplicationList()).thenReturn(
      getApplicationReports(reports, applicationTypes, applicationStates));
  return super.getApplications(applicationTypes, applicationStates);
}
 
Example #30
Source File: AbstractYarnClusterTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public ApplicationReport getApplicationReport(ApplicationId appId) throws YarnException, IOException {
	final ApplicationReport applicationReport = applicationReports.get(appId);

	if (applicationReport != null) {
		return applicationReport;
	} else {
		return super.getApplicationReport(appId);
	}
}