|
@@ -269,6 +269,7 @@ public class ResourceManager extends CompositeService implements Recoverable {
|
|
|
@VisibleForTesting
|
|
|
protected void setRMStateStore(RMStateStore rmStore) {
|
|
|
rmStore.setRMDispatcher(rmDispatcher);
|
|
|
+ rmStore.setResourceManager(this);
|
|
|
rmContext.setStateStore(rmStore);
|
|
|
}
|
|
|
|
|
@@ -397,11 +398,12 @@ public class ResourceManager extends CompositeService implements Recoverable {
|
|
|
private EventHandler<SchedulerEvent> schedulerDispatcher;
|
|
|
private ApplicationMasterLauncher applicationMasterLauncher;
|
|
|
private ContainerAllocationExpirer containerAllocationExpirer;
|
|
|
-
|
|
|
+ private ResourceManager rm;
|
|
|
private boolean recoveryEnabled;
|
|
|
|
|
|
- RMActiveServices() {
|
|
|
+ RMActiveServices(ResourceManager rm) {
|
|
|
super("RMActiveServices");
|
|
|
+ this.rm = rm;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -449,6 +451,7 @@ public class ResourceManager extends CompositeService implements Recoverable {
|
|
|
try {
|
|
|
rmStore.init(conf);
|
|
|
rmStore.setRMDispatcher(rmDispatcher);
|
|
|
+ rmStore.setResourceManager(rm);
|
|
|
} catch (Exception e) {
|
|
|
// the Exception from stateStore.init() needs to be handled for
|
|
|
// HA and we need to give up master status if we got fenced
|
|
@@ -729,39 +732,31 @@ public class ResourceManager extends CompositeService implements Recoverable {
|
|
|
@Private
|
|
|
public static class RMFatalEventDispatcher
|
|
|
implements EventHandler<RMFatalEvent> {
|
|
|
- private final RMContext rmContext;
|
|
|
- private final ResourceManager rm;
|
|
|
-
|
|
|
- public RMFatalEventDispatcher(
|
|
|
- RMContext rmContext, ResourceManager resourceManager) {
|
|
|
- this.rmContext = rmContext;
|
|
|
- this.rm = resourceManager;
|
|
|
- }
|
|
|
|
|
|
@Override
|
|
|
public void handle(RMFatalEvent event) {
|
|
|
LOG.fatal("Received a " + RMFatalEvent.class.getName() + " of type " +
|
|
|
event.getType().name() + ". Cause:\n" + event.getCause());
|
|
|
|
|
|
- if (event.getType() == RMFatalEventType.STATE_STORE_FENCED) {
|
|
|
- LOG.info("RMStateStore has been fenced");
|
|
|
- if (rmContext.isHAEnabled()) {
|
|
|
- try {
|
|
|
- // Transition to standby and reinit active services
|
|
|
- LOG.info("Transitioning RM to Standby mode");
|
|
|
- rm.transitionToStandby(true);
|
|
|
- rm.adminService.resetLeaderElection();
|
|
|
- return;
|
|
|
- } catch (Exception e) {
|
|
|
- LOG.fatal("Failed to transition RM to Standby mode.");
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
ExitUtil.terminate(1, event.getCause());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public void handleTransitionToStandBy() {
|
|
|
+ if (rmContext.isHAEnabled()) {
|
|
|
+ try {
|
|
|
+ // Transition to standby and reinit active services
|
|
|
+ LOG.info("Transitioning RM to Standby mode");
|
|
|
+ transitionToStandby(true);
|
|
|
+ adminService.resetLeaderElection();
|
|
|
+ return;
|
|
|
+ } catch (Exception e) {
|
|
|
+ LOG.fatal("Failed to transition RM to Standby mode.");
|
|
|
+ ExitUtil.terminate(1, e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@Private
|
|
|
public static final class ApplicationEventDispatcher implements
|
|
|
EventHandler<RMAppEvent> {
|
|
@@ -990,7 +985,7 @@ public class ResourceManager extends CompositeService implements Recoverable {
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
protected void createAndInitActiveServices() throws Exception {
|
|
|
- activeServices = new RMActiveServices();
|
|
|
+ activeServices = new RMActiveServices(this);
|
|
|
activeServices.init(conf);
|
|
|
}
|
|
|
|
|
@@ -1227,7 +1222,7 @@ public class ResourceManager extends CompositeService implements Recoverable {
|
|
|
private Dispatcher setupDispatcher() {
|
|
|
Dispatcher dispatcher = createDispatcher();
|
|
|
dispatcher.register(RMFatalEventType.class,
|
|
|
- new ResourceManager.RMFatalEventDispatcher(this.rmContext, this));
|
|
|
+ new ResourceManager.RMFatalEventDispatcher());
|
|
|
return dispatcher;
|
|
|
}
|
|
|
|