Search in sources :

Example 41 with TopologyContext

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);
}
Also used : SpoutOutputCollectorImpl(org.apache.storm.spout.SpoutOutputCollectorImpl) TopologyContext(org.apache.storm.task.TopologyContext)

Example 42 with TopologyContext

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);
    }
}
Also used : TopologyContext(org.apache.storm.task.TopologyContext)

Example 43 with TopologyContext

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);
}
Also used : TopologyContext(org.apache.storm.task.TopologyContext) OutputCollectorImpl(org.apache.storm.task.OutputCollectorImpl)

Example 44 with TopologyContext

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()));
}
Also used : ResponseData(org.openkilda.messaging.ctrl.ResponseData) TopologyContext(org.apache.storm.task.TopologyContext)

Example 45 with TopologyContext

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.
    }
}
Also used : OutputCollector(org.apache.storm.task.OutputCollector) TopologyContext(org.apache.storm.task.TopologyContext) ClientConfiguration(org.apache.pulsar.client.api.ClientConfiguration) Test(org.testng.annotations.Test)

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