Search in sources :

Example 26 with TopologyContext

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

the class KafkaSpoutConstructorTest method testOpenWithOverloadedConstructorAndStormConfig.

/**
 * If we use the overloaded constructor, with the topic name, it does not matter what is in the storm config.
 */
@Test
public void testOpenWithOverloadedConstructorAndStormConfig() {
    KafkaSpout spout = spy(new KafkaSpout("OVERLOAD"));
    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, "OVERLOAD");
}
Also used : HashMap(java.util.HashMap) SpoutOutputCollector(org.apache.storm.spout.SpoutOutputCollector) TopologyContext(org.apache.storm.task.TopologyContext) Test(org.junit.Test)

Example 27 with TopologyContext

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

the class IWindowedBoltDelegate method prepare.

@Override
public void prepare(Map<String, Object> conf, org.apache.heron.api.topology.TopologyContext context, org.apache.heron.api.bolt.OutputCollector collector) {
    topologyContextImpl = new TopologyContext(context);
    outputCollectorImpl = new OutputCollectorImpl(collector);
    delegate.prepare(conf, topologyContextImpl, outputCollectorImpl);
}
Also used : TopologyContext(org.apache.storm.task.TopologyContext) OutputCollectorImpl(org.apache.storm.task.OutputCollectorImpl)

Example 28 with TopologyContext

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

the class IRichBoltDelegate method prepare.

@Override
@SuppressWarnings("rawtypes")
public void prepare(Map<String, Object> conf, org.apache.heron.api.topology.TopologyContext context, org.apache.heron.api.bolt.OutputCollector collector) {
    topologyContextImpl = new TopologyContext(context);
    outputCollectorImpl = new OutputCollectorImpl(collector);
    delegate.prepare(conf, topologyContextImpl, outputCollectorImpl);
}
Also used : TopologyContext(org.apache.storm.task.TopologyContext) OutputCollectorImpl(org.apache.storm.task.OutputCollectorImpl)

Example 29 with TopologyContext

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

the class IRichSpoutDelegate method open.

@Override
@SuppressWarnings("rawtypes")
public void open(Map conf, org.apache.heron.api.topology.TopologyContext context, SpoutOutputCollector collector) {
    topologyContextImpl = new TopologyContext(context);
    spoutOutputCollectorImpl = new SpoutOutputCollectorImpl(collector);
    delegate.open(conf, topologyContextImpl, spoutOutputCollectorImpl);
}
Also used : SpoutOutputCollectorImpl(org.apache.storm.spout.SpoutOutputCollectorImpl) TopologyContext(org.apache.storm.task.TopologyContext)

Example 30 with TopologyContext

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

the class ITaskHookDelegate method prepare.

@Override
public void prepare(Map<String, Object> newConf, org.apache.heron.api.topology.TopologyContext context) {
    this.conf = newConf;
    if (!newConf.containsKey(Config.STORMCOMPAT_TOPOLOGY_AUTO_TASK_HOOKS)) {
        throw new RuntimeException("StormCompat Translation not done for task hooks");
    }
    List<String> hookClassNames = TypeUtils.getListOfStrings(newConf.get(Config.STORMCOMPAT_TOPOLOGY_AUTO_TASK_HOOKS));
    for (String className : hookClassNames) {
        ITaskHook hook;
        try {
            hook = (ITaskHook) Class.forName(className).newInstance();
        } catch (ClassNotFoundException ex) {
            throw new RuntimeException(ex + " ITaskHook class must be in class path.");
        } catch (InstantiationException ex) {
            throw new RuntimeException(ex + " ITaskHook class must be concrete.");
        } catch (IllegalAccessException ex) {
            throw new RuntimeException(ex + " ITaskHook class must have a no-arg constructor.");
        }
        hooks.add(hook);
    }
    // Invoke the prepare() for all ITaskHooks
    TopologyContext ctxt = new TopologyContext(context);
    for (ITaskHook hook : hooks) {
        hook.prepare(newConf, ctxt);
    }
}
Also used : 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