YARN-8085. ResourceProfilesManager should be set in RMActiveServiceContext. Contributed by Tao Yang.

This commit is contained in:
Sunil G 2018-03-29 21:41:16 +05:30
parent ad10cbd91b
commit 7a59d60e0c
4 changed files with 58 additions and 11 deletions

View File

@ -36,6 +36,7 @@ import org.apache.hadoop.yarn.server.resourcemanager.placement.PlacementManager;
import org.apache.hadoop.yarn.server.resourcemanager.recovery.NullRMStateStore; import org.apache.hadoop.yarn.server.resourcemanager.recovery.NullRMStateStore;
import org.apache.hadoop.yarn.server.resourcemanager.recovery.RMStateStore; import org.apache.hadoop.yarn.server.resourcemanager.recovery.RMStateStore;
import org.apache.hadoop.yarn.server.resourcemanager.reservation.ReservationSystem; import org.apache.hadoop.yarn.server.resourcemanager.reservation.ReservationSystem;
import org.apache.hadoop.yarn.server.resourcemanager.resource.ResourceProfilesManager;
import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp; import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp;
import org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.AMLivelinessMonitor; import org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.AMLivelinessMonitor;
import org.apache.hadoop.yarn.server.resourcemanager.rmapp.monitor.RMAppLifetimeMonitor; import org.apache.hadoop.yarn.server.resourcemanager.rmapp.monitor.RMAppLifetimeMonitor;
@ -111,6 +112,7 @@ public class RMActiveServiceContext {
private QueueLimitCalculator queueLimitCalculator; private QueueLimitCalculator queueLimitCalculator;
private AllocationTagsManager allocationTagsManager; private AllocationTagsManager allocationTagsManager;
private PlacementConstraintManager placementConstraintManager; private PlacementConstraintManager placementConstraintManager;
private ResourceProfilesManager resourceProfilesManager;
public RMActiveServiceContext() { public RMActiveServiceContext() {
queuePlacementManager = new PlacementManager(); queuePlacementManager = new PlacementManager();
@ -513,4 +515,13 @@ public class RMActiveServiceContext {
QueueLimitCalculator limitCalculator) { QueueLimitCalculator limitCalculator) {
this.queueLimitCalculator = limitCalculator; this.queueLimitCalculator = limitCalculator;
} }
public ResourceProfilesManager getResourceProfilesManager() {
return resourceProfilesManager;
}
public void setResourceProfilesManager(
ResourceProfilesManager resourceProfilesManager) {
this.resourceProfilesManager = resourceProfilesManager;
}
} }

View File

@ -93,8 +93,6 @@ public class RMContextImpl implements RMContext {
*/ */
private RMActiveServiceContext activeServiceContext; private RMActiveServiceContext activeServiceContext;
private ResourceProfilesManager resourceProfilesManager;
private String proxyHostAndPort = null; private String proxyHostAndPort = null;
/** /**
@ -591,7 +589,7 @@ public class RMContextImpl implements RMContext {
@Override @Override
public ResourceProfilesManager getResourceProfilesManager() { public ResourceProfilesManager getResourceProfilesManager() {
return this.resourceProfilesManager; return this.activeServiceContext.getResourceProfilesManager();
} }
String getProxyHostAndPort(Configuration conf) { String getProxyHostAndPort(Configuration conf) {
@ -619,7 +617,7 @@ public class RMContextImpl implements RMContext {
@Override @Override
public void setResourceProfilesManager(ResourceProfilesManager mgr) { public void setResourceProfilesManager(ResourceProfilesManager mgr) {
this.resourceProfilesManager = mgr; this.activeServiceContext.setResourceProfilesManager(mgr);
} }
// Note: Read java doc before adding any services over here. // Note: Read java doc before adding any services over here.
} }

View File

@ -245,13 +245,6 @@ public class ResourceManager extends CompositeService implements Recoverable {
this.rmContext = new RMContextImpl(); this.rmContext = new RMContextImpl();
rmContext.setResourceManager(this); rmContext.setResourceManager(this);
// add resource profiles here because it's used by AbstractYarnScheduler
ResourceProfilesManager resourceProfilesManager =
createResourceProfileManager();
resourceProfilesManager.init(conf);
rmContext.setResourceProfilesManager(resourceProfilesManager);
this.configurationProvider = this.configurationProvider =
ConfigurationProviderFactory.getConfigurationProvider(conf); ConfigurationProviderFactory.getConfigurationProvider(conf);
this.configurationProvider.init(this.conf); this.configurationProvider.init(this.conf);
@ -655,6 +648,12 @@ public class ResourceManager extends CompositeService implements Recoverable {
addService(placementConstraintManager); addService(placementConstraintManager);
rmContext.setPlacementConstraintManager(placementConstraintManager); rmContext.setPlacementConstraintManager(placementConstraintManager);
// add resource profiles here because it's used by AbstractYarnScheduler
ResourceProfilesManager resourceProfilesManager =
createResourceProfileManager();
resourceProfilesManager.init(conf);
rmContext.setResourceProfilesManager(resourceProfilesManager);
RMDelegatedNodeLabelsUpdater delegatedNodeLabelsUpdater = RMDelegatedNodeLabelsUpdater delegatedNodeLabelsUpdater =
createRMDelegatedNodeLabelsUpdater(); createRMDelegatedNodeLabelsUpdater();
if (delegatedNodeLabelsUpdater != null) { if (delegatedNodeLabelsUpdater != null) {

View File

@ -658,6 +658,45 @@ public class TestRMHA {
assertEquals(HAServiceState.STANDBY, rm.getRMContext().getHAServiceState()); assertEquals(HAServiceState.STANDBY, rm.getRMContext().getHAServiceState());
} }
@Test
public void testResourceProfilesManagerAfterRMWentStandbyThenBackToActive()
throws Exception {
configuration.setBoolean(YarnConfiguration.AUTO_FAILOVER_ENABLED, false);
configuration.setBoolean(YarnConfiguration.RECOVERY_ENABLED, true);
Configuration conf = new YarnConfiguration(configuration);
conf.set(YarnConfiguration.RM_STORE, MemoryRMStateStore.class.getName());
// 1. start RM
rm = new MockRM(conf);
rm.init(conf);
rm.start();
StateChangeRequestInfo requestInfo = new StateChangeRequestInfo(
HAServiceProtocol.RequestSource.REQUEST_BY_USER);
checkMonitorHealth();
checkStandbyRMFunctionality();
// 2. Transition to active
rm.adminService.transitionToActive(requestInfo);
checkMonitorHealth();
checkActiveRMFunctionality();
// 3. Transition to standby
rm.adminService.transitionToStandby(requestInfo);
checkMonitorHealth();
checkStandbyRMFunctionality();
// 4. Transition to active
rm.adminService.transitionToActive(requestInfo);
checkMonitorHealth();
checkActiveRMFunctionality();
// 5. Check ResourceProfilesManager
Assert.assertNotNull(
"ResourceProfilesManager should not be null!",
rm.getRMContext().getResourceProfilesManager());
}
public void innerTestHAWithRMHostName(boolean includeBindHost) { public void innerTestHAWithRMHostName(boolean includeBindHost) {
//this is run two times, with and without a bind host configured //this is run two times, with and without a bind host configured
if (includeBindHost) { if (includeBindHost) {