Search in sources :

Example 61 with ResourceMetrics

use of org.apache.storm.scheduler.resource.normalization.ResourceMetrics in project storm by apache.

the class TestBlacklistScheduler method TestResumeBlacklist.

@Test
public void TestResumeBlacklist() {
    INimbus iNimbus = new TestUtilsForBlacklistScheduler.INimbusTest();
    Map<String, SupervisorDetails> supMap = TestUtilsForBlacklistScheduler.genSupervisors(3, 4);
    Config config = new Config();
    config.putAll(Utils.readDefaultConfig());
    config.put(DaemonConfig.BLACKLIST_SCHEDULER_TOLERANCE_TIME, 200);
    config.put(DaemonConfig.BLACKLIST_SCHEDULER_TOLERANCE_COUNT, 2);
    config.put(DaemonConfig.BLACKLIST_SCHEDULER_RESUME_TIME, 300);
    Map<String, TopologyDetails> topoMap = new HashMap<String, TopologyDetails>();
    TopologyDetails topo1 = TestUtilsForBlacklistScheduler.getTopology("topo-1", config, 5, 15, 1, 1, currentTime - 2, true);
    topoMap.put(topo1.getId(), topo1);
    Topologies topologies = new Topologies(topoMap);
    StormMetricsRegistry metricsRegistry = new StormMetricsRegistry();
    ResourceMetrics resourceMetrics = new ResourceMetrics(metricsRegistry);
    Cluster cluster = new Cluster(iNimbus, resourceMetrics, supMap, new HashMap<String, SchedulerAssignmentImpl>(), topologies, config);
    scheduler = new BlacklistScheduler(new DefaultScheduler());
    scheduler.prepare(config, metricsRegistry);
    scheduler.schedule(topologies, cluster);
    cluster = new Cluster(iNimbus, resourceMetrics, TestUtilsForBlacklistScheduler.removeSupervisorFromSupervisors(supMap, "sup-0"), TestUtilsForBlacklistScheduler.assignmentMapToImpl(cluster.getAssignments()), topologies, config);
    scheduler.schedule(topologies, cluster);
    cluster = new Cluster(iNimbus, resourceMetrics, TestUtilsForBlacklistScheduler.removeSupervisorFromSupervisors(supMap, "sup-0"), TestUtilsForBlacklistScheduler.assignmentMapToImpl(cluster.getAssignments()), topologies, config);
    scheduler.schedule(topologies, cluster);
    cluster = new Cluster(iNimbus, resourceMetrics, supMap, new HashMap<String, SchedulerAssignmentImpl>(), topologies, config);
    scheduler.schedule(topologies, cluster);
    Assert.assertEquals("blacklist", Collections.singleton("host-0"), cluster.getBlacklistedHosts());
    for (int i = 0; i < 300 / 10 - 2; i++) {
        scheduler.schedule(topologies, cluster);
    }
    Assert.assertEquals("blacklist", Collections.singleton("host-0"), cluster.getBlacklistedHosts());
    scheduler.schedule(topologies, cluster);
    Assert.assertEquals("blacklist", Collections.emptySet(), cluster.getBlacklistedHosts());
}
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) INimbus(org.apache.storm.scheduler.INimbus) TopologyDetails(org.apache.storm.scheduler.TopologyDetails) ResourceMetrics(org.apache.storm.scheduler.resource.normalization.ResourceMetrics) SchedulerAssignmentImpl(org.apache.storm.scheduler.SchedulerAssignmentImpl) Topologies(org.apache.storm.scheduler.Topologies) SupervisorDetails(org.apache.storm.scheduler.SupervisorDetails) DefaultScheduler(org.apache.storm.scheduler.DefaultScheduler) Test(org.junit.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

StormMetricsRegistry (org.apache.storm.metric.StormMetricsRegistry)61 Cluster (org.apache.storm.scheduler.Cluster)61 SupervisorDetails (org.apache.storm.scheduler.SupervisorDetails)61 ResourceMetrics (org.apache.storm.scheduler.resource.normalization.ResourceMetrics)61 Topologies (org.apache.storm.scheduler.Topologies)60 Config (org.apache.storm.Config)59 INimbus (org.apache.storm.scheduler.INimbus)58 TopologyDetails (org.apache.storm.scheduler.TopologyDetails)50 TestUtilsForResourceAwareScheduler (org.apache.storm.scheduler.resource.TestUtilsForResourceAwareScheduler)49 HashMap (java.util.HashMap)40 DaemonConfig (org.apache.storm.DaemonConfig)36 Test (org.junit.jupiter.api.Test)35 ResourceAwareScheduler (org.apache.storm.scheduler.resource.ResourceAwareScheduler)29 TopologyBuilder (org.apache.storm.topology.TopologyBuilder)27 SchedulerAssignment (org.apache.storm.scheduler.SchedulerAssignment)26 ExecutorDetails (org.apache.storm.scheduler.ExecutorDetails)25 Map (java.util.Map)24 HashSet (java.util.HashSet)22 StormTopology (org.apache.storm.generated.StormTopology)21 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)21