List of usage examples for org.apache.hadoop.yarn.api.records YarnApplicationAttemptState RUNNING
YarnApplicationAttemptState RUNNING
To view the source code for org.apache.hadoop.yarn.api.records YarnApplicationAttemptState RUNNING.
Click Source Link
From source file:io.hops.hopsworks.common.admin.llap.LlapClusterFacade.java
License:Open Source License
public List<String> getLlapHosts() { ArrayList<String> hosts = new ArrayList<>(); if (!isClusterUp() || isClusterStarting()) { return hosts; }//from ww w. ja v a 2s. c om // The cluster is app, so the appId exists String llapAppID = variablesFacade.getVariableValue(Settings.VARIABLE_LLAP_APP_ID); ApplicationId appId = ApplicationId.fromString(llapAppID); YarnClient yarnClient = yarnClientService.getYarnClientSuper(settings.getConfiguration()).getYarnClient(); try { List<ApplicationAttemptReport> attempts = yarnClient.getApplicationAttempts(appId); ApplicationAttemptReport current = null; for (ApplicationAttemptReport attempt : attempts) { // Only if the app is running the metrics are available if (attempt.getYarnApplicationAttemptState() == YarnApplicationAttemptState.RUNNING) { current = attempt; break; } } if (current == null) { return hosts; } List<ContainerReport> containerReports = yarnClient.getContainers(current.getApplicationAttemptId()); // For all the new/running containers, which are not the application master, get the host for (ContainerReport containerReport : containerReports) { // Only if the container is running the metrics are available if (containerReport.getContainerState() == ContainerState.RUNNING && !containerReport.getContainerId().equals(current.getAMContainerId())) { hosts.add(containerReport.getAssignedNode().getHost()); } } } catch (IOException | YarnException ex) { logger.log(Level.SEVERE, "Couldn't retrieve the containers for LLAP cluster", ex); } finally { try { yarnClient.close(); } catch (IOException ex) { } } return hosts; }
From source file:org.apache.samza.validation.TestYarnJobValidationTool.java
License:Apache License
@Test public void testValidateRunningAttemptId() throws Exception { ApplicationReport appReport = mock(ApplicationReport.class); when(client.getApplicationReport(appId)).thenReturn(appReport); when(appReport.getCurrentApplicationAttemptId()).thenReturn(attemptId); ApplicationAttemptReport attemptReport = mock(ApplicationAttemptReport.class); when(attemptReport.getYarnApplicationAttemptState()).thenReturn(YarnApplicationAttemptState.RUNNING); when(attemptReport.getApplicationAttemptId()).thenReturn(attemptId); when(client.getApplicationAttemptReport(attemptId)).thenReturn(attemptReport); assertTrue(tool.validateRunningAttemptId(appId).equals(attemptId)); when(attemptReport.getYarnApplicationAttemptState()).thenReturn(YarnApplicationAttemptState.FAILED); exception.expect(SamzaException.class); tool.validateRunningAttemptId(appId); }
From source file:org.apache.samza.validation.YarnJobValidationTool.java
License:Apache License
public ApplicationAttemptId validateRunningAttemptId(ApplicationId appId) throws Exception { ApplicationAttemptId attemptId = this.client.getApplicationReport(appId).getCurrentApplicationAttemptId(); ApplicationAttemptReport attemptReport = this.client.getApplicationAttemptReport(attemptId); if (attemptReport.getYarnApplicationAttemptState() == YarnApplicationAttemptState.RUNNING) { log.info("Job is running. AttempId " + attemptId.toString()); return attemptId; } else {/*w w w. j a v a2 s .co m*/ throw new SamzaException("Job not running " + this.jobName); } }