List of usage examples for org.apache.hadoop.yarn.api.protocolrecords GetApplicationReportRequest newInstance
@Public @Stable public static GetApplicationReportRequest newInstance(ApplicationId applicationId)
From source file:org.apache.hoya.yarn.appmaster.rpc.RpcBinder.java
License:Apache License
/** * This loops for a limited period trying to get the Proxy - * by doing so it handles AM failover/*from www. jav a2 s.co m*/ * @param conf configuration to patch and use * @param rmClient client of the resource manager * @param application application to work with * @param connectTimeout timeout for the whole proxy operation to timeout * (milliseconds). Use 0 to indicate "do not attempt to wait" -fail fast. * @param rpcTimeout timeout for RPCs to block during communications * @return the proxy * @throws IOException IO problems * @throws YarnException Hoya-generated exceptions related to the binding * failing. This can include the application finishing or timeouts * @throws InterruptedException if a sleep operation waiting for * the cluster to respond is interrupted. */ @SuppressWarnings("NestedAssignment") public static HoyaClusterProtocol getProxy(final Configuration conf, final ApplicationClientProtocol rmClient, ApplicationReport application, final int connectTimeout, final int rpcTimeout) throws IOException, YarnException, InterruptedException { ApplicationId appId; appId = application.getApplicationId(); Duration timeout = new Duration(connectTimeout); timeout.start(); Exception exception = null; YarnApplicationState state = null; while (application != null && (state = application.getYarnApplicationState()).equals(YarnApplicationState.RUNNING)) { try { return getProxy(conf, application, rpcTimeout); } catch (IOException e) { if (connectTimeout <= 0 || timeout.getLimitExceeded()) { throw e; } exception = e; } catch (YarnException e) { if (connectTimeout <= 0 || timeout.getLimitExceeded()) { throw e; } exception = e; } //at this point: app failed to work log.debug("Could not connect to {}. Waiting for getting the latest AM address...", appId); Thread.sleep(1000); //or get the app report application = rmClient.getApplicationReport(GetApplicationReportRequest.newInstance(appId)) .getApplicationReport(); } //get here if the app is no longer running. Raise a specific //exception but init it with the previous failure throw new BadClusterStateException(exception, ErrorStrings.E_FINISHED_APPLICATION, appId, state); }
From source file:org.apache.slider.server.appmaster.rpc.RpcBinder.java
License:Apache License
/** * This loops for a limited period trying to get the Proxy - * by doing so it handles AM failover/*from w ww. j a v a 2s . c o m*/ * @param conf configuration to patch and use * @param rmClient client of the resource manager * @param application application to work with * @param connectTimeout timeout for the whole proxy operation to timeout * (milliseconds). Use 0 to indicate "do not attempt to wait" -fail fast. * @param rpcTimeout timeout for RPCs to block during communications * @return the proxy * @throws IOException IO problems * @throws YarnException Slider-generated exceptions related to the binding * failing. This can include the application finishing or timeouts * @throws InterruptedException if a sleep operation waiting for * the cluster to respond is interrupted. */ @SuppressWarnings("NestedAssignment") public static SliderClusterProtocol getProxy(final Configuration conf, final ApplicationClientProtocol rmClient, ApplicationReport application, final int connectTimeout, final int rpcTimeout) throws IOException, YarnException, InterruptedException { ApplicationId appId; appId = application.getApplicationId(); Duration timeout = new Duration(connectTimeout); timeout.start(); Exception exception = null; YarnApplicationState state = null; while (application != null && (state = application.getYarnApplicationState()).equals(YarnApplicationState.RUNNING)) { try { return getProxy(conf, application, rpcTimeout); } catch (IOException e) { if (connectTimeout <= 0 || timeout.getLimitExceeded()) { throw e; } exception = e; } catch (YarnException e) { if (connectTimeout <= 0 || timeout.getLimitExceeded()) { throw e; } exception = e; } //at this point: app failed to work log.debug("Could not connect to {}. Waiting for getting the latest AM address...", appId); Thread.sleep(1000); //or get the app report application = rmClient.getApplicationReport(GetApplicationReportRequest.newInstance(appId)) .getApplicationReport(); } //get here if the app is no longer running. Raise a specific //exception but init it with the previous failure throw new BadClusterStateException(exception, ErrorStrings.E_FINISHED_APPLICATION, appId, state); }