YARN-6819. Application report fails if app rejected due to nodesize. Contributed by Bibin A Chundatt.

This commit is contained in:
Rohith Sharma K S 2017-07-19 11:10:52 +05:30
parent daaf530fce
commit 845c4e52bd
6 changed files with 33 additions and 36 deletions

View File

@ -221,8 +221,9 @@ public RMStateStoreState transition(RMStateStore store,
} catch (Exception e) {
LOG.error("Error storing app: " + appId, e);
if (e instanceof StoreLimitException) {
store.notifyApplication(new RMAppEvent(appId,
RMAppEventType.APP_REJECTED, e.getMessage(), false));
store.notifyApplication(
new RMAppEvent(appId, RMAppEventType.APP_SAVE_FAILED,
e.getMessage()));
} else {
isFenced = store.notifyStoreOperationFailedInternal(e);
}

View File

@ -25,7 +25,6 @@ public class RMAppEvent extends AbstractEvent<RMAppEventType>{
private final ApplicationId appId;
private final String diagnosticMsg;
private boolean storeAppInfo;
public RMAppEvent(ApplicationId appId, RMAppEventType type) {
this(appId, type, "");
@ -36,21 +35,6 @@ public RMAppEvent(ApplicationId appId, RMAppEventType type,
super(type);
this.appId = appId;
this.diagnosticMsg = diagnostic;
this.storeAppInfo = true;
}
/**
* Constructor to create RM Application Event type.
*
* @param appId application Id
* @param type RM Event type
* @param diagnostic Diagnostic message for event
* @param storeApp Application should be saved or not
*/
public RMAppEvent(ApplicationId appId, RMAppEventType type, String diagnostic,
boolean storeApp) {
this(appId, type, diagnostic);
this.storeAppInfo = storeApp;
}
public ApplicationId getApplicationId() {
@ -61,12 +45,4 @@ public String getDiagnosticMsg() {
return this.diagnosticMsg;
}
/**
* Store application to state store or not.
*
* @return boolean application should be saved to store.
*/
public boolean doStoreAppInfo() {
return storeAppInfo;
}
}

View File

@ -47,4 +47,5 @@ public enum RMAppEventType {
// Source: RMStateStore
APP_NEW_SAVED,
APP_UPDATE_SAVED,
APP_SAVE_FAILED,
}

View File

@ -243,6 +243,8 @@ RMAppEventType.APP_NEW_SAVED, new AddApplicationToSchedulerTransition())
RMAppEventType.APP_REJECTED,
new FinalSavingTransition(new AppRejectedTransition(),
RMAppState.FAILED))
.addTransition(RMAppState.NEW_SAVING, RMAppState.FAILED,
RMAppEventType.APP_SAVE_FAILED, new AppRejectedTransition())
// Transitions from SUBMITTED state
.addTransition(RMAppState.SUBMITTED, RMAppState.SUBMITTED,
@ -1307,12 +1309,10 @@ public FinalSavingTransition(Object transitionToDo,
@Override
public void transition(RMAppImpl app, RMAppEvent event) {
if (event.doStoreAppInfo()) {
app.rememberTargetTransitionsAndStoreState(event, transitionToDo,
targetedFinalState, stateToBeStored);
}
}
}
private static class AttemptUnregisteredTransition extends RMAppTransition {
@Override

View File

@ -270,20 +270,22 @@ public void testZKNodeLimit() throws Exception {
GenericTestUtils.waitFor(new Supplier<Boolean>() {
@Override
public Boolean get() {
return dispatcher.apprejectedEvnt;
return dispatcher.appsavefailedEvnt;
}
}, 100, 5000);
}
static class TestAppRejDispatcher extends TestDispatcher {
private boolean apprejectedEvnt;
private boolean appsavefailedEvnt;
public void handle(Event event) {
if (event instanceof RMAppEvent
&& event.getType().equals(RMAppEventType.APP_REJECTED)) {
apprejectedEvnt = true;
if (event instanceof RMAppEvent && event.getType()
.equals(RMAppEventType.APP_SAVE_FAILED)) {
appsavefailedEvnt = true;
}
};
}
;
}
@Test (timeout = 60000)

View File

@ -652,6 +652,23 @@ public void testAppNewSavingReject() throws IOException {
verifyApplicationFinished(RMAppState.FAILED);
}
@Test (timeout = 30000)
public void testAppNewSavingSaveReject() throws IOException {
LOG.info("--- START: testAppNewSavingSaveReject ---");
RMApp application = testCreateAppNewSaving(null);
// NEW_SAVING => FAILED event RMAppEventType.APP_SAVE_FAILED
String rejectedText = "Test Application Rejected";
RMAppEvent event = new RMAppEvent(application.getApplicationId(),
RMAppEventType.APP_SAVE_FAILED, rejectedText);
application.handle(event);
rmDispatcher.await();
assertFailed(application, rejectedText);
verify(store, times(0)).updateApplicationState(
any(ApplicationStateData.class));
verifyApplicationFinished(RMAppState.FAILED);
assertTimesAtFinish(application);
}
@Test (timeout = 30000)
public void testAppSubmittedRejected() throws IOException {
LOG.info("--- START: testAppSubmittedRejected ---");