|
@@ -24,6 +24,7 @@ import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.C
|
|
|
import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerConfigGeneratorForTest.setMinAllocMb;
|
|
|
import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerConfigGeneratorForTest.setMinAllocVcores;
|
|
|
import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerQueueHelpers.findQueue;
|
|
|
+import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerQueueHelpers.setupAdditionalQueues;
|
|
|
import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerQueueHelpers.setupBlockedQueueConfiguration;
|
|
|
import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerQueueHelpers.setupOtherBlockedQueueConfiguration;
|
|
|
import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerQueueHelpers.setupQueueConfiguration;
|
|
@@ -81,6 +82,7 @@ import java.util.concurrent.CyclicBarrier;
|
|
|
import org.apache.hadoop.util.Sets;
|
|
|
import org.apache.hadoop.service.ServiceStateException;
|
|
|
import org.apache.hadoop.yarn.server.api.records.NodeStatus;
|
|
|
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.QueueMetrics;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.apache.hadoop.conf.Configuration;
|
|
@@ -2663,6 +2665,64 @@ public class TestCapacityScheduler {
|
|
|
ContainerAllocation.QUEUE_SKIPPED.getAllocationState());
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Tests
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ @Test
|
|
|
+ public void testCSQueueMetricsDoesNotLeakOnReinit() throws Exception {
|
|
|
+ // Initialize resource map
|
|
|
+ Map<String, ResourceInformation> riMap = new HashMap<>();
|
|
|
+
|
|
|
+ // Initialize mandatory resources
|
|
|
+ ResourceInformation memory =
|
|
|
+ ResourceInformation.newInstance(ResourceInformation.MEMORY_MB.getName(),
|
|
|
+ ResourceInformation.MEMORY_MB.getUnits(),
|
|
|
+ YarnConfiguration.DEFAULT_RM_SCHEDULER_MINIMUM_ALLOCATION_MB,
|
|
|
+ YarnConfiguration.DEFAULT_RM_SCHEDULER_MAXIMUM_ALLOCATION_MB);
|
|
|
+ ResourceInformation vcores =
|
|
|
+ ResourceInformation.newInstance(ResourceInformation.VCORES.getName(),
|
|
|
+ ResourceInformation.VCORES.getUnits(),
|
|
|
+ YarnConfiguration.DEFAULT_RM_SCHEDULER_MINIMUM_ALLOCATION_VCORES,
|
|
|
+ YarnConfiguration.DEFAULT_RM_SCHEDULER_MAXIMUM_ALLOCATION_VCORES);
|
|
|
+ riMap.put(ResourceInformation.MEMORY_URI, memory);
|
|
|
+ riMap.put(ResourceInformation.VCORES_URI, vcores);
|
|
|
+
|
|
|
+ ResourceUtils.initializeResourcesFromResourceInformationMap(riMap);
|
|
|
+
|
|
|
+ CapacitySchedulerConfiguration csConf =
|
|
|
+ new CapacitySchedulerConfiguration();
|
|
|
+ csConf.setResourceComparator(DominantResourceCalculator.class);
|
|
|
+
|
|
|
+ setupQueueConfiguration(csConf);
|
|
|
+
|
|
|
+ YarnConfiguration conf = new YarnConfiguration(csConf);
|
|
|
+
|
|
|
+ // Don't reset resource types since we have already configured resource
|
|
|
+ // types
|
|
|
+ conf.setBoolean(TestResourceProfiles.TEST_CONF_RESET_RESOURCE_TYPES, false);
|
|
|
+ conf.setClass(YarnConfiguration.RM_SCHEDULER, CapacityScheduler.class,
|
|
|
+ ResourceScheduler.class);
|
|
|
+
|
|
|
+ MockRM rm = new MockRM(conf);
|
|
|
+ rm.start();
|
|
|
+
|
|
|
+ CapacityScheduler cs = (CapacityScheduler) rm.getResourceScheduler();
|
|
|
+ csConf = new CapacitySchedulerConfiguration();
|
|
|
+ setupAdditionalQueues(csConf);
|
|
|
+ cs.reinitialize(csConf, cs.getRMContext());
|
|
|
+ QueueMetrics a3DefaultPartitionMetrics = QueueMetrics.getQueueMetrics().get(
|
|
|
+ "default.root.a.a3");
|
|
|
+
|
|
|
+ Assert.assertSame("Different ParentQueue of siblings is a sign of a memory leak",
|
|
|
+ QueueMetrics.getQueueMetrics().get("root.a.a1").getParentQueue(),
|
|
|
+ QueueMetrics.getQueueMetrics().get("root.a.a3").getParentQueue());
|
|
|
+
|
|
|
+ Assert.assertSame("Different ParentQueue of partition metrics is a sign of a memory leak",
|
|
|
+ QueueMetrics.getQueueMetrics().get("root.a.a1").getParentQueue(),
|
|
|
+ a3DefaultPartitionMetrics.getParentQueue());
|
|
|
+ }
|
|
|
+
|
|
|
@Test
|
|
|
public void testCSQueueMetrics() throws Exception {
|
|
|
|