use of org.apache.storm.generated.StormTopology in project storm by apache.
the class TCKTest method testIncludes.
@Test
public void testIncludes() throws Exception {
TopologyDef topologyDef = FluxParser.parseResource("/configs/include_test.yaml", false, true, null, false);
Config conf = FluxBuilder.buildConfig(topologyDef);
ExecutionContext context = new ExecutionContext(topologyDef, conf);
StormTopology topology = FluxBuilder.buildTopology(context);
assertNotNull(topology);
assertTrue(topologyDef.getName().equals("include-topology"));
assertTrue(topologyDef.getBolts().size() > 0);
assertTrue(topologyDef.getSpouts().size() > 0);
topology.validate();
}
use of org.apache.storm.generated.StormTopology in project storm by apache.
the class TCKTest method testDiamondTopology.
@Test
public void testDiamondTopology() throws Exception {
TopologyDef topologyDef = FluxParser.parseResource("/configs/diamond-topology.yaml", false, true, null, false);
Config conf = FluxBuilder.buildConfig(topologyDef);
ExecutionContext context = new ExecutionContext(topologyDef, conf);
StormTopology topology = FluxBuilder.buildTopology(context);
assertNotNull(topology);
topology.validate();
}
use of org.apache.storm.generated.StormTopology in project storm by apache.
the class TCKTest method testInvalidTopologySource.
@Test(expected = IllegalArgumentException.class)
public void testInvalidTopologySource() throws Exception {
TopologyDef topologyDef = FluxParser.parseResource("/configs/invalid-existing-topology.yaml", false, true, null, false);
assertFalse("Topology config is invalid.", topologyDef.validate());
Config conf = FluxBuilder.buildConfig(topologyDef);
ExecutionContext context = new ExecutionContext(topologyDef, conf);
StormTopology topology = FluxBuilder.buildTopology(context);
}
use of org.apache.storm.generated.StormTopology in project storm by apache.
the class TCKTest method testHbase.
@Test
public void testHbase() throws Exception {
TopologyDef topologyDef = FluxParser.parseResource("/configs/simple_hbase.yaml", false, true, null, false);
Config conf = FluxBuilder.buildConfig(topologyDef);
ExecutionContext context = new ExecutionContext(topologyDef, conf);
StormTopology topology = FluxBuilder.buildTopology(context);
assertNotNull(topology);
topology.validate();
}
use of org.apache.storm.generated.StormTopology in project storm by apache.
the class FluxBuilder method buildTopology.
/**
* Given a topology definition, return a Storm topology that can be run either locally or remotely.
*
* @param context
* @return
* @throws IllegalAccessException
* @throws InstantiationException
* @throws ClassNotFoundException
* @throws NoSuchMethodException
* @throws InvocationTargetException
*/
public static StormTopology buildTopology(ExecutionContext context) throws IllegalAccessException, InstantiationException, ClassNotFoundException, NoSuchMethodException, InvocationTargetException, NoSuchFieldException {
StormTopology topology = null;
TopologyDef topologyDef = context.getTopologyDef();
if (!topologyDef.validate()) {
throw new IllegalArgumentException("Invalid topology config. Spouts, bolts and streams cannot be " + "defined in the same configuration as a topologySource.");
}
// build components that may be referenced by spouts, bolts, etc.
// the map will be a String --> Object where the object is a fully
// constructed class instance
buildComponents(context);
if (topologyDef.isDslTopology()) {
// This is a DSL (YAML, etc.) topology...
LOG.info("Detected DSL topology...");
TopologyBuilder builder = new TopologyBuilder();
// create spouts
buildSpouts(context, builder);
// we need to be able to lookup bolts by id, then switch based
// on whether they are IBasicBolt or IRichBolt instances
buildBolts(context);
// process stream definitions
buildStreamDefinitions(context, builder);
topology = builder.createTopology();
} else {
// user class supplied...
// this also provides a bridge to Trident...
LOG.info("A topology source has been specified...");
ObjectDef def = topologyDef.getTopologySource();
topology = buildExternalTopology(def, context);
}
return topology;
}
Aggregations