Search in sources :

Example 56 with StormTopology

use of org.apache.storm.generated.StormTopology in project storm by apache.

the class LocalNimbusTest method testSubmitTopologyToLocalNimbus.

@Test
public void testSubmitTopologyToLocalNimbus() throws Exception {
    int port = Utils.getAvailablePort();
    try (ILocalCluster localCluster = new LocalCluster.Builder().withNimbusDaemon(true).withDaemonConf(Config.NIMBUS_THRIFT_PORT, port).build()) {
        Config topoConf = new Config();
        topoConf.putAll(Utils.readDefaultConfig());
        topoConf.setDebug(true);
        // default is aways "distributed" but here local cluster is being used.
        topoConf.put("storm.cluster.mode", "local");
        topoConf.put(Config.STORM_TOPOLOGY_SUBMISSION_NOTIFIER_PLUGIN, InmemoryTopologySubmitterHook.class.getName());
        topoConf.put(Config.NIMBUS_THRIFT_PORT, port);
        List<TopologyDetails> topologyNames = new ArrayList<>();
        for (int i = 0; i < 4; i++) {
            final String topologyName = "word-count-" + UUID.randomUUID().toString();
            final StormTopology stormTopology = createTestTopology();
            topologyNames.add(new TopologyDetails(topologyName, stormTopology));
            localCluster.submitTopology(topologyName, topoConf, stormTopology);
        }
        Assert.assertEquals(InmemoryTopologySubmitterHook.submittedTopologies, topologyNames);
    }
}
Also used : LocalCluster(org.apache.storm.LocalCluster) ILocalCluster(org.apache.storm.ILocalCluster) ILocalCluster(org.apache.storm.ILocalCluster) Config(org.apache.storm.Config) StormTopology(org.apache.storm.generated.StormTopology) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 57 with StormTopology

use of org.apache.storm.generated.StormTopology in project storm by apache.

the class TestUtilsForBlacklistScheduler method getTopology.

public static TopologyDetails getTopology(String name, Map<String, Object> config, int numSpout, int numBolt, int spoutParallelism, int boltParallelism, int launchTime, boolean blacklistEnable) {
    Config conf = new Config();
    conf.putAll(config);
    conf.put(Config.TOPOLOGY_NAME, name);
    StormTopology topology = buildTopology(numSpout, numBolt, spoutParallelism, boltParallelism);
    TopologyDetails topo = new TopologyDetails(name + "-" + launchTime, conf, topology, 3, genExecsAndComps(topology, spoutParallelism, boltParallelism), launchTime, "user");
    return topo;
}
Also used : Config(org.apache.storm.Config) StormTopology(org.apache.storm.generated.StormTopology) TopologyDetails(org.apache.storm.scheduler.TopologyDetails)

Example 58 with StormTopology

use of org.apache.storm.generated.StormTopology in project storm by apache.

the class TestResourceAwareScheduler method testTopologyWorkerMaxHeapSize.

@Test
public void testTopologyWorkerMaxHeapSize() {
    // Test1: If RAS spreads executors across multiple workers based on the set limit for a worker used by the topology
    INimbus iNimbus = new INimbusTest();
    Map<String, SupervisorDetails> supMap = genSupervisors(2, 2, 400, 2000);
    TopologyBuilder builder1 = new TopologyBuilder();
    builder1.setSpout("wordSpout1", new TestWordSpout(), 4);
    StormTopology stormTopology1 = builder1.createTopology();
    Config config1 = new Config();
    config1.putAll(defaultTopologyConf);
    config1.put(Config.TOPOLOGY_WORKER_MAX_HEAP_SIZE_MB, 128.0);
    Map<ExecutorDetails, String> executorMap1 = genExecsAndComps(stormTopology1);
    TopologyDetails topology1 = new TopologyDetails("topology1", config1, stormTopology1, 1, executorMap1, 0, "user");
    ResourceAwareScheduler rs = new ResourceAwareScheduler();
    Topologies topologies = new Topologies(topology1);
    Cluster cluster = new Cluster(iNimbus, new ResourceMetrics(new StormMetricsRegistry()), supMap, new HashMap<>(), topologies, config1);
    rs.prepare(config1, new StormMetricsRegistry());
    try {
        rs.schedule(topologies, cluster);
        assertFalse(cluster.needsSchedulingRas(topology1));
        assertTrue(cluster.getStatusMap().get(topology1.getId()).startsWith("Running - Fully Scheduled by DefaultResourceAwareStrategy"));
        assertEquals(4, cluster.getAssignedNumWorkers(topology1));
    } finally {
        rs.cleanup();
    }
    // Test2: test when no more workers are available due to topology worker max heap size limit but there is memory is still available
    // wordSpout2 is going to contain 5 executors that needs scheduling. Each of those executors has a memory requirement of 128.0 MB
    // The cluster contains 4 free WorkerSlots. For this topolology each worker is limited to a max heap size of 128.0
    // Thus, one executor not going to be able to get scheduled thus failing the scheduling of this topology and no executors of this
    // topology will be scheduled
    TopologyBuilder builder2 = new TopologyBuilder();
    builder2.setSpout("wordSpout2", new TestWordSpout(), 5);
    StormTopology stormTopology2 = builder2.createTopology();
    Config config2 = new Config();
    config2.putAll(defaultTopologyConf);
    config2.put(Config.TOPOLOGY_WORKER_MAX_HEAP_SIZE_MB, 128.0);
    Map<ExecutorDetails, String> executorMap2 = genExecsAndComps(stormTopology2);
    TopologyDetails topology2 = new TopologyDetails("topology2", config2, stormTopology2, 1, executorMap2, 0, "user");
    topologies = new Topologies(topology2);
    cluster = new Cluster(iNimbus, new ResourceMetrics(new StormMetricsRegistry()), supMap, new HashMap<>(), topologies, config2);
    rs.prepare(config2, new StormMetricsRegistry());
    try {
        rs.schedule(topologies, cluster);
        assertTrue(cluster.needsSchedulingRas(topology2));
        String status = cluster.getStatusMap().get(topology2.getId());
        assert status.startsWith("Not enough resources to schedule") : status;
        // assert status.endsWith("5 executors not scheduled") : status;
        assertEquals(5, cluster.getUnassignedExecutors(topology2).size());
    } finally {
        rs.cleanup();
    }
}
Also used : ExecutorDetails(org.apache.storm.scheduler.ExecutorDetails) TopologyBuilder(org.apache.storm.topology.TopologyBuilder) HashMap(java.util.HashMap) DaemonConfig(org.apache.storm.DaemonConfig) Config(org.apache.storm.Config) StormTopology(org.apache.storm.generated.StormTopology) StormMetricsRegistry(org.apache.storm.metric.StormMetricsRegistry) Cluster(org.apache.storm.scheduler.Cluster) INimbus(org.apache.storm.scheduler.INimbus) TopologyDetails(org.apache.storm.scheduler.TopologyDetails) TestUtilsForResourceAwareScheduler(org.apache.storm.scheduler.resource.TestUtilsForResourceAwareScheduler) ResourceMetrics(org.apache.storm.scheduler.resource.normalization.ResourceMetrics) TestWordSpout(org.apache.storm.testing.TestWordSpout) Topologies(org.apache.storm.scheduler.Topologies) SupervisorDetails(org.apache.storm.scheduler.SupervisorDetails) Test(org.junit.jupiter.api.Test) PerformanceTest(org.apache.storm.testing.PerformanceTest)

Example 59 with StormTopology

use of org.apache.storm.generated.StormTopology in project storm by apache.

the class TestResourceAwareScheduler method testMultipleSpoutsAndCyclicTopologies.

/**
 * Test multiple spouts and cyclic topologies
 */
@Test
public void testMultipleSpoutsAndCyclicTopologies() {
    TopologyBuilder builder = new TopologyBuilder();
    builder.setSpout("spout-1", new TestSpout(), 5);
    builder.setSpout("spout-2", new TestSpout(), 5);
    builder.setBolt("bolt-1", new TestBolt(), 5).shuffleGrouping("spout-1").shuffleGrouping("bolt-3");
    builder.setBolt("bolt-2", new TestBolt(), 5).shuffleGrouping("bolt-1");
    builder.setBolt("bolt-3", new TestBolt(), 5).shuffleGrouping("bolt-2").shuffleGrouping("spout-2");
    INimbus iNimbus = new INimbusTest();
    Map<String, SupervisorDetails> supMap = genSupervisors(25, 1, 100, 1000);
    Config config = createClusterConfig(100, 500, 500, null);
    StormTopology stormTopology = builder.createTopology();
    config.put(Config.TOPOLOGY_SUBMITTER_USER, "jerry");
    TopologyDetails topo = new TopologyDetails("topo-1", config, stormTopology, 0, genExecsAndComps(stormTopology), 0, "jerry");
    Topologies topologies = new Topologies(topo);
    Cluster cluster = new Cluster(iNimbus, new ResourceMetrics(new StormMetricsRegistry()), supMap, new HashMap<String, SchedulerAssignmentImpl>(), topologies, config);
    scheduler = new ResourceAwareScheduler();
    scheduler.prepare(config, new StormMetricsRegistry());
    scheduler.schedule(topologies, cluster);
    assertTrue("Topo scheduled?", cluster.getAssignmentById(topo.getId()) != null);
    assertEquals("Topo all executors scheduled?", 25, cluster.getAssignmentById(topo.getId()).getExecutorToSlot().size());
}
Also used : TopologyBuilder(org.apache.storm.topology.TopologyBuilder) DaemonConfig(org.apache.storm.DaemonConfig) Config(org.apache.storm.Config) StormTopology(org.apache.storm.generated.StormTopology) StormMetricsRegistry(org.apache.storm.metric.StormMetricsRegistry) Cluster(org.apache.storm.scheduler.Cluster) INimbus(org.apache.storm.scheduler.INimbus) TopologyDetails(org.apache.storm.scheduler.TopologyDetails) TestUtilsForResourceAwareScheduler(org.apache.storm.scheduler.resource.TestUtilsForResourceAwareScheduler) 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) Test(org.junit.jupiter.api.Test) PerformanceTest(org.apache.storm.testing.PerformanceTest)

Example 60 with StormTopology

use of org.apache.storm.generated.StormTopology in project storm by apache.

the class AsyncLocalizerTest method constructEmptyStormTopology.

private StormTopology constructEmptyStormTopology() {
    StormTopology topology = new StormTopology();
    topology.set_spouts(new HashMap<>());
    topology.set_bolts(new HashMap<>());
    topology.set_state_spouts(new HashMap<>());
    return topology;
}
Also used : StormTopology(org.apache.storm.generated.StormTopology)

Aggregations

StormTopology (org.apache.storm.generated.StormTopology)162 Config (org.apache.storm.Config)72 HashMap (java.util.HashMap)67 Test (org.junit.Test)59 TopologyBuilder (org.apache.storm.topology.TopologyBuilder)44 Map (java.util.Map)35 ArrayList (java.util.ArrayList)29 TopologyDetails (org.apache.storm.scheduler.TopologyDetails)27 Test (org.junit.jupiter.api.Test)26 List (java.util.List)24 Bolt (org.apache.storm.generated.Bolt)23 Values (org.apache.storm.tuple.Values)23 StormMetricsRegistry (org.apache.storm.metric.StormMetricsRegistry)22 Cluster (org.apache.storm.scheduler.Cluster)22 SupervisorDetails (org.apache.storm.scheduler.SupervisorDetails)22 Topologies (org.apache.storm.scheduler.Topologies)22 Fields (org.apache.storm.tuple.Fields)22 INimbus (org.apache.storm.scheduler.INimbus)21 TopologyDef (org.apache.storm.flux.model.TopologyDef)20 TestUtilsForResourceAwareScheduler (org.apache.storm.scheduler.resource.TestUtilsForResourceAwareScheduler)20