Search in sources :

Example 1 with INimbusTest

use of org.apache.storm.scheduler.resource.TestUtilsForResourceAwareScheduler.INimbusTest in project storm by apache.

the class TestUser method testResourcePoolUtilization.

@Test
public void testResourcePoolUtilization() {
    INimbus iNimbus = new INimbusTest();
    Map<String, SupervisorDetails> supMap = genSupervisors(4, 4, 100, 1000);
    Double cpuGuarantee = 400.0;
    Double memoryGuarantee = 1000.0;
    Map<String, Map<String, Number>> resourceUserPool = userResourcePool(userRes("user1", cpuGuarantee, memoryGuarantee));
    Config config = createClusterConfig(100, 200, 200, resourceUserPool);
    TopologyDetails topo1 = genTopology("topo-1", config, 1, 1, 2, 1, Time.currentTimeSecs() - 24, 9, "user1");
    Topologies topologies = new Topologies(topo1);
    Cluster cluster = new Cluster(iNimbus, new ResourceMetrics(new StormMetricsRegistry()), supMap, new HashMap<>(), topologies, config);
    User user1 = new User("user1", toDouble(resourceUserPool.get("user1")));
    WorkerSlot slot = cluster.getAvailableSlots().get(0);
    cluster.assign(slot, topo1.getId(), topo1.getExecutors());
    Assert.assertEquals("check cpu resource guarantee", cpuGuarantee, user1.getCpuResourceGuaranteed(), 0.001);
    Assert.assertEquals("check memory resource guarantee", memoryGuarantee, user1.getMemoryResourceGuaranteed(), 0.001);
    Assert.assertEquals("check cpu resource pool utilization", ((100.0 * 3.0) / cpuGuarantee), user1.getCpuResourcePoolUtilization(cluster), 0.001);
    Assert.assertEquals("check memory resource pool utilization", ((200.0 + 200.0) * 3.0) / memoryGuarantee, user1.getMemoryResourcePoolUtilization(cluster), 0.001);
}
Also used : INimbusTest(org.apache.storm.scheduler.resource.TestUtilsForResourceAwareScheduler.INimbusTest) Config(org.apache.storm.Config) StormMetricsRegistry(org.apache.storm.metric.StormMetricsRegistry) Cluster(org.apache.storm.scheduler.Cluster) INimbus(org.apache.storm.scheduler.INimbus) TestUtilsForResourceAwareScheduler.toDouble(org.apache.storm.scheduler.resource.TestUtilsForResourceAwareScheduler.toDouble) TopologyDetails(org.apache.storm.scheduler.TopologyDetails) ResourceMetrics(org.apache.storm.scheduler.resource.normalization.ResourceMetrics) WorkerSlot(org.apache.storm.scheduler.WorkerSlot) Topologies(org.apache.storm.scheduler.Topologies) SupervisorDetails(org.apache.storm.scheduler.SupervisorDetails) HashMap(java.util.HashMap) Map(java.util.Map) Test(org.junit.Test) INimbusTest(org.apache.storm.scheduler.resource.TestUtilsForResourceAwareScheduler.INimbusTest)

Aggregations

HashMap (java.util.HashMap)1 Map (java.util.Map)1 Config (org.apache.storm.Config)1 StormMetricsRegistry (org.apache.storm.metric.StormMetricsRegistry)1 Cluster (org.apache.storm.scheduler.Cluster)1 INimbus (org.apache.storm.scheduler.INimbus)1 SupervisorDetails (org.apache.storm.scheduler.SupervisorDetails)1 Topologies (org.apache.storm.scheduler.Topologies)1 TopologyDetails (org.apache.storm.scheduler.TopologyDetails)1 WorkerSlot (org.apache.storm.scheduler.WorkerSlot)1 INimbusTest (org.apache.storm.scheduler.resource.TestUtilsForResourceAwareScheduler.INimbusTest)1 TestUtilsForResourceAwareScheduler.toDouble (org.apache.storm.scheduler.resource.TestUtilsForResourceAwareScheduler.toDouble)1 ResourceMetrics (org.apache.storm.scheduler.resource.normalization.ResourceMetrics)1 Test (org.junit.Test)1