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

The following examples show how to use org.apache.hadoop.yarn.api.records.ApplicationReport. These examples are extracted from open source projects. 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 Project: hadoop   Source File: YARNRunner.java    License: 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 Project: attic-apex-core   Source File: YarnAppLauncherImpl.java    License: 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 3
Source Project: Bats   Source File: ApexCli.java    License: 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 Project: big-c   Source File: TestApplicatonReport.java    License: 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 5
@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 6
Source Project: hadoop   Source File: AppInfo.java    License: 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 7
Source Project: samza   Source File: YarnJobValidationTool.java    License: 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 8
Source Project: big-c   Source File: TestResourceMgrDelegate.java    License: 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 9
Source Project: attic-apex-core   Source File: ApexCli.java    License: 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 10
Source Project: hadoop   Source File: TestApplicationHistoryManagerImpl.java    License: 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 11
Source Project: hadoop   Source File: TestClientServiceDelegate.java    License: 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 12
Source Project: hadoop   Source File: TestYarnClient.java    License: 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 13
Source Project: flink   Source File: YARNSessionCapacitySchedulerITCase.java    License: 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 14
Source Project: big-c   Source File: TestYarnClient.java    License: 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 15
Source Project: attic-apex-core   Source File: ApexCli.java    License: 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 16
Source Project: AthenaX   Source File: AthenaXYarnClusterDescriptor.java    License: 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 17
Source Project: cloudbreak   Source File: AppReportConverter.java    License: 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 18
Source Project: big-c   Source File: TestApplicationHistoryManagerImpl.java    License: 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 19
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 20
Source Project: big-c   Source File: TestAHSClient.java    License: 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 21
Source Project: incubator-gobblin   Source File: YarnServiceTest.java    License: 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 22
public Collection<CloudAppInstanceInfo> getSubmittedApplications() {
	List<CloudAppInstanceInfo> appIds = new ArrayList<CloudAppInstanceInfo>();
	for (ApplicationReport report : yarnClient.listApplications("DATAFLOW")) {
		appIds.add(new CloudAppInstanceInfo(report.getApplicationId().toString(), report.getName(),
				report.getYarnApplicationState().toString(), report.getOriginalTrackingUrl()));
	}
	return appIds;
}
 
Example 23
private ApplicationReport findApplicationReport(YarnClient client, ApplicationId applicationId) {
	Assert.notNull(getYarnClient(), "Yarn client must be set");
	for (ApplicationReport report : client.listApplications()) {
		if (report.getApplicationId().equals(applicationId)) {
			return report;
		}
	}
	return null;
}
 
Example 24
Source Project: hadoop   Source File: ClientRMService.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * It gives response which includes application report if the application
 * present otherwise throws ApplicationNotFoundException.
 */
@Override
public GetApplicationReportResponse getApplicationReport(
    GetApplicationReportRequest request) throws YarnException {
  ApplicationId applicationId = request.getApplicationId();

  UserGroupInformation callerUGI;
  try {
    callerUGI = UserGroupInformation.getCurrentUser();
  } catch (IOException ie) {
    LOG.info("Error getting UGI ", ie);
    throw RPCUtil.getRemoteException(ie);
  }

  RMApp application = this.rmContext.getRMApps().get(applicationId);
  if (application == null) {
    // If the RM doesn't have the application, throw
    // ApplicationNotFoundException and let client to handle.
    throw new ApplicationNotFoundException("Application with id '"
        + applicationId + "' doesn't exist in RM.");
  }

  boolean allowAccess = checkAccess(callerUGI, application.getUser(),
      ApplicationAccessType.VIEW_APP, application);
  ApplicationReport report =
      application.createAndGetApplicationReport(callerUGI.getUserName(),
          allowAccess);

  GetApplicationReportResponse response = recordFactory
      .newRecordInstance(GetApplicationReportResponse.class);
  response.setApplicationReport(report);
  return response;
}
 
Example 25
Source Project: hadoop   Source File: TestRemoteAppChecker.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testRunningApp() throws Exception {
  YarnClient client = createCheckerWithMockedClient();
  ApplicationId id = ApplicationId.newInstance(1, 1);

  // create a report and set the state to an active one
  ApplicationReport report = new ApplicationReportPBImpl();
  report.setYarnApplicationState(YarnApplicationState.ACCEPTED);
  doReturn(report).when(client).getApplicationReport(id);

  assertTrue(checker.isApplicationActive(id));
}
 
Example 26
Source Project: big-c   Source File: ClientServiceDelegate.java    License: Apache License 2.0 5 votes vote down vote up
private MRClientProtocol checkAndGetHSProxy(
    ApplicationReport applicationReport, JobState state) {
  if (null == historyServerProxy) {
    LOG.warn("Job History Server is not configured.");
    return getNotRunningJob(applicationReport, state);
  }
  return historyServerProxy;
}
 
Example 27
Source Project: tez   Source File: DAGClientImpl.java    License: Apache License 2.0 5 votes vote down vote up
private void checkAndSetDagCompletionStatus() {
  ApplicationReport appReport = realClient.getApplicationReportInternal();
  if (appReport != null) {
    final YarnApplicationState appState = appReport.getYarnApplicationState();
    if (appState == YarnApplicationState.FINISHED || appState == YarnApplicationState.FAILED ||
        appState == YarnApplicationState.KILLED) {
      dagCompleted = true;
    }
  }
}
 
Example 28
Source Project: Flink-CEPplus   Source File: YarnClusterDescriptor.java    License: 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 29
Source Project: Flink-CEPplus   Source File: FlinkYarnSessionCli.java    License: 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 30
Source Project: big-c   Source File: TestYARNRunner.java    License: Apache License 2.0 5 votes vote down vote up
@Test(timeout=20000)
public void testJobKill() throws Exception {
  clientDelegate = mock(ClientServiceDelegate.class);
  when(clientDelegate.getJobStatus(any(JobID.class))).thenReturn(new
      org.apache.hadoop.mapreduce.JobStatus(jobId, 0f, 0f, 0f, 0f,
          State.PREP, JobPriority.HIGH, "tmp", "tmp", "tmp", "tmp"));
  when(clientDelegate.killJob(any(JobID.class))).thenReturn(true);
  doAnswer(
      new Answer<ClientServiceDelegate>() {
        @Override
        public ClientServiceDelegate answer(InvocationOnMock invocation)
            throws Throwable {
          return clientDelegate;
        }
      }
      ).when(clientCache).getClient(any(JobID.class));
  yarnRunner.killJob(jobId);
  verify(resourceMgrDelegate).killApplication(appId);
  when(clientDelegate.getJobStatus(any(JobID.class))).thenReturn(new
      org.apache.hadoop.mapreduce.JobStatus(jobId, 0f, 0f, 0f, 0f,
          State.RUNNING, JobPriority.HIGH, "tmp", "tmp", "tmp", "tmp"));
  yarnRunner.killJob(jobId);
  verify(clientDelegate).killJob(jobId);

  when(clientDelegate.getJobStatus(any(JobID.class))).thenReturn(null);
  when(resourceMgrDelegate.getApplicationReport(any(ApplicationId.class)))
      .thenReturn(
          ApplicationReport.newInstance(appId, null, "tmp", "tmp", "tmp",
              "tmp", 0, null, YarnApplicationState.FINISHED, "tmp", "tmp",
              0l, 0l, FinalApplicationStatus.SUCCEEDED, null, null, 0f,
              "tmp", null));
  yarnRunner.killJob(jobId);
  verify(clientDelegate).killJob(jobId);
}