thanks for you patch,
1, waitForSchedulerAppAttemptAdded may be not done as expected
public T getApplicationAttempt(ApplicationAttemptId applicationAttemptId)
SchedulerApplication<T> app =
return app == null ? null : app.getCurrentAppAttempt();
as above shows, this func just get the current appAttempt not the appAttempt correspongding to applicationAttemptId. (A BUG?)
2, SCHEDULED is not a stable state, is it possible other nm heartbeat makes it becomes allocated, wait for this state will be blocked?