{"action":"created","comment":{"url":"https://api.github.com/repos/apache/storm/pulls/comments/47998594","id":47998594,"diff_hunk":"@@ -0,0 +1,1166 @@\n+/**\n+ * Licensed to the Apache Software Foundation (ASF) under one\n+ * or more contributor license agreements.  See the NOTICE file\n+ * distributed with this work for additional information\n+ * regarding copyright ownership.  The ASF licenses this file\n+ * to you under the Apache License, Version 2.0 (the\n+ * \"License\"); you may not use this file except in compliance\n+ * with the License.  You may obtain a copy of the License at\n+ * <p>\n+ * http://www.apache.org/licenses/LICENSE-2.0\n+ * <p>\n+ * Unless required by applicable law or agreed to in writing, software\n+ * distributed under the License is distributed on an \"AS IS\" BASIS,\n+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+ * See the License for the specific language governing permissions and\n+ * limitations under the License.\n+ */\n+\n+package backtype.storm.scheduler.resource;\n+\n+import backtype.storm.Config;\n+import backtype.storm.scheduler.Cluster;\n+import backtype.storm.scheduler.ExecutorDetails;\n+import backtype.storm.scheduler.INimbus;\n+import backtype.storm.scheduler.IScheduler;\n+import backtype.storm.scheduler.SchedulerAssignment;\n+import backtype.storm.scheduler.SchedulerAssignmentImpl;\n+import backtype.storm.scheduler.SupervisorDetails;\n+import backtype.storm.scheduler.Topologies;\n+import backtype.storm.scheduler.TopologyDetails;\n+import backtype.storm.scheduler.WorkerSlot;\n+import backtype.storm.utils.Time;\n+import backtype.storm.utils.Utils;\n+import backtype.storm.validation.ConfigValidation;\n+import org.junit.Assert;\n+import org.junit.Test;\n+import org.slf4j.Logger;\n+import org.slf4j.LoggerFactory;\n+\n+import java.util.Collection;\n+import java.util.HashMap;\n+import java.util.Iterator;\n+import java.util.Map;\n+import java.util.Set;\n+\n+public class TestResourceAwareScheduler {\n+\n+    private static final int NUM_SUPS = 20;\n+    private static final int NUM_WORKERS_PER_SUP = 4;\n+    private final String TOPOLOGY_SUBMITTER = \"jerry\";\n+\n+    private static final Logger LOG = LoggerFactory.getLogger(TestResourceAwareScheduler.class);\n+\n+    @Test\n+    public void TestReadInResourceAwareSchedulerUserPools() {\n+\n+        Map fromFile = Utils.findAndReadConfigFile(\"user-resource-pools.yaml\", false);\n+        LOG.info(\"fromFile: {}\", fromFile);\n+        ConfigValidation.validateFields(fromFile);\n+    }\n+\n+    @Test\n+    public void TestTopologySortedInCorrectOrder() {\n+        INimbus iNimbus = new TestUtilsForResourceAwareScheduler.INimbusTest();\n+        Map<String, Number> resourceMap = new HashMap<String, Number>();\n+        resourceMap.put(Config.SUPERVISOR_CPU_CAPACITY, 100.0);\n+        resourceMap.put(Config.SUPERVISOR_MEMORY_CAPACITY_MB, 1024.0);\n+        Map<String, SupervisorDetails> supMap = TestUtilsForResourceAwareScheduler.genSupervisors(20, 4, resourceMap);\n+        Config config = new Config();\n+        config.putAll(Utils.readDefaultConfig());\n+        config.put(Config.RESOURCE_AWARE_SCHEDULER_EVICTION_STRATEGY, backtype.storm.scheduler.resource.strategies.eviction.DefaultEvictionStrategy.class.getName());\n+        config.put(Config.RESOURCE_AWARE_SCHEDULER_PRIORITY_STRATEGY, backtype.storm.scheduler.resource.strategies.priority.DefaultSchedulingPriorityStrategy.class.getName());\n+        config.put(Config.TOPOLOGY_SCHEDULER_STRATEGY, backtype.storm.scheduler.resource.strategies.scheduling.DefaultResourceAwareStrategy.class.getName());\n+\n+        config.put(Config.TOPOLOGY_SUBMITTER_USER, TOPOLOGY_SUBMITTER);\n+\n+        Map<String, Map<String, Number>> resourceUserPool = new HashMap<String, Map<String, Number>>();\n+        resourceUserPool.put(\"jerry\", new HashMap<String, Number>());\n+        resourceUserPool.get(\"jerry\").put(\"cpu\", 1000);\n+        resourceUserPool.get(\"jerry\").put(\"memory\", 8192.0);\n+\n+        resourceUserPool.put(\"bobby\", new HashMap<String, Number>());\n+        resourceUserPool.get(\"bobby\").put(\"cpu\", 10000.0);\n+        resourceUserPool.get(\"bobby\").put(\"memory\", 32768);\n+\n+        resourceUserPool.put(\"derek\", new HashMap<String, Number>());\n+        resourceUserPool.get(\"derek\").put(\"cpu\", 5000.0);\n+        resourceUserPool.get(\"derek\").put(\"memory\", 16384.0);\n+\n+        config.put(Config.RESOURCE_AWARE_SCHEDULER_USER_POOLS, resourceUserPool);\n+\n+        TopologyDetails topo1 = TestUtilsForResourceAwareScheduler.getTopology(\"topo-1\", config, 5, 15, 1, 1, Time.currentTimeSecs() - 2, 20);\n+        TopologyDetails topo2 = TestUtilsForResourceAwareScheduler.getTopology(\"topo-2\", config, 5, 15, 1, 1, Time.currentTimeSecs() - 8, 30);\n+        TopologyDetails topo3 = TestUtilsForResourceAwareScheduler.getTopology(\"topo-3\", config, 5, 15, 1, 1, Time.currentTimeSecs() - 16, 30);\n+        TopologyDetails topo4 = TestUtilsForResourceAwareScheduler.getTopology(\"topo-4\", config, 5, 15, 1, 1, Time.currentTimeSecs() - 16, 20);\n+        TopologyDetails topo5 = TestUtilsForResourceAwareScheduler.getTopology(\"topo-5\", config, 5, 15, 1, 1, Time.currentTimeSecs() - 24, 30);\n+\n+        Map<String, TopologyDetails> topoMap = new HashMap<String, TopologyDetails>();\n+        topoMap.put(topo1.getId(), topo1);\n+        topoMap.put(topo2.getId(), topo2);\n+        topoMap.put(topo3.getId(), topo3);\n+        topoMap.put(topo4.getId(), topo4);\n+        topoMap.put(topo5.getId(), topo5);\n+\n+        Cluster cluster = new Cluster(iNimbus, supMap, new HashMap<String, SchedulerAssignmentImpl>(), config);\n+\n+        Topologies topologies = new Topologies(topoMap);\n+\n+        ResourceAwareScheduler rs = new ResourceAwareScheduler();\n+\n+        rs.prepare(config);\n+        rs.schedule(topologies, cluster);\n+\n+        Set<TopologyDetails> queue = rs.getUser(\"jerry\").getTopologiesPending();\n+        Assert.assertEquals(\"check size\", queue.size(), 0);\n+\n+        queue = rs.getUser(\"jerry\").getTopologiesRunning();\n+\n+        Iterator<TopologyDetails> itr = queue.iterator();\n+\n+        TopologyDetails topo = itr.next();\n+        LOG.info(\"{} - {}\", topo.getName(), queue);\n+        Assert.assertEquals(\"check order\", topo.getName(), \"topo-4\");\n+\n+        topo = itr.next();\n+        LOG.info(\"{} - {}\", topo.getName(), queue);\n+        Assert.assertEquals(\"check order\", topo.getName(), \"topo-1\");\n+\n+        topo = itr.next();\n+        LOG.info(\"{} - {}\", topo.getName(), queue);\n+        Assert.assertEquals(\"check order\", topo.getName(), \"topo-5\");\n+\n+        topo = itr.next();\n+        LOG.info(\"{} - {}\", topo.getName(), queue);\n+        Assert.assertEquals(\"check order\", topo.getName(), \"topo-3\");\n+\n+        topo = itr.next();\n+        LOG.info(\"{} - {}\", topo.getName(), queue);\n+        Assert.assertEquals(\"check order\", topo.getName(), \"topo-2\");\n+\n+        TopologyDetails topo6 = TestUtilsForResourceAwareScheduler.getTopology(\"topo-6\", config, 5, 15, 1, 1, Time.currentTimeSecs() - 30, 10);\n+        topoMap.put(topo6.getId(), topo6);\n+\n+        topologies = new Topologies(topoMap);\n+        rs.prepare(config);\n+        rs.schedule(topologies, cluster);\n+\n+        queue = rs.getUser(\"jerry\").getTopologiesRunning();\n+        itr = queue.iterator();\n+\n+        topo = itr.next();\n+        Assert.assertEquals(\"check order\", topo.getName(), \"topo-6\");\n+\n+        topo = itr.next();\n+        Assert.assertEquals(\"check order\", topo.getName(), \"topo-4\");\n+\n+        topo = itr.next();\n+        Assert.assertEquals(\"check order\", topo.getName(), \"topo-1\");\n+\n+        topo = itr.next();\n+        Assert.assertEquals(\"check order\", topo.getName(), \"topo-5\");\n+\n+        topo = itr.next();\n+        Assert.assertEquals(\"check order\", topo.getName(), \"topo-3\");\n+\n+        topo = itr.next();\n+        Assert.assertEquals(\"check order\", topo.getName(), \"topo-2\");\n+\n+        queue = rs.getUser(\"jerry\").getTopologiesPending();\n+        Assert.assertEquals(\"check size\", queue.size(), 0);\n+    }\n+\n+    @Test\n+    public void TestMultipleUsers() {\n+        INimbus iNimbus = new TestUtilsForResourceAwareScheduler.INimbusTest();\n+        Map<String, Number> resourceMap = new HashMap<String, Number>();\n+        resourceMap.put(Config.SUPERVISOR_CPU_CAPACITY, 1000.0);\n+        resourceMap.put(Config.SUPERVISOR_MEMORY_CAPACITY_MB, 1024.0 * 10);\n+        Map<String, SupervisorDetails> supMap = TestUtilsForResourceAwareScheduler.genSupervisors(20, 4, resourceMap);\n+        Config config = new Config();\n+        config.putAll(Utils.readDefaultConfig());\n+        config.put(Config.RESOURCE_AWARE_SCHEDULER_EVICTION_STRATEGY, backtype.storm.scheduler.resource.strategies.eviction.DefaultEvictionStrategy.class.getName());\n+        config.put(Config.RESOURCE_AWARE_SCHEDULER_PRIORITY_STRATEGY, backtype.storm.scheduler.resource.strategies.priority.DefaultSchedulingPriorityStrategy.class.getName());\n+        config.put(Config.TOPOLOGY_SCHEDULER_STRATEGY, backtype.storm.scheduler.resource.strategies.scheduling.DefaultResourceAwareStrategy.class.getName());\n+        Map<String, Map<String, Number>> resourceUserPool = new HashMap<String, Map<String, Number>>();\n+        resourceUserPool.put(\"jerry\", new HashMap<String, Number>());\n+        resourceUserPool.get(\"jerry\").put(\"cpu\", 1000);\n+        resourceUserPool.get(\"jerry\").put(\"memory\", 8192.0);\n+\n+        resourceUserPool.put(\"bobby\", new HashMap<String, Number>());\n+        resourceUserPool.get(\"bobby\").put(\"cpu\", 10000.0);\n+        resourceUserPool.get(\"bobby\").put(\"memory\", 32768);\n+\n+        resourceUserPool.put(\"derek\", new HashMap<String, Number>());\n+        resourceUserPool.get(\"derek\").put(\"cpu\", 5000.0);\n+        resourceUserPool.get(\"derek\").put(\"memory\", 16384.0);\n+\n+        config.put(Config.RESOURCE_AWARE_SCHEDULER_USER_POOLS, resourceUserPool);\n+        Cluster cluster = new Cluster(iNimbus, supMap, new HashMap<String, SchedulerAssignmentImpl>(), config);\n+\n+        config.put(Config.TOPOLOGY_SUBMITTER_USER, \"jerry\");\n+\n+        TopologyDetails topo1 = TestUtilsForResourceAwareScheduler.getTopology(\"topo-1\", config, 5, 15, 1, 1, Time.currentTimeSecs() - 2, 20);\n+        TopologyDetails topo2 = TestUtilsForResourceAwareScheduler.getTopology(\"topo-2\", config, 5, 15, 1, 1, Time.currentTimeSecs() - 8, 29);\n+        TopologyDetails topo3 = TestUtilsForResourceAwareScheduler.getTopology(\"topo-3\", config, 5, 15, 1, 1, Time.currentTimeSecs() - 16, 29);\n+        TopologyDetails topo4 = TestUtilsForResourceAwareScheduler.getTopology(\"topo-4\", config, 5, 15, 1, 1, Time.currentTimeSecs() - 16, 20);\n+        TopologyDetails topo5 = TestUtilsForResourceAwareScheduler.getTopology(\"topo-5\", config, 5, 15, 1, 1, Time.currentTimeSecs() - 24, 29);\n+\n+        config.put(Config.TOPOLOGY_SUBMITTER_USER, \"bobby\");\n+\n+        TopologyDetails topo6 = TestUtilsForResourceAwareScheduler.getTopology(\"topo-6\", config, 5, 15, 1, 1, Time.currentTimeSecs() - 2, 20);\n+        TopologyDetails topo7 = TestUtilsForResourceAwareScheduler.getTopology(\"topo-7\", config, 5, 15, 1, 1, Time.currentTimeSecs() - 8, 29);\n+        TopologyDetails topo8 = TestUtilsForResourceAwareScheduler.getTopology(\"topo-8\", config, 5, 15, 1, 1, Time.currentTimeSecs() - 16, 29);\n+        TopologyDetails topo9 = TestUtilsForResourceAwareScheduler.getTopology(\"topo-9\", config, 5, 15, 1, 1, Time.currentTimeSecs() - 16, 20);\n+        TopologyDetails topo10 = TestUtilsForResourceAwareScheduler.getTopology(\"topo-10\", config, 5, 15, 1, 1, Time.currentTimeSecs() - 24, 29);\n+\n+        config.put(Config.TOPOLOGY_SUBMITTER_USER, \"derek\");\n+\n+        TopologyDetails topo11 = TestUtilsForResourceAwareScheduler.getTopology(\"topo-11\", config, 5, 15, 1, 1, Time.currentTimeSecs() - 2, 20);\n+        TopologyDetails topo12 = TestUtilsForResourceAwareScheduler.getTopology(\"topo-12\", config, 5, 15, 1, 1, Time.currentTimeSecs() - 8, 29);\n+        TopologyDetails topo13 = TestUtilsForResourceAwareScheduler.getTopology(\"topo-13\", config, 5, 15, 1, 1, Time.currentTimeSecs() - 16, 29);\n+        TopologyDetails topo14 = TestUtilsForResourceAwareScheduler.getTopology(\"topo-14\", config, 5, 15, 1, 1, Time.currentTimeSecs() - 16, 20);\n+        TopologyDetails topo15 = TestUtilsForResourceAwareScheduler.getTopology(\"topo-15\", config, 5, 15, 1, 1, Time.currentTimeSecs() - 24, 29);\n+\n+        Map<String, TopologyDetails> topoMap = new HashMap<String, TopologyDetails>();\n+        topoMap.put(topo1.getId(), topo1);\n+        topoMap.put(topo2.getId(), topo2);\n+        topoMap.put(topo3.getId(), topo3);\n+        topoMap.put(topo4.getId(), topo4);\n+        topoMap.put(topo5.getId(), topo5);\n+        topoMap.put(topo6.getId(), topo6);\n+        topoMap.put(topo7.getId(), topo7);\n+        topoMap.put(topo8.getId(), topo8);\n+        topoMap.put(topo9.getId(), topo9);\n+        topoMap.put(topo10.getId(), topo10);\n+        topoMap.put(topo11.getId(), topo11);\n+        topoMap.put(topo12.getId(), topo12);\n+        topoMap.put(topo13.getId(), topo13);\n+        topoMap.put(topo14.getId(), topo14);\n+        topoMap.put(topo15.getId(), topo15);\n+\n+        Topologies topologies = new Topologies(topoMap);\n+\n+        ResourceAwareScheduler rs = new ResourceAwareScheduler();\n+\n+        rs.prepare(config);\n+        rs.schedule(topologies, cluster);\n+\n+        for (TopologyDetails topo : topoMap.values()) {\n+            Assert.assertTrue(TestUtilsForResourceAwareScheduler.assertStatusSuccess(cluster.getStatusMap().get(topo.getId())));\n+        }\n+\n+        for (User user : rs.getUserMap().values()) {\n+            Assert.assertEquals(user.getTopologiesPending().size(), 0);\n+            Assert.assertEquals(user.getTopologiesRunning().size(), 5);\n+        }\n+    }\n+\n+    @Test\n+    public void testHandlingClusterSubscription() {\n+        INimbus iNimbus = new TestUtilsForResourceAwareScheduler.INimbusTest();\n+        Map<String, Number> resourceMap = new HashMap<String, Number>();\n+        resourceMap.put(Config.SUPERVISOR_CPU_CAPACITY, 200.0);\n+        resourceMap.put(Config.SUPERVISOR_MEMORY_CAPACITY_MB, 1024.0 * 10);\n+        Map<String, SupervisorDetails> supMap = TestUtilsForResourceAwareScheduler.genSupervisors(1, 4, resourceMap);\n+        Config config = new Config();\n+        config.putAll(Utils.readDefaultConfig());\n+        config.put(Config.RESOURCE_AWARE_SCHEDULER_EVICTION_STRATEGY, backtype.storm.scheduler.resource.strategies.eviction.DefaultEvictionStrategy.class.getName());\n+        config.put(Config.RESOURCE_AWARE_SCHEDULER_PRIORITY_STRATEGY, backtype.storm.scheduler.resource.strategies.priority.DefaultSchedulingPriorityStrategy.class.getName());\n+        config.put(Config.TOPOLOGY_SCHEDULER_STRATEGY, backtype.storm.scheduler.resource.strategies.scheduling.DefaultResourceAwareStrategy.class.getName());\n+        Map<String, Map<String, Number>> resourceUserPool = new HashMap<String, Map<String, Number>>();\n+        resourceUserPool.put(\"jerry\", new HashMap<String, Number>());\n+        resourceUserPool.get(\"jerry\").put(\"cpu\", 1000);\n+        resourceUserPool.get(\"jerry\").put(\"memory\", 8192.0);\n+\n+        resourceUserPool.put(\"bobby\", new HashMap<String, Number>());\n+        resourceUserPool.get(\"bobby\").put(\"cpu\", 10000.0);\n+        resourceUserPool.get(\"bobby\").put(\"memory\", 32768);\n+\n+        resourceUserPool.put(\"derek\", new HashMap<String, Number>());\n+        resourceUserPool.get(\"derek\").put(\"cpu\", 5000.0);\n+        resourceUserPool.get(\"derek\").put(\"memory\", 16384.0);\n+\n+        config.put(Config.RESOURCE_AWARE_SCHEDULER_USER_POOLS, resourceUserPool);\n+        Cluster cluster = new Cluster(iNimbus, supMap, new HashMap<String, SchedulerAssignmentImpl>(), config);\n+\n+        config.put(Config.TOPOLOGY_SUBMITTER_USER, \"jerry\");\n+\n+        TopologyDetails topo1 = TestUtilsForResourceAwareScheduler.getTopology(\"topo-1\", config, 5, 15, 1, 1, Time.currentTimeSecs() - 2, 20);\n+        TopologyDetails topo2 = TestUtilsForResourceAwareScheduler.getTopology(\"topo-2\", config, 5, 15, 1, 1, Time.currentTimeSecs() - 8, 29);\n+\n+        Map<String, TopologyDetails> topoMap = new HashMap<String, TopologyDetails>();\n+        topoMap.put(topo1.getId(), topo1);\n+        topoMap.put(topo2.getId(), topo2);\n+\n+        Topologies topologies = new Topologies(topoMap);\n+\n+        ResourceAwareScheduler rs = new ResourceAwareScheduler();\n+\n+        rs.prepare(config);\n+        rs.schedule(topologies, cluster);\n+\n+        int fullyScheduled = 0;\n+        for (TopologyDetails topo : topoMap.values()) {\n+            if (TestUtilsForResourceAwareScheduler.assertStatusSuccess(cluster.getStatusMap().get(topo.getId()))) {\n+                fullyScheduled++;\n+            }\n+        }\n+        Assert.assertEquals(\"# of Fully scheduled\", 1, fullyScheduled);\n+        Assert.assertEquals(\"# of topologies schedule attempted\", 1, rs.getUser(\"jerry\").getTopologiesAttempted().size());\n+        Assert.assertEquals(\"# of topologies running\", 1, rs.getUser(\"jerry\").getTopologiesRunning().size());\n+        Assert.assertEquals(\"# of topologies schedule pending\", 0, rs.getUser(\"jerry\").getTopologiesPending().size());\n+    }\n+\n+    /**\n+     * The resources in the cluster is limited. In the first round of scheduling, all resources in the cluster is used.\n+     * User jerry submits another toplogy.  Since user jerry has has his resource guarantees satisfied, and user bobby\n+     * has exceeded his resource guarantee, topo-3 from user bobby should be eviced.\n+     */\n+    @Test\n+    public void testEviction() {\n+        INimbus iNimbus = new TestUtilsForResourceAwareScheduler.INimbusTest();\n+        Map<String, Number> resourceMap = new HashMap<String, Number>();\n+        resourceMap.put(Config.SUPERVISOR_CPU_CAPACITY, 100.0);\n+        resourceMap.put(Config.SUPERVISOR_MEMORY_CAPACITY_MB, 1000.0);\n+        Map<String, SupervisorDetails> supMap = TestUtilsForResourceAwareScheduler.genSupervisors(4, 4, resourceMap);\n+        Config config = new Config();\n+        config.putAll(Utils.readDefaultConfig());\n+        config.put(Config.RESOURCE_AWARE_SCHEDULER_EVICTION_STRATEGY, backtype.storm.scheduler.resource.strategies.eviction.DefaultEvictionStrategy.class.getName());\n+        config.put(Config.RESOURCE_AWARE_SCHEDULER_PRIORITY_STRATEGY, backtype.storm.scheduler.resource.strategies.priority.DefaultSchedulingPriorityStrategy.class.getName());\n+        config.put(Config.TOPOLOGY_SCHEDULER_STRATEGY, backtype.storm.scheduler.resource.strategies.scheduling.DefaultResourceAwareStrategy.class.getName());\n+        config.put(Config.TOPOLOGY_COMPONENT_CPU_PCORE_PERCENT, 100.0);\n+        config.put(Config.TOPOLOGY_COMPONENT_RESOURCES_OFFHEAP_MEMORY_MB, 500);\n+        config.put(Config.TOPOLOGY_COMPONENT_RESOURCES_ONHEAP_MEMORY_MB, 500);\n+        Map<String, Map<String, Number>> resourceUserPool = new HashMap<String, Map<String, Number>>();\n+        resourceUserPool.put(\"jerry\", new HashMap<String, Number>());\n+        resourceUserPool.get(\"jerry\").put(\"cpu\", 200.0);\n+        resourceUserPool.get(\"jerry\").put(\"memory\", 2000.0);\n+\n+        resourceUserPool.put(\"bobby\", new HashMap<String, Number>());\n+        resourceUserPool.get(\"bobby\").put(\"cpu\", 100.0);\n+        resourceUserPool.get(\"bobby\").put(\"memory\", 1000.0);\n+\n+        resourceUserPool.put(\"derek\", new HashMap<String, Number>());\n+        resourceUserPool.get(\"derek\").put(\"cpu\", 200.0);\n+        resourceUserPool.get(\"derek\").put(\"memory\", 2000.0);\n+\n+        config.put(Config.RESOURCE_AWARE_SCHEDULER_USER_POOLS, resourceUserPool);\n+        Cluster cluster = new Cluster(iNimbus, supMap, new HashMap<String, SchedulerAssignmentImpl>(), config);\n+\n+        config.put(Config.TOPOLOGY_SUBMITTER_USER, \"jerry\");\n+\n+        TopologyDetails topo1 = TestUtilsForResourceAwareScheduler.getTopology(\"topo-1\", config, 1, 0, 1, 0, Time.currentTimeSecs() - 2, 10);\n+        TopologyDetails topo6 = TestUtilsForResourceAwareScheduler.getTopology(\"topo-6\", config, 1, 0, 1, 0, Time.currentTimeSecs() - 2, 20);\n+\n+\n+        config.put(Config.TOPOLOGY_SUBMITTER_USER, \"bobby\");\n+\n+        TopologyDetails topo2 = TestUtilsForResourceAwareScheduler.getTopology(\"topo-2\", config, 1, 0, 1, 0, Time.currentTimeSecs() - 2, 10);\n+        TopologyDetails topo3 = TestUtilsForResourceAwareScheduler.getTopology(\"topo-3\", config, 1, 0, 1, 0, Time.currentTimeSecs() - 2, 20);\n+\n+        config.put(Config.TOPOLOGY_SUBMITTER_USER, \"derek\");\n+\n+        TopologyDetails topo4 = TestUtilsForResourceAwareScheduler.getTopology(\"topo-4\", config, 1, 0, 1, 0, Time.currentTimeSecs() - 2, 29);\n+\n+        Map<String, TopologyDetails> topoMap = new HashMap<String, TopologyDetails>();\n+        topoMap.put(topo1.getId(), topo1);\n+        topoMap.put(topo2.getId(), topo2);\n+        topoMap.put(topo3.getId(), topo3);\n+        topoMap.put(topo4.getId(), topo4);\n+\n+        Topologies topologies = new Topologies(topoMap);\n+\n+        ResourceAwareScheduler rs = new ResourceAwareScheduler();\n+\n+        rs.prepare(config);\n+        rs.schedule(topologies, cluster);\n+\n+        for (TopologyDetails topo : rs.getUser(\"jerry\").getTopologiesRunning()) {\n+            Assert.assertTrue(\"correct topology to evict\", TestUtilsForResourceAwareScheduler.assertStatusSuccess(cluster.getStatusMap().get(topo.getId())));\n+        }\n+        Assert.assertEquals(\"# of running topologies\", 1, rs.getUser(\"jerry\").getTopologiesRunning().size());\n+        Assert.assertEquals(\"# of pending topologies\", 0, rs.getUser(\"jerry\").getTopologiesPending().size());\n+        Assert.assertEquals(\"# of attempted topologies\", 0, rs.getUser(\"jerry\").getTopologiesAttempted().size());\n+        Assert.assertEquals(\"# of invalid topologies\", 0, rs.getUser(\"jerry\").getTopologiesInvalid().size());\n+\n+        for (TopologyDetails topo : rs.getUser(\"derek\").getTopologiesRunning()) {\n+            Assert.assertTrue(\"correct topology to evict\", TestUtilsForResourceAwareScheduler.assertStatusSuccess(cluster.getStatusMap().get(topo.getId())));\n+        }\n+        Assert.assertEquals(\"# of running topologies\", 1, rs.getUser(\"derek\").getTopologiesRunning().size());\n+        Assert.assertEquals(\"# of pending topologies\", 0, rs.getUser(\"derek\").getTopologiesPending().size());\n+        Assert.assertEquals(\"# of attempted topologies\", 0, rs.getUser(\"derek\").getTopologiesAttempted().size());\n+        Assert.assertEquals(\"# of invalid topologies\", 0, rs.getUser(\"derek\").getTopologiesInvalid().size());\n+\n+        for (TopologyDetails topo : rs.getUser(\"bobby\").getTopologiesRunning()) {\n+            Assert.assertTrue(\"correct topology to evict\", TestUtilsForResourceAwareScheduler.assertStatusSuccess(cluster.getStatusMap().get(topo.getId())));\n+        }\n+        Assert.assertEquals(\"# of running topologies\", 2, rs.getUser(\"bobby\").getTopologiesRunning().size());\n+        Assert.assertEquals(\"# of pending topologies\", 0, rs.getUser(\"bobby\").getTopologiesPending().size());\n+        Assert.assertEquals(\"# of attempted topologies\", 0, rs.getUser(\"bobby\").getTopologiesAttempted().size());\n+        Assert.assertEquals(\"# of invalid topologies\", 0, rs.getUser(\"bobby\").getTopologiesInvalid().size());\n+\n+        //user jerry submits another topology\n+        topoMap.put(topo6.getId(), topo6);\n+        topologies = new Topologies(topoMap);\n+\n+        rs.schedule(topologies, cluster);\n+\n+        for (TopologyDetails topo : rs.getUser(\"jerry\").getTopologiesRunning()) {\n+            Assert.assertTrue(\"correct topology to evict\", TestUtilsForResourceAwareScheduler.assertStatusSuccess(cluster.getStatusMap().get(topo.getId())));\n+        }\n+        Assert.assertEquals(\"# of running topologies\", 2, rs.getUser(\"jerry\").getTopologiesRunning().size());\n+        Assert.assertEquals(\"# of pending topologies\", 0, rs.getUser(\"jerry\").getTopologiesPending().size());\n+        Assert.assertEquals(\"# of attempted topologies\", 0, rs.getUser(\"jerry\").getTopologiesAttempted().size());\n+        Assert.assertEquals(\"# of invalid topologies\", 0, rs.getUser(\"jerry\").getTopologiesInvalid().size());\n+\n+        for (TopologyDetails topo : rs.getUser(\"derek\").getTopologiesRunning()) {\n+            Assert.assertTrue(\"correct topology to evict\", TestUtilsForResourceAwareScheduler.assertStatusSuccess(cluster.getStatusMap().get(topo.getId())));\n+        }\n+        Assert.assertEquals(\"# of running topologies\", 1, rs.getUser(\"derek\").getTopologiesRunning().size());\n+        Assert.assertEquals(\"# of pending topologies\", 0, rs.getUser(\"derek\").getTopologiesPending().size());\n+        Assert.assertEquals(\"# of attempted topologies\", 0, rs.getUser(\"derek\").getTopologiesAttempted().size());\n+        Assert.assertEquals(\"# of invalid topologies\", 0, rs.getUser(\"derek\").getTopologiesInvalid().size());\n+\n+        for (TopologyDetails topo : rs.getUser(\"bobby\").getTopologiesRunning()) {\n+            Assert.assertTrue(\"correct topology to evict\", TestUtilsForResourceAwareScheduler.assertStatusSuccess(cluster.getStatusMap().get(topo.getId())));\n+        }\n+        Assert.assertEquals(\"# of running topologies\", 1, rs.getUser(\"bobby\").getTopologiesRunning().size());\n+\n+        for (TopologyDetails topo : rs.getUser(\"bobby\").getTopologiesAttempted()) {\n+            Assert.assertFalse(\"correct topology to evict\", TestUtilsForResourceAwareScheduler.assertStatusSuccess(cluster.getStatusMap().get(topo.getId())));\n+        }\n+        Assert.assertEquals(\"# of attempted topologies\", 1, rs.getUser(\"bobby\").getTopologiesAttempted().size());\n+        Assert.assertEquals(\"# of pending topologies\", 0, rs.getUser(\"bobby\").getTopologiesPending().size());\n+        Assert.assertEquals(\"# of invalid topologies\", 0, rs.getUser(\"bobby\").getTopologiesInvalid().size());\n+    }\n+\n+    @Test\n+    public void TestEvictMultipleTopologies() {\n+        INimbus iNimbus = new TestUtilsForResourceAwareScheduler.INimbusTest();\n+        Map<String, Number> resourceMap = new HashMap<String, Number>();\n+        resourceMap.put(Config.SUPERVISOR_CPU_CAPACITY, 100.0);\n+        resourceMap.put(Config.SUPERVISOR_MEMORY_CAPACITY_MB, 1000.0);\n+        Map<String, SupervisorDetails> supMap = TestUtilsForResourceAwareScheduler.genSupervisors(4, 4, resourceMap);\n+        Config config = new Config();\n+        config.putAll(Utils.readDefaultConfig());\n+        config.put(Config.RESOURCE_AWARE_SCHEDULER_EVICTION_STRATEGY, backtype.storm.scheduler.resource.strategies.eviction.DefaultEvictionStrategy.class.getName());\n+        config.put(Config.RESOURCE_AWARE_SCHEDULER_PRIORITY_STRATEGY, backtype.storm.scheduler.resource.strategies.priority.DefaultSchedulingPriorityStrategy.class.getName());\n+        config.put(Config.TOPOLOGY_SCHEDULER_STRATEGY, backtype.storm.scheduler.resource.strategies.scheduling.DefaultResourceAwareStrategy.class.getName());\n+        config.put(Config.TOPOLOGY_COMPONENT_CPU_PCORE_PERCENT, 100.0);\n+        config.put(Config.TOPOLOGY_COMPONENT_RESOURCES_OFFHEAP_MEMORY_MB, 500);\n+        config.put(Config.TOPOLOGY_COMPONENT_RESOURCES_ONHEAP_MEMORY_MB, 500);\n+        Map<String, Map<String, Number>> resourceUserPool = new HashMap<String, Map<String, Number>>();\n+        resourceUserPool.put(\"jerry\", new HashMap<String, Number>());\n+        resourceUserPool.get(\"jerry\").put(\"cpu\", 200.0);\n+        resourceUserPool.get(\"jerry\").put(\"memory\", 2000.0);\n+\n+        resourceUserPool.put(\"derek\", new HashMap<String, Number>());\n+        resourceUserPool.get(\"derek\").put(\"cpu\", 100.0);\n+        resourceUserPool.get(\"derek\").put(\"memory\", 1000.0);\n+\n+        config.put(Config.RESOURCE_AWARE_SCHEDULER_USER_POOLS, resourceUserPool);\n+        Cluster cluster = new Cluster(iNimbus, supMap, new HashMap<String, SchedulerAssignmentImpl>(), config);\n+\n+        config.put(Config.TOPOLOGY_SUBMITTER_USER, \"jerry\");\n+\n+        TopologyDetails topo1 = TestUtilsForResourceAwareScheduler.getTopology(\"topo-1\", config, 2, 0, 1, 0, Time.currentTimeSecs() - 2, 10);\n+\n+        config.put(Config.TOPOLOGY_SUBMITTER_USER, \"bobby\");\n+\n+        TopologyDetails topo2 = TestUtilsForResourceAwareScheduler.getTopology(\"topo-2\", config, 1, 0, 1, 0, Time.currentTimeSecs() - 2, 10);\n+        TopologyDetails topo3 = TestUtilsForResourceAwareScheduler.getTopology(\"topo-3\", config, 1, 0, 1, 0, Time.currentTimeSecs() - 2, 20);\n+\n+        config.put(Config.TOPOLOGY_SUBMITTER_USER, \"derek\");\n+\n+        TopologyDetails topo4 = TestUtilsForResourceAwareScheduler.getTopology(\"topo-4\", config, 1, 0, 1, 0, Time.currentTimeSecs() - 2, 29);\n+        TopologyDetails topo5 = TestUtilsForResourceAwareScheduler.getTopology(\"topo-5\", config, 1, 0, 1, 0, Time.currentTimeSecs() - 2, 29);\n+\n+        Map<String, TopologyDetails> topoMap = new HashMap<String, TopologyDetails>();\n+        topoMap.put(topo2.getId(), topo2);\n+        topoMap.put(topo3.getId(), topo3);\n+        topoMap.put(topo4.getId(), topo4);\n+        topoMap.put(topo5.getId(), topo5);\n+\n+        Topologies topologies = new Topologies(topoMap);\n+\n+        ResourceAwareScheduler rs = new ResourceAwareScheduler();\n+\n+        rs.prepare(config);\n+        rs.schedule(topologies, cluster);\n+\n+        for (TopologyDetails topo : rs.getUser(\"derek\").getTopologiesRunning()) {\n+            Assert.assertTrue(\"correct topology to evict\", TestUtilsForResourceAwareScheduler.assertStatusSuccess(cluster.getStatusMap().get(topo.getId())));\n+        }\n+        Assert.assertEquals(\"# of running topologies\", 2, rs.getUser(\"derek\").getTopologiesRunning().size());\n+        Assert.assertEquals(\"# of pending topologies\", 0, rs.getUser(\"derek\").getTopologiesPending().size());\n+        Assert.assertEquals(\"# of attempted topologies\", 0, rs.getUser(\"derek\").getTopologiesAttempted().size());\n+        Assert.assertEquals(\"# of invalid topologies\", 0, rs.getUser(\"derek\").getTopologiesInvalid().size());\n+\n+        for (TopologyDetails topo : rs.getUser(\"bobby\").getTopologiesRunning()) {\n+            Assert.assertTrue(\"correct topology to evict\", TestUtilsForResourceAwareScheduler.assertStatusSuccess(cluster.getStatusMap().get(topo.getId())));\n+        }\n+        Assert.assertEquals(\"# of running topologies\", 2, rs.getUser(\"bobby\").getTopologiesRunning().size());\n+        Assert.assertEquals(\"# of pending topologies\", 0, rs.getUser(\"bobby\").getTopologiesPending().size());\n+        Assert.assertEquals(\"# of invalid topologies\", 0, rs.getUser(\"bobby\").getTopologiesInvalid().size());\n+        Assert.assertEquals(\"# of attempted topologies\", 0, rs.getUser(\"bobby\").getTopologiesAttempted().size());\n+\n+        //user jerry submits another topology\n+        topoMap.put(topo1.getId(), topo1);\n+        topologies = new Topologies(topoMap);\n+        rs.schedule(topologies, cluster);\n+\n+        for (TopologyDetails topo : rs.getUser(\"jerry\").getTopologiesRunning()) {\n+            Assert.assertTrue(\"correct topology to evict\", TestUtilsForResourceAwareScheduler.assertStatusSuccess(cluster.getStatusMap().get(topo.getId())));\n+        }\n+        Assert.assertEquals(\"# of running topologies\", 1, rs.getUser(\"jerry\").getTopologiesRunning().size());\n+        Assert.assertEquals(\"# of pending topologies\", 0, rs.getUser(\"jerry\").getTopologiesPending().size());\n+        Assert.assertEquals(\"# of attempted topologies\", 0, rs.getUser(\"jerry\").getTopologiesAttempted().size());\n+        Assert.assertEquals(\"# of invalid topologies\", 0, rs.getUser(\"jerry\").getTopologiesInvalid().size());\n+\n+        for (TopologyDetails topo : rs.getUser(\"derek\").getTopologiesRunning()) {\n+            Assert.assertTrue(\"correct topology to evict\", TestUtilsForResourceAwareScheduler.assertStatusSuccess(cluster.getStatusMap().get(topo.getId())));\n+        }\n+        Assert.assertEquals(\"# of running topologies\", 2, rs.getUser(\"derek\").getTopologiesRunning().size());\n+        Assert.assertEquals(\"# of pending topologies\", 0, rs.getUser(\"derek\").getTopologiesPending().size());\n+        Assert.assertEquals(\"# of attempted topologies\", 0, rs.getUser(\"derek\").getTopologiesAttempted().size());\n+        Assert.assertEquals(\"# of invalid topologies\", 0, rs.getUser(\"derek\").getTopologiesInvalid().size());\n+\n+        for (TopologyDetails topo : rs.getUser(\"bobby\").getTopologiesAttempted()) {\n+            Assert.assertFalse(\"correct topology to evict\", TestUtilsForResourceAwareScheduler.assertStatusSuccess(cluster.getStatusMap().get(topo.getId())));\n+        }\n+        Assert.assertEquals(\"# of attempted topologies\", 2, rs.getUser(\"bobby\").getTopologiesAttempted().size());\n+        Assert.assertEquals(\"# of pending topologies\", 0, rs.getUser(\"bobby\").getTopologiesPending().size());\n+        Assert.assertEquals(\"# of invalid topologies\", 0, rs.getUser(\"bobby\").getTopologiesInvalid().size());\n+        Assert.assertEquals(\"# of running topologies\", 0, rs.getUser(\"bobby\").getTopologiesRunning().size());\n+    }\n+\n+    /**\n+     * Eviction order:\n+     * topo-3: since user bobby don't have any resource guarantees and topo-3 is the lowest priority for user bobby\n+     * topo-2: since user bobby don't have any resource guarantees and topo-2 is the next lowest priority for user bobby\n+     * topo-5: since user derek has exceeded his resource guarantee while user jerry has not.  topo-5 and topo-4 has the same priority\n+     * but topo-4 was submitted earlier thus we choose that one to evict\n+     */\n+    @Test\n+    public void TestEvictMultipleTopologiesFromMultipleUsersInCorrectOrder() {\n+        INimbus iNimbus = new TestUtilsForResourceAwareScheduler.INimbusTest();\n+        Map<String, Number> resourceMap = new HashMap<String, Number>();\n+        resourceMap.put(Config.SUPERVISOR_CPU_CAPACITY, 100.0);\n+        resourceMap.put(Config.SUPERVISOR_MEMORY_CAPACITY_MB, 1000.0);\n+        Map<String, SupervisorDetails> supMap = TestUtilsForResourceAwareScheduler.genSupervisors(4, 4, resourceMap);\n+        Config config = new Config();\n+        config.putAll(Utils.readDefaultConfig());\n+        config.put(Config.RESOURCE_AWARE_SCHEDULER_EVICTION_STRATEGY, backtype.storm.scheduler.resource.strategies.eviction.DefaultEvictionStrategy.class.getName());\n+        config.put(Config.RESOURCE_AWARE_SCHEDULER_PRIORITY_STRATEGY, backtype.storm.scheduler.resource.strategies.priority.DefaultSchedulingPriorityStrategy.class.getName());\n+        config.put(Config.TOPOLOGY_SCHEDULER_STRATEGY, backtype.storm.scheduler.resource.strategies.scheduling.DefaultResourceAwareStrategy.class.getName());\n+        config.put(Config.TOPOLOGY_COMPONENT_CPU_PCORE_PERCENT, 100.0);\n+        config.put(Config.TOPOLOGY_COMPONENT_RESOURCES_OFFHEAP_MEMORY_MB, 500);\n+        config.put(Config.TOPOLOGY_COMPONENT_RESOURCES_ONHEAP_MEMORY_MB, 500);\n+        Map<String, Map<String, Number>> resourceUserPool = new HashMap<String, Map<String, Number>>();\n+        resourceUserPool.put(\"jerry\", new HashMap<String, Number>());\n+        resourceUserPool.get(\"jerry\").put(\"cpu\", 300.0);\n+        resourceUserPool.get(\"jerry\").put(\"memory\", 3000.0);\n+\n+        resourceUserPool.put(\"derek\", new HashMap<String, Number>());\n+        resourceUserPool.get(\"derek\").put(\"cpu\", 100.0);\n+        resourceUserPool.get(\"derek\").put(\"memory\", 1000.0);\n+\n+        config.put(Config.RESOURCE_AWARE_SCHEDULER_USER_POOLS, resourceUserPool);\n+        Cluster cluster = new Cluster(iNimbus, supMap, new HashMap<String, SchedulerAssignmentImpl>(), config);\n+\n+        config.put(Config.TOPOLOGY_SUBMITTER_USER, \"jerry\");\n+\n+        TopologyDetails topo1 = TestUtilsForResourceAwareScheduler.getTopology(\"topo-1\", config, 1, 0, 1, 0, Time.currentTimeSecs() - 2, 10);\n+        TopologyDetails topo6 = TestUtilsForResourceAwareScheduler.getTopology(\"topo-6\", config, 1, 0, 1, 0, Time.currentTimeSecs() - 2, 10);\n+        TopologyDetails topo7 = TestUtilsForResourceAwareScheduler.getTopology(\"topo-7\", config, 1, 0, 1, 0, Time.currentTimeSecs() - 2, 10);\n+\n+        config.put(Config.TOPOLOGY_SUBMITTER_USER, \"bobby\");\n+\n+        TopologyDetails topo2 = TestUtilsForResourceAwareScheduler.getTopology(\"topo-2\", config, 1, 0, 1, 0, Time.currentTimeSecs() - 2, 10);\n+        TopologyDetails topo3 = TestUtilsForResourceAwareScheduler.getTopology(\"topo-3\", config, 1, 0, 1, 0, Time.currentTimeSecs() - 2, 20);\n+\n+        config.put(Config.TOPOLOGY_SUBMITTER_USER, \"derek\");\n+\n+        TopologyDetails topo4 = TestUtilsForResourceAwareScheduler.getTopology(\"topo-4\", config, 1, 0, 1, 0, Time.currentTimeSecs() - 2, 29);\n+        TopologyDetails topo5 = TestUtilsForResourceAwareScheduler.getTopology(\"topo-5\", config, 1, 0, 1, 0, Time.currentTimeSecs() - 15, 29);\n+\n+        Map<String, TopologyDetails> topoMap = new HashMap<String, TopologyDetails>();\n+        topoMap.put(topo2.getId(), topo2);\n+        topoMap.put(topo3.getId(), topo3);\n+        topoMap.put(topo4.getId(), topo4);\n+        topoMap.put(topo5.getId(), topo5);\n+\n+        Topologies topologies = new Topologies(topoMap);\n+\n+        ResourceAwareScheduler rs = new ResourceAwareScheduler();\n+\n+        rs.prepare(config);\n+        rs.schedule(topologies, cluster);\n+\n+        for (TopologyDetails topo : rs.getUser(\"derek\").getTopologiesRunning()) {\n+            Assert.assertTrue(\"Assert scheduling topology success\", TestUtilsForResourceAwareScheduler.assertStatusSuccess(cluster.getStatusMap().get(topo.getId())));\n+        }\n+        Assert.assertEquals(\"# of running topologies\", 2, rs.getUser(\"derek\").getTopologiesRunning().size());\n+        Assert.assertEquals(\"# of pending topologies\", 0, rs.getUser(\"derek\").getTopologiesPending().size());\n+        Assert.assertEquals(\"# of attempted topologies\", 0, rs.getUser(\"derek\").getTopologiesAttempted().size());\n+        Assert.assertEquals(\"# of invalid topologies\", 0, rs.getUser(\"derek\").getTopologiesInvalid().size());\n+\n+        for (TopologyDetails topo : rs.getUser(\"bobby\").getTopologiesRunning()) {\n+            Assert.assertTrue(\"Assert scheduling topology success\", TestUtilsForResourceAwareScheduler.assertStatusSuccess(cluster.getStatusMap().get(topo.getId())));\n+        }\n+        Assert.assertEquals(\"# of running topologies\", 2, rs.getUser(\"bobby\").getTopologiesRunning().size());\n+        Assert.assertEquals(\"# of pending topologies\", 0, rs.getUser(\"bobby\").getTopologiesPending().size());\n+        Assert.assertEquals(\"# of invalid topologies\", 0, rs.getUser(\"bobby\").getTopologiesInvalid().size());\n+        Assert.assertEquals(\"# of attempted topologies\", 0, rs.getUser(\"bobby\").getTopologiesAttempted().size());\n+\n+        //user jerry submits another topology\n+        topoMap.put(topo1.getId(), topo1);\n+        topologies = new Topologies(topoMap);\n+        rs.schedule(topologies, cluster);\n+\n+        for (TopologyDetails topo : rs.getUser(\"jerry\").getTopologiesRunning()) {\n+            Assert.assertTrue(\"Assert scheduling topology success\", TestUtilsForResourceAwareScheduler.assertStatusSuccess(cluster.getStatusMap().get(topo.getId())));\n+        }\n+        Assert.assertEquals(\"# of running topologies\", 1, rs.getUser(\"jerry\").getTopologiesRunning().size());\n+        Assert.assertEquals(\"# of pending topologies\", 0, rs.getUser(\"jerry\").getTopologiesPending().size());\n+        Assert.assertEquals(\"# of attempted topologies\", 0, rs.getUser(\"jerry\").getTopologiesAttempted().size());\n+        Assert.assertEquals(\"# of invalid topologies\", 0, rs.getUser(\"jerry\").getTopologiesInvalid().size());\n+\n+        for (TopologyDetails topo : rs.getUser(\"derek\").getTopologiesRunning()) {\n+            Assert.assertTrue(\"Assert scheduling topology success\", TestUtilsForResourceAwareScheduler.assertStatusSuccess(cluster.getStatusMap().get(topo.getId())));\n+        }\n+        Assert.assertEquals(\"# of running topologies\", 2, rs.getUser(\"derek\").getTopologiesRunning().size());\n+        Assert.assertEquals(\"# of pending topologies\", 0, rs.getUser(\"derek\").getTopologiesPending().size());\n+        Assert.assertEquals(\"# of attempted topologies\", 0, rs.getUser(\"derek\").getTopologiesAttempted().size());\n+        Assert.assertEquals(\"# of invalid topologies\", 0, rs.getUser(\"derek\").getTopologiesInvalid().size());\n+\n+        for (TopologyDetails topo : rs.getUser(\"bobby\").getTopologiesAttempted()) {\n+            Assert.assertFalse(\"Assert scheduling topology success\", TestUtilsForResourceAwareScheduler.assertStatusSuccess(cluster.getStatusMap().get(topo.getId())));\n+        }\n+        for (TopologyDetails topo : rs.getUser(\"bobby\").getTopologiesRunning()) {\n+            Assert.assertTrue(\"Assert scheduling topology success\", TestUtilsForResourceAwareScheduler.assertStatusSuccess(cluster.getStatusMap().get(topo.getId())));\n+        }\n+        Assert.assertEquals(\"# of attempted topologies\", 1, rs.getUser(\"bobby\").getTopologiesAttempted().size());\n+        Assert.assertEquals(\"# of pending topologies\", 0, rs.getUser(\"bobby\").getTopologiesPending().size());\n+        Assert.assertEquals(\"# of invalid topologies\", 0, rs.getUser(\"bobby\").getTopologiesInvalid().size());\n+        Assert.assertEquals(\"# of running topologies\", 1, rs.getUser(\"bobby\").getTopologiesRunning().size());\n+        Assert.assertEquals(\"correct topology to evict\", rs.getUser(\"bobby\").getTopologiesAttempted().iterator().next().getName(), \"topo-3\");\n+\n+        topoMap.put(topo6.getId(), topo6);\n+        topologies = new Topologies(topoMap);\n+        rs.schedule(topologies, cluster);\n+\n+        for (TopologyDetails topo : rs.getUser(\"jerry\").getTopologiesRunning()) {\n+            Assert.assertTrue(\"Assert scheduling topology success\", TestUtilsForResourceAwareScheduler.assertStatusSuccess(cluster.getStatusMap().get(topo.getId())));\n+        }\n+        Assert.assertEquals(\"# of running topologies\", 2, rs.getUser(\"jerry\").getTopologiesRunning().size());\n+        Assert.assertEquals(\"# of pending topologies\", 0, rs.getUser(\"jerry\").getTopologiesPending().size());\n+        Assert.assertEquals(\"# of attempted topologies\", 0, rs.getUser(\"jerry\").getTopologiesAttempted().size());\n+        Assert.assertEquals(\"# of invalid topologies\", 0, rs.getUser(\"jerry\").getTopologiesInvalid().size());\n+\n+        for (TopologyDetails topo : rs.getUser(\"derek\").getTopologiesRunning()) {\n+            Assert.assertTrue(\"Assert scheduling topology success\", TestUtilsForResourceAwareScheduler.assertStatusSuccess(cluster.getStatusMap().get(topo.getId())));\n+        }\n+        Assert.assertEquals(\"# of running topologies\", 2, rs.getUser(\"derek\").getTopologiesRunning().size());\n+        Assert.assertEquals(\"# of pending topologies\", 0, rs.getUser(\"derek\").getTopologiesPending().size());\n+        Assert.assertEquals(\"# of attempted topologies\", 0, rs.getUser(\"derek\").getTopologiesAttempted().size());\n+        Assert.assertEquals(\"# of invalid topologies\", 0, rs.getUser(\"derek\").getTopologiesInvalid().size());\n+\n+        for (TopologyDetails topo : rs.getUser(\"bobby\").getTopologiesAttempted()) {\n+            Assert.assertFalse(\"Assert scheduling topology success\", TestUtilsForResourceAwareScheduler.assertStatusSuccess(cluster.getStatusMap().get(topo.getId())));\n+        }\n+        Assert.assertEquals(\"# of attempted topologies\", 2, rs.getUser(\"bobby\").getTopologiesAttempted().size());\n+        Assert.assertEquals(\"# of pending topologies\", 0, rs.getUser(\"bobby\").getTopologiesPending().size());\n+        Assert.assertEquals(\"# of invalid topologies\", 0, rs.getUser(\"bobby\").getTopologiesInvalid().size());\n+        Assert.assertEquals(\"# of running topologies\", 0, rs.getUser(\"bobby\").getTopologiesRunning().size());\n+\n+        Assert.assertTrue(\"correct topology to evict\", TestUtilsForResourceAwareScheduler.findTopologyInSetFromName(\"topo-2\", rs.getUser(\"bobby\").getTopologiesAttempted()) != null);\n+        Assert.assertTrue(\"correct topology to evict\", TestUtilsForResourceAwareScheduler.findTopologyInSetFromName(\"topo-3\", rs.getUser(\"bobby\").getTopologiesAttempted()) != null);\n+\n+        topoMap.put(topo7.getId(), topo7);\n+        topologies = new Topologies(topoMap);\n+        rs.schedule(topologies, cluster);\n+\n+        for (TopologyDetails topo : rs.getUser(\"jerry\").getTopologiesRunning()) {\n+            Assert.assertTrue(\"Assert scheduling topology success\", TestUtilsForResourceAwareScheduler.assertStatusSuccess(cluster.getStatusMap().get(topo.getId())));\n+        }\n+        Assert.assertEquals(\"# of running topologies\", 3, rs.getUser(\"jerry\").getTopologiesRunning().size());\n+        Assert.assertEquals(\"# of pending topologies\", 0, rs.getUser(\"jerry\").getTopologiesPending().size());\n+        Assert.assertEquals(\"# of attempted topologies\", 0, rs.getUser(\"jerry\").getTopologiesAttempted().size());\n+        Assert.assertEquals(\"# of invalid topologies\", 0, rs.getUser(\"jerry\").getTopologiesInvalid().size());\n+\n+        for (TopologyDetails topo : rs.getUser(\"derek\").getTopologiesRunning()) {\n+            Assert.assertTrue(\"Assert scheduling topology success\", TestUtilsForResourceAwareScheduler.assertStatusSuccess(cluster.getStatusMap().get(topo.getId())));\n+        }\n+        for (TopologyDetails topo : rs.getUser(\"derek\").getTopologiesAttempted()) {\n+            Assert.assertFalse(\"Assert scheduling topology success\", TestUtilsForResourceAwareScheduler.assertStatusSuccess(cluster.getStatusMap().get(topo.getId())));\n+        }\n+        Assert.assertEquals(\"# of running topologies\", 1, rs.getUser(\"derek\").getTopologiesRunning().size());\n+        Assert.assertEquals(\"# of pending topologies\", 0, rs.getUser(\"derek\").getTopologiesPending().size());\n+        Assert.assertEquals(\"# of attempted topologies\", 1, rs.getUser(\"derek\").getTopologiesAttempted().size());\n+        Assert.assertEquals(\"# of invalid topologies\", 0, rs.getUser(\"derek\").getTopologiesInvalid().size());\n+        Assert.assertEquals(\"correct topology to evict\", rs.getUser(\"derek\").getTopologiesAttempted().iterator().next().getName(), \"topo-4\");\n+\n+        for (TopologyDetails topo : rs.getUser(\"bobby\").getTopologiesAttempted()) {\n+            Assert.assertFalse(\"Assert scheduling topology success\", TestUtilsForResourceAwareScheduler.assertStatusSuccess(cluster.getStatusMap().get(topo.getId())));\n+        }\n+        Assert.assertEquals(\"# of attempted topologies\", 2, rs.getUser(\"bobby\").getTopologiesAttempted().size());\n+        Assert.assertEquals(\"# of pending topologies\", 0, rs.getUser(\"bobby\").getTopologiesPending().size());\n+        Assert.assertEquals(\"# of invalid topologies\", 0, rs.getUser(\"bobby\").getTopologiesInvalid().size());\n+        Assert.assertEquals(\"# of running topologies\", 0, rs.getUser(\"bobby\").getTopologiesRunning().size());\n+\n+        Assert.assertTrue(\"correct topology to evict\", TestUtilsForResourceAwareScheduler.findTopologyInSetFromName(\"topo-2\", rs.getUser(\"bobby\").getTopologiesAttempted()) != null);\n+        Assert.assertTrue(\"correct topology to evict\", TestUtilsForResourceAwareScheduler.findTopologyInSetFromName(\"topo-3\", rs.getUser(\"bobby\").getTopologiesAttempted()) != null);\n+    }\n+\n+    /**\n+     * If topologies from other users cannot be evicted to make space\n+     * check if there is a topology with lower priority that can be evicted from the current user\n+     */\n+    @Test\n+    public void TestEvictTopologyFromItself() {\n+        INimbus iNimbus = new TestUtilsForResourceAwareScheduler.INimbusTest();\n+        Map<String, Number> resourceMap = new HashMap<String, Number>();\n+        resourceMap.put(Config.SUPERVISOR_CPU_CAPACITY, 100.0);\n+        resourceMap.put(Config.SUPERVISOR_MEMORY_CAPACITY_MB, 1000.0);\n+        Map<String, SupervisorDetails> supMap = TestUtilsForResourceAwareScheduler.genSupervisors(4, 4, resourceMap);\n+        Config config = new Config();\n+        config.putAll(Utils.readDefaultConfig());\n+        config.put(Config.RESOURCE_AWARE_SCHEDULER_EVICTION_STRATEGY, backtype.storm.scheduler.resource.strategies.eviction.DefaultEvictionStrategy.class.getName());\n+        config.put(Config.RESOURCE_AWARE_SCHEDULER_PRIORITY_STRATEGY, backtype.storm.scheduler.resource.strategies.priority.DefaultSchedulingPriorityStrategy.class.getName());\n+        config.put(Config.TOPOLOGY_SCHEDULER_STRATEGY, backtype.storm.scheduler.resource.strategies.scheduling.DefaultResourceAwareStrategy.class.getName());\n+        config.put(Config.TOPOLOGY_COMPONENT_CPU_PCORE_PERCENT, 100.0);\n+        config.put(Config.TOPOLOGY_COMPONENT_RESOURCES_OFFHEAP_MEMORY_MB, 500);\n+        config.put(Config.TOPOLOGY_COMPONENT_RESOURCES_ONHEAP_MEMORY_MB, 500);\n+        Map<String, Map<String, Number>> resourceUserPool = new HashMap<String, Map<String, Number>>();\n+        resourceUserPool.put(\"jerry\", new HashMap<String, Number>());\n+        resourceUserPool.get(\"jerry\").put(\"cpu\", 200.0);\n+        resourceUserPool.get(\"jerry\").put(\"memory\", 2000.0);\n+\n+        resourceUserPool.put(\"bobby\", new HashMap<String, Number>());\n+        resourceUserPool.get(\"bobby\").put(\"cpu\", 100.0);\n+        resourceUserPool.get(\"bobby\").put(\"memory\", 1000.0);\n+\n+        resourceUserPool.put(\"derek\", new HashMap<String, Number>());\n+        resourceUserPool.get(\"derek\").put(\"cpu\", 100.0);\n+        resourceUserPool.get(\"derek\").put(\"memory\", 1000.0);\n+\n+        config.put(Config.RESOURCE_AWARE_SCHEDULER_USER_POOLS, resourceUserPool);\n+        Cluster cluster = new Cluster(iNimbus, supMap, new HashMap<String, SchedulerAssignmentImpl>(), config);\n+\n+        config.put(Config.TOPOLOGY_SUBMITTER_USER, \"jerry\");\n+\n+        TopologyDetails topo1 = TestUtilsForResourceAwareScheduler.getTopology(\"topo-1\", config, 1, 0, 1, 0, Time.currentTimeSecs() - 2, 20);\n+        TopologyDetails topo2 = TestUtilsForResourceAwareScheduler.getTopology(\"topo-2\", config, 1, 0, 1, 0, Time.currentTimeSecs() - 2, 20);\n+        TopologyDetails topo3 = TestUtilsForResourceAwareScheduler.getTopology(\"topo-3\", config, 1, 0, 1, 0, Time.currentTimeSecs() - 2, 29);\n+        TopologyDetails topo4 = TestUtilsForResourceAwareScheduler.getTopology(\"topo-4\", config, 1, 0, 1, 0, Time.currentTimeSecs() - 2, 10);\n+\n+\n+        config.put(Config.TOPOLOGY_SUBMITTER_USER, \"bobby\");\n+\n+        TopologyDetails topo5 = TestUtilsForResourceAwareScheduler.getTopology(\"topo-5\", config, 1, 0, 1, 0, Time.currentTimeSecs() - 2, 10);\n+\n+        config.put(Config.TOPOLOGY_SUBMITTER_USER, \"derek\");\n+\n+        TopologyDetails topo6 = TestUtilsForResourceAwareScheduler.getTopology(\"topo-6\", config, 1, 0, 1, 0, Time.currentTimeSecs() - 2, 29);\n+\n+        Map<String, TopologyDetails> topoMap = new HashMap<String, TopologyDetails>();\n+        topoMap.put(topo1.getId(), topo1);\n+        topoMap.put(topo2.getId(), topo2);\n+        topoMap.put(topo5.getId(), topo5);\n+        topoMap.put(topo6.getId(), topo6);\n+\n+        Topologies topologies = new Topologies(topoMap);\n+\n+        ResourceAwareScheduler rs = new ResourceAwareScheduler();\n+\n+        rs.prepare(config);\n+        rs.schedule(topologies, cluster);\n+\n+        for (TopologyDetails topo : rs.getUser(\"jerry\").getTopologiesRunning()) {\n+            Assert.assertTrue(\"Assert scheduling topology success\", TestUtilsForResourceAwareScheduler.assertStatusSuccess(cluster.getStatusMap().get(topo.getId())));\n+        }\n+        Assert.assertEquals(\"# of running topologies\", 2, rs.getUser(\"jerry\").getTopologiesRunning().size());\n+        Assert.assertEquals(\"# of pending topologies\", 0, rs.getUser(\"jerry\").getTopologiesPending().size());\n+        Assert.assertEquals(\"# of attempted topologies\", 0, rs.getUser(\"jerry\").getTopologiesAttempted().size());\n+        Assert.assertEquals(\"# of invalid topologies\", 0, rs.getUser(\"jerry\").getTopologiesInvalid().size());\n+\n+\n+        for (TopologyDetails topo : rs.getUser(\"derek\").getTopologiesRunning()) {\n+            Assert.assertTrue(\"Assert scheduling topology success\", TestUtilsForResourceAwareScheduler.assertStatusSuccess(cluster.getStatusMap().get(topo.getId())));\n+        }\n+        Assert.assertEquals(\"# of running topologies\", 1, rs.getUser(\"derek\").getTopologiesRunning().size());\n+        Assert.assertEquals(\"# of pending topologies\", 0, rs.getUser(\"derek\").getTopologiesPending().size());\n+        Assert.assertEquals(\"# of attempted topologies\", 0, rs.getUser(\"derek\").getTopologiesAttempted().size());\n+        Assert.assertEquals(\"# of invalid topologies\", 0, rs.getUser(\"derek\").getTopologiesInvalid().size());\n+\n+        for (TopologyDetails topo : rs.getUser(\"bobby\").getTopologiesRunning()) {\n+            Assert.assertTrue(\"Assert scheduling topology success\", TestUtilsForResourceAwareScheduler.assertStatusSuccess(cluster.getStatusMap().get(topo.getId())));\n+        }\n+        Assert.assertEquals(\"# of running topologies\", 1, rs.getUser(\"bobby\").getTopologiesRunning().size());\n+        Assert.assertEquals(\"# of pending topologies\", 0, rs.getUser(\"bobby\").getTopologiesPending().size());\n+        Assert.assertEquals(\"# of invalid topologies\", 0, rs.getUser(\"bobby\").getTopologiesInvalid().size());\n+        Assert.assertEquals(\"# of attempted topologies\", 0, rs.getUser(\"bobby\").getTopologiesAttempted().size());\n+\n+        //user jerry submits another topology into a full cluster\n+        // topo3 should not be able to scheduled\n+        topoMap.put(topo3.getId(), topo3);\n+        topologies = new Topologies(topoMap);\n+        rs.schedule(topologies, cluster);\n+\n+        for (TopologyDetails topo : rs.getUser(\"jerry\").getTopologiesRunning()) {\n+            Assert.assertTrue(\"Assert scheduling topology success\", TestUtilsForResourceAwareScheduler.assertStatusSuccess(cluster.getStatusMap().get(topo.getId())));\n+        }\n+        Assert.assertEquals(\"# of running topologies\", 2, rs.getUser(\"jerry\").getTopologiesRunning().size());\n+        Assert.assertEquals(\"# of pending topologies\", 0, rs.getUser(\"jerry\").getTopologiesPending().size());\n+        Assert.assertEquals(\"# of attempted topologies\", 1, rs.getUser(\"jerry\").getTopologiesAttempted().size());\n+        Assert.assertEquals(\"# of invalid topologies\", 0, rs.getUser(\"jerry\").getTopologiesInvalid().size());\n+        //make sure that topo-3 didn't get scheduled.\n+        Assert.assertEquals(\"correct topology in attempted queue\", rs.getUser(\"jerry\").getTopologiesAttempted().iterator().next().getName(), \"topo-3\");\n+\n+\n+        for (TopologyDetails topo : rs.getUser(\"derek\").getTopologiesRunning()) {\n+            Assert.assertTrue(\"Assert scheduling topology success\", TestUtilsForResourceAwareScheduler.assertStatusSuccess(cluster.getStatusMap().get(topo.getId())));\n+        }\n+        Assert.assertEquals(\"# of running topologies\", 1, rs.getUser(\"derek\").getTopologiesRunning().size());\n+        Assert.assertEquals(\"# of pending topologies\", 0, rs.getUser(\"derek\").getTopologiesPending().size());\n+        Assert.assertEquals(\"# of attempted topologies\", 0, rs.getUser(\"derek\").getTopologiesAttempted().size());\n+        Assert.assertEquals(\"# of invalid topologies\", 0, rs.getUser(\"derek\").getTopologiesInvalid().size());\n+\n+        for (TopologyDetails topo : rs.getUser(\"bobby\").getTopologiesRunning()) {\n+            Assert.assertTrue(\"Assert scheduling topology success\", TestUtilsForResourceAwareScheduler.assertStatusSuccess(cluster.getStatusMap().get(topo.getId())));\n+        }\n+        Assert.assertEquals(\"# of running topologies\", 1, rs.getUser(\"bobby\").getTopologiesRunning().size());\n+        Assert.assertEquals(\"# of pending topologies\", 0, rs.getUser(\"bobby\").getTopologiesPending().size());\n+        Assert.assertEquals(\"# of attempted topologies\", 0, rs.getUser(\"bobby\").getTopologiesAttempted().size());\n+        Assert.assertEquals(\"# of invalid topologies\", 0, rs.getUser(\"bobby\").getTopologiesInvalid().size());\n+\n+        //user jerry submits another topology but this one should be scheduled since it has higher priority than than the\n+        //rest of jerry's running topologies\n+        topoMap.put(topo4.getId(), topo4);\n+        topologies = new Topologies(topoMap);\n+        rs.schedule(topologies, cluster);\n+\n+        for (TopologyDetails topo : rs.getUser(\"jerry\").getTopologiesRunning()) {\n+            Assert.assertTrue(\"Assert scheduling topology success\", TestUtilsForResourceAwareScheduler.assertStatusSuccess(cluster.getStatusMap().get(topo.getId())));\n+        }\n+        Assert.assertEquals(\"# of running topologies\", 2, rs.getUser(\"jerry\").getTopologiesRunning().size());\n+        Assert.assertEquals(\"# of pending topologies\", 0, rs.getUser(\"jerry\").getTopologiesPending().size());\n+        Assert.assertEquals(\"# of attempted topologies\", 2, rs.getUser(\"jerry\").getTopologiesAttempted().size());\n+        Assert.assertEquals(\"# of invalid topologies\", 0, rs.getUser(\"jerry\").getTopologiesInvalid().size());\n+        Assert.assertTrue(\"correct topology in attempted queue\", TestUtilsForResourceAwareScheduler.findTopologyInSetFromName(\"topo-3\", rs.getUser(\"jerry\").getTopologiesAttempted()) != null);\n+        //Either topo-1 or topo-2 should have gotten evicted\n+        Assert.assertTrue(\"correct topology in attempted queue\", ((TestUtilsForResourceAwareScheduler.findTopologyInSetFromName(\"topo-1\", rs.getUser(\"jerry\").getTopologiesAttempted())) != null)\n+                || (TestUtilsForResourceAwareScheduler.findTopologyInSetFromName(\"topo-2\", rs.getUser(\"jerry\").getTopologiesAttempted()) != null));\n+        //assert that topo-4 got scheduled\n+        Assert.assertTrue(\"correct topology in running queue\", TestUtilsForResourceAwareScheduler.findTopologyInSetFromName(\"topo-4\", rs.getUser(\"jerry\").getTopologiesRunning()) != null);\n+\n+        for (TopologyDetails topo : rs.getUser(\"derek\").getTopologiesRunning()) {\n+            Assert.assertTrue(\"Assert scheduling topology success\", TestUtilsForResourceAwareScheduler.assertStatusSuccess(cluster.getStatusMap().get(topo.getId())));\n+        }\n+        Assert.assertEquals(\"# of running topologies\", 1, rs.getUser(\"derek\").getTopologiesRunning().size());\n+        Assert.assertEquals(\"# of pending topologies\", 0, rs.getUser(\"derek\").getTopologiesPending().size());\n+        Assert.assertEquals(\"# of attempted topologies\", 0, rs.getUser(\"derek\").getTopologiesAttempted().size());\n+        Assert.assertEquals(\"# of invalid topologies\", 0, rs.getUser(\"derek\").getTopologiesInvalid().size());\n+\n+        for (TopologyDetails topo : rs.getUser(\"bobby\").getTopologiesRunning()) {\n+            Assert.assertTrue(\"Assert scheduling topology success\", TestUtilsForResourceAwareScheduler.assertStatusSuccess(cluster.getStatusMap().get(topo.getId())));\n+        }\n+        Assert.assertEquals(\"# of running topologies\", 1, rs.getUser(\"bobby\").getTopologiesRunning().size());\n+        Assert.assertEquals(\"# of pending topologies\", 0, rs.getUser(\"bobby\").getTopologiesPending().size());\n+        Assert.assertEquals(\"# of attempted topologies\", 0, rs.getUser(\"bobby\").getTopologiesAttempted().size());\n+        Assert.assertEquals(\"# of invalid topologies\", 0, rs.getUser(\"bobby\").getTopologiesInvalid().size());\n+    }\n+\n+    /**\n+     * If topologies from other users cannot be evicted to make space\n+     * check if there is a topology with lower priority that can be evicted from the current user\n+     */\n+    @Test\n+    public void TestOverGuaranteeEviction() {\n+        INimbus iNimbus = new TestUtilsForResourceAwareScheduler.INimbusTest();\n+        Map<String, Number> resourceMap = new HashMap<String, Number>();\n+        resourceMap.put(Config.SUPERVISOR_CPU_CAPACITY, 100.0);\n+        resourceMap.put(Config.SUPERVISOR_MEMORY_CAPACITY_MB, 1000.0);\n+        Map<String, SupervisorDetails> supMap = TestUtilsForResourceAwareScheduler.genSupervisors(4, 4, resourceMap);\n+        Config config = new Config();\n+        config.putAll(Utils.readDefaultConfig());\n+        config.put(Config.RESOURCE_AWARE_SCHEDULER_EVICTION_STRATEGY, backtype.storm.scheduler.resource.strategies.eviction.DefaultEvictionStrategy.class.getName());\n+        config.put(Config.RESOURCE_AWARE_SCHEDULER_PRIORITY_STRATEGY, backtype.storm.scheduler.resource.strategies.priority.DefaultSchedulingPriorityStrategy.class.getName());\n+        config.put(Config.TOPOLOGY_SCHEDULER_STRATEGY, backtype.storm.scheduler.resource.strategies.scheduling.DefaultResourceAwareStrategy.class.getName());\n+        config.put(Config.TOPOLOGY_COMPONENT_CPU_PCORE_PERCENT, 100.0);\n+        config.put(Config.TOPOLOGY_COMPONENT_RESOURCES_OFFHEAP_MEMORY_MB, 500);\n+        config.put(Config.TOPOLOGY_COMPONENT_RESOURCES_ONHEAP_MEMORY_MB, 500);\n+        Map<String, Map<String, Number>> resourceUserPool = new HashMap<String, Map<String, Number>>();\n+        resourceUserPool.put(\"jerry\", new HashMap<String, Number>());\n+        resourceUserPool.get(\"jerry\").put(\"cpu\", 70.0);\n+        resourceUserPool.get(\"jerry\").put(\"memory\", 700.0);\n+\n+        resourceUserPool.put(\"bobby\", new HashMap<String, Number>());\n+        resourceUserPool.get(\"bobby\").put(\"cpu\", 100.0);\n+        resourceUserPool.get(\"bobby\").put(\"memory\", 1000.0);\n+\n+        resourceUserPool.put(\"derek\", new HashMap<String, Number>());\n+        resourceUserPool.get(\"derek\").put(\"cpu\", 25.0);\n+        resourceUserPool.get(\"derek\").put(\"memory\", 250.0);\n+\n+        config.put(Config.RESOURCE_AWARE_SCHEDULER_USER_POOLS, resourceUserPool);\n+        Cluster cluster = new Cluster(iNimbus, supMap, new HashMap<String, SchedulerAssignmentImpl>(), config);\n+\n+        config.put(Config.TOPOLOGY_SUBMITTER_USER, \"jerry\");\n+\n+        TopologyDetails topo1 = TestUtilsForResourceAwareScheduler.getTopology(\"topo-1\", config, 1, 0, 1, 0, Time.currentTimeSecs() - 2, 20);\n+        TopologyDetails topo2 = TestUtilsForResourceAwareScheduler.getTopology(\"topo-2\", config, 1, 0, 1, 0, Time.currentTimeSecs() - 2, 20);\n+\n+        config.put(Config.TOPOLOGY_SUBMITTER_USER, \"bobby\");\n+\n+        TopologyDetails topo3 = TestUtilsForResourceAwareScheduler.getTopology(\"topo-3\", config, 1, 0, 1, 0, Time.currentTimeSecs() - 2, 10);\n+        TopologyDetails topo4 = TestUtilsForResourceAwareScheduler.getTopology(\"topo-4\", config, 1, 0, 1, 0, Time.currentTimeSecs() - 2, 10);\n+\n+        config.put(Config.TOPOLOGY_SUBMITTER_USER, \"derek\");\n+\n+        TopologyDetails topo5 = TestUtilsForResourceAwareScheduler.getTopology(\"topo-5\", config, 1, 0, 1, 0, Time.currentTimeSecs() - 2, 29);\n+        TopologyDetails topo6 = TestUtilsForResourceAwareScheduler.getTopology(\"topo-6\", config, 1, 0, 1, 0, Time.currentTimeSecs() - 2, 10);\n+\n+        Map<String, TopologyDetails> topoMap = new HashMap<String, TopologyDetails>();\n+        topoMap.put(topo1.getId(), topo1);\n+        topoMap.put(topo3.getId(), topo3);\n+        topoMap.put(topo4.getId(), topo4);\n+        topoMap.put(topo5.getId(), topo5);\n+\n+        Topologies topologies = new Topologies(topoMap);\n+\n+        ResourceAwareScheduler rs = new ResourceAwareScheduler();\n+\n+        rs.prepare(config);\n+        rs.schedule(topologies, cluster);\n+\n+        for (TopologyDetails topo : rs.getUser(\"jerry\").getTopologiesRunning()) {\n+            Assert.assertTrue(\"Assert scheduling topology success\", TestUtilsForResourceAwareScheduler.assertStatusSuccess(cluster.getStatusMap().get(topo.getId())));\n+        }\n+        Assert.assertEquals(\"# of running topologies\", 1, rs.getUser(\"jerry\").getTopologiesRunning().size());\n+        Assert.assertEquals(\"# of pending topologies\", 0, rs.getUser(\"jerry\").getTopologiesPending().size());\n+        Assert.assertEquals(\"# of attempted topologies\", 0, rs.getUser(\"jerry\").getTopologiesAttempted().size());\n+        Assert.assertEquals(\"# of invalid topologies\", 0, rs.getUser(\"jerry\").getTopologiesInvalid().size());\n+\n+        for (TopologyDetails topo : rs.getUser(\"derek\").getTopologiesRunning()) {\n+            Assert.assertTrue(\"Assert scheduling topology success\", TestUtilsForResourceAwareScheduler.assertStatusSuccess(cluster.getStatusMap().get(topo.getId())));\n+        }\n+        Assert.assertEquals(\"# of running topologies\", 1, rs.getUser(\"derek\").getTopologiesRunning().size());\n+        Assert.assertEquals(\"# of pending topologies\", 0, rs.getUser(\"derek\").getTopologiesPending().size());\n+        Assert.assertEquals(\"# of attempted topologies\", 0, rs.getUser(\"derek\").getTopologiesAttempted().size());\n+        Assert.assertEquals(\"# of invalid topologies\", 0, rs.getUser(\"derek\").getTopologiesInvalid().size());\n+\n+        for (TopologyDetails topo : rs.getUser(\"bobby\").getTopologiesRunning()) {\n+            Assert.assertTrue(\"Assert scheduling topology success\", TestUtilsForResourceAwareScheduler.assertStatusSuccess(cluster.getStatusMap().get(topo.getId())));\n+        }\n+        Assert.assertEquals(\"# of running topologies\", 2, rs.getUser(\"bobby\").getTopologiesRunning().size());\n+        Assert.assertEquals(\"# of pending topologies\", 0, rs.getUser(\"bobby\").getTopologiesPending().size());\n+        Assert.assertEquals(\"# of invalid topologies\", 0, rs.getUser(\"bobby\").getTopologiesInvalid().size());\n+        Assert.assertEquals(\"# of attempted topologies\", 0, rs.getUser(\"bobby\").getTopologiesAttempted().size());\n+\n+        //user derek submits another topology into a full cluster\n+        // topo6 should not be able to scheduled\n+        topoMap.put(topo6.getId(), topo6);\n+        topologies = new Topologies(topoMap);\n+        rs.schedule(topologies, cluster);\n+\n+        for (TopologyDetails topo : rs.getUser(\"jerry\").getTopologiesRunning()) {\n+            Assert.assertTrue(\"Assert scheduling topology success\", TestUtilsForResourceAwareScheduler.assertStatusSuccess(cluster.getStatusMap().get(topo.getId())));\n+        }\n+        Assert.assertEquals(\"# of running topologies\", 1, rs.getUser(\"jerry\").getTopologiesRunning().size());\n+        Assert.assertEquals(\"# of pending topologies\", 0, rs.getUser(\"jerry\").getTopologiesPending().size());\n+        Assert.assertEquals(\"# of attempted topologies\", 0, rs.getUser(\"jerry\").getTopologiesAttempted().size());\n+        Assert.assertEquals(\"# of invalid topologies\", 0, rs.getUser(\"jerry\").getTopologiesInvalid().size());\n+\n+        for (TopologyDetails topo : rs.","path":"storm-core/test/jvm/backtype/storm/scheduler/resource/TestResourceAwareScheduler.java","position":1140,"original_position":1140,"commit_id":"068a8c21e9e4f5e213fca9eab86398685036ac9e","original_commit_id":"068a8c21e9e4f5e213fca9eab86398685036ac9e","user":{"login":"jerrypeng","id":3613359,"avatar_url":"https://avatars.githubusercontent.com/u/3613359?v=3","gravatar_id":"","url":"https://api.github.com/users/jerrypeng","html_url":"https://github.com/jerrypeng","followers_url":"https://api.github.com/users/jerrypeng/followers","following_url":"https://api.github.com/users/jerrypeng/following{/other_user}","gists_url":"https://api.github.com/users/jerrypeng/gists{/gist_id}","starred_url":"https://api.github.com/users/jerrypeng/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jerrypeng/subscriptions","organizations_url":"https://api.github.com/users/jerrypeng/orgs","repos_url":"https://api.github.com/users/jerrypeng/repos","events_url":"https://api.github.com/users/jerrypeng/events{/privacy}","received_events_url":"https://api.github.com/users/jerrypeng/received_events","type":"User","site_admin":false},"body":"Is this comment in the right place?  This test doesn't kill any supervisors","created_at":"2015-12-18T06:44:39Z","updated_at":"2015-12-18T06:44:39Z","html_url":"https://github.com/apache/storm/pull/921#discussion_r47998594","pull_request_url":"https://api.github.com/repos/apache/storm/pulls/921","_links":{"self":{"href":"https://api.github.com/repos/apache/storm/pulls/comments/47998594"},"html":{"href":"https://github.com/apache/storm/pull/921#discussion_r47998594"},"pull_request":{"href":"https://api.github.com/repos/apache/storm/pulls/921"}}},"pull_request":{"url":"https://api.github.com/repos/apache/storm/pulls/921","id":52622402,"html_url":"https://github.com/apache/storm/pull/921","diff_url":"https://github.com/apache/storm/pull/921.diff","patch_url":"https://github.com/apache/storm/pull/921.patch","issue_url":"https://api.github.com/repos/apache/storm/issues/921","number":921,"state":"open","locked":false,"title":"[STORM-898] - Add priorities and per user resource guarantees to Resource Aware Scheduler","user":{"login":"jerrypeng","id":3613359,"avatar_url":"https://avatars.githubusercontent.com/u/3613359?v=3","gravatar_id":"","url":"https://api.github.com/users/jerrypeng","html_url":"https://github.com/jerrypeng","followers_url":"https://api.github.com/users/jerrypeng/followers","following_url":"https://api.github.com/users/jerrypeng/following{/other_user}","gists_url":"https://api.github.com/users/jerrypeng/gists{/gist_id}","starred_url":"https://api.github.com/users/jerrypeng/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jerrypeng/subscriptions","organizations_url":"https://api.github.com/users/jerrypeng/orgs","repos_url":"https://api.github.com/users/jerrypeng/repos","events_url":"https://api.github.com/users/jerrypeng/events{/privacy}","received_events_url":"https://api.github.com/users/jerrypeng/received_events","type":"User","site_admin":false},"body":"https://issues.apache.org/jira/browse/STORM-898\r\n\r\nAllows the Resource Aware Scheduler to how multi-tenant capabilites. In a multi-tenant environment we would like to be able to give individual users a guarantee of how much CPU/Memory/Network they will be able to use in a cluster. We would also like to know which topologies a user feels are the most important to keep running if there are not enough resources to run all of their topologies.\r\n\r\nEach user should be able to specify if their topology is production, staging, or development.\r\n\r\nBased on topology priorities and resource guarantees, we need to be able to evict topologies that are less important so that users can have there resource guarantees satisfied\r\n\r\nEach topology can also be scheduled by a different strategy.  Users can define custom scheduling strategies and the user can specify on a per topology basis what strategy to use for a topology\r\n\r\nFor more details please read documentation:\r\n\r\nhttps://issues.apache.org/jira/secure/attachment/12775719/Resource%20Aware%20Scheduler%20for%20Storm.pdf\r\n\r\nI have also recently updated the documentation","created_at":"2015-12-04T02:24:51Z","updated_at":"2015-12-18T06:44:39Z","closed_at":null,"merged_at":null,"merge_commit_sha":"eaf9a3fb5195139ec8af83c4c61b81a40751a412","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/apache/storm/pulls/921/commits","review_comments_url":"https://api.github.com/repos/apache/storm/pulls/921/comments","review_comment_url":"https://api.github.com/repos/apache/storm/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/storm/issues/921/comments","statuses_url":"https://api.github.com/repos/apache/storm/statuses/068a8c21e9e4f5e213fca9eab86398685036ac9e","head":{"label":"jerrypeng:STORM-898","ref":"STORM-898","sha":"068a8c21e9e4f5e213fca9eab86398685036ac9e","user":{"login":"jerrypeng","id":3613359,"avatar_url":"https://avatars.githubusercontent.com/u/3613359?v=3","gravatar_id":"","url":"https://api.github.com/users/jerrypeng","html_url":"https://github.com/jerrypeng","followers_url":"https://api.github.com/users/jerrypeng/followers","following_url":"https://api.github.com/users/jerrypeng/following{/other_user}","gists_url":"https://api.github.com/users/jerrypeng/gists{/gist_id}","starred_url":"https://api.github.com/users/jerrypeng/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jerrypeng/subscriptions","organizations_url":"https://api.github.com/users/jerrypeng/orgs","repos_url":"https://api.github.com/users/jerrypeng/repos","events_url":"https://api.github.com/users/jerrypeng/events{/privacy}","received_events_url":"https://api.github.com/users/jerrypeng/received_events","type":"User","site_admin":false},"repo":{"id":37741458,"name":"storm","full_name":"jerrypeng/storm","owner":{"login":"jerrypeng","id":3613359,"avatar_url":"https://avatars.githubusercontent.com/u/3613359?v=3","gravatar_id":"","url":"https://api.github.com/users/jerrypeng","html_url":"https://github.com/jerrypeng","followers_url":"https://api.github.com/users/jerrypeng/followers","following_url":"https://api.github.com/users/jerrypeng/following{/other_user}","gists_url":"https://api.github.com/users/jerrypeng/gists{/gist_id}","starred_url":"https://api.github.com/users/jerrypeng/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jerrypeng/subscriptions","organizations_url":"https://api.github.com/users/jerrypeng/orgs","repos_url":"https://api.github.com/users/jerrypeng/repos","events_url":"https://api.github.com/users/jerrypeng/events{/privacy}","received_events_url":"https://api.github.com/users/jerrypeng/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jerrypeng/storm","description":"Mirror of Apache Storm","fork":true,"url":"https://api.github.com/repos/jerrypeng/storm","forks_url":"https://api.github.com/repos/jerrypeng/storm/forks","keys_url":"https://api.github.com/repos/jerrypeng/storm/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jerrypeng/storm/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jerrypeng/storm/teams","hooks_url":"https://api.github.com/repos/jerrypeng/storm/hooks","issue_events_url":"https://api.github.com/repos/jerrypeng/storm/issues/events{/number}","events_url":"https://api.github.com/repos/jerrypeng/storm/events","assignees_url":"https://api.github.com/repos/jerrypeng/storm/assignees{/user}","branches_url":"https://api.github.com/repos/jerrypeng/storm/branches{/branch}","tags_url":"https://api.github.com/repos/jerrypeng/storm/tags","blobs_url":"https://api.github.com/repos/jerrypeng/storm/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jerrypeng/storm/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jerrypeng/storm/git/refs{/sha}","trees_url":"https://api.github.com/repos/jerrypeng/storm/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jerrypeng/storm/statuses/{sha}","languages_url":"https://api.github.com/repos/jerrypeng/storm/languages","stargazers_url":"https://api.github.com/repos/jerrypeng/storm/stargazers","contributors_url":"https://api.github.com/repos/jerrypeng/storm/contributors","subscribers_url":"https://api.github.com/repos/jerrypeng/storm/subscribers","subscription_url":"https://api.github.com/repos/jerrypeng/storm/subscription","commits_url":"https://api.github.com/repos/jerrypeng/storm/commits{/sha}","git_commits_url":"https://api.github.com/repos/jerrypeng/storm/git/commits{/sha}","comments_url":"https://api.github.com/repos/jerrypeng/storm/comments{/number}","issue_comment_url":"https://api.github.com/repos/jerrypeng/storm/issues/comments{/number}","contents_url":"https://api.github.com/repos/jerrypeng/storm/contents/{+path}","compare_url":"https://api.github.com/repos/jerrypeng/storm/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jerrypeng/storm/merges","archive_url":"https://api.github.com/repos/jerrypeng/storm/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jerrypeng/storm/downloads","issues_url":"https://api.github.com/repos/jerrypeng/storm/issues{/number}","pulls_url":"https://api.github.com/repos/jerrypeng/storm/pulls{/number}","milestones_url":"https://api.github.com/repos/jerrypeng/storm/milestones{/number}","notifications_url":"https://api.github.com/repos/jerrypeng/storm/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jerrypeng/storm/labels{/name}","releases_url":"https://api.github.com/repos/jerrypeng/storm/releases{/id}","created_at":"2015-06-19T19:23:06Z","updated_at":"2015-11-23T22:33:09Z","pushed_at":"2015-12-16T22:07:19Z","git_url":"git://github.com/jerrypeng/storm.git","ssh_url":"git@github.com:jerrypeng/storm.git","clone_url":"https://github.com/jerrypeng/storm.git","svn_url":"https://github.com/jerrypeng/storm","homepage":null,"size":26956,"stargazers_count":2,"watchers_count":2,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":2,"default_branch":"master"}},"base":{"label":"apache:master","ref":"master","sha":"8b3c20846a026732a15108e49c5f43fcea37674e","user":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"repo":{"id":14135470,"name":"storm","full_name":"apache/storm","owner":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/apache/storm","description":"Mirror of Apache Storm","fork":false,"url":"https://api.github.com/repos/apache/storm","forks_url":"https://api.github.com/repos/apache/storm/forks","keys_url":"https://api.github.com/repos/apache/storm/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apache/storm/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apache/storm/teams","hooks_url":"https://api.github.com/repos/apache/storm/hooks","issue_events_url":"https://api.github.com/repos/apache/storm/issues/events{/number}","events_url":"https://api.github.com/repos/apache/storm/events","assignees_url":"https://api.github.com/repos/apache/storm/assignees{/user}","branches_url":"https://api.github.com/repos/apache/storm/branches{/branch}","tags_url":"https://api.github.com/repos/apache/storm/tags","blobs_url":"https://api.github.com/repos/apache/storm/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apache/storm/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apache/storm/git/refs{/sha}","trees_url":"https://api.github.com/repos/apache/storm/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apache/storm/statuses/{sha}","languages_url":"https://api.github.com/repos/apache/storm/languages","stargazers_url":"https://api.github.com/repos/apache/storm/stargazers","contributors_url":"https://api.github.com/repos/apache/storm/contributors","subscribers_url":"https://api.github.com/repos/apache/storm/subscribers","subscription_url":"https://api.github.com/repos/apache/storm/subscription","commits_url":"https://api.github.com/repos/apache/storm/commits{/sha}","git_commits_url":"https://api.github.com/repos/apache/storm/git/commits{/sha}","comments_url":"https://api.github.com/repos/apache/storm/comments{/number}","issue_comment_url":"https://api.github.com/repos/apache/storm/issues/comments{/number}","contents_url":"https://api.github.com/repos/apache/storm/contents/{+path}","compare_url":"https://api.github.com/repos/apache/storm/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apache/storm/merges","archive_url":"https://api.github.com/repos/apache/storm/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apache/storm/downloads","issues_url":"https://api.github.com/repos/apache/storm/issues{/number}","pulls_url":"https://api.github.com/repos/apache/storm/pulls{/number}","milestones_url":"https://api.github.com/repos/apache/storm/milestones{/number}","notifications_url":"https://api.github.com/repos/apache/storm/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apache/storm/labels{/name}","releases_url":"https://api.github.com/repos/apache/storm/releases{/id}","created_at":"2013-11-05T08:00:14Z","updated_at":"2015-12-18T06:36:18Z","pushed_at":"2015-12-18T01:45:12Z","git_url":"git://github.com/apache/storm.git","ssh_url":"git@github.com:apache/storm.git","clone_url":"https://github.com/apache/storm.git","svn_url":"https://github.com/apache/storm","homepage":null,"size":160391,"stargazers_count":2648,"watchers_count":2648,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":1981,"mirror_url":"git://git.apache.org/storm.git","open_issues_count":88,"forks":1981,"open_issues":88,"watchers":2648,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/storm/pulls/921"},"html":{"href":"https://github.com/apache/storm/pull/921"},"issue":{"href":"https://api.github.com/repos/apache/storm/issues/921"},"comments":{"href":"https://api.github.com/repos/apache/storm/issues/921/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/storm/pulls/921/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/storm/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/storm/pulls/921/commits"},"statuses":{"href":"https://api.github.com/repos/apache/storm/statuses/068a8c21e9e4f5e213fca9eab86398685036ac9e"}}}}