|
@@ -19,10 +19,7 @@
|
|
|
package org.apache.hadoop.yarn.server.resourcemanager.webapp;
|
|
|
|
|
|
import com.google.inject.Guice;
|
|
|
-import com.google.inject.servlet.ServletModule;
|
|
|
import com.sun.jersey.api.client.ClientResponse;
|
|
|
-import com.sun.jersey.guice.spi.container.servlet.GuiceContainer;
|
|
|
-import com.sun.jersey.test.framework.WebAppDescriptor;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
import java.util.HashMap;
|
|
@@ -34,67 +31,28 @@ import org.apache.hadoop.conf.Configuration;
|
|
|
import org.apache.hadoop.yarn.conf.YarnConfiguration;
|
|
|
import org.apache.hadoop.yarn.exceptions.YarnException;
|
|
|
import org.apache.hadoop.yarn.server.resourcemanager.MockRM;
|
|
|
-import org.apache.hadoop.yarn.server.resourcemanager.ResourceManager;
|
|
|
-import org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceScheduler;
|
|
|
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.AutoCreatedQueueTemplate;
|
|
|
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacityScheduler;
|
|
|
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerConfiguration;
|
|
|
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerQueueManager;
|
|
|
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.QueuePath;
|
|
|
-import org.apache.hadoop.yarn.webapp.GenericExceptionHandler;
|
|
|
import org.apache.hadoop.yarn.webapp.GuiceServletConfig;
|
|
|
import org.apache.hadoop.yarn.webapp.JerseyTestBase;
|
|
|
import org.junit.Test;
|
|
|
|
|
|
+import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerTestUtilities.GB;
|
|
|
import static org.apache.hadoop.yarn.server.resourcemanager.webapp.TestRMWebServicesCapacitySched.assertJsonResponse;
|
|
|
+import static org.apache.hadoop.yarn.server.resourcemanager.webapp.TestRMWebServicesCapacitySched.createMockRM;
|
|
|
+import static org.apache.hadoop.yarn.server.resourcemanager.webapp.TestRMWebServicesCapacitySched.createWebAppDescriptor;
|
|
|
|
|
|
public class TestRMWebServicesCapacitySchedDynamicConfig extends
|
|
|
JerseyTestBase {
|
|
|
- private static final int GB = 1024;
|
|
|
- private static MockRM rm;
|
|
|
+ private MockRM rm;
|
|
|
|
|
|
private CapacitySchedulerQueueManager autoQueueHandler;
|
|
|
|
|
|
- private static class WebServletModule extends ServletModule {
|
|
|
- private final Configuration conf;
|
|
|
-
|
|
|
- WebServletModule(Configuration conf) {
|
|
|
- this.conf = conf;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- protected void configureServlets() {
|
|
|
- bind(JAXBContextResolver.class);
|
|
|
- bind(RMWebServices.class);
|
|
|
- bind(GenericExceptionHandler.class);
|
|
|
- conf.setClass(YarnConfiguration.RM_SCHEDULER, CapacityScheduler.class,
|
|
|
- ResourceScheduler.class);
|
|
|
- conf.set(YarnConfiguration.RM_PLACEMENT_CONSTRAINTS_HANDLER,
|
|
|
- YarnConfiguration.SCHEDULER_RM_PLACEMENT_CONSTRAINTS_HANDLER);
|
|
|
- rm = new MockRM(conf);
|
|
|
- bind(ResourceManager.class).toInstance(rm);
|
|
|
- serve("/*").with(GuiceContainer.class);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private void initResourceManager(Configuration conf) throws IOException {
|
|
|
- GuiceServletConfig.setInjector(
|
|
|
- Guice.createInjector(new WebServletModule(conf)));
|
|
|
- rm.start();
|
|
|
- //Need to call reinitialize as
|
|
|
- //MutableCSConfigurationProvider with InMemoryConfigurationStore
|
|
|
- //somehow does not load the queues properly and falls back to default config.
|
|
|
- //Therefore CS will think there's only the default queue there.
|
|
|
- ((CapacityScheduler) rm.getResourceScheduler()).reinitialize(conf,
|
|
|
- rm.getRMContext(), true);
|
|
|
- }
|
|
|
-
|
|
|
public TestRMWebServicesCapacitySchedDynamicConfig() {
|
|
|
- super(new WebAppDescriptor.Builder(
|
|
|
- "org.apache.hadoop.yarn.server.resourcemanager.webapp")
|
|
|
- .contextListenerClass(GuiceServletConfig.class)
|
|
|
- .filterClass(com.google.inject.servlet.GuiceFilter.class)
|
|
|
- .contextPath("jersey-guice-filter").servletPath("/").build());
|
|
|
+ super(createWebAppDescriptor());
|
|
|
}
|
|
|
|
|
|
@Test
|
|
@@ -327,4 +285,17 @@ public class TestRMWebServicesCapacitySchedDynamicConfig extends
|
|
|
return config;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ private void initResourceManager(Configuration conf) throws IOException {
|
|
|
+ rm = createMockRM(new CapacitySchedulerConfiguration(conf));
|
|
|
+ GuiceServletConfig.setInjector(
|
|
|
+ Guice.createInjector(new TestRMWebServicesCapacitySched.WebServletModule(rm)));
|
|
|
+ rm.start();
|
|
|
+ //Need to call reinitialize as
|
|
|
+ //MutableCSConfigurationProvider with InMemoryConfigurationStore
|
|
|
+ //somehow does not load the queues properly and falls back to default config.
|
|
|
+ //Therefore CS will think there's only the default queue there.
|
|
|
+ ((CapacityScheduler) rm.getResourceScheduler()).reinitialize(conf,
|
|
|
+ rm.getRMContext(), true);
|
|
|
+ }
|
|
|
}
|