|
@@ -46,6 +46,7 @@ import java.util.regex.Pattern;
|
|
|
|
|
|
import org.apache.commons.cli.Options;
|
|
|
import org.apache.commons.lang.time.DateFormatUtils;
|
|
|
+import org.apache.hadoop.conf.Configuration;
|
|
|
import org.apache.hadoop.yarn.api.records.ApplicationAttemptId;
|
|
|
import org.apache.hadoop.yarn.api.records.ApplicationAttemptReport;
|
|
|
import org.apache.hadoop.yarn.api.records.ApplicationId;
|
|
@@ -69,9 +70,15 @@ import org.apache.hadoop.yarn.api.records.SignalContainerCommand;
|
|
|
import org.apache.hadoop.yarn.api.records.YarnApplicationAttemptState;
|
|
|
import org.apache.hadoop.yarn.api.records.YarnApplicationState;
|
|
|
import org.apache.hadoop.yarn.client.api.YarnClient;
|
|
|
+import org.apache.hadoop.yarn.conf.YarnConfiguration;
|
|
|
import org.apache.hadoop.yarn.exceptions.ApplicationAttemptNotFoundException;
|
|
|
import org.apache.hadoop.yarn.exceptions.ApplicationNotFoundException;
|
|
|
import org.apache.hadoop.yarn.exceptions.ContainerNotFoundException;
|
|
|
+import org.apache.hadoop.yarn.server.MiniYARNCluster;
|
|
|
+import org.apache.hadoop.yarn.server.resourcemanager.reservation.ReservationSystemTestUtil;
|
|
|
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceScheduler;
|
|
|
+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.util.Records;
|
|
|
import org.junit.Assert;
|
|
|
import org.junit.Before;
|
|
@@ -1324,7 +1331,7 @@ public class TestYarnCLI {
|
|
|
nodeLabels.add("GPU");
|
|
|
nodeLabels.add("JDK_7");
|
|
|
QueueInfo queueInfo = QueueInfo.newInstance("queueA", 0.4f, 0.8f, 0.5f,
|
|
|
- null, null, QueueState.RUNNING, nodeLabels, "GPU", null);
|
|
|
+ null, null, QueueState.RUNNING, nodeLabels, "GPU", null, false);
|
|
|
when(client.getQueueInfo(any(String.class))).thenReturn(queueInfo);
|
|
|
int result = cli.run(new String[] { "-status", "queueA" });
|
|
|
assertEquals(0, result);
|
|
@@ -1339,16 +1346,103 @@ public class TestYarnCLI {
|
|
|
pw.println("\tMaximum Capacity : " + "80.0%");
|
|
|
pw.println("\tDefault Node Label expression : " + "GPU");
|
|
|
pw.println("\tAccessible Node Labels : " + "JDK_7,GPU");
|
|
|
+ pw.println("\tPreemption : " + "enabled");
|
|
|
pw.close();
|
|
|
String queueInfoStr = baos.toString("UTF-8");
|
|
|
Assert.assertEquals(queueInfoStr, sysOutStream.toString());
|
|
|
}
|
|
|
+
|
|
|
+ @Test
|
|
|
+ public void testGetQueueInfoPreemptionEnabled() throws Exception {
|
|
|
+ CapacitySchedulerConfiguration conf = new CapacitySchedulerConfiguration();
|
|
|
+ ReservationSystemTestUtil.setupQueueConfiguration(conf);
|
|
|
+ conf.setClass(YarnConfiguration.RM_SCHEDULER, CapacityScheduler.class,
|
|
|
+ ResourceScheduler.class);
|
|
|
+ conf.setBoolean(YarnConfiguration.RM_SCHEDULER_ENABLE_MONITORS, true);
|
|
|
+ conf.set(YarnConfiguration.RM_SCHEDULER_MONITOR_POLICIES,
|
|
|
+ "org.apache.hadoop.yarn.server.resourcemanager.monitor.capacity."
|
|
|
+ + "ProportionalCapacityPreemptionPolicy");
|
|
|
+ conf.setBoolean(YarnConfiguration.RM_SCHEDULER_ENABLE_MONITORS, true);
|
|
|
+ MiniYARNCluster cluster =
|
|
|
+ new MiniYARNCluster("testReservationAPIs", 2, 1, 1);
|
|
|
+
|
|
|
+ YarnClient yarnClient = null;
|
|
|
+ try {
|
|
|
+ cluster.init(conf);
|
|
|
+ cluster.start();
|
|
|
+ final Configuration yarnConf = cluster.getConfig();
|
|
|
+ yarnClient = YarnClient.createYarnClient();
|
|
|
+ yarnClient.init(yarnConf);
|
|
|
+ yarnClient.start();
|
|
|
+
|
|
|
+ QueueCLI cli = new QueueCLI();
|
|
|
+ cli.setClient(yarnClient);
|
|
|
+ cli.setSysOutPrintStream(sysOut);
|
|
|
+ cli.setSysErrPrintStream(sysErr);
|
|
|
+ sysOutStream.reset();
|
|
|
+ int result = cli.run(new String[] { "-status", "a1" });
|
|
|
+ assertEquals(0, result);
|
|
|
+ Assert.assertTrue(sysOutStream.toString()
|
|
|
+ .contains("Preemption : enabled"));
|
|
|
+ } finally {
|
|
|
+ // clean-up
|
|
|
+ if (yarnClient != null) {
|
|
|
+ yarnClient.stop();
|
|
|
+ }
|
|
|
+ cluster.stop();
|
|
|
+ cluster.close();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Test
|
|
|
+ public void testGetQueueInfoPreemptionDisabled() throws Exception {
|
|
|
+ CapacitySchedulerConfiguration conf = new CapacitySchedulerConfiguration();
|
|
|
+ ReservationSystemTestUtil.setupQueueConfiguration(conf);
|
|
|
+ conf.setClass(YarnConfiguration.RM_SCHEDULER, CapacityScheduler.class,
|
|
|
+ ResourceScheduler.class);
|
|
|
+ conf.setBoolean(YarnConfiguration.RM_SCHEDULER_ENABLE_MONITORS, true);
|
|
|
+ conf.set(YarnConfiguration.RM_SCHEDULER_MONITOR_POLICIES,
|
|
|
+ "org.apache.hadoop.yarn.server.resourcemanager.monitor.capacity."
|
|
|
+ + "ProportionalCapacityPreemptionPolicy");
|
|
|
+ conf.setBoolean(YarnConfiguration.RM_SCHEDULER_ENABLE_MONITORS, true);
|
|
|
+ conf.setBoolean(
|
|
|
+ "yarn.scheduler.capacity.root.a.a1.disable_preemption", true);
|
|
|
+ MiniYARNCluster cluster =
|
|
|
+ new MiniYARNCluster("testReservationAPIs", 2, 1, 1);
|
|
|
+
|
|
|
+ YarnClient yarnClient = null;
|
|
|
+ try {
|
|
|
+ cluster.init(conf);
|
|
|
+ cluster.start();
|
|
|
+ final Configuration yarnConf = cluster.getConfig();
|
|
|
+ yarnClient = YarnClient.createYarnClient();
|
|
|
+ yarnClient.init(yarnConf);
|
|
|
+ yarnClient.start();
|
|
|
+
|
|
|
+ QueueCLI cli = new QueueCLI();
|
|
|
+ cli.setClient(yarnClient);
|
|
|
+ cli.setSysOutPrintStream(sysOut);
|
|
|
+ cli.setSysErrPrintStream(sysErr);
|
|
|
+ sysOutStream.reset();
|
|
|
+ int result = cli.run(new String[] { "-status", "a1" });
|
|
|
+ assertEquals(0, result);
|
|
|
+ Assert.assertTrue(sysOutStream.toString()
|
|
|
+ .contains("Preemption : disabled"));
|
|
|
+ } finally {
|
|
|
+ // clean-up
|
|
|
+ if (yarnClient != null) {
|
|
|
+ yarnClient.stop();
|
|
|
+ }
|
|
|
+ cluster.stop();
|
|
|
+ cluster.close();
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
@Test
|
|
|
public void testGetQueueInfoWithEmptyNodeLabel() throws Exception {
|
|
|
QueueCLI cli = createAndGetQueueCLI();
|
|
|
QueueInfo queueInfo = QueueInfo.newInstance("queueA", 0.4f, 0.8f, 0.5f,
|
|
|
- null, null, QueueState.RUNNING, null, null, null);
|
|
|
+ null, null, QueueState.RUNNING, null, null, null, true);
|
|
|
when(client.getQueueInfo(any(String.class))).thenReturn(queueInfo);
|
|
|
int result = cli.run(new String[] { "-status", "queueA" });
|
|
|
assertEquals(0, result);
|
|
@@ -1364,6 +1458,7 @@ public class TestYarnCLI {
|
|
|
pw.println("\tDefault Node Label expression : "
|
|
|
+ NodeLabel.DEFAULT_NODE_LABEL_PARTITION);
|
|
|
pw.println("\tAccessible Node Labels : ");
|
|
|
+ pw.println("\tPreemption : " + "disabled");
|
|
|
pw.close();
|
|
|
String queueInfoStr = baos.toString("UTF-8");
|
|
|
Assert.assertEquals(queueInfoStr, sysOutStream.toString());
|