use of org.apache.storm.task.TopologyContext in project incubator-heron by apache.
the class IRichSpoutDelegate method open.
@Override
@SuppressWarnings("rawtypes")
public void open(Map<String, Object> conf, com.twitter.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 incubator-heron by apache.
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 org.apache.storm.task.TopologyContext in project incubator-heron by apache.
the class IWindowedBoltDelegate method prepare.
@Override
public void prepare(Map<String, Object> 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 org.apache.storm.task.TopologyContext in project open-kilda by telstra.
the class ClearStateAction method handle.
@Override
protected void handle() throws JsonProcessingException {
getMaster().getBolt().clearState();
TopologyContext context = getBolt().getContext();
emitResponse(new ResponseData(context.getThisComponentId(), context.getThisTaskId(), getMessage().getTopology()));
}
use of org.apache.storm.task.TopologyContext in project incubator-pulsar by apache.
the class PulsarBoltTest method testFailedProducer.
@Test
public void testFailedProducer() {
PulsarBoltConfiguration pulsarBoltConf = new PulsarBoltConfiguration();
pulsarBoltConf.setServiceUrl(serviceUrl);
pulsarBoltConf.setTopic("persistent://invalid");
pulsarBoltConf.setTupleToMessageMapper(tupleToMessageMapper);
pulsarBoltConf.setMetricsTimeIntervalInSecs(60);
PulsarBolt bolt = new PulsarBolt(pulsarBoltConf, new ClientConfiguration());
MockOutputCollector mockCollector = new MockOutputCollector();
OutputCollector collector = new OutputCollector(mockCollector);
TopologyContext context = mock(TopologyContext.class);
when(context.getThisComponentId()).thenReturn("new" + methodName);
when(context.getThisTaskId()).thenReturn(0);
try {
bolt.prepare(Maps.newHashMap(), context, collector);
fail("should have failed as producer creation failed");
} catch (IllegalStateException ie) {
// Ok.
}
}
Aggregations