use of backtype.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 backtype.storm.task.TopologyContext in project heron by twitter.
the class CustomStreamGroupingDelegate method prepare.
@Override
public void prepare(com.twitter.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);
}
use of backtype.storm.task.TopologyContext in project heron by twitter.
the class ITaskHookDelegate method prepare.
@Override
public void prepare(Map<String, Object> newConf, com.twitter.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);
}
}
use of backtype.storm.task.TopologyContext in project heron by twitter.
the class IRichBoltDelegate method prepare.
@Override
@SuppressWarnings("rawtypes")
public void prepare(Map conf, com.twitter.heron.api.topology.TopologyContext context, com.twitter.heron.api.bolt.OutputCollector collector) {
topologyContextImpl = new TopologyContext(context);
outputCollectorImpl = new OutputCollectorImpl(collector);
delegate.prepare(conf, topologyContextImpl, outputCollectorImpl);
}
use of backtype.storm.task.TopologyContext in project heron by twitter.
the class IRichSpoutDelegate method open.
@Override
@SuppressWarnings("rawtypes")
public void open(Map conf, com.twitter.heron.api.topology.TopologyContext context, SpoutOutputCollector collector) {
topologyContextImpl = new TopologyContext(context);
spoutOutputCollectorImpl = new SpoutOutputCollectorImpl(collector);
delegate.open(conf, topologyContextImpl, spoutOutputCollectorImpl);
}
Aggregations