org.apache.hadoop.yarn.api.protocolrecords.GetApplicationsResponse Java Examples

The following examples show how to use org.apache.hadoop.yarn.api.protocolrecords.GetApplicationsResponse. 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: FlinkIntegrationTest.java    From zeppelin with Apache License 2.0 6 votes vote down vote up
@Test
public void testYarnMode() throws IOException, InterpreterException, YarnException {
  InterpreterSetting flinkInterpreterSetting = interpreterSettingManager.getInterpreterSettingByName("flink");
  flinkInterpreterSetting.setProperty("HADOOP_CONF_DIR", hadoopCluster.getConfigPath());
  flinkInterpreterSetting.setProperty("FLINK_HOME", flinkHome);
  flinkInterpreterSetting.setProperty("PATH", hadoopHome + "/bin:" + System.getenv("PATH"));
  flinkInterpreterSetting.setProperty("ZEPPELIN_CONF_DIR", zeppelin.getZeppelinConfDir().getAbsolutePath());
  flinkInterpreterSetting.setProperty("flink.execution.mode", "YARN");
  testInterpreterBasics();

  // 1 yarn application launched
  GetApplicationsRequest request = GetApplicationsRequest.newInstance(EnumSet.of(YarnApplicationState.RUNNING));
  GetApplicationsResponse response = hadoopCluster.getYarnCluster().getResourceManager().getClientRMService().getApplications(request);
  assertEquals(1, response.getApplicationList().size());

  interpreterSettingManager.close();
}
 
Example #2
Source File: SparkIntegrationTest.java    From zeppelin with Apache License 2.0 6 votes vote down vote up
private void waitForYarnAppCompleted(int timeout) throws YarnException {
  long start = System.currentTimeMillis();
  boolean yarnAppCompleted = false;
  while ((System.currentTimeMillis() - start) < timeout ) {
    GetApplicationsRequest request = GetApplicationsRequest.newInstance(EnumSet.of(YarnApplicationState.RUNNING));
    GetApplicationsResponse response = hadoopCluster.getYarnCluster().getResourceManager().getClientRMService().getApplications(request);
    if (response.getApplicationList().isEmpty()) {
      yarnAppCompleted = true;
      break;
    }
    try {
      Thread.sleep(1000);
    } catch (InterruptedException e) {
      e.printStackTrace();
    }
  }
  assertTrue("Yarn app is not completed in " + timeout + " milliseconds.", yarnAppCompleted);
}
 
Example #3
Source File: SparkIntegrationTest.java    From zeppelin with Apache License 2.0 6 votes vote down vote up
@Test
public void testLocalMode() throws IOException, YarnException, InterpreterException, XmlPullParserException {
  InterpreterSetting sparkInterpreterSetting = interpreterSettingManager.getInterpreterSettingByName("spark");
  sparkInterpreterSetting.setProperty("spark.master", "local[*]");
  sparkInterpreterSetting.setProperty("SPARK_HOME", sparkHome);
  sparkInterpreterSetting.setProperty("ZEPPELIN_CONF_DIR", zeppelin.getZeppelinConfDir().getAbsolutePath());
  sparkInterpreterSetting.setProperty("zeppelin.spark.useHiveContext", "false");
  sparkInterpreterSetting.setProperty("zeppelin.pyspark.useIPython", "false");
  sparkInterpreterSetting.setProperty("zeppelin.spark.scala.color", "false");
  sparkInterpreterSetting.setProperty("zeppelin.spark.deprecatedMsg.show", "false");

  try {
    setUpSparkInterpreterSetting(sparkInterpreterSetting);
    testInterpreterBasics();

    // no yarn application launched
    GetApplicationsRequest request = GetApplicationsRequest.newInstance(EnumSet.of(YarnApplicationState.RUNNING));
    GetApplicationsResponse response = hadoopCluster.getYarnCluster().getResourceManager().getClientRMService().getApplications(request);
    assertEquals(0, response.getApplicationList().size());
  } finally {
    interpreterSettingManager.close();
  }
}
 
Example #4
Source File: YarnInterpreterLauncherIntegrationTest.java    From zeppelin with Apache License 2.0 6 votes vote down vote up
@Test
public void testLaunchShellInYarn() throws YarnException, InterpreterException, InterruptedException {
  InterpreterSetting shellInterpreterSetting = interpreterSettingManager.getInterpreterSettingByName("sh");
  shellInterpreterSetting.setProperty("zeppelin.interpreter.launcher", "yarn");
  shellInterpreterSetting.setProperty("HADOOP_CONF_DIR", hadoopCluster.getConfigPath());

  Interpreter shellInterpreter = interpreterFactory.getInterpreter("sh", new ExecutionContextBuilder().setUser("user1").setNoteId("note1").setDefaultInterpreterGroup("sh").createExecutionContext());

  InterpreterContext context = new InterpreterContext.Builder().setNoteId("note1").setParagraphId("paragraph_1").build();
  InterpreterResult interpreterResult = shellInterpreter.interpret("pwd", context);
  assertEquals(InterpreterResult.Code.SUCCESS, interpreterResult.code());
  assertTrue(interpreterResult.toString(), interpreterResult.message().get(0).getData().contains("/usercache/"));

  Thread.sleep(1000);
  // 1 yarn application launched
  GetApplicationsRequest request = GetApplicationsRequest.newInstance(EnumSet.of(YarnApplicationState.RUNNING));
  GetApplicationsResponse response = hadoopCluster.getYarnCluster().getResourceManager().getClientRMService().getApplications(request);
  assertEquals(1, response.getApplicationList().size());

  interpreterSettingManager.close();
}
 
Example #5
Source File: TestRMWebServices.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Test
public void testAppsRace() throws Exception {
  // mock up an RM that returns app reports for apps that don't exist
  // in the RMApps list
  ApplicationId appId = ApplicationId.newInstance(1, 1);
  ApplicationReport mockReport = mock(ApplicationReport.class);
  when(mockReport.getApplicationId()).thenReturn(appId);
  GetApplicationsResponse mockAppsResponse =
      mock(GetApplicationsResponse.class);
  when(mockAppsResponse.getApplicationList())
    .thenReturn(Arrays.asList(new ApplicationReport[] { mockReport }));
  ClientRMService mockClientSvc = mock(ClientRMService.class);
  when(mockClientSvc.getApplications(isA(GetApplicationsRequest.class),
      anyBoolean())).thenReturn(mockAppsResponse);
  ResourceManager mockRM = mock(ResourceManager.class);
  RMContextImpl rmContext = new RMContextImpl(null, null, null, null, null,
      null, null, null, null, null);
  when(mockRM.getRMContext()).thenReturn(rmContext);
  when(mockRM.getClientRMService()).thenReturn(mockClientSvc);

  RMWebServices webSvc = new RMWebServices(mockRM, new Configuration(),
      mock(HttpServletResponse.class));

  final Set<String> emptySet =
      Collections.unmodifiableSet(Collections.<String>emptySet());

  // verify we don't get any apps when querying
  HttpServletRequest mockHsr = mock(HttpServletRequest.class);
  AppsInfo appsInfo = webSvc.getApps(mockHsr, null, emptySet, null,
      null, null, null, null, null, null, null, emptySet, emptySet);
  assertTrue(appsInfo.getApps().isEmpty());

  // verify we don't get an NPE when specifying a final status query
  appsInfo = webSvc.getApps(mockHsr, null, emptySet, "FAILED",
      null, null, null, null, null, null, null, emptySet, emptySet);
  assertTrue(appsInfo.getApps().isEmpty());
}
 
Example #6
Source File: TestRMWebApp.java    From big-c with Apache License 2.0 5 votes vote down vote up
public static ClientRMService mockClientRMService(RMContext rmContext) {
  ClientRMService clientRMService = mock(ClientRMService.class);
  List<ApplicationReport> appReports = new ArrayList<ApplicationReport>();
  for (RMApp app : rmContext.getRMApps().values()) {
    ApplicationReport appReport =
        ApplicationReport.newInstance(
            app.getApplicationId(), (ApplicationAttemptId) null,
            app.getUser(), app.getQueue(),
            app.getName(), (String) null, 0, (Token) null,
            app.createApplicationState(),
            app.getDiagnostics().toString(), (String) null,
            app.getStartTime(), app.getFinishTime(),
            app.getFinalApplicationStatus(),
            (ApplicationResourceUsageReport) null, app.getTrackingUrl(),
            app.getProgress(), app.getApplicationType(), (Token) null);
    appReports.add(appReport);
  }
  GetApplicationsResponse response = mock(GetApplicationsResponse.class);
  when(response.getApplicationList()).thenReturn(appReports);
  try {
    when(clientRMService.getApplications(any(GetApplicationsRequest.class)))
        .thenReturn(response);
  } catch (YarnException e) {
    Assert.fail("Exception is not expteced.");
  }
  return clientRMService;
}
 
Example #7
Source File: ApplicationHistoryProtocolPBClientImpl.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@Override
public GetApplicationsResponse
    getApplications(GetApplicationsRequest request) throws YarnException,
        IOException {
  GetApplicationsRequestProto requestProto =
      ((GetApplicationsRequestPBImpl) request).getProto();
  try {
    return new GetApplicationsResponsePBImpl(proxy.getApplications(null,
      requestProto));
  } catch (ServiceException e) {
    RPCUtil.unwrapAndThrowException(e);
    return null;
  }
}
 
Example #8
Source File: ApplicationHistoryClientService.java    From big-c 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 #9
Source File: TestApplicationHistoryClientService.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Test
public void testApplications() throws IOException, YarnException {
  ApplicationId appId = null;
  appId = ApplicationId.newInstance(0, 1);
  ApplicationId appId1 = ApplicationId.newInstance(0, 2);
  GetApplicationsRequest request = GetApplicationsRequest.newInstance();
  GetApplicationsResponse response =
      clientService.getApplications(request);
  List<ApplicationReport> appReport = response.getApplicationList();
  Assert.assertNotNull(appReport);
  Assert.assertEquals(appId, appReport.get(0).getApplicationId());
  Assert.assertEquals(appId1, appReport.get(1).getApplicationId());
}
 
Example #10
Source File: AHSClientImpl.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Override
public List<ApplicationReport> getApplications() throws YarnException,
    IOException {
  GetApplicationsRequest request = GetApplicationsRequest.newInstance(null,
      null);
  GetApplicationsResponse response = ahsClient.getApplications(request);
  return response.getApplicationList();
}
 
Example #11
Source File: YarnClientImpl.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 {
  GetApplicationsRequest request =
      GetApplicationsRequest.newInstance(applicationTypes, applicationStates);
  GetApplicationsResponse response = rmClient.getApplications(request);
  return response.getApplicationList();
}
 
Example #12
Source File: ProtocolHATestBase.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Override
public GetApplicationsResponse getApplications(
    GetApplicationsRequest request) throws YarnException {
  resetStartFailoverFlag(true);

  // make sure failover has been triggered
  Assert.assertTrue(waittingForFailOver());

  // create GetApplicationsResponse with fake applicationList
  GetApplicationsResponse response =
      GetApplicationsResponse.newInstance(createFakeAppReports());
  return response;
}
 
Example #13
Source File: TestResourceMgrDelegate.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Test
public void tesAllJobs() throws Exception {
  final ApplicationClientProtocol applicationsManager = Mockito.mock(ApplicationClientProtocol.class);
  GetApplicationsResponse allApplicationsResponse = Records
      .newRecord(GetApplicationsResponse.class);
  List<ApplicationReport> applications = new ArrayList<ApplicationReport>();
  applications.add(getApplicationReport(YarnApplicationState.FINISHED,
      FinalApplicationStatus.FAILED));
  applications.add(getApplicationReport(YarnApplicationState.FINISHED,
      FinalApplicationStatus.SUCCEEDED));
  applications.add(getApplicationReport(YarnApplicationState.FINISHED,
      FinalApplicationStatus.KILLED));
  applications.add(getApplicationReport(YarnApplicationState.FAILED,
      FinalApplicationStatus.FAILED));
  allApplicationsResponse.setApplicationList(applications);
  Mockito.when(
      applicationsManager.getApplications(Mockito
          .any(GetApplicationsRequest.class))).thenReturn(
      allApplicationsResponse);
  ResourceMgrDelegate resourceMgrDelegate = new ResourceMgrDelegate(
    new YarnConfiguration()) {
    @Override
    protected void serviceStart() throws Exception {
      Assert.assertTrue(this.client instanceof YarnClientImpl);
      ((YarnClientImpl) this.client).setRMClient(applicationsManager);
    }
  };
  JobStatus[] allJobs = resourceMgrDelegate.getAllJobs();

  Assert.assertEquals(State.FAILED, allJobs[0].getState());
  Assert.assertEquals(State.SUCCEEDED, allJobs[1].getState());
  Assert.assertEquals(State.KILLED, allJobs[2].getState());
  Assert.assertEquals(State.FAILED, allJobs[3].getState());
}
 
Example #14
Source File: SparkIntegrationTest.java    From zeppelin with Apache License 2.0 5 votes vote down vote up
@Test
public void testYarnClientMode() throws IOException, YarnException, InterruptedException, InterpreterException, XmlPullParserException {
  InterpreterSetting sparkInterpreterSetting = interpreterSettingManager.getInterpreterSettingByName("spark");
  sparkInterpreterSetting.setProperty("spark.master", "yarn-client");
  sparkInterpreterSetting.setProperty("HADOOP_CONF_DIR", hadoopCluster.getConfigPath());
  sparkInterpreterSetting.setProperty("SPARK_HOME", sparkHome);
  sparkInterpreterSetting.setProperty("ZEPPELIN_CONF_DIR", zeppelin.getZeppelinConfDir().getAbsolutePath());
  sparkInterpreterSetting.setProperty("zeppelin.spark.useHiveContext", "false");
  sparkInterpreterSetting.setProperty("zeppelin.pyspark.useIPython", "false");
  sparkInterpreterSetting.setProperty("PYSPARK_PYTHON", getPythonExec());
  sparkInterpreterSetting.setProperty("spark.driver.memory", "512m");
  sparkInterpreterSetting.setProperty("zeppelin.spark.scala.color", "false");
  sparkInterpreterSetting.setProperty("zeppelin.spark.deprecatedMsg.show", "false");

  try {
    setUpSparkInterpreterSetting(sparkInterpreterSetting);
    testInterpreterBasics();

    // 1 yarn application launched
    GetApplicationsRequest request = GetApplicationsRequest.newInstance(EnumSet.of(YarnApplicationState.RUNNING));
    GetApplicationsResponse response = hadoopCluster.getYarnCluster().getResourceManager().getClientRMService().getApplications(request);
    assertEquals(1, response.getApplicationList().size());

  } finally {
    interpreterSettingManager.close();
    waitForYarnAppCompleted(30 * 1000);
  }
}
 
Example #15
Source File: SparkIntegrationTest.java    From zeppelin with Apache License 2.0 5 votes vote down vote up
@Test
public void testYarnClusterMode() throws IOException, YarnException, InterruptedException, InterpreterException, XmlPullParserException {
  InterpreterSetting sparkInterpreterSetting = interpreterSettingManager.getInterpreterSettingByName("spark");
  sparkInterpreterSetting.setProperty("spark.master", "yarn-cluster");
  sparkInterpreterSetting.setProperty("HADOOP_CONF_DIR", hadoopCluster.getConfigPath());
  sparkInterpreterSetting.setProperty("SPARK_HOME", sparkHome);
  sparkInterpreterSetting.setProperty("ZEPPELIN_CONF_DIR", zeppelin.getZeppelinConfDir().getAbsolutePath());
  sparkInterpreterSetting.setProperty("zeppelin.spark.useHiveContext", "false");
  sparkInterpreterSetting.setProperty("zeppelin.pyspark.useIPython", "false");
  sparkInterpreterSetting.setProperty("PYSPARK_PYTHON", getPythonExec());
  sparkInterpreterSetting.setProperty("spark.driver.memory", "512m");
  sparkInterpreterSetting.setProperty("zeppelin.spark.scala.color", "false");
  sparkInterpreterSetting.setProperty("zeppelin.spark.deprecatedMsg.show", "false");

  try {
    setUpSparkInterpreterSetting(sparkInterpreterSetting);
    testInterpreterBasics();

    // 1 yarn application launched
    GetApplicationsRequest request = GetApplicationsRequest.newInstance(EnumSet.of(YarnApplicationState.RUNNING));
    GetApplicationsResponse response = hadoopCluster.getYarnCluster().getResourceManager().getClientRMService().getApplications(request);
    assertEquals(1, response.getApplicationList().size());

  } finally {
    interpreterSettingManager.close();
    waitForYarnAppCompleted(30 * 1000);
  }
}
 
Example #16
Source File: FlinkIntegrationTest.java    From zeppelin with Apache License 2.0 5 votes vote down vote up
@Test
public void testLocalMode() throws IOException, YarnException, InterpreterException {
  InterpreterSetting flinkInterpreterSetting = interpreterSettingManager.getInterpreterSettingByName("flink");
  flinkInterpreterSetting.setProperty("FLINK_HOME", flinkHome);
  flinkInterpreterSetting.setProperty("ZEPPELIN_CONF_DIR", zeppelin.getZeppelinConfDir().getAbsolutePath());

  testInterpreterBasics();

  // no yarn application launched
  GetApplicationsRequest request = GetApplicationsRequest.newInstance(EnumSet.of(YarnApplicationState.RUNNING));
  GetApplicationsResponse response = hadoopCluster.getYarnCluster().getResourceManager().getClientRMService().getApplications(request);
  assertEquals(0, response.getApplicationList().size());

  interpreterSettingManager.close();
}
 
Example #17
Source File: RMCommunicator.java    From jumbune with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Get list of all applications known to RM.
 *
 * @return list of application report
 * @throws YarnException the yarn exception
 * @throws IOException Signals that an I/O exception has occurred.
 */
public List<ApplicationReport> getApplications() throws YarnException, IOException{
	if ((System.currentTimeMillis() - lastCacheUpdateTime) > 60000) {
		synchronized (this) {
			if ( (System.currentTimeMillis() - lastCacheUpdateTime) > 60000) {
				GetApplicationsResponse response = proxy.getApplications(GetApplicationsRequest.newInstance());
				appListCache = response.getApplicationList();
				lastCacheUpdateTime = System.currentTimeMillis();
			}
		}
	}
	return appListCache;
}
 
Example #18
Source File: ApplicationClientProtocolPBClientImpl.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@Override
public GetApplicationsResponse getApplications(
    GetApplicationsRequest request) throws YarnException,
    IOException {
  GetApplicationsRequestProto requestProto =
      ((GetApplicationsRequestPBImpl) request).getProto();
  try {
    return new GetApplicationsResponsePBImpl(proxy.getApplications(
      null, requestProto));
  } catch (ServiceException e) {
    RPCUtil.unwrapAndThrowException(e);
    return null;
  }
}
 
Example #19
Source File: ApplicationHistoryProtocolPBClientImpl.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Override
public GetApplicationsResponse
    getApplications(GetApplicationsRequest request) throws YarnException,
        IOException {
  GetApplicationsRequestProto requestProto =
      ((GetApplicationsRequestPBImpl) request).getProto();
  try {
    return new GetApplicationsResponsePBImpl(proxy.getApplications(null,
      requestProto));
  } catch (ServiceException e) {
    RPCUtil.unwrapAndThrowException(e);
    return null;
  }
}
 
Example #20
Source File: TestResourceMgrDelegate.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@Test
public void tesAllJobs() throws Exception {
  final ApplicationClientProtocol applicationsManager = Mockito.mock(ApplicationClientProtocol.class);
  GetApplicationsResponse allApplicationsResponse = Records
      .newRecord(GetApplicationsResponse.class);
  List<ApplicationReport> applications = new ArrayList<ApplicationReport>();
  applications.add(getApplicationReport(YarnApplicationState.FINISHED,
      FinalApplicationStatus.FAILED));
  applications.add(getApplicationReport(YarnApplicationState.FINISHED,
      FinalApplicationStatus.SUCCEEDED));
  applications.add(getApplicationReport(YarnApplicationState.FINISHED,
      FinalApplicationStatus.KILLED));
  applications.add(getApplicationReport(YarnApplicationState.FAILED,
      FinalApplicationStatus.FAILED));
  allApplicationsResponse.setApplicationList(applications);
  Mockito.when(
      applicationsManager.getApplications(Mockito
          .any(GetApplicationsRequest.class))).thenReturn(
      allApplicationsResponse);
  ResourceMgrDelegate resourceMgrDelegate = new ResourceMgrDelegate(
    new YarnConfiguration()) {
    @Override
    protected void serviceStart() throws Exception {
      Assert.assertTrue(this.client instanceof YarnClientImpl);
      ((YarnClientImpl) this.client).setRMClient(applicationsManager);
    }
  };
  JobStatus[] allJobs = resourceMgrDelegate.getAllJobs();

  Assert.assertEquals(State.FAILED, allJobs[0].getState());
  Assert.assertEquals(State.SUCCEEDED, allJobs[1].getState());
  Assert.assertEquals(State.KILLED, allJobs[2].getState());
  Assert.assertEquals(State.FAILED, allJobs[3].getState());
}
 
Example #21
Source File: TestRMWebServices.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@Test
public void testAppsRace() throws Exception {
  // mock up an RM that returns app reports for apps that don't exist
  // in the RMApps list
  ApplicationId appId = ApplicationId.newInstance(1, 1);
  ApplicationReport mockReport = mock(ApplicationReport.class);
  when(mockReport.getApplicationId()).thenReturn(appId);
  GetApplicationsResponse mockAppsResponse =
      mock(GetApplicationsResponse.class);
  when(mockAppsResponse.getApplicationList())
    .thenReturn(Arrays.asList(new ApplicationReport[] { mockReport }));
  ClientRMService mockClientSvc = mock(ClientRMService.class);
  when(mockClientSvc.getApplications(isA(GetApplicationsRequest.class),
      anyBoolean())).thenReturn(mockAppsResponse);
  ResourceManager mockRM = mock(ResourceManager.class);
  RMContextImpl rmContext = new RMContextImpl(null, null, null, null, null,
      null, null, null, null, null);
  when(mockRM.getRMContext()).thenReturn(rmContext);
  when(mockRM.getClientRMService()).thenReturn(mockClientSvc);

  RMWebServices webSvc = new RMWebServices(mockRM, new Configuration(),
      mock(HttpServletResponse.class));

  final Set<String> emptySet =
      Collections.unmodifiableSet(Collections.<String>emptySet());

  // verify we don't get any apps when querying
  HttpServletRequest mockHsr = mock(HttpServletRequest.class);
  AppsInfo appsInfo = webSvc.getApps(mockHsr, null, emptySet, null,
      null, null, null, null, null, null, null, emptySet, emptySet);
  assertTrue(appsInfo.getApps().isEmpty());

  // verify we don't get an NPE when specifying a final status query
  appsInfo = webSvc.getApps(mockHsr, null, emptySet, "FAILED",
      null, null, null, null, null, null, null, emptySet, emptySet);
  assertTrue(appsInfo.getApps().isEmpty());
}
 
Example #22
Source File: TestRMWebApp.java    From hadoop with Apache License 2.0 5 votes vote down vote up
public static ClientRMService mockClientRMService(RMContext rmContext) {
  ClientRMService clientRMService = mock(ClientRMService.class);
  List<ApplicationReport> appReports = new ArrayList<ApplicationReport>();
  for (RMApp app : rmContext.getRMApps().values()) {
    ApplicationReport appReport =
        ApplicationReport.newInstance(
            app.getApplicationId(), (ApplicationAttemptId) null,
            app.getUser(), app.getQueue(),
            app.getName(), (String) null, 0, (Token) null,
            app.createApplicationState(),
            app.getDiagnostics().toString(), (String) null,
            app.getStartTime(), app.getFinishTime(),
            app.getFinalApplicationStatus(),
            (ApplicationResourceUsageReport) null, app.getTrackingUrl(),
            app.getProgress(), app.getApplicationType(), (Token) null);
    appReports.add(appReport);
  }
  GetApplicationsResponse response = mock(GetApplicationsResponse.class);
  when(response.getApplicationList()).thenReturn(appReports);
  try {
    when(clientRMService.getApplications(any(GetApplicationsRequest.class)))
        .thenReturn(response);
  } catch (YarnException e) {
    Assert.fail("Exception is not expteced.");
  }
  return clientRMService;
}
 
Example #23
Source File: ProtocolHATestBase.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@Override
public GetApplicationsResponse getApplications(
    GetApplicationsRequest request) throws YarnException {
  resetStartFailoverFlag(true);

  // make sure failover has been triggered
  Assert.assertTrue(waittingForFailOver());

  // create GetApplicationsResponse with fake applicationList
  GetApplicationsResponse response =
      GetApplicationsResponse.newInstance(createFakeAppReports());
  return response;
}
 
Example #24
Source File: YarnClientImpl.java    From hadoop 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 {
  GetApplicationsRequest request =
      GetApplicationsRequest.newInstance(applicationTypes, applicationStates);
  GetApplicationsResponse response = rmClient.getApplications(request);
  return response.getApplicationList();
}
 
Example #25
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 #26
Source File: ApplicationClientProtocolPBClientImpl.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Override
public GetApplicationsResponse getApplications(
    GetApplicationsRequest request) throws YarnException,
    IOException {
  GetApplicationsRequestProto requestProto =
      ((GetApplicationsRequestPBImpl) request).getProto();
  try {
    return new GetApplicationsResponsePBImpl(proxy.getApplications(
      null, requestProto));
  } catch (ServiceException e) {
    RPCUtil.unwrapAndThrowException(e);
    return null;
  }
}
 
Example #27
Source File: AHSClientImpl.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@Override
public List<ApplicationReport> getApplications() throws YarnException,
    IOException {
  GetApplicationsRequest request = GetApplicationsRequest.newInstance(null,
      null);
  GetApplicationsResponse response = ahsClient.getApplications(request);
  return response.getApplicationList();
}
 
Example #28
Source File: TestApplicationHistoryClientService.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@Test
public void testApplications() throws IOException, YarnException {
  ApplicationId appId = null;
  appId = ApplicationId.newInstance(0, 1);
  ApplicationId appId1 = ApplicationId.newInstance(0, 2);
  GetApplicationsRequest request = GetApplicationsRequest.newInstance();
  GetApplicationsResponse response =
      clientService.getApplications(request);
  List<ApplicationReport> appReport = response.getApplicationList();
  Assert.assertNotNull(appReport);
  Assert.assertEquals(appId, appReport.get(0).getApplicationId());
  Assert.assertEquals(appId1, appReport.get(1).getApplicationId());
}
 
Example #29
Source File: TestYARNRunner.java    From big-c with Apache License 2.0 4 votes vote down vote up
@Test(timeout=20000)
public void testResourceMgrDelegate() throws Exception {
  /* we not want a mock of resource mgr delegate */
  final ApplicationClientProtocol clientRMProtocol = mock(ApplicationClientProtocol.class);
  ResourceMgrDelegate delegate = new ResourceMgrDelegate(conf) {
    @Override
    protected void serviceStart() throws Exception {
      assertTrue(this.client instanceof YarnClientImpl);
      ((YarnClientImpl) this.client).setRMClient(clientRMProtocol);
    }
  };
  /* make sure kill calls finish application master */
  when(clientRMProtocol.forceKillApplication(any(KillApplicationRequest.class)))
  .thenReturn(KillApplicationResponse.newInstance(true));
  delegate.killApplication(appId);
  verify(clientRMProtocol).forceKillApplication(any(KillApplicationRequest.class));

  /* make sure getalljobs calls get all applications */
  when(clientRMProtocol.getApplications(any(GetApplicationsRequest.class))).
  thenReturn(recordFactory.newRecordInstance(GetApplicationsResponse.class));
  delegate.getAllJobs();
  verify(clientRMProtocol).getApplications(any(GetApplicationsRequest.class));

  /* make sure getapplication report is called */
  when(clientRMProtocol.getApplicationReport(any(GetApplicationReportRequest.class)))
  .thenReturn(recordFactory.newRecordInstance(GetApplicationReportResponse.class));
  delegate.getApplicationReport(appId);
  verify(clientRMProtocol).getApplicationReport(any(GetApplicationReportRequest.class));

  /* make sure metrics is called */
  GetClusterMetricsResponse clusterMetricsResponse = recordFactory.newRecordInstance
      (GetClusterMetricsResponse.class);
  clusterMetricsResponse.setClusterMetrics(recordFactory.newRecordInstance(
      YarnClusterMetrics.class));
  when(clientRMProtocol.getClusterMetrics(any(GetClusterMetricsRequest.class)))
  .thenReturn(clusterMetricsResponse);
  delegate.getClusterMetrics();
  verify(clientRMProtocol).getClusterMetrics(any(GetClusterMetricsRequest.class));

  when(clientRMProtocol.getClusterNodes(any(GetClusterNodesRequest.class))).
  thenReturn(recordFactory.newRecordInstance(GetClusterNodesResponse.class));
  delegate.getActiveTrackers();
  verify(clientRMProtocol).getClusterNodes(any(GetClusterNodesRequest.class));
  
  GetNewApplicationResponse newAppResponse = recordFactory.newRecordInstance(
      GetNewApplicationResponse.class);
  newAppResponse.setApplicationId(appId);
  when(clientRMProtocol.getNewApplication(any(GetNewApplicationRequest.class))).
  thenReturn(newAppResponse);
  delegate.getNewJobID();
  verify(clientRMProtocol).getNewApplication(any(GetNewApplicationRequest.class));
  
  GetQueueInfoResponse queueInfoResponse = recordFactory.newRecordInstance(
      GetQueueInfoResponse.class);
  queueInfoResponse.setQueueInfo(recordFactory.newRecordInstance(QueueInfo.class));
  when(clientRMProtocol.getQueueInfo(any(GetQueueInfoRequest.class))).
  thenReturn(queueInfoResponse);
  delegate.getQueues();
  verify(clientRMProtocol).getQueueInfo(any(GetQueueInfoRequest.class));

  GetQueueUserAclsInfoResponse aclResponse = recordFactory.newRecordInstance(
      GetQueueUserAclsInfoResponse.class);
  when(clientRMProtocol.getQueueUserAcls(any(GetQueueUserAclsInfoRequest.class)))
  .thenReturn(aclResponse);
  delegate.getQueueAclsForCurrentUser();
  verify(clientRMProtocol).getQueueUserAcls(any(GetQueueUserAclsInfoRequest.class));
}
 
Example #30
Source File: ClientRMService.java    From hadoop with Apache License 2.0 4 votes vote down vote up
@Override
public GetApplicationsResponse getApplications(
    GetApplicationsRequest request) throws YarnException {
  return getApplications(request, true);
}