|
@@ -22,11 +22,8 @@ import static org.junit.Assert.assertEquals;
|
|
|
import static org.junit.Assert.assertNotNull;
|
|
|
import static org.junit.Assert.assertNull;
|
|
|
import static org.junit.Assert.assertTrue;
|
|
|
+import static org.junit.Assert.assertFalse;
|
|
|
import static org.junit.Assert.fail;
|
|
|
-import static org.mockito.Matchers.any;
|
|
|
-import static org.mockito.Matchers.anyString;
|
|
|
-import static org.mockito.Mockito.mock;
|
|
|
-import static org.mockito.Mockito.when;
|
|
|
|
|
|
import java.io.File;
|
|
|
import java.io.FileWriter;
|
|
@@ -36,7 +33,6 @@ import java.util.ArrayList;
|
|
|
import java.util.Arrays;
|
|
|
import java.util.Collection;
|
|
|
import java.util.Collections;
|
|
|
-import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
@@ -46,8 +42,6 @@ import junit.framework.Assert;
|
|
|
|
|
|
import org.apache.hadoop.conf.Configuration;
|
|
|
import org.apache.hadoop.metrics2.lib.DefaultMetricsSystem;
|
|
|
-import org.apache.hadoop.security.UserGroupInformation;
|
|
|
-import org.apache.hadoop.security.authorize.AccessControlList;
|
|
|
import org.apache.hadoop.yarn.MockApps;
|
|
|
import org.apache.hadoop.yarn.api.records.ApplicationAttemptId;
|
|
|
import org.apache.hadoop.yarn.api.records.ApplicationId;
|
|
@@ -79,7 +73,6 @@ import org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainer;
|
|
|
import org.apache.hadoop.yarn.server.resourcemanager.rmnode.RMNode;
|
|
|
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.QueueMetrics;
|
|
|
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceScheduler;
|
|
|
-import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerConfiguration;
|
|
|
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.TestCapacityScheduler;
|
|
|
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.event.AppAddedSchedulerEvent;
|
|
|
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.event.AppRemovedSchedulerEvent;
|
|
@@ -89,16 +82,12 @@ import org.apache.hadoop.yarn.server.resourcemanager.scheduler.event.NodeUpdateS
|
|
|
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.policies.DominantResourceFairnessPolicy;
|
|
|
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.policies.FairSharePolicy;
|
|
|
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.policies.FifoPolicy;
|
|
|
-import org.apache.hadoop.yarn.server.resourcemanager.scheduler.fifo.FifoScheduler;
|
|
|
-import org.apache.hadoop.yarn.server.resourcemanager.security.QueueACLsManager;
|
|
|
import org.apache.hadoop.yarn.server.utils.BuilderUtils;
|
|
|
import org.apache.hadoop.yarn.util.Clock;
|
|
|
import org.apache.hadoop.yarn.util.resource.Resources;
|
|
|
import org.junit.After;
|
|
|
import org.junit.Before;
|
|
|
import org.junit.Test;
|
|
|
-import org.mockito.invocation.InvocationOnMock;
|
|
|
-import org.mockito.stubbing.Answer;
|
|
|
import org.xml.sax.SAXException;
|
|
|
|
|
|
public class TestFairScheduler {
|
|
@@ -2367,4 +2356,55 @@ public class TestFairScheduler {
|
|
|
assertEquals(2, jerryQueue.getAppSchedulables().size());
|
|
|
assertEquals(2, defaultQueue.getAppSchedulables().size());
|
|
|
}
|
|
|
+
|
|
|
+ @SuppressWarnings("resource")
|
|
|
+ @Test
|
|
|
+ public void testBlacklistNodes() throws Exception {
|
|
|
+ final int GB = 1024;
|
|
|
+ String host = "127.0.0.1";
|
|
|
+ RMNode node =
|
|
|
+ MockNodes.newNodeInfo(1, Resources.createResource(16 * GB, 16),
|
|
|
+ 0, host);
|
|
|
+ NodeAddedSchedulerEvent nodeEvent = new NodeAddedSchedulerEvent(node);
|
|
|
+ NodeUpdateSchedulerEvent updateEvent = new NodeUpdateSchedulerEvent(node);
|
|
|
+ scheduler.handle(nodeEvent);
|
|
|
+
|
|
|
+ ApplicationAttemptId appAttemptId =
|
|
|
+ createSchedulingRequest(GB, "root.default", "user", 1);
|
|
|
+ FSSchedulerApp app = scheduler.applications.get(appAttemptId);
|
|
|
+
|
|
|
+ // Verify the blacklist can be updated independent of requesting containers
|
|
|
+ scheduler.allocate(appAttemptId, Collections.<ResourceRequest>emptyList(),
|
|
|
+ Collections.<ContainerId>emptyList(),
|
|
|
+ Collections.singletonList(host), null);
|
|
|
+ assertTrue(app.isBlacklisted(host));
|
|
|
+ scheduler.allocate(appAttemptId, Collections.<ResourceRequest>emptyList(),
|
|
|
+ Collections.<ContainerId>emptyList(), null,
|
|
|
+ Collections.singletonList(host));
|
|
|
+ assertFalse(scheduler.applications.get(appAttemptId).isBlacklisted(host));
|
|
|
+
|
|
|
+ List<ResourceRequest> update = Arrays.asList(
|
|
|
+ createResourceRequest(GB, node.getHostName(), 1, 0, true));
|
|
|
+
|
|
|
+ // Verify a container does not actually get placed on the blacklisted host
|
|
|
+ scheduler.allocate(appAttemptId, update,
|
|
|
+ Collections.<ContainerId>emptyList(),
|
|
|
+ Collections.singletonList(host), null);
|
|
|
+ assertTrue(app.isBlacklisted(host));
|
|
|
+ scheduler.update();
|
|
|
+ scheduler.handle(updateEvent);
|
|
|
+ assertEquals("Incorrect number of containers allocated", 0, app
|
|
|
+ .getLiveContainers().size());
|
|
|
+
|
|
|
+ // Verify a container gets placed on the empty blacklist
|
|
|
+ scheduler.allocate(appAttemptId, update,
|
|
|
+ Collections.<ContainerId>emptyList(), null,
|
|
|
+ Collections.singletonList(host));
|
|
|
+ assertFalse(app.isBlacklisted(host));
|
|
|
+ createSchedulingRequest(GB, "root.default", "user", 1);
|
|
|
+ scheduler.update();
|
|
|
+ scheduler.handle(updateEvent);
|
|
|
+ assertEquals("Incorrect number of containers allocated", 1, app
|
|
|
+ .getLiveContainers().size());
|
|
|
+ }
|
|
|
}
|