Search in sources :

Example 61 with TopologyContext

use of org.apache.storm.task.TopologyContext in project kafka-spout by HolmesNL.

the class KafkaSpoutConstructorTest method testOpenWithDefaultConstructor.

/**
 * Using the default constructor, a topic name must be in the storm config
 */
@Test
public void testOpenWithDefaultConstructor() {
    KafkaSpout spout = spy(new KafkaSpout());
    TopologyContext topology = mock(TopologyContext.class);
    SpoutOutputCollector collector = mock(SpoutOutputCollector.class);
    Map<String, Object> config = new HashMap<String, Object>();
    config.put(ConfigUtils.CONFIG_TOPIC, "topic");
    doNothing().when(spout).createConsumer(config);
    spout.open(config, topology, collector);
    assertEquals("Wrong Topic Name", spout._topic, "topic");
}
Also used : HashMap(java.util.HashMap) SpoutOutputCollector(org.apache.storm.spout.SpoutOutputCollector) TopologyContext(org.apache.storm.task.TopologyContext) Test(org.junit.Test)

Example 62 with TopologyContext

use of org.apache.storm.task.TopologyContext in project heron by twitter.

the class CustomStreamGroupingDelegate method prepare.

@Override
public void prepare(org.apache.heron.api.topology.TopologyContext context, String component, String streamId, List<Integer> targetTasks) {
    TopologyContext c = new TopologyContext(context);
    GlobalStreamId g = new GlobalStreamId(component, streamId);
    delegate.prepare(c, g, targetTasks);
}
Also used : GlobalStreamId(org.apache.storm.generated.GlobalStreamId) TopologyContext(org.apache.storm.task.TopologyContext)

Aggregations

TopologyContext (org.apache.storm.task.TopologyContext)62 Test (org.junit.Test)29 HashMap (java.util.HashMap)25 OutputCollector (org.apache.storm.task.OutputCollector)19 Tuple (org.apache.storm.tuple.Tuple)16 SpoutOutputCollector (org.apache.storm.spout.SpoutOutputCollector)15 Map (java.util.Map)14 GlobalStreamId (org.apache.storm.generated.GlobalStreamId)8 ClientConfiguration (org.apache.pulsar.client.api.ClientConfiguration)7 Test (org.testng.annotations.Test)7 WriterConfiguration (org.apache.metron.common.configuration.writer.WriterConfiguration)6 BulkWriterResponse (org.apache.metron.common.writer.BulkWriterResponse)6 Collections (java.util.Collections)5 Grouping (org.apache.storm.generated.Grouping)5 StormTopology (org.apache.storm.generated.StormTopology)5 GeneralTopologyContext (org.apache.storm.task.GeneralTopologyContext)5 OutputCollectorImpl (org.apache.storm.task.OutputCollectorImpl)5 IRichBolt (org.apache.storm.topology.IRichBolt)5 IRichSpout (org.apache.storm.topology.IRichSpout)5 ParserConfigurations (org.apache.metron.common.configuration.ParserConfigurations)4