Example usage for org.apache.hadoop.yarn.api.protocolrecords FinishApplicationMasterRequest newInstance

List of usage examples for org.apache.hadoop.yarn.api.protocolrecords FinishApplicationMasterRequest newInstance

Introduction

In this page you can find the example usage for org.apache.hadoop.yarn.api.protocolrecords FinishApplicationMasterRequest newInstance.

Prototype

@Public
    @Stable
    public static FinishApplicationMasterRequest newInstance(FinalApplicationStatus finalAppStatus,
            String diagnostics, String url) 

Source Link

Usage

From source file:disAMS.AMRMClient.Impl.AMRMClientImpl.java

License:Apache License

@Override
public void unregisterApplicationMaster(FinalApplicationStatus appStatus, String appMessage,
        String appTrackingUrl) throws YarnException, IOException {
    Preconditions.checkArgument(appStatus != null, "AppStatus should not be null.");
    FinishApplicationMasterRequest request = FinishApplicationMasterRequest.newInstance(appStatus, appMessage,
            appTrackingUrl);/*from  ww w .  ja v a  2s. c  o  m*/
    try {
        while (true) {
            FinishApplicationMasterResponse response = rmClient.finishApplicationMaster(request);
            if (response.getIsUnregistered()) {
                break;
            }
            LOG.info("Waiting for application to be successfully unregistered.");
            Thread.sleep(100);
        }
    } catch (InterruptedException e) {
        LOG.info("Interrupted while waiting for application" + " to be removed from RMStateStore");
    } catch (ApplicationMasterNotRegisteredException e) {
        LOG.warn("ApplicationMaster is out of sync with ResourceManager," + " hence resyncing.");
        // re register with RM
        registerApplicationMaster();
        unregisterApplicationMaster(appStatus, appMessage, appTrackingUrl);
    }
}