@Override public void close() throws Exception { // Calling close instead of stop on YarnClient as the current close method would typically have been called as // part of closeable handling by the vm and it would be appropriate to continue this pattern by calling close on // YarnClient. Effectively, this should be the same as calling stop as the documentation of YarnClient close calls // for the close method to be a call to stop. yarnClient.close(); } }
@Override public final void close() throws IOException { yarnClient.close(); }
public void close() { if (null != yarnClient) { try { yarnClient.close(); } catch (IOException ex) { LOG.log(Level.WARNING, "Error while closing YarnClient", ex); } } } }
private ContainerReport getContainerReport(String containerIdStr) throws YarnException, IOException { YarnClient yarnClient = createYarnClient(); try { return yarnClient.getContainerReport( ContainerId.fromString(containerIdStr)); } finally { yarnClient.close(); } }
@Override protected void serviceStart() throws Exception { assertTrue(this.client instanceof YarnClientImpl); this.client = spy(this.client); doNothing().when(this.client).close(); ((YarnClientImpl) this.client).setRMClient(cRMProtocol); } };
private YarnApplicationState getApplicationState(ApplicationId appId) throws IOException, YarnException { YarnClient yarnClient = createYarnClient(); try { ApplicationReport appReport = yarnClient.getApplicationReport(appId); return appReport.getYarnApplicationState(); } finally { yarnClient.close(); } }
private int verifyApplicationState(ApplicationId appId) throws IOException, YarnException { YarnClient yarnClient = createYarnClient(); try { ApplicationReport appReport = yarnClient.getApplicationReport(appId); switch (appReport.getYarnApplicationState()) { case NEW: case NEW_SAVING: case SUBMITTED: return -1; case ACCEPTED: case RUNNING: case FAILED: case FINISHED: case KILLED: default: break; } } finally { yarnClient.close(); } return 0; }
private int verifyApplicationState(ApplicationId appId) throws IOException, YarnException { YarnClient yarnClient = createYarnClient(); try { ApplicationReport appReport = yarnClient.getApplicationReport(appId); switch (appReport.getYarnApplicationState()) { case NEW: case NEW_SAVING: case SUBMITTED: return -1; case ACCEPTED: case RUNNING: case FAILED: case FINISHED: case KILLED: default: break; } } finally { yarnClient.close(); } return 0; }
@Lock(LockType.WRITE) public boolean stopCluster() { String llapAppID = variablesFacade.getVariableValue(Settings.VARIABLE_LLAP_APP_ID); if (llapAppID == null || llapAppID.isEmpty()) { return false; } ApplicationId appId = ApplicationId.fromString(llapAppID); YarnClient yarnClient = yarnClientService.getYarnClientSuper(settings.getConfiguration()).getYarnClient(); try { yarnClient.killApplication(appId); } catch (IOException | YarnException e) { logger.log(Level.SEVERE, "Could not kill llap cluster with appId: " + appId.toString(), e); return false; } finally { try { yarnClient.close(); } catch (IOException ex) {} } return true; }
public boolean isClusterUp() { String llapAppID = variablesFacade.getVariableValue(Settings.VARIABLE_LLAP_APP_ID); if (llapAppID == null || llapAppID.isEmpty()) { return false; } ApplicationId appId = ApplicationId.fromString(llapAppID); YarnClient yarnClient = yarnClientService.getYarnClientSuper(settings.getConfiguration()).getYarnClient(); ApplicationReport applicationReport = null; try { applicationReport = yarnClient.getApplicationReport(appId); } catch (IOException | YarnException e) { logger.log(Level.SEVERE, "Could not retrieve application state for llap cluster with appId: " + appId.toString(), e); return false; } finally { try { yarnClient.close(); } catch (IOException ex) {} } YarnApplicationState appState = applicationReport.getYarnApplicationState(); return appState == YarnApplicationState.RUNNING || appState == YarnApplicationState.SUBMITTED || appState == YarnApplicationState.ACCEPTED || appState == YarnApplicationState.NEW || appState == YarnApplicationState.NEW_SAVING; }
@Override public int run(String[] args) throws Exception { try { yarnClient = createYarnClient(); webServiceClient = new Client(new URLConnectionClientHandler( new HttpURLConnectionFactory() { @Override public HttpURLConnection getHttpURLConnection(URL url) throws IOException { AuthenticatedURL.Token token = new AuthenticatedURL.Token(); HttpURLConnection conn = null; try { conn = new AuthenticatedURL().openConnection(url, token); } catch (AuthenticationException e) { throw new IOException(e); } return conn; } })); return runCommand(args); } finally { if (yarnClient != null) { yarnClient.close(); } } }
} finally { try { yarnClient.close(); } catch (IOException ex) {}
protected YarnApplicationState waitUntilYarnAppState(String externalId, final EnumSet<YarnApplicationState> acceptedStates, int timeoutMs) throws HadoopAccessorException, IOException, YarnException { final ApplicationId appId = ConverterUtils.toApplicationId(externalId); final MutableObject<YarnApplicationState> finalState = new MutableObject<YarnApplicationState>(); Configuration conf = Services.get().get(HadoopAccessorService.class).createConfiguration(getJobTrackerUri()); final YarnClient yarnClient = Services.get().get(HadoopAccessorService.class).createYarnClient(getTestUser(), conf); try { waitFor(timeoutMs, new Predicate() { @Override public boolean evaluate() throws Exception { YarnApplicationState state = yarnClient.getApplicationReport(appId).getYarnApplicationState(); finalState.setValue(state); return acceptedStates.contains(state); } }); } finally { if (yarnClient != null) { yarnClient.close(); } } log.info("Final state is: {0}", finalState.getValue()); return finalState.getValue(); }