Search in sources :

Example 6 with TopologyContext

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");
}
Also used : HashMap(java.util.HashMap) SpoutOutputCollector(backtype.storm.spout.SpoutOutputCollector) TopologyContext(backtype.storm.task.TopologyContext) Test(org.junit.Test)

Example 7 with TopologyContext

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);
}
Also used : GlobalStreamId(backtype.storm.generated.GlobalStreamId) TopologyContext(backtype.storm.task.TopologyContext)

Example 8 with TopologyContext

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

Example 9 with TopologyContext

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

Example 10 with TopologyContext

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

Aggregations

TopologyContext (backtype.storm.task.TopologyContext)17 SpoutOutputCollector (backtype.storm.spout.SpoutOutputCollector)7 ClientConfiguration (com.yahoo.pulsar.client.api.ClientConfiguration)5 HashMap (java.util.HashMap)5 Test (org.junit.Test)5 PersistentTopicStats (com.yahoo.pulsar.common.policies.data.PersistentTopicStats)3 Test (org.testng.annotations.Test)3 OutputCollector (backtype.storm.task.OutputCollector)2 Config (backtype.storm.Config)1 GlobalStreamId (backtype.storm.generated.GlobalStreamId)1 Grouping (backtype.storm.generated.Grouping)1 StormTopology (backtype.storm.generated.StormTopology)1 ITaskHook (backtype.storm.hooks.ITaskHook)1 SpoutOutputCollectorImpl (backtype.storm.spout.SpoutOutputCollectorImpl)1 OutputCollectorImpl (backtype.storm.task.OutputCollectorImpl)1 WorkerTopologyContext (backtype.storm.task.WorkerTopologyContext)1 TopologyBuilder (backtype.storm.topology.TopologyBuilder)1 Tuple (backtype.storm.tuple.Tuple)1 TupleImpl (backtype.storm.tuple.TupleImpl)1 AsyncLoopThread (com.alibaba.jstorm.callback.AsyncLoopThread)1