diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/ProtocolHATestBase.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/ProtocolHATestBase.java index 15bfa28..ea189e6 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/ProtocolHATestBase.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/ProtocolHATestBase.java @@ -354,10 +354,7 @@ protected void doSecureLogin() throws IOException { @Override protected ClientRMService createClientRMService() { if (overrideClientRMService) { - return new CustomedClientRMService(this.rmContext, this.scheduler, - this.rmAppManager, this.applicationACLsManager, - this.queueACLsManager, - this.rmContext.getRMDelegationTokenSecretManager()); + return new CustomedClientRMService(this.rmContext, this.scheduler); } return super.createClientRMService(); } @@ -365,7 +362,8 @@ protected ClientRMService createClientRMService() { protected ResourceTrackerService createResourceTrackerService() { if (overrideRTS) { return new CustomedResourceTrackerService(this.rmContext, - this.nodesListManager, this.nmLivelinessMonitor, + this.rmContext.getNodesListManager(), + this.rmContext.getNMLivelinessMonitor(), this.rmContext.getContainerTokenSecretManager(), this.rmContext.getNMTokenSecretManager()); } @@ -384,12 +382,8 @@ protected ApplicationMasterService createApplicationMasterService() { private class CustomedClientRMService extends ClientRMService { public CustomedClientRMService(RMContext rmContext, - YarnScheduler scheduler, RMAppManager rmAppManager, - ApplicationACLsManager applicationACLsManager, - QueueACLsManager queueACLsManager, - RMDelegationTokenSecretManager rmDTSecretManager) { - super(rmContext, scheduler, rmAppManager, applicationACLsManager, - queueACLsManager, rmDTSecretManager); + YarnScheduler scheduler) { + super(rmContext, scheduler); } @Override diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ClientRMService.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ClientRMService.java index d8554bd..f1eec91 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ClientRMService.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ClientRMService.java @@ -118,10 +118,7 @@ import org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerAppReport; import org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerNodeReport; import org.apache.hadoop.yarn.server.resourcemanager.scheduler.YarnScheduler; -import org.apache.hadoop.yarn.server.resourcemanager.security.QueueACLsManager; -import org.apache.hadoop.yarn.server.resourcemanager.security.RMDelegationTokenSecretManager; import org.apache.hadoop.yarn.server.resourcemanager.security.authorize.RMPolicyProvider; -import org.apache.hadoop.yarn.server.security.ApplicationACLsManager; import org.apache.hadoop.yarn.server.utils.BuilderUtils; import org.apache.hadoop.yarn.util.Records; @@ -143,28 +140,17 @@ final private AtomicInteger applicationCounter = new AtomicInteger(0); final private YarnScheduler scheduler; final private RMContext rmContext; - private final RMAppManager rmAppManager; private Server server; - protected RMDelegationTokenSecretManager rmDTSecretManager; private final RecordFactory recordFactory = RecordFactoryProvider.getRecordFactory(null); InetSocketAddress clientBindAddress; - private final ApplicationACLsManager applicationsACLsManager; - private final QueueACLsManager queueACLsManager; - public ClientRMService(RMContext rmContext, YarnScheduler scheduler, - RMAppManager rmAppManager, ApplicationACLsManager applicationACLsManager, - QueueACLsManager queueACLsManager, - RMDelegationTokenSecretManager rmDTSecretManager) { + public ClientRMService(RMContext rmContext, YarnScheduler scheduler) { super(ClientRMService.class.getName()); this.scheduler = scheduler; this.rmContext = rmContext; - this.rmAppManager = rmAppManager; - this.applicationsACLsManager = applicationACLsManager; - this.queueACLsManager = queueACLsManager; - this.rmDTSecretManager = rmDTSecretManager; } @Override @@ -180,7 +166,7 @@ protected void serviceStart() throws Exception { this.server = rpc.getServer(ApplicationClientProtocol.class, this, clientBindAddress, - conf, this.rmDTSecretManager, + conf, rmContext.getRMDelegationTokenSecretManager(), conf.getInt(YarnConfiguration.RM_CLIENT_THREAD_COUNT, YarnConfiguration.DEFAULT_RM_CLIENT_THREAD_COUNT)); @@ -234,10 +220,10 @@ public InetSocketAddress getBindAddress() { private boolean checkAccess(UserGroupInformation callerUGI, String owner, ApplicationAccessType operationPerformed, RMApp application) { - return applicationsACLsManager.checkAccess(callerUGI, operationPerformed, - owner, application.getApplicationId()) - || queueACLsManager.checkAccess(callerUGI, QueueACL.ADMINISTER_QUEUE, - application.getQueue()); + return rmContext.getApplicationACLsManager().checkAccess( + callerUGI, operationPerformed, owner, application.getApplicationId()) + || rmContext.getQueueACLsManager().checkAccess( + callerUGI, QueueACL.ADMINISTER_QUEUE, application.getQueue()); } ApplicationId getNewApplicationId() { @@ -532,7 +518,7 @@ public SubmitApplicationResponse submitApplication( try { // call RMAppManager to submit application directly - rmAppManager.submitApplication(submissionContext, + rmContext.getRMAppManager().submitApplication(submissionContext, System.currentTimeMillis(), user); LOG.info("Application with id " + applicationId.getId() + @@ -867,7 +853,7 @@ public GetDelegationTokenResponse getDelegationToken( realUser); Token realRMDTtoken = new Token(tokenIdentifier, - this.rmDTSecretManager); + rmContext.getRMDelegationTokenSecretManager()); response.setRMDelegationToken( BuilderUtils.newDelegationToken( realRMDTtoken.getIdentifier(), @@ -896,7 +882,8 @@ public RenewDelegationTokenResponse renewDelegationToken( new Text(protoToken.getKind()), new Text(protoToken.getService())); String user = getRenewerForToken(token); - long nextExpTime = rmDTSecretManager.renewToken(token, user); + long nextExpTime = rmContext.getRMDelegationTokenSecretManager() + .renewToken(token, user); RenewDelegationTokenResponse renewResponse = Records .newRecord(RenewDelegationTokenResponse.class); renewResponse.setNextExpirationTime(nextExpTime); @@ -920,7 +907,7 @@ public CancelDelegationTokenResponse cancelDelegationToken( new Text(protoToken.getKind()), new Text(protoToken.getService())); String user = getRenewerForToken(token); - rmDTSecretManager.cancelToken(token, user); + rmContext.getRMDelegationTokenSecretManager().cancelToken(token, user); return Records.newRecord(CancelDelegationTokenResponse.class); } catch (IOException e) { throw RPCUtil.getRemoteException(e); diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/RMAppManager.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/RMAppManager.java index 51024cf..4daccfb 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/RMAppManager.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/RMAppManager.java @@ -52,7 +52,6 @@ import org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttemptImpl; import org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerUtils; import org.apache.hadoop.yarn.server.resourcemanager.scheduler.YarnScheduler; -import org.apache.hadoop.yarn.server.security.ApplicationACLsManager; import org.apache.hadoop.yarn.server.utils.BuilderUtils; import com.google.common.annotations.VisibleForTesting; @@ -73,16 +72,14 @@ private final RMContext rmContext; private final ApplicationMasterService masterService; private final YarnScheduler scheduler; - private final ApplicationACLsManager applicationACLsManager; private Configuration conf; public RMAppManager(RMContext context, YarnScheduler scheduler, ApplicationMasterService masterService, - ApplicationACLsManager applicationACLsManager, Configuration conf) { + Configuration conf) { this.rmContext = context; this.scheduler = scheduler; this.masterService = masterService; - this.applicationACLsManager = applicationACLsManager; this.conf = conf; this.maxCompletedAppsInMemory = conf.getInt( YarnConfiguration.RM_MAX_COMPLETED_APPLICATIONS, @@ -258,7 +255,7 @@ protected synchronized void checkAppNumCompletedLimit() { + this.maxCompletedAppsInMemory + ", removing app " + removeId + " from memory: "); rmContext.getRMApps().remove(removeId); - this.applicationACLsManager.removeApplication(removeId); + rmContext.getApplicationACLsManager().removeApplication(removeId); } } @@ -363,7 +360,7 @@ private RMAppImpl createAndPopulateNewRMApp( throw RPCUtil.getRemoteException(message); } // Inform the ACLs Manager - this.applicationACLsManager.addApplication(applicationId, + rmContext.getApplicationACLsManager().addApplication(applicationId, submissionContext.getAMContainerSpec().getApplicationACLs()); return application; } diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/RMContext.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/RMContext.java index 517e680..07f03f2 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/RMContext.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/RMContext.java @@ -36,8 +36,10 @@ import org.apache.hadoop.yarn.server.resourcemanager.security.ClientToAMTokenSecretManagerInRM; import org.apache.hadoop.yarn.server.resourcemanager.security.DelegationTokenRenewer; import org.apache.hadoop.yarn.server.resourcemanager.security.NMTokenSecretManagerInRM; +import org.apache.hadoop.yarn.server.resourcemanager.security.QueueACLsManager; import org.apache.hadoop.yarn.server.resourcemanager.security.RMContainerTokenSecretManager; import org.apache.hadoop.yarn.server.resourcemanager.security.RMDelegationTokenSecretManager; +import org.apache.hadoop.yarn.server.security.ApplicationACLsManager; /** * Context of the ResourceManager. @@ -76,6 +78,8 @@ NodesListManager getNodesListManager(); + NMLivelinessMonitor getNMLivelinessMonitor(); + ClientToAMTokenSecretManagerInRM getClientToAMTokenSecretManager(); AdminService getRMAdminService(); @@ -100,5 +104,12 @@ void setRMApplicationHistoryWriter( ConfigurationProvider getConfigurationProvider(); + ApplicationACLsManager getApplicationACLsManager(); + + QueueACLsManager getQueueACLsManager(); + + RMAppManager getRMAppManager(); + boolean isWorkPreservingRecoveryEnabled(); + } \ No newline at end of file diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/RMContextImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/RMContextImpl.java index 1abc660..4ad5a72 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/RMContextImpl.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/RMContextImpl.java @@ -41,10 +41,12 @@ import org.apache.hadoop.yarn.server.resourcemanager.security.ClientToAMTokenSecretManagerInRM; import org.apache.hadoop.yarn.server.resourcemanager.security.DelegationTokenRenewer; import org.apache.hadoop.yarn.server.resourcemanager.security.NMTokenSecretManagerInRM; +import org.apache.hadoop.yarn.server.resourcemanager.security.QueueACLsManager; import org.apache.hadoop.yarn.server.resourcemanager.security.RMContainerTokenSecretManager; import org.apache.hadoop.yarn.server.resourcemanager.security.RMDelegationTokenSecretManager; import com.google.common.annotations.VisibleForTesting; +import org.apache.hadoop.yarn.server.security.ApplicationACLsManager; public class RMContextImpl implements RMContext { @@ -78,10 +80,14 @@ private RMDelegationTokenSecretManager rmDelegationTokenSecretManager; private ResourceScheduler scheduler; private NodesListManager nodesListManager; + private NMLivelinessMonitor nmLivelinessMonitor; private ResourceTrackerService resourceTrackerService; private ApplicationMasterService applicationMasterService; private RMApplicationHistoryWriter rmApplicationHistoryWriter; private ConfigurationProvider configurationProvider; + private ApplicationACLsManager applicationACLsManager; + private QueueACLsManager queueACLsManager; + private RMAppManager rmAppManager; /** * Default constructor. To be used in conjunction with setter methods for @@ -199,6 +205,11 @@ public NodesListManager getNodesListManager() { } @Override + public NMLivelinessMonitor getNMLivelinessMonitor() { + return this.nmLivelinessMonitor; + } + + @Override public ClientToAMTokenSecretManagerInRM getClientToAMTokenSecretManager() { return this.clientToAMTokenSecretManager; } @@ -228,6 +239,21 @@ public ResourceTrackerService getResourceTrackerService() { return resourceTrackerService; } + @Override + public ApplicationACLsManager getApplicationACLsManager() { + return applicationACLsManager; + } + + @Override + public QueueACLsManager getQueueACLsManager() { + return queueACLsManager; + } + + @Override + public RMAppManager getRMAppManager() { + return rmAppManager; + } + void setHAEnabled(boolean isHAEnabled) { this.isHAEnabled = isHAEnabled; } @@ -307,6 +333,10 @@ void setAMRMTokenSecretManager( void setNodesListManager(NodesListManager nodesListManager) { this.nodesListManager = nodesListManager; } + + void setNMLivelinessMonitor(NMLivelinessMonitor nmLivelinessMonitor) { + this.nmLivelinessMonitor = nmLivelinessMonitor; + } void setApplicationMasterService( ApplicationMasterService applicationMasterService) { @@ -318,6 +348,20 @@ void setResourceTrackerService( this.resourceTrackerService = resourceTrackerService; } + void setApplicationACLsManager( + ApplicationACLsManager applicationACLsManager) { + this.applicationACLsManager = applicationACLsManager; + } + + void setQueueACLsManager(QueueACLsManager queueACLsManager) { + this.queueACLsManager = queueACLsManager; + } + + void setRMAppManager(RMAppManager rmAppManager) { + this.rmAppManager = rmAppManager; + } + + @Override public boolean isHAEnabled() { return isHAEnabled; diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ResourceManager.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ResourceManager.java index 77de209..e1b82e2 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ResourceManager.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ResourceManager.java @@ -136,19 +136,10 @@ * in Active state. */ protected RMActiveServices activeServices; - protected RMSecretManagerService rmSecretManagerService; protected ResourceScheduler scheduler; - private ClientRMService clientRM; - protected ApplicationMasterService masterService; - protected NMLivelinessMonitor nmLivelinessMonitor; - protected NodesListManager nodesListManager; - protected RMAppManager rmAppManager; - protected ApplicationACLsManager applicationACLsManager; - protected QueueACLsManager queueACLsManager; private WebApp webApp; private AppReportFetcher fetcher = null; - protected ResourceTrackerService resourceTracker; private String webAppAddress; private ConfigurationProvider configurationProvider = null; @@ -288,8 +279,9 @@ protected DelegationTokenRenewer createDelegationTokenRenewer() { } protected RMAppManager createRMAppManager() { - return new RMAppManager(this.rmContext, this.scheduler, this.masterService, - this.applicationACLsManager, this.conf); + return new RMAppManager(this.rmContext, this.scheduler, + this.rmContext.getApplicationMasterService(), + this.conf); } protected RMApplicationHistoryWriter createRMApplicationHistoryWriter() { @@ -333,7 +325,7 @@ protected static void validateConfigs(Configuration conf) { private EventHandler schedulerDispatcher; private ApplicationMasterLauncher applicationMasterLauncher; private ContainerAllocationExpirer containerAllocationExpirer; - + private boolean recoveryEnabled; RMActiveServices() { @@ -344,7 +336,8 @@ protected static void validateConfigs(Configuration conf) { protected void serviceInit(Configuration configuration) throws Exception { conf.setBoolean(Dispatcher.DISPATCHER_EXIT_ON_ERROR_KEY, true); - rmSecretManagerService = createRMSecretManagerService(); + RMSecretManagerService rmSecretManagerService = + createRMSecretManagerService(); addService(rmSecretManagerService); containerAllocationExpirer = new ContainerAllocationExpirer(rmDispatcher); @@ -400,7 +393,7 @@ protected void serviceInit(Configuration configuration) throws Exception { rmContext.setRMApplicationHistoryWriter(rmApplicationHistoryWriter); // Register event handler for NodesListManager - nodesListManager = new NodesListManager(rmContext); + NodesListManager nodesListManager = new NodesListManager(rmContext); rmDispatcher.register(NodesListManagerEventType.class, nodesListManager); addService(nodesListManager); rmContext.setNodesListManager(nodesListManager); @@ -427,10 +420,11 @@ protected void serviceInit(Configuration configuration) throws Exception { rmDispatcher.register( RMNodeEventType.class, new NodeEventDispatcher(rmContext)); - nmLivelinessMonitor = createNMLivelinessMonitor(); + NMLivelinessMonitor nmLivelinessMonitor = createNMLivelinessMonitor(); addService(nmLivelinessMonitor); + rmContext.setNMLivelinessMonitor(nmLivelinessMonitor); - resourceTracker = createResourceTrackerService(); + ResourceTrackerService resourceTracker = createResourceTrackerService(); addService(resourceTracker); rmContext.setResourceTrackerService(resourceTracker); @@ -440,19 +434,24 @@ protected void serviceInit(Configuration configuration) throws Exception { // creating monitors that handle preemption createPolicyMonitors(); - masterService = createApplicationMasterService(); + ApplicationMasterService masterService = createApplicationMasterService(); addService(masterService) ; rmContext.setApplicationMasterService(masterService); - applicationACLsManager = new ApplicationACLsManager(conf); + ApplicationACLsManager applicationACLsManager = + new ApplicationACLsManager(conf); + rmContext.setApplicationACLsManager(applicationACLsManager); - queueACLsManager = createQueueACLsManager(scheduler, conf); + QueueACLsManager queueACLsManager = + createQueueACLsManager(scheduler, conf); + rmContext.setQueueACLsManager(queueACLsManager); - rmAppManager = createRMAppManager(); + RMAppManager rmAppManager = createRMAppManager(); // Register event handler for RMAppManagerEvents rmDispatcher.register(RMAppManagerEventType.class, rmAppManager); + rmContext.setRMAppManager(rmAppManager); - clientRM = createClientRMService(); + ClientRMService clientRM = createClientRMService(); rmContext.setClientRMService(clientRM); addService(clientRM); rmContext.setClientRMService(clientRM); @@ -788,7 +787,8 @@ public void handle(RMNodeEvent event) { protected void startWepApp() { Builder builder = WebApps - .$for("cluster", ApplicationMasterService.class, masterService, + .$for("cluster", ApplicationMasterService.class, + getRMContext().getApplicationMasterService(), "ws") .with(conf) .withHttpSpnegoPrincipalKey( @@ -951,16 +951,15 @@ protected void serviceStop() throws Exception { } protected ResourceTrackerService createResourceTrackerService() { - return new ResourceTrackerService(this.rmContext, this.nodesListManager, - this.nmLivelinessMonitor, + return new ResourceTrackerService(this.rmContext, + this.rmContext.getNodesListManager(), + this.rmContext.getNMLivelinessMonitor(), this.rmContext.getContainerTokenSecretManager(), this.rmContext.getNMTokenSecretManager()); } protected ClientRMService createClientRMService() { - return new ClientRMService(this.rmContext, scheduler, this.rmAppManager, - this.applicationACLsManager, this.queueACLsManager, - this.rmContext.getRMDelegationTokenSecretManager()); + return new ClientRMService(this.rmContext, scheduler); } protected ApplicationMasterService createApplicationMasterService() { @@ -977,7 +976,7 @@ protected RMSecretManagerService createRMSecretManagerService() { @Private public ClientRMService getClientRMService() { - return this.clientRM; + return this.getRMContext().getClientRMService(); } /** @@ -995,22 +994,22 @@ public ResourceScheduler getResourceScheduler() { */ @Private public ResourceTrackerService getResourceTrackerService() { - return this.resourceTracker; + return this.getRMContext().getResourceTrackerService(); } @Private public ApplicationMasterService getApplicationMasterService() { - return this.masterService; + return this.getRMContext().getApplicationMasterService(); } @Private public ApplicationACLsManager getApplicationACLsManager() { - return this.applicationACLsManager; + return this.getRMContext().getApplicationACLsManager(); } @Private public QueueACLsManager getQueueACLsManager() { - return this.queueACLsManager; + return this.getRMContext().getQueueACLsManager(); } @Private @@ -1024,7 +1023,7 @@ public void recover(RMState state) throws Exception { rmContext.getRMDelegationTokenSecretManager().recover(state); // recover applications - rmAppManager.recover(state); + rmContext.getRMAppManager().recover(state); } public static void main(String argv[]) { diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/MockRM.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/MockRM.java index 45c2e5f..97ebc37 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/MockRM.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/MockRM.java @@ -397,7 +397,8 @@ public KillApplicationResponse killApp(ApplicationId appId) throws Exception { // from AMLauncher public MockAM sendAMLaunched(ApplicationAttemptId appAttemptId) throws Exception { - MockAM am = new MockAM(getRMContext(), masterService, appAttemptId); + MockAM am = new MockAM(getRMContext(), + getRMContext().getApplicationMasterService(), appAttemptId); am.waitForState(RMAppAttemptState.ALLOCATED); getRMContext() .getDispatcher() @@ -409,7 +410,8 @@ public MockAM sendAMLaunched(ApplicationAttemptId appAttemptId) public void sendAMLaunchFailed(ApplicationAttemptId appAttemptId) throws Exception { - MockAM am = new MockAM(getRMContext(), masterService, appAttemptId); + MockAM am = new MockAM(getRMContext(), + getRMContext().getApplicationMasterService(), appAttemptId); am.waitForState(RMAppAttemptState.ALLOCATED); getRMContext().getDispatcher().getEventHandler() .handle(new RMAppAttemptLaunchFailedEvent(appAttemptId, "Failed")); @@ -417,9 +419,7 @@ public void sendAMLaunchFailed(ApplicationAttemptId appAttemptId) @Override protected ClientRMService createClientRMService() { - return new ClientRMService(getRMContext(), getResourceScheduler(), - rmAppManager, applicationACLsManager, queueACLsManager, - getRMContext().getRMDelegationTokenSecretManager()) { + return new ClientRMService(getRMContext(), getResourceScheduler()) { @Override protected void serviceStart() { // override to not start rpc handler @@ -442,8 +442,10 @@ protected ResourceTrackerService createResourceTrackerService() { NMTokenSecretManagerInRM nmTokenSecretManager = getRMContext().getNMTokenSecretManager(); nmTokenSecretManager.rollMasterKey(); - return new ResourceTrackerService(getRMContext(), nodesListManager, - this.nmLivelinessMonitor, containerTokenSecretManager, + return new ResourceTrackerService(getRMContext(), + getRMContext().getNodesListManager(), + getRMContext().getNMLivelinessMonitor(), + containerTokenSecretManager, nmTokenSecretManager) { @Override @@ -514,7 +516,7 @@ protected EmbeddedElectorService createEmbeddedElectorService() { } public NodesListManager getNodesListManager() { - return this.nodesListManager; + return this.getRMContext().getNodesListManager(); } public ClientToAMTokenSecretManagerInRM getClientToAMTokenSecretManager() { @@ -522,7 +524,7 @@ public ClientToAMTokenSecretManagerInRM getClientToAMTokenSecretManager() { } public RMAppManager getRMAppManager() { - return this.rmAppManager; + return this.getRMContext().getRMAppManager(); } @Override diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/QueueACLsTestBase.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/QueueACLsTestBase.java index e8f1425..a50de3a 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/QueueACLsTestBase.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/QueueACLsTestBase.java @@ -84,9 +84,7 @@ public void setup() throws InterruptedException, IOException { resourceManager = new MockRM(conf) { protected ClientRMService createClientRMService() { - return new ClientRMService(getRMContext(), this.scheduler, - this.rmAppManager, this.applicationACLsManager, - this.queueACLsManager, getRMContext().getRMDelegationTokenSecretManager()); + return new ClientRMService(getRMContext(), this.scheduler); }; @Override diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/RMHATestBase.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/RMHATestBase.java index 58258ac..9699eb2 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/RMHATestBase.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/RMHATestBase.java @@ -116,7 +116,7 @@ protected void startRMsWithCustomizedRMAppManager() throws IOException { @Override protected RMAppManager createRMAppManager() { return new MyRMAppManager(this.rmContext, this.scheduler, - this.masterService, this.applicationACLsManager, conf1); + this.rmContext.getApplicationMasterService(), conf1); } }; @@ -131,9 +131,8 @@ protected RMAppManager createRMAppManager() { private RMContext rmContext; public MyRMAppManager(RMContext context, YarnScheduler scheduler, - ApplicationMasterService masterService, - ApplicationACLsManager applicationACLsManager, Configuration conf) { - super(context, scheduler, masterService, applicationACLsManager, conf); + ApplicationMasterService masterService, Configuration conf) { + super(context, scheduler, masterService, conf); this.conf = conf; this.rmContext = context; } diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestAppManager.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestAppManager.java index d720eb6..c03c3c7 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestAppManager.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestAppManager.java @@ -154,14 +154,12 @@ public void handle(RMAppEvent event) { public class TestRMAppManager extends RMAppManager { public TestRMAppManager(RMContext context, Configuration conf) { - super(context, null, null, new ApplicationACLsManager(conf), conf); + super(context, null, null, conf); } - public TestRMAppManager(RMContext context, - ClientToAMTokenSecretManagerInRM clientToAMSecretManager, - YarnScheduler scheduler, ApplicationMasterService masterService, - ApplicationACLsManager applicationACLsManager, Configuration conf) { - super(context, scheduler, masterService, applicationACLsManager, conf); + public TestRMAppManager(RMContext context, YarnScheduler scheduler, + ApplicationMasterService masterService, Configuration conf) { + super(context, scheduler, masterService, conf); } public void checkAppNumCompletedLimit() { @@ -208,11 +206,12 @@ public void setUp() { rmContext = mockRMContext(1, now - 10); ResourceScheduler scheduler = mockResourceScheduler(); Configuration conf = new Configuration(); + ((RMContextImpl) rmContext).setApplicationACLsManager( + new ApplicationACLsManager(conf)); ApplicationMasterService masterService = new ApplicationMasterService(rmContext, scheduler); - appMonitor = new TestRMAppManager(rmContext, - new ClientToAMTokenSecretManagerInRM(), scheduler, masterService, - new ApplicationACLsManager(conf), conf); + appMonitor = new TestRMAppManager(rmContext, scheduler, + masterService,conf); appId = MockApps.newAppID(1); RecordFactory recordFactory = RecordFactoryProvider.getRecordFactory(null); @@ -239,6 +238,8 @@ public void testRMAppRetireNone() throws Exception { RMContext rmContext = mockRMContext(10, now - 10); Configuration conf = new YarnConfiguration(); conf.setInt(YarnConfiguration.RM_MAX_COMPLETED_APPLICATIONS, 10); + ((RMContextImpl) rmContext).setApplicationACLsManager( + new ApplicationACLsManager(conf)); TestRMAppManager appMonitor = new TestRMAppManager(rmContext,conf); Assert.assertEquals("Number of apps incorrect before checkAppTimeLimit", @@ -265,6 +266,8 @@ public void testRMAppRetireSome() throws Exception { Configuration conf = new YarnConfiguration(); conf.setInt(YarnConfiguration.RM_STATE_STORE_MAX_COMPLETED_APPLICATIONS, 3); conf.setInt(YarnConfiguration.RM_MAX_COMPLETED_APPLICATIONS, 3); + ((RMContextImpl) rmContext).setApplicationACLsManager( + new ApplicationACLsManager(conf)); TestRMAppManager appMonitor = new TestRMAppManager(rmContext, conf); Assert.assertEquals("Number of apps incorrect before", 10, rmContext @@ -293,6 +296,8 @@ public void testRMAppRetireSomeDifferentStates() throws Exception { conf.setInt(YarnConfiguration.RM_STATE_STORE_MAX_COMPLETED_APPLICATIONS, 2); conf.setInt(YarnConfiguration.RM_MAX_COMPLETED_APPLICATIONS, 2); + ((RMContextImpl) rmContext).setApplicationACLsManager( + new ApplicationACLsManager(conf)); TestRMAppManager appMonitor = new TestRMAppManager(rmContext, conf); // clear out applications map @@ -346,7 +351,10 @@ public void testRMAppRetireNullApp() throws Exception { long now = System.currentTimeMillis(); RMContext rmContext = mockRMContext(10, now - 20000); - TestRMAppManager appMonitor = new TestRMAppManager(rmContext, new Configuration()); + Configuration conf = new Configuration(); + ((RMContextImpl) rmContext).setApplicationACLsManager( + new ApplicationACLsManager(conf)); + TestRMAppManager appMonitor = new TestRMAppManager(rmContext, conf); Assert.assertEquals("Number of apps incorrect before", 10, rmContext .getRMApps().size()); @@ -365,6 +373,8 @@ public void testRMAppRetireZeroSetting() throws Exception { Configuration conf = new YarnConfiguration(); conf.setInt(YarnConfiguration.RM_STATE_STORE_MAX_COMPLETED_APPLICATIONS, 0); conf.setInt(YarnConfiguration.RM_MAX_COMPLETED_APPLICATIONS, 0); + ((RMContextImpl) rmContext).setApplicationACLsManager( + new ApplicationACLsManager(conf)); TestRMAppManager appMonitor = new TestRMAppManager(rmContext, conf); Assert.assertEquals("Number of apps incorrect before", 10, rmContext .getRMApps().size()); @@ -393,6 +403,8 @@ public void testStateStoreAppLimitLessThanMemoryAppLimit() { conf.setInt(YarnConfiguration.RM_MAX_COMPLETED_APPLICATIONS, maxAppsInMemory); conf.setInt(YarnConfiguration.RM_STATE_STORE_MAX_COMPLETED_APPLICATIONS, maxAppsInStateStore); + ((RMContextImpl) rmContext).setApplicationACLsManager( + new ApplicationACLsManager(conf)); TestRMAppManager appMonitor = new TestRMAppManager(rmContext, conf); addToCompletedApps(appMonitor, rmContext); @@ -421,6 +433,8 @@ public void testStateStoreAppLimitLargerThanMemoryAppLimit() { conf.setInt(YarnConfiguration.RM_MAX_COMPLETED_APPLICATIONS, maxAppsInMemory); // larger than maxCompletedAppsInMemory, reset to RM_MAX_COMPLETED_APPLICATIONS. conf.setInt(YarnConfiguration.RM_STATE_STORE_MAX_COMPLETED_APPLICATIONS, 1000); + ((RMContextImpl) rmContext).setApplicationACLsManager( + new ApplicationACLsManager(conf)); TestRMAppManager appMonitor = new TestRMAppManager(rmContext, conf); addToCompletedApps(appMonitor, rmContext); @@ -484,9 +498,10 @@ public void testRMAppSubmitMaxAppAttempts() throws Exception { conf.setInt(YarnConfiguration.RM_AM_MAX_ATTEMPTS, globalMaxAppAttempts[i]); ApplicationMasterService masterService = new ApplicationMasterService(rmContext, scheduler); + ((RMContextImpl) rmContext).setApplicationACLsManager( + new ApplicationACLsManager(conf)); TestRMAppManager appMonitor = new TestRMAppManager(rmContext, - new ClientToAMTokenSecretManagerInRM(), scheduler, masterService, - new ApplicationACLsManager(conf), conf); + scheduler, masterService, conf); ApplicationId appID = MockApps.newAppID(i * 4 + j + 1); asContext.setApplicationId(appID); diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestApplicationACLs.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestApplicationACLs.java index a288c57..f23fadc 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestApplicationACLs.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestApplicationACLs.java @@ -119,9 +119,7 @@ public Object answer(InvocationOnMock invocation) { } protected ClientRMService createClientRMService() { - return new ClientRMService(getRMContext(), this.scheduler, - this.rmAppManager, this.applicationACLsManager, - this.queueACLsManager, null); + return new ClientRMService(getRMContext(), this.scheduler); }; }; new Thread() { diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestClientRMService.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestClientRMService.java index 4b1f59c..327308b 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestClientRMService.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestClientRMService.java @@ -158,9 +158,7 @@ public static void teardownSecretManager() { public void testGetClusterNodes() throws Exception { MockRM rm = new MockRM() { protected ClientRMService createClientRMService() { - return new ClientRMService(this.rmContext, scheduler, - this.rmAppManager, this.applicationACLsManager, this.queueACLsManager, - this.getRMContext().getRMDelegationTokenSecretManager()); + return new ClientRMService(this.rmContext, scheduler); }; }; rm.start(); @@ -222,8 +220,7 @@ public void testGetApplicationReport() throws YarnException { RMContext rmContext = mock(RMContext.class); when(rmContext.getRMApps()).thenReturn( new ConcurrentHashMap()); - ClientRMService rmService = new ClientRMService(rmContext, null, null, - null, null, null); + ClientRMService rmService = new ClientRMService(rmContext, null); RecordFactory recordFactory = RecordFactoryProvider.getRecordFactory(null); GetApplicationReportRequest request = recordFactory .newRecordInstance(GetApplicationReportRequest.class); @@ -351,7 +348,8 @@ public ClientRMService createRMService() throws IOException { yarnScheduler); when(rmContext.getRMApps()).thenReturn(apps); RMAppManager appManager = new RMAppManager(rmContext, yarnScheduler, null, - mock(ApplicationACLsManager.class), new Configuration()); + new Configuration()); + when(rmContext.getRMAppManager()).thenReturn(appManager); when(rmContext.getDispatcher().getEventHandler()).thenReturn( new EventHandler() { public void handle(Event event) { @@ -359,12 +357,13 @@ public void handle(Event event) { }); ApplicationACLsManager mockAclsManager = mock(ApplicationACLsManager.class); + when(rmContext.getApplicationACLsManager()).thenReturn(mockAclsManager); QueueACLsManager mockQueueACLsManager = mock(QueueACLsManager.class); when( mockQueueACLsManager.checkAccess(any(UserGroupInformation.class), any(QueueACL.class), anyString())).thenReturn(true); - return new ClientRMService(rmContext, yarnScheduler, appManager, - mockAclsManager, mockQueueACLsManager, null); + when(rmContext.getQueueACLsManager()).thenReturn(mockQueueACLsManager); + return new ClientRMService(rmContext, yarnScheduler); } @Test @@ -372,8 +371,7 @@ public void testForceKillNonExistingApplication() throws YarnException { RMContext rmContext = mock(RMContext.class); when(rmContext.getRMApps()).thenReturn( new ConcurrentHashMap()); - ClientRMService rmService = new ClientRMService(rmContext, null, null, - null, null, null); + ClientRMService rmService = new ClientRMService(rmContext, null); ApplicationId applicationId = BuilderUtils.newApplicationId(System.currentTimeMillis(), 0); KillApplicationRequest request = @@ -445,8 +443,7 @@ public void testMoveAbsentApplication() throws YarnException { RMContext rmContext = mock(RMContext.class); when(rmContext.getRMApps()).thenReturn( new ConcurrentHashMap()); - ClientRMService rmService = new ClientRMService(rmContext, null, null, - null, null, null); + ClientRMService rmService = new ClientRMService(rmContext, null); ApplicationId applicationId = BuilderUtils.newApplicationId(System.currentTimeMillis(), 0); MoveApplicationAcrossQueuesRequest request = @@ -459,8 +456,7 @@ public void testGetQueueInfo() throws Exception { YarnScheduler yarnScheduler = mock(YarnScheduler.class); RMContext rmContext = mock(RMContext.class); mockRMContext(yarnScheduler, rmContext); - ClientRMService rmService = new ClientRMService(rmContext, yarnScheduler, - null, null, null, null); + ClientRMService rmService = new ClientRMService(rmContext, yarnScheduler); GetQueueInfoRequest request = recordFactory .newRecordInstance(GetQueueInfoRequest.class); request.setQueueName("testqueue"); @@ -541,8 +537,8 @@ private void checkTokenRenewal(UserGroupInformation owner, request.setDelegationToken(dToken); RMContext rmContext = mock(RMContext.class); - ClientRMService rmService = new ClientRMService( - rmContext, null, null, null, null, dtsm); + when(rmContext.getRMDelegationTokenSecretManager()).thenReturn(dtsm); + ClientRMService rmService = new ClientRMService(rmContext, null); rmService.renewDelegationToken(request); } @@ -554,25 +550,26 @@ public void testAppSubmit() throws Exception { mockRMContext(yarnScheduler, rmContext); RMStateStore stateStore = mock(RMStateStore.class); when(rmContext.getStateStore()).thenReturn(stateStore); - RMAppManager appManager = new RMAppManager(rmContext, yarnScheduler, - null, mock(ApplicationACLsManager.class), new Configuration()); + RMAppManager appManager = new RMAppManager(rmContext, yarnScheduler, null, + new Configuration()); when(rmContext.getDispatcher().getEventHandler()).thenReturn( new EventHandler() { public void handle(Event event) {} }); + when(rmContext.getRMAppManager()).thenReturn(appManager); ApplicationId appId1 = getApplicationId(100); ApplicationACLsManager mockAclsManager = mock(ApplicationACLsManager.class); when( mockAclsManager.checkAccess(UserGroupInformation.getCurrentUser(), ApplicationAccessType.VIEW_APP, null, appId1)).thenReturn(true); + when(rmContext.getApplicationACLsManager()).thenReturn(mockAclsManager); QueueACLsManager mockQueueACLsManager = mock(QueueACLsManager.class); when(mockQueueACLsManager.checkAccess(any(UserGroupInformation.class), any(QueueACL.class), anyString())).thenReturn(true); - ClientRMService rmService = - new ClientRMService(rmContext, yarnScheduler, appManager, - mockAclsManager, mockQueueACLsManager, null); + when(rmContext.getQueueACLsManager()).thenReturn(mockQueueACLsManager); + ClientRMService rmService = new ClientRMService(rmContext, yarnScheduler); // without name and queue @@ -648,7 +645,7 @@ public void testGetApplications() throws IOException, YarnException { RMStateStore stateStore = mock(RMStateStore.class); when(rmContext.getStateStore()).thenReturn(stateStore); RMAppManager appManager = new RMAppManager(rmContext, yarnScheduler, - null, mock(ApplicationACLsManager.class), new Configuration()); + null, new Configuration()); when(rmContext.getDispatcher().getEventHandler()).thenReturn( new EventHandler() { public void handle(Event event) {} @@ -658,9 +655,11 @@ public void handle(Event event) {} QueueACLsManager mockQueueACLsManager = mock(QueueACLsManager.class); when(mockQueueACLsManager.checkAccess(any(UserGroupInformation.class), any(QueueACL.class), anyString())).thenReturn(true); + when(rmContext.getRMAppManager()).thenReturn(appManager); + when(rmContext.getApplicationACLsManager()).thenReturn(mockAclsManager); + when(rmContext.getQueueACLsManager()).thenReturn(mockQueueACLsManager); ClientRMService rmService = - new ClientRMService(rmContext, yarnScheduler, appManager, - mockAclsManager, mockQueueACLsManager, null); + new ClientRMService(rmContext, yarnScheduler); // Initialize appnames and queues String[] queues = {QUEUE_1, QUEUE_2}; @@ -785,7 +784,10 @@ public void testConcurrentAppSubmit() RMStateStore stateStore = mock(RMStateStore.class); when(rmContext.getStateStore()).thenReturn(stateStore); RMAppManager appManager = new RMAppManager(rmContext, yarnScheduler, - null, mock(ApplicationACLsManager.class), new Configuration()); + null, new Configuration()); + when(rmContext.getRMAppManager()).thenReturn(appManager); + ApplicationACLsManager mockAclsManager = mock(ApplicationACLsManager.class); + when(rmContext.getApplicationACLsManager()).thenReturn(mockAclsManager); final ApplicationId appId1 = getApplicationId(100); final ApplicationId appId2 = getApplicationId(101); @@ -820,8 +822,7 @@ public void handle(Event rawEvent) { when(rmContext.getDispatcher().getEventHandler()).thenReturn(eventHandler); final ClientRMService rmService = - new ClientRMService(rmContext, yarnScheduler, appManager, null, null, - null); + new ClientRMService(rmContext, yarnScheduler); // submit an app and wait for it to block while in app submission Thread t = new Thread() { diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestClientRMTokens.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestClientRMTokens.java index ebe7ff0..3453afb 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestClientRMTokens.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestClientRMTokens.java @@ -64,9 +64,7 @@ import org.apache.hadoop.yarn.security.client.RMDelegationTokenIdentifier; import org.apache.hadoop.yarn.server.resourcemanager.recovery.NullRMStateStore; import org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceScheduler; -import org.apache.hadoop.yarn.server.resourcemanager.security.QueueACLsManager; import org.apache.hadoop.yarn.server.resourcemanager.security.RMDelegationTokenSecretManager; -import org.apache.hadoop.yarn.server.security.ApplicationACLsManager; import org.apache.hadoop.yarn.server.utils.BuilderUtils; import org.apache.hadoop.yarn.util.ConverterUtils; import org.apache.hadoop.yarn.util.Records; @@ -105,8 +103,11 @@ public void testDelegationToken() throws IOException, InterruptedException { + initialInterval + ", maxLifetime: " + maxLifetime + ", renewInterval: " + renewInterval); - final ClientRMService clientRMService = new ClientRMServiceForTest(conf, - scheduler, rmDtSecretManager); + RMContext rmContext = mock(RMContext.class); + when(rmContext.getRMDelegationTokenSecretManager()) + .thenReturn(rmDtSecretManager); + final ClientRMService clientRMService = new ClientRMServiceForTest( + rmContext, conf, scheduler); clientRMService.init(conf); clientRMService.start(); @@ -428,13 +429,14 @@ public ApplicationClientProtocol run() { } class ClientRMServiceForTest extends ClientRMService { - - public ClientRMServiceForTest(Configuration conf, - ResourceScheduler scheduler, - RMDelegationTokenSecretManager rmDTSecretManager) { - super(mock(RMContext.class), scheduler, mock(RMAppManager.class), - new ApplicationACLsManager(conf), new QueueACLsManager(scheduler, - conf), rmDTSecretManager); + private RMContext rmContext; + + public ClientRMServiceForTest( + RMContext rmContext, + Configuration conf, + ResourceScheduler scheduler) { + super(rmContext, scheduler); + this.rmContext = rmContext; } // Use a random port unless explicitly specified. @@ -446,8 +448,8 @@ InetSocketAddress getBindAddress(Configuration conf) { @Override protected void serviceStop() throws Exception { - if (rmDTSecretManager != null) { - rmDTSecretManager.stopThreads(); + if (rmContext.getRMDelegationTokenSecretManager() != null) { + rmContext.getRMDelegationTokenSecretManager().stopThreads(); } super.serviceStop(); } diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestKillApplicationWithRMHA.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestKillApplicationWithRMHA.java index 149ddf5..7256b11 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestKillApplicationWithRMHA.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestKillApplicationWithRMHA.java @@ -193,9 +193,7 @@ private void startRMsWithCustomizedClientRMService() throws IOException { rm1 = new MockRM(conf1) { @Override protected ClientRMService createClientRMService() { - return new MyClientRMService(this.rmContext, this.scheduler, - this.rmAppManager, this.applicationACLsManager, - this.queueACLsManager, getRMContext().getRMDelegationTokenSecretManager()); + return new MyClientRMService(this.rmContext, this.scheduler); } }; @@ -208,13 +206,8 @@ protected ClientRMService createClientRMService() { private RMContext rmContext; - public MyClientRMService(RMContext rmContext, YarnScheduler scheduler, - RMAppManager rmAppManager, - ApplicationACLsManager applicationACLsManager, - QueueACLsManager queueACLsManager, - RMDelegationTokenSecretManager rmDTSecretManager) { - super(rmContext, scheduler, rmAppManager, applicationACLsManager, - queueACLsManager, rmDTSecretManager); + public MyClientRMService(RMContext rmContext, YarnScheduler scheduler) { + super(rmContext, scheduler); this.rmContext = rmContext; } diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestRMRestart.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestRMRestart.java index 8eed4e6..4cdfe71 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestRMRestart.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestRMRestart.java @@ -1795,9 +1795,10 @@ public void testSynchronouslyRenewDTOnRecovery() throws Exception { @Override protected ResourceTrackerService createResourceTrackerService() { return new ResourceTrackerService(this.rmContext, - this.nodesListManager, this.nmLivelinessMonitor, - this.rmContext.getContainerTokenSecretManager(), - this.rmContext.getNMTokenSecretManager()) { + this.rmContext.getNodesListManager(), + this.rmContext.getNMLivelinessMonitor(), + this.rmContext.getContainerTokenSecretManager(), + this.rmContext.getNMTokenSecretManager()) { @Override protected void serviceStart() throws Exception { // send the container_finished event as soon as the @@ -1806,7 +1807,7 @@ protected void serviceStart() throws Exception { nm1.setResourceTrackerService(getResourceTrackerService()); NMContainerStatus status = TestRMRestart.createNMContainerStatus( - am0.getApplicationAttemptId(), 1, ContainerState.COMPLETE); + am0.getApplicationAttemptId(), 1, ContainerState.COMPLETE); nm1.registerNode(Arrays.asList(status), null); } }; @@ -1894,9 +1895,7 @@ public void init(Configuration conf) { @Override protected ClientRMService createClientRMService() { - return new ClientRMService(getRMContext(), getResourceScheduler(), - rmAppManager, applicationACLsManager, null, - getRMContext().getRMDelegationTokenSecretManager()){ + return new ClientRMService(getRMContext(), getResourceScheduler()) { @Override protected void serviceStart() throws Exception { // do nothing diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/security/TestClientToAMTokens.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/security/TestClientToAMTokens.java index 0dcd228..e8aed4f 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/security/TestClientToAMTokens.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/security/TestClientToAMTokens.java @@ -166,9 +166,7 @@ public void testClientToAMTokens() throws Exception { MockRM rm = new MockRMWithCustomAMLauncher(conf, containerManager) { protected ClientRMService createClientRMService() { - return new ClientRMService(this.rmContext, scheduler, - this.rmAppManager, this.applicationACLsManager, this.queueACLsManager, - getRMContext().getRMDelegationTokenSecretManager()); + return new ClientRMService(this.rmContext, scheduler); }; @Override