|
@@ -180,7 +180,10 @@ public class RMAppAttemptImpl implements RMAppAttempt, Recoverable {
|
|
new ExpiredTransition();
|
|
new ExpiredTransition();
|
|
private static final AttemptFailedTransition FAILED_TRANSITION =
|
|
private static final AttemptFailedTransition FAILED_TRANSITION =
|
|
new AttemptFailedTransition();
|
|
new AttemptFailedTransition();
|
|
-
|
|
|
|
|
|
+ private static final AMRegisteredTransition REGISTERED_TRANSITION =
|
|
|
|
+ new AMRegisteredTransition();
|
|
|
|
+ private static final AMLaunchedTransition LAUNCHED_TRANSITION =
|
|
|
|
+ new AMLaunchedTransition();
|
|
private RMAppAttemptEvent eventCausingFinalSaving;
|
|
private RMAppAttemptEvent eventCausingFinalSaving;
|
|
private RMAppAttemptState targetedFinalState;
|
|
private RMAppAttemptState targetedFinalState;
|
|
private RMAppAttemptState recoveredFinalState;
|
|
private RMAppAttemptState recoveredFinalState;
|
|
@@ -310,7 +313,7 @@ public class RMAppAttemptImpl implements RMAppAttempt, Recoverable {
|
|
|
|
|
|
// Transitions from ALLOCATED State
|
|
// Transitions from ALLOCATED State
|
|
.addTransition(RMAppAttemptState.ALLOCATED, RMAppAttemptState.LAUNCHED,
|
|
.addTransition(RMAppAttemptState.ALLOCATED, RMAppAttemptState.LAUNCHED,
|
|
- RMAppAttemptEventType.LAUNCHED, new AMLaunchedTransition())
|
|
|
|
|
|
+ RMAppAttemptEventType.LAUNCHED, LAUNCHED_TRANSITION)
|
|
.addTransition(RMAppAttemptState.ALLOCATED, RMAppAttemptState.FINAL_SAVING,
|
|
.addTransition(RMAppAttemptState.ALLOCATED, RMAppAttemptState.FINAL_SAVING,
|
|
RMAppAttemptEventType.LAUNCH_FAILED,
|
|
RMAppAttemptEventType.LAUNCH_FAILED,
|
|
new FinalSavingTransition(new LaunchFailedTransition(),
|
|
new FinalSavingTransition(new LaunchFailedTransition(),
|
|
@@ -324,6 +327,8 @@ public class RMAppAttemptImpl implements RMAppAttempt, Recoverable {
|
|
RMAppAttemptEventType.FAIL,
|
|
RMAppAttemptEventType.FAIL,
|
|
new FinalSavingTransition(FAILED_TRANSITION,
|
|
new FinalSavingTransition(FAILED_TRANSITION,
|
|
RMAppAttemptState.FAILED))
|
|
RMAppAttemptState.FAILED))
|
|
|
|
+ .addTransition(RMAppAttemptState.ALLOCATED, RMAppAttemptState.RUNNING,
|
|
|
|
+ RMAppAttemptEventType.REGISTERED, REGISTERED_TRANSITION)
|
|
.addTransition(RMAppAttemptState.ALLOCATED, RMAppAttemptState.FINAL_SAVING,
|
|
.addTransition(RMAppAttemptState.ALLOCATED, RMAppAttemptState.FINAL_SAVING,
|
|
RMAppAttemptEventType.CONTAINER_FINISHED,
|
|
RMAppAttemptEventType.CONTAINER_FINISHED,
|
|
new FinalSavingTransition(
|
|
new FinalSavingTransition(
|
|
@@ -331,7 +336,7 @@ public class RMAppAttemptImpl implements RMAppAttempt, Recoverable {
|
|
|
|
|
|
// Transitions from LAUNCHED State
|
|
// Transitions from LAUNCHED State
|
|
.addTransition(RMAppAttemptState.LAUNCHED, RMAppAttemptState.RUNNING,
|
|
.addTransition(RMAppAttemptState.LAUNCHED, RMAppAttemptState.RUNNING,
|
|
- RMAppAttemptEventType.REGISTERED, new AMRegisteredTransition())
|
|
|
|
|
|
+ RMAppAttemptEventType.REGISTERED, REGISTERED_TRANSITION)
|
|
.addTransition(RMAppAttemptState.LAUNCHED,
|
|
.addTransition(RMAppAttemptState.LAUNCHED,
|
|
EnumSet.of(RMAppAttemptState.LAUNCHED, RMAppAttemptState.FINAL_SAVING),
|
|
EnumSet.of(RMAppAttemptState.LAUNCHED, RMAppAttemptState.FINAL_SAVING),
|
|
RMAppAttemptEventType.CONTAINER_FINISHED,
|
|
RMAppAttemptEventType.CONTAINER_FINISHED,
|
|
@@ -353,6 +358,8 @@ public class RMAppAttemptImpl implements RMAppAttempt, Recoverable {
|
|
RMAppAttemptState.FAILED))
|
|
RMAppAttemptState.FAILED))
|
|
|
|
|
|
// Transitions from RUNNING State
|
|
// Transitions from RUNNING State
|
|
|
|
+ .addTransition(RMAppAttemptState.RUNNING, RMAppAttemptState.RUNNING,
|
|
|
|
+ RMAppAttemptEventType.LAUNCHED)
|
|
.addTransition(RMAppAttemptState.RUNNING, RMAppAttemptState.FINAL_SAVING,
|
|
.addTransition(RMAppAttemptState.RUNNING, RMAppAttemptState.FINAL_SAVING,
|
|
RMAppAttemptEventType.UNREGISTERED, new AMUnregisteredTransition())
|
|
RMAppAttemptEventType.UNREGISTERED, new AMUnregisteredTransition())
|
|
.addTransition(RMAppAttemptState.RUNNING, RMAppAttemptState.RUNNING,
|
|
.addTransition(RMAppAttemptState.RUNNING, RMAppAttemptState.RUNNING,
|
|
@@ -417,6 +424,7 @@ public class RMAppAttemptImpl implements RMAppAttempt, Recoverable {
|
|
RMAppAttemptState.FAILED,
|
|
RMAppAttemptState.FAILED,
|
|
RMAppAttemptState.FAILED,
|
|
RMAppAttemptState.FAILED,
|
|
EnumSet.of(
|
|
EnumSet.of(
|
|
|
|
+ RMAppAttemptEventType.LAUNCHED,
|
|
RMAppAttemptEventType.EXPIRE,
|
|
RMAppAttemptEventType.EXPIRE,
|
|
RMAppAttemptEventType.KILL,
|
|
RMAppAttemptEventType.KILL,
|
|
RMAppAttemptEventType.FAIL,
|
|
RMAppAttemptEventType.FAIL,
|
|
@@ -434,6 +442,7 @@ public class RMAppAttemptImpl implements RMAppAttempt, Recoverable {
|
|
new FinalTransition(RMAppAttemptState.FINISHED))
|
|
new FinalTransition(RMAppAttemptState.FINISHED))
|
|
.addTransition(RMAppAttemptState.FINISHING, RMAppAttemptState.FINISHING,
|
|
.addTransition(RMAppAttemptState.FINISHING, RMAppAttemptState.FINISHING,
|
|
EnumSet.of(
|
|
EnumSet.of(
|
|
|
|
+ RMAppAttemptEventType.LAUNCHED,
|
|
RMAppAttemptEventType.UNREGISTERED,
|
|
RMAppAttemptEventType.UNREGISTERED,
|
|
RMAppAttemptEventType.STATUS_UPDATE,
|
|
RMAppAttemptEventType.STATUS_UPDATE,
|
|
RMAppAttemptEventType.CONTAINER_ALLOCATED,
|
|
RMAppAttemptEventType.CONTAINER_ALLOCATED,
|
|
@@ -447,6 +456,7 @@ public class RMAppAttemptImpl implements RMAppAttempt, Recoverable {
|
|
RMAppAttemptState.FINISHED,
|
|
RMAppAttemptState.FINISHED,
|
|
RMAppAttemptState.FINISHED,
|
|
RMAppAttemptState.FINISHED,
|
|
EnumSet.of(
|
|
EnumSet.of(
|
|
|
|
+ RMAppAttemptEventType.LAUNCHED,
|
|
RMAppAttemptEventType.EXPIRE,
|
|
RMAppAttemptEventType.EXPIRE,
|
|
RMAppAttemptEventType.UNREGISTERED,
|
|
RMAppAttemptEventType.UNREGISTERED,
|
|
RMAppAttemptEventType.CONTAINER_ALLOCATED,
|
|
RMAppAttemptEventType.CONTAINER_ALLOCATED,
|
|
@@ -1226,7 +1236,7 @@ public class RMAppAttemptImpl implements RMAppAttempt, Recoverable {
|
|
* 2) OR AMLivelinessMonitor expires this attempt (when am doesn't
|
|
* 2) OR AMLivelinessMonitor expires this attempt (when am doesn't
|
|
* heart beat back).
|
|
* heart beat back).
|
|
*/
|
|
*/
|
|
- (new AMLaunchedTransition()).transition(appAttempt, event);
|
|
|
|
|
|
+ LAUNCHED_TRANSITION.transition(appAttempt, event);
|
|
return RMAppAttemptState.LAUNCHED;
|
|
return RMAppAttemptState.LAUNCHED;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -1459,7 +1469,8 @@ public class RMAppAttemptImpl implements RMAppAttempt, Recoverable {
|
|
@Override
|
|
@Override
|
|
public void transition(RMAppAttemptImpl appAttempt,
|
|
public void transition(RMAppAttemptImpl appAttempt,
|
|
RMAppAttemptEvent event) {
|
|
RMAppAttemptEvent event) {
|
|
- if (event.getType() == RMAppAttemptEventType.LAUNCHED) {
|
|
|
|
|
|
+ if (event.getType() == RMAppAttemptEventType.LAUNCHED
|
|
|
|
+ || event.getType() == RMAppAttemptEventType.REGISTERED) {
|
|
appAttempt.launchAMEndTime = System.currentTimeMillis();
|
|
appAttempt.launchAMEndTime = System.currentTimeMillis();
|
|
long delay = appAttempt.launchAMEndTime -
|
|
long delay = appAttempt.launchAMEndTime -
|
|
appAttempt.launchAMStartTime;
|
|
appAttempt.launchAMStartTime;
|
|
@@ -1586,6 +1597,10 @@ public class RMAppAttemptImpl implements RMAppAttempt, Recoverable {
|
|
@Override
|
|
@Override
|
|
public void transition(RMAppAttemptImpl appAttempt,
|
|
public void transition(RMAppAttemptImpl appAttempt,
|
|
RMAppAttemptEvent event) {
|
|
RMAppAttemptEvent event) {
|
|
|
|
+ if (!RMAppAttemptState.LAUNCHED.equals(appAttempt.getState())) {
|
|
|
|
+ // registered received before launch
|
|
|
|
+ LAUNCHED_TRANSITION.transition(appAttempt, event);
|
|
|
|
+ }
|
|
long delay = System.currentTimeMillis() - appAttempt.launchAMEndTime;
|
|
long delay = System.currentTimeMillis() - appAttempt.launchAMEndTime;
|
|
ClusterMetrics.getMetrics().addAMRegisterDelay(delay);
|
|
ClusterMetrics.getMetrics().addAMRegisterDelay(delay);
|
|
RMAppAttemptRegistrationEvent registrationEvent
|
|
RMAppAttemptRegistrationEvent registrationEvent
|