Search in sources :

Example 1 with SpoutOutputCollector

use of backtype.storm.spout.SpoutOutputCollector in project storm by nathanmarz.

the class RichSpoutBatchTriggerer method open.

@Override
public void open(Map conf, TopologyContext context, SpoutOutputCollector collector) {
    _delegate.open(conf, context, new SpoutOutputCollector(new StreamOverrideCollector(collector)));
    _outputTasks = new ArrayList<Integer>();
    for (String component : Utils.get(context.getThisTargets(), _coordStream, new HashMap<String, Grouping>()).keySet()) {
        _outputTasks.addAll(context.getComponentTasks(component));
    }
    _rand = new Random(Utils.secureRandomLong());
}
Also used : Random(java.util.Random) HashMap(java.util.HashMap) SpoutOutputCollector(backtype.storm.spout.SpoutOutputCollector) ISpoutOutputCollector(backtype.storm.spout.ISpoutOutputCollector)

Example 2 with SpoutOutputCollector

use of backtype.storm.spout.SpoutOutputCollector in project storm by nathanmarz.

the class SpoutTracker method open.

public void open(Map conf, TopologyContext context, SpoutOutputCollector collector) {
    _tracker = new SpoutTrackOutputCollector(collector);
    _delegate.open(conf, context, new SpoutOutputCollector(_tracker));
}
Also used : ISpoutOutputCollector(backtype.storm.spout.ISpoutOutputCollector) SpoutOutputCollector(backtype.storm.spout.SpoutOutputCollector)

Example 3 with SpoutOutputCollector

use of backtype.storm.spout.SpoutOutputCollector in project jstorm by alibaba.

the class RichSpoutBatchTriggerer method open.

@Override
public void open(Map conf, TopologyContext context, SpoutOutputCollector collector) {
    _delegate.open(conf, context, new SpoutOutputCollector(new StreamOverrideCollector(collector)));
    _outputTasks = new ArrayList<>();
    for (String component : Utils.get(context.getThisTargets(), _coordStream, new HashMap<String, Grouping>()).keySet()) {
        _outputTasks.addAll(context.getComponentTasks(component));
    }
    _rand = new Random(Utils.secureRandomLong());
}
Also used : Random(java.util.Random) HashMap(java.util.HashMap) SpoutOutputCollector(backtype.storm.spout.SpoutOutputCollector) ISpoutOutputCollector(backtype.storm.spout.ISpoutOutputCollector)

Example 4 with SpoutOutputCollector

use of backtype.storm.spout.SpoutOutputCollector in project jstorm by alibaba.

the class TransactionSpout method open.

@Override
public void open(Map conf, TopologyContext context, SpoutOutputCollector collector) {
    this.conf = conf;
    this.topologyContext = context;
    this.topologyId = topologyContext.getTopologyId();
    this.taskId = topologyContext.getThisTaskId();
    this.topologyMasterId = topologyContext.getTopologyMasterId();
    this.componentId = topologyContext.getThisComponentId();
    this.groupId = TransactionCommon.groupIndex(context.getRawTopology(), componentId);
    this.downstreamTasks = TransactionCommon.getDownstreamTasks(componentId, topologyContext);
    this.outputCollector = new TransactionSpoutOutputCollector(collector, this);
    this.spoutStatus = State.INIT;
    this.committingBatches = new TreeSet<Long>();
    this.isMaxPending = false;
    this.MAX_PENDING_BATCH_NUM = JStormUtils.parseInt(conf.get("transaction.max.pending.batch"), 2);
    int taskLaunchTimeout = JStormUtils.parseInt(conf.get(Config.NIMBUS_TASK_LAUNCH_SECS));
    int spoutInitRetryDelaySec = JStormUtils.parseInt(conf.get("transaction.spout.init.retry.secs"), taskLaunchTimeout);
    this.initRetryCheck = new IntervalCheck();
    initRetryCheck.setInterval(spoutInitRetryDelaySec);
    this.lock = new ReentrantLock(true);
    spoutExecutor.open(conf, context, new SpoutOutputCollector(outputCollector));
}
Also used : ReentrantLock(java.util.concurrent.locks.ReentrantLock) SpoutOutputCollector(backtype.storm.spout.SpoutOutputCollector) IntervalCheck(com.alibaba.jstorm.utils.IntervalCheck)

Example 5 with SpoutOutputCollector

use of backtype.storm.spout.SpoutOutputCollector in project pulsar by yahoo.

the class PulsarSpoutTest method testSharedConsumer.

@Test
public void testSharedConsumer() throws Exception {
    PersistentTopicStats topicStats = admin.persistentTopics().getStats(topic);
    Assert.assertEquals(topicStats.subscriptions.get(subscriptionName).consumers.size(), 1);
    PulsarSpout otherSpout = new PulsarSpout(pulsarSpoutConf, new ClientConfiguration(), consumerConf);
    MockSpoutOutputCollector otherMockCollector = new MockSpoutOutputCollector();
    SpoutOutputCollector collector = new SpoutOutputCollector(otherMockCollector);
    TopologyContext context = mock(TopologyContext.class);
    when(context.getThisComponentId()).thenReturn("test-spout-" + methodName);
    when(context.getThisTaskId()).thenReturn(1);
    otherSpout.open(Maps.newHashMap(), context, collector);
    topicStats = admin.persistentTopics().getStats(topic);
    Assert.assertEquals(topicStats.subscriptions.get(subscriptionName).consumers.size(), 1);
    otherSpout.close();
    topicStats = admin.persistentTopics().getStats(topic);
    Assert.assertEquals(topicStats.subscriptions.get(subscriptionName).consumers.size(), 1);
}
Also used : SpoutOutputCollector(backtype.storm.spout.SpoutOutputCollector) PersistentTopicStats(com.yahoo.pulsar.common.policies.data.PersistentTopicStats) TopologyContext(backtype.storm.task.TopologyContext) ClientConfiguration(com.yahoo.pulsar.client.api.ClientConfiguration) Test(org.testng.annotations.Test)

Aggregations

SpoutOutputCollector (backtype.storm.spout.SpoutOutputCollector)12 TopologyContext (backtype.storm.task.TopologyContext)7 HashMap (java.util.HashMap)6 ISpoutOutputCollector (backtype.storm.spout.ISpoutOutputCollector)4 Test (org.junit.Test)4 ClientConfiguration (com.yahoo.pulsar.client.api.ClientConfiguration)3 PersistentTopicStats (com.yahoo.pulsar.common.policies.data.PersistentTopicStats)2 Random (java.util.Random)2 Test (org.testng.annotations.Test)2 IntervalCheck (com.alibaba.jstorm.utils.IntervalCheck)1 ConsumerConfiguration (com.yahoo.pulsar.client.api.ConsumerConfiguration)1 ReentrantLock (java.util.concurrent.locks.ReentrantLock)1