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);
}
}
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;
}
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();
}
}
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());
}
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;
}
Aggregations