Example usage for org.apache.hadoop.yarn.api.protocolrecords FinishApplicationMasterResponse getIsUnregistered

List of usage examples for org.apache.hadoop.yarn.api.protocolrecords FinishApplicationMasterResponse getIsUnregistered

Introduction

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

Prototype

@Public
@Stable
public abstract boolean getIsUnregistered();

Source Link

Document

Get the flag which indicates that the application has successfully unregistered with the RM and the application can safely stop.

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 .  j a v a 2s.  co 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);
    }
}