Search in sources :

Example 41 with Cluster

use of org.apache.storm.scheduler.Cluster in project storm by apache.

the class TestDefaultEvictionStrategy method testEvictMultipleTopologiesFromMultipleUsersInCorrectOrder.

@Test
public void testEvictMultipleTopologiesFromMultipleUsersInCorrectOrder() {
    INimbus iNimbus = new INimbusTest();
    Map<String, SupervisorDetails> supMap = genSupervisors(4, 4, 100, 1000);
    Map<String, Map<String, Number>> resourceUserPool = userResourcePool(userRes("jerry", 300, 3000), userRes("derek", 100, 1000));
    Config config = createClusterConfig(100, 500, 500, resourceUserPool);
    Topologies topologies = new Topologies(genTopology("topo-2", config, 1, 0, 1, 0, currentTime - 2, 10, "bobby"), genTopology("topo-3", config, 1, 0, 1, 0, currentTime - 2, 20, "bobby"), genTopology("topo-4", config, 1, 0, 1, 0, currentTime - 2, 29, "derek"), genTopology("topo-5", config, 1, 0, 1, 0, currentTime - 15, 29, "derek"));
    Cluster cluster = new Cluster(iNimbus, new ResourceMetrics(new StormMetricsRegistry()), supMap, new HashMap<>(), topologies, config);
    scheduler = new ResourceAwareScheduler();
    scheduler.prepare(config, new StormMetricsRegistry());
    scheduler.schedule(topologies, cluster);
    assertTopologiesFullyScheduled(cluster, "topo-2", "topo-3", "topo-4", "topo-5");
    // user jerry submits another topology
    topologies = addTopologies(topologies, genTopology("topo-1", config, 1, 0, 1, 0, currentTime - 2, 10, "jerry"));
    cluster = new Cluster(cluster, topologies);
    scheduler.schedule(topologies, cluster);
    // topo-3 evicted since user bobby don't have any resource guarantees and topo-3 is the lowest priority for user bobby
    assertTopologiesFullyScheduled(cluster, "topo-1", "topo-2", "topo-4", "topo-5");
    assertTopologiesNotScheduled(cluster, "topo-3");
    topologies = addTopologies(topologies, genTopology("topo-6", config, 1, 0, 1, 0, currentTime - 2, 10, "jerry"));
    cluster = new Cluster(cluster, topologies);
    scheduler.schedule(topologies, cluster);
    // topo-2 evicted since user bobby don't have any resource guarantees and topo-2 is the next lowest priority for user bobby
    assertTopologiesFullyScheduled(cluster, "topo-1", "topo-4", "topo-5");
    assertTopologiesNotScheduled(cluster, "topo-2", "topo-3");
    topologies = addTopologies(topologies, genTopology("topo-7", config, 1, 0, 1, 0, currentTime - 2, 10, "jerry"));
    cluster = new Cluster(cluster, topologies);
    scheduler.schedule(topologies, cluster);
    // since user derek has exceeded his resource guarantee while user jerry has not topo-5 or topo-4 could be evicted because they have the same priority
    // but topo-4 was submitted earlier thus we choose that one to evict (somewhat arbitrary)
    assertTopologiesFullyScheduled(cluster, "topo-1", "topo-5", "topo-7");
    assertTopologiesNotScheduled(cluster, "topo-2", "topo-3", "topo-4");
}
Also used : Config(org.apache.storm.Config) StormMetricsRegistry(org.apache.storm.metric.StormMetricsRegistry) Cluster(org.apache.storm.scheduler.Cluster) INimbus(org.apache.storm.scheduler.INimbus) ResourceAwareScheduler(org.apache.storm.scheduler.resource.ResourceAwareScheduler) TestUtilsForResourceAwareScheduler(org.apache.storm.scheduler.resource.TestUtilsForResourceAwareScheduler) ResourceMetrics(org.apache.storm.scheduler.resource.normalization.ResourceMetrics) Topologies(org.apache.storm.scheduler.Topologies) SupervisorDetails(org.apache.storm.scheduler.SupervisorDetails) HashMap(java.util.HashMap) Map(java.util.Map) Test(org.junit.Test)

Example 42 with Cluster

use of org.apache.storm.scheduler.Cluster in project storm by apache.

the class TestGenericResourceAwareSchedulingPriorityStrategy method testGenericSchedulingPriorityStrategyEvicting.

/*
     * GenericResourceAwareSchedulingPriorityStrategy extend scoring formula to accommodate generic resources
     *
     *   Same setting as testDefaultSchedulingPriorityStrategyEvicting, but this time, new scoring system is taking generic resources into account,
     *   the score of rui's new topo will be higher than all Ethan's topos' due to its crazy generic request.
     *   At the end, all Ethan's topo will not be evicted as expected.
     */
@Test
public void testGenericSchedulingPriorityStrategyEvicting() {
    Map<String, Double> requestedgenericResourcesMap = new HashMap<>();
    requestedgenericResourcesMap.put("generic.resource.1", 40.0);
    Config ruiConf = createGrasClusterConfig(10, 10, 10, null, requestedgenericResourcesMap);
    Config ethanConf = createGrasClusterConfig(60, 200, 300, null, Collections.emptyMap());
    Topologies topologies = new Topologies(genTopology("ethan-topo-1", ethanConf, 1, 0, 1, 0, currentTime - 2, 10, "ethan"), genTopology("ethan-topo-2", ethanConf, 1, 0, 1, 0, currentTime - 2, 20, "ethan"), genTopology("ethan-topo-3", ethanConf, 1, 0, 1, 0, currentTime - 2, 28, "ethan"), genTopology("ethan-topo-4", ethanConf, 1, 0, 1, 0, currentTime - 2, 29, "ethan"));
    Topologies withNewTopo = addTopologies(topologies, genTopology("rui-topo-1", ruiConf, 1, 0, 5, 0, currentTime - 2, 10, "rui"));
    Config config = mkClusterConfig(GenericResourceAwareSchedulingPriorityStrategy.class.getName());
    Cluster cluster = mkTestCluster(topologies, config);
    scheduler = new ResourceAwareScheduler();
    scheduler.prepare(config, new StormMetricsRegistry());
    scheduler.schedule(topologies, cluster);
    assertTopologiesFullyScheduled(cluster, "ethan-topo-1", "ethan-topo-2", "ethan-topo-3", "ethan-topo-4");
    cluster = new Cluster(cluster, withNewTopo);
    scheduler.schedule(withNewTopo, cluster);
    Map<String, Set<String>> evictedTopos = ((ResourceAwareScheduler) scheduler).getEvictedTopologiesMap();
    assertTopologiesFullyScheduled(cluster, "ethan-topo-1", "ethan-topo-2", "ethan-topo-3", "ethan-topo-4");
    assertTopologiesNotBeenEvicted(cluster, collectMapValues(evictedTopos), "ethan-topo-1", "ethan-topo-2", "ethan-topo-3", "ethan-topo-4");
    assertTopologiesNotScheduled(cluster, "rui-topo-1");
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) HashMap(java.util.HashMap) DaemonConfig(org.apache.storm.DaemonConfig) Config(org.apache.storm.Config) StormMetricsRegistry(org.apache.storm.metric.StormMetricsRegistry) Topologies(org.apache.storm.scheduler.Topologies) TestUtilsForResourceAwareScheduler.addTopologies(org.apache.storm.scheduler.resource.TestUtilsForResourceAwareScheduler.addTopologies) Cluster(org.apache.storm.scheduler.Cluster) ResourceAwareScheduler(org.apache.storm.scheduler.resource.ResourceAwareScheduler) TestUtilsForResourceAwareScheduler(org.apache.storm.scheduler.resource.TestUtilsForResourceAwareScheduler) Test(org.junit.Test)

Example 43 with Cluster

use of org.apache.storm.scheduler.Cluster in project storm by apache.

the class TestGenericResourceAwareSchedulingPriorityStrategy method testDefaultSchedulingPriorityStrategyNotEvicting.

/*
     * DefaultSchedulingPriorityStrategy will not evict topo as long as the resources request can be met
     *
     *  Ethan asks for heavy cpu and memory while Rui asks for little cpu and memory but heavy generic resource
     *  Since Rui's all types of resources request can be met, no eviction will happen.
    */
@Test
public void testDefaultSchedulingPriorityStrategyNotEvicting() {
    Map<String, Double> requestedgenericResourcesMap = new HashMap<>();
    requestedgenericResourcesMap.put("generic.resource.1", 40.0);
    // Use full memory and cpu of the cluster capacity
    Config ruiConf = createGrasClusterConfig(20, 50, 50, null, requestedgenericResourcesMap);
    Config ethanConf = createGrasClusterConfig(80, 400, 500, null, Collections.emptyMap());
    Topologies topologies = new Topologies(genTopology("ethan-topo-1", ethanConf, 1, 0, 1, 0, currentTime - 2, 10, "ethan"), genTopology("ethan-topo-2", ethanConf, 1, 0, 1, 0, currentTime - 2, 20, "ethan"), genTopology("ethan-topo-3", ethanConf, 1, 0, 1, 0, currentTime - 2, 28, "ethan"), genTopology("ethan-topo-4", ethanConf, 1, 0, 1, 0, currentTime - 2, 29, "ethan"));
    Topologies withNewTopo = addTopologies(topologies, genTopology("rui-topo-1", ruiConf, 1, 0, 4, 0, currentTime - 2, 10, "rui"));
    Config config = mkClusterConfig(DefaultSchedulingPriorityStrategy.class.getName());
    Cluster cluster = mkTestCluster(topologies, config);
    scheduler = new ResourceAwareScheduler();
    scheduler.prepare(config, new StormMetricsRegistry());
    scheduler.schedule(topologies, cluster);
    assertTopologiesFullyScheduled(cluster, "ethan-topo-1", "ethan-topo-2", "ethan-topo-3", "ethan-topo-4");
    cluster = new Cluster(cluster, withNewTopo);
    scheduler.schedule(withNewTopo, cluster);
    Map<String, Set<String>> evictedTopos = ((ResourceAwareScheduler) scheduler).getEvictedTopologiesMap();
    assertTopologiesFullyScheduled(cluster, "ethan-topo-1", "ethan-topo-2", "ethan-topo-3", "ethan-topo-4");
    assertTopologiesNotBeenEvicted(cluster, collectMapValues(evictedTopos), "ethan-topo-1", "ethan-topo-2", "ethan-topo-3", "ethan-topo-4");
    assertTopologiesFullyScheduled(cluster, "rui-topo-1");
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) HashMap(java.util.HashMap) DaemonConfig(org.apache.storm.DaemonConfig) Config(org.apache.storm.Config) StormMetricsRegistry(org.apache.storm.metric.StormMetricsRegistry) Topologies(org.apache.storm.scheduler.Topologies) TestUtilsForResourceAwareScheduler.addTopologies(org.apache.storm.scheduler.resource.TestUtilsForResourceAwareScheduler.addTopologies) Cluster(org.apache.storm.scheduler.Cluster) ResourceAwareScheduler(org.apache.storm.scheduler.resource.ResourceAwareScheduler) TestUtilsForResourceAwareScheduler(org.apache.storm.scheduler.resource.TestUtilsForResourceAwareScheduler) Test(org.junit.Test)

Example 44 with Cluster

use of org.apache.storm.scheduler.Cluster in project storm by apache.

the class TestConstraintSolverStrategy method testScheduleLargeExecutorConstraintCount.

private void testScheduleLargeExecutorConstraintCount(int parallelismMultiplier) {
    if (parallelismMultiplier > 1 && !consolidatedConfigFlag) {
        Assert.assertFalse("Large parallelism test requires new consolidated constraint format with maxCoLocationCnt=" + parallelismMultiplier, consolidatedConfigFlag);
        return;
    }
    // Add 1 topology with large number of executors and constraints. Too many can cause a java.lang.StackOverflowError
    Config config = createCSSClusterConfig(10, 10, 0, null);
    config.put(Config.TOPOLOGY_RAS_CONSTRAINT_MAX_STATE_SEARCH, 50000);
    config.put(Config.TOPOLOGY_RAS_CONSTRAINT_MAX_TIME_SECS, 120);
    config.put(DaemonConfig.SCHEDULING_TIMEOUT_SECONDS_PER_TOPOLOGY, 120);
    List<List<String>> constraints = new LinkedList<>();
    addConstraints("spout-0", "spout-0", constraints);
    addConstraints("bolt-1", "bolt-1", constraints);
    addConstraints("spout-0", "bolt-0", constraints);
    addConstraints("bolt-2", "spout-0", constraints);
    addConstraints("bolt-1", "bolt-2", constraints);
    addConstraints("bolt-1", "bolt-0", constraints);
    addConstraints("bolt-1", "spout-0", constraints);
    Map<String, Integer> spreads = new HashMap<>();
    spreads.put("spout-0", parallelismMultiplier);
    spreads.put("bolt-1", parallelismMultiplier);
    setConstraintConfig(constraints, spreads, config);
    TopologyDetails topo = genTopology("testTopo-" + parallelismMultiplier, config, 10, 10, 30 * parallelismMultiplier, 30 * parallelismMultiplier, 31414, 0, "user");
    Topologies topologies = new Topologies(topo);
    Map<String, SupervisorDetails> supMap = genSupervisors(30 * parallelismMultiplier, 30, 3500, 35000);
    Cluster cluster = makeCluster(topologies, supMap);
    ResourceAwareScheduler scheduler = new ResourceAwareScheduler();
    scheduler.prepare(config, new StormMetricsRegistry());
    scheduler.schedule(topologies, cluster);
    boolean scheduleSuccess = isStatusSuccess(cluster.getStatus(topo.getId()));
    LOG.info("testScheduleLargeExecutorCount scheduling {} with {}x executor multiplier, consolidatedConfigFlag={}", scheduleSuccess ? "succeeds" : "fails", parallelismMultiplier, consolidatedConfigFlag);
    Assert.assertTrue(scheduleSuccess);
}
Also used : HashMap(java.util.HashMap) DaemonConfig(org.apache.storm.DaemonConfig) Config(org.apache.storm.Config) StormMetricsRegistry(org.apache.storm.metric.StormMetricsRegistry) Cluster(org.apache.storm.scheduler.Cluster) TopologyDetails(org.apache.storm.scheduler.TopologyDetails) LinkedList(java.util.LinkedList) ResourceAwareScheduler(org.apache.storm.scheduler.resource.ResourceAwareScheduler) TestUtilsForResourceAwareScheduler(org.apache.storm.scheduler.resource.TestUtilsForResourceAwareScheduler) Topologies(org.apache.storm.scheduler.Topologies) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) List(java.util.List) SupervisorDetails(org.apache.storm.scheduler.SupervisorDetails)

Example 45 with Cluster

use of org.apache.storm.scheduler.Cluster in project storm by apache.

the class TestFIFOSchedulingPriorityStrategy method testFIFOEvictionStrategy.

@Test
public void testFIFOEvictionStrategy() {
    try (Time.SimulatedTime sim = new Time.SimulatedTime()) {
        INimbus iNimbus = new INimbusTest();
        Map<String, SupervisorDetails> supMap = genSupervisors(4, 4, 100.0, 1000.0);
        Map<String, Map<String, Number>> resourceUserPool = userResourcePool(userRes("jerry", 200.0, 2000.0));
        Config config = createClusterConfig(100, 500, 500, resourceUserPool);
        config.put(DaemonConfig.RESOURCE_AWARE_SCHEDULER_PRIORITY_STRATEGY, FIFOSchedulingPriorityStrategy.class.getName());
        Topologies topologies = new Topologies(genTopology("topo-1-jerry", config, 1, 0, 1, 0, Time.currentTimeSecs() - 250, 20, "jerry"), genTopology("topo-2-bobby", config, 1, 0, 1, 0, Time.currentTimeSecs() - 200, 10, "bobby"), genTopology("topo-3-bobby", config, 1, 0, 1, 0, Time.currentTimeSecs() - 300, 20, "bobby"), genTopology("topo-4-derek", config, 1, 0, 1, 0, Time.currentTimeSecs() - 201, 29, "derek"));
        Cluster cluster = new Cluster(iNimbus, new ResourceMetrics(new StormMetricsRegistry()), supMap, new HashMap<>(), topologies, config);
        ResourceAwareScheduler rs = new ResourceAwareScheduler();
        rs.prepare(config, new StormMetricsRegistry());
        try {
            rs.schedule(topologies, cluster);
            assertTopologiesFullyScheduled(cluster, "topo-1-jerry", "topo-2-bobby", "topo-3-bobby", "topo-4-derek");
            LOG.info("\n\n\t\tINSERTING topo-5");
            // new topology needs to be scheduled
            // topo-3 should be evicted since its been up the longest
            topologies = addTopologies(topologies, genTopology("topo-5-derek", config, 1, 0, 1, 0, Time.currentTimeSecs() - 15, 29, "derek"));
            cluster = new Cluster(iNimbus, new ResourceMetrics(new StormMetricsRegistry()), supMap, new HashMap<>(), topologies, config);
            rs.schedule(topologies, cluster);
            assertTopologiesFullyScheduled(cluster, "topo-1-jerry", "topo-2-bobby", "topo-4-derek", "topo-5-derek");
            assertTopologiesNotScheduled(cluster, "topo-3-bobby");
            LOG.info("\n\n\t\tINSERTING topo-6");
            // new topology needs to be scheduled.  topo-4 should be evicted. Even though topo-1 from user jerry is older, topo-1 will not be evicted
            // since user jerry has enough resource guarantee
            topologies = addTopologies(topologies, genTopology("topo-6-bobby", config, 1, 0, 1, 0, Time.currentTimeSecs() - 10, 29, "bobby"));
            cluster = new Cluster(iNimbus, new ResourceMetrics(new StormMetricsRegistry()), supMap, new HashMap<>(), topologies, config);
            rs.schedule(topologies, cluster);
            assertTopologiesFullyScheduled(cluster, "topo-1-jerry", "topo-2-bobby", "topo-5-derek", "topo-6-bobby");
            assertTopologiesNotScheduled(cluster, "topo-3-bobby", "topo-4-derek");
        } finally {
            rs.cleanup();
        }
    }
}
Also used : HashMap(java.util.HashMap) DaemonConfig(org.apache.storm.DaemonConfig) Config(org.apache.storm.Config) StormMetricsRegistry(org.apache.storm.metric.StormMetricsRegistry) Cluster(org.apache.storm.scheduler.Cluster) Time(org.apache.storm.utils.Time) INimbus(org.apache.storm.scheduler.INimbus) ResourceAwareScheduler(org.apache.storm.scheduler.resource.ResourceAwareScheduler) TestUtilsForResourceAwareScheduler(org.apache.storm.scheduler.resource.TestUtilsForResourceAwareScheduler) ResourceMetrics(org.apache.storm.scheduler.resource.normalization.ResourceMetrics) Topologies(org.apache.storm.scheduler.Topologies) SupervisorDetails(org.apache.storm.scheduler.SupervisorDetails) HashMap(java.util.HashMap) Map(java.util.Map) Test(org.junit.Test)

Aggregations

Cluster (org.apache.storm.scheduler.Cluster)95 Config (org.apache.storm.Config)85 Topologies (org.apache.storm.scheduler.Topologies)83 TopologyDetails (org.apache.storm.scheduler.TopologyDetails)81 SupervisorDetails (org.apache.storm.scheduler.SupervisorDetails)79 INimbus (org.apache.storm.scheduler.INimbus)73 HashMap (java.util.HashMap)69 StormMetricsRegistry (org.apache.storm.metric.StormMetricsRegistry)68 ResourceMetrics (org.apache.storm.scheduler.resource.normalization.ResourceMetrics)62 TestUtilsForResourceAwareScheduler (org.apache.storm.scheduler.resource.TestUtilsForResourceAwareScheduler)59 Map (java.util.Map)44 DaemonConfig (org.apache.storm.DaemonConfig)43 SchedulerAssignment (org.apache.storm.scheduler.SchedulerAssignment)40 ResourceAwareScheduler (org.apache.storm.scheduler.resource.ResourceAwareScheduler)40 HashSet (java.util.HashSet)39 ExecutorDetails (org.apache.storm.scheduler.ExecutorDetails)39 Test (org.junit.Test)37 WorkerSlot (org.apache.storm.scheduler.WorkerSlot)35 Test (org.junit.jupiter.api.Test)35 SchedulerAssignmentImpl (org.apache.storm.scheduler.SchedulerAssignmentImpl)33