|
19 | 19 | package org.apache.hadoop.yarn.server.resourcemanager.webapp; |
20 | 20 |
|
21 | 21 | import com.google.inject.Guice; |
22 | | -import com.google.inject.servlet.ServletModule; |
23 | 22 | import com.sun.jersey.api.client.ClientResponse; |
24 | | -import com.sun.jersey.guice.spi.container.servlet.GuiceContainer; |
25 | | -import com.sun.jersey.test.framework.WebAppDescriptor; |
26 | 23 |
|
27 | 24 | import java.io.IOException; |
28 | 25 | import java.util.HashMap; |
|
34 | 31 | import org.apache.hadoop.yarn.conf.YarnConfiguration; |
35 | 32 | import org.apache.hadoop.yarn.exceptions.YarnException; |
36 | 33 | import org.apache.hadoop.yarn.server.resourcemanager.MockRM; |
37 | | -import org.apache.hadoop.yarn.server.resourcemanager.ResourceManager; |
38 | | -import org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceScheduler; |
39 | 34 | import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.AutoCreatedQueueTemplate; |
40 | 35 | import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacityScheduler; |
41 | 36 | import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerConfiguration; |
42 | 37 | import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerQueueManager; |
43 | 38 | import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.QueuePath; |
44 | | -import org.apache.hadoop.yarn.webapp.GenericExceptionHandler; |
45 | 39 | import org.apache.hadoop.yarn.webapp.GuiceServletConfig; |
46 | 40 | import org.apache.hadoop.yarn.webapp.JerseyTestBase; |
47 | 41 | import org.junit.Test; |
48 | 42 |
|
| 43 | +import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerTestUtilities.GB; |
49 | 44 | import static org.apache.hadoop.yarn.server.resourcemanager.webapp.TestRMWebServicesCapacitySched.assertJsonResponse; |
| 45 | +import static org.apache.hadoop.yarn.server.resourcemanager.webapp.TestRMWebServicesCapacitySched.createMockRM; |
| 46 | +import static org.apache.hadoop.yarn.server.resourcemanager.webapp.TestRMWebServicesCapacitySched.createWebAppDescriptor; |
50 | 47 |
|
51 | 48 | public class TestRMWebServicesCapacitySchedDynamicConfig extends |
52 | 49 | JerseyTestBase { |
53 | | - private static final int GB = 1024; |
54 | | - private static MockRM rm; |
| 50 | + private MockRM rm; |
55 | 51 |
|
56 | 52 | private CapacitySchedulerQueueManager autoQueueHandler; |
57 | 53 |
|
58 | | - private static class WebServletModule extends ServletModule { |
59 | | - private final Configuration conf; |
60 | | - |
61 | | - WebServletModule(Configuration conf) { |
62 | | - this.conf = conf; |
63 | | - } |
64 | | - |
65 | | - @Override |
66 | | - protected void configureServlets() { |
67 | | - bind(JAXBContextResolver.class); |
68 | | - bind(RMWebServices.class); |
69 | | - bind(GenericExceptionHandler.class); |
70 | | - conf.setClass(YarnConfiguration.RM_SCHEDULER, CapacityScheduler.class, |
71 | | - ResourceScheduler.class); |
72 | | - conf.set(YarnConfiguration.RM_PLACEMENT_CONSTRAINTS_HANDLER, |
73 | | - YarnConfiguration.SCHEDULER_RM_PLACEMENT_CONSTRAINTS_HANDLER); |
74 | | - rm = new MockRM(conf); |
75 | | - bind(ResourceManager.class).toInstance(rm); |
76 | | - serve("/*").with(GuiceContainer.class); |
77 | | - } |
78 | | - } |
79 | | - |
80 | | - private void initResourceManager(Configuration conf) throws IOException { |
81 | | - GuiceServletConfig.setInjector( |
82 | | - Guice.createInjector(new WebServletModule(conf))); |
83 | | - rm.start(); |
84 | | - //Need to call reinitialize as |
85 | | - //MutableCSConfigurationProvider with InMemoryConfigurationStore |
86 | | - //somehow does not load the queues properly and falls back to default config. |
87 | | - //Therefore CS will think there's only the default queue there. |
88 | | - ((CapacityScheduler) rm.getResourceScheduler()).reinitialize(conf, |
89 | | - rm.getRMContext(), true); |
90 | | - } |
91 | | - |
92 | 54 | public TestRMWebServicesCapacitySchedDynamicConfig() { |
93 | | - super(new WebAppDescriptor.Builder( |
94 | | - "org.apache.hadoop.yarn.server.resourcemanager.webapp") |
95 | | - .contextListenerClass(GuiceServletConfig.class) |
96 | | - .filterClass(com.google.inject.servlet.GuiceFilter.class) |
97 | | - .contextPath("jersey-guice-filter").servletPath("/").build()); |
| 55 | + super(createWebAppDescriptor()); |
98 | 56 | } |
99 | 57 |
|
100 | 58 | @Test |
@@ -335,4 +293,17 @@ public static Configuration createConfiguration( |
335 | 293 | return config; |
336 | 294 | } |
337 | 295 | } |
| 296 | + |
| 297 | + private void initResourceManager(Configuration conf) throws IOException { |
| 298 | + rm = createMockRM(new CapacitySchedulerConfiguration(conf)); |
| 299 | + GuiceServletConfig.setInjector( |
| 300 | + Guice.createInjector(new TestRMWebServicesCapacitySched.WebServletModule(rm))); |
| 301 | + rm.start(); |
| 302 | + //Need to call reinitialize as |
| 303 | + //MutableCSConfigurationProvider with InMemoryConfigurationStore |
| 304 | + //somehow does not load the queues properly and falls back to default config. |
| 305 | + //Therefore CS will think there's only the default queue there. |
| 306 | + ((CapacityScheduler) rm.getResourceScheduler()).reinitialize(conf, |
| 307 | + rm.getRMContext(), true); |
| 308 | + } |
338 | 309 | } |
0 commit comments