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