Search in sources :

Example 6 with SpoutOutputCollector

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

the class PulsarSpoutTest method setup.

@Override
protected void setup() throws Exception {
    super.internalSetup();
    super.producerBaseSetup();
    pulsarSpoutConf = new PulsarSpoutConfiguration();
    pulsarSpoutConf.setServiceUrl(serviceUrl);
    pulsarSpoutConf.setTopic(topic);
    pulsarSpoutConf.setSubscriptionName(subscriptionName);
    pulsarSpoutConf.setMessageToValuesMapper(messageToValuesMapper);
    pulsarSpoutConf.setFailedRetriesTimeout(1, TimeUnit.SECONDS);
    pulsarSpoutConf.setMaxFailedRetries(2);
    pulsarSpoutConf.setSharedConsumerEnabled(true);
    pulsarSpoutConf.setMetricsTimeIntervalInSecs(60);
    consumerConf = new ConsumerConfiguration();
    consumerConf.setSubscriptionType(SubscriptionType.Shared);
    spout = new PulsarSpout(pulsarSpoutConf, new ClientConfiguration(), consumerConf);
    mockCollector = new MockSpoutOutputCollector();
    SpoutOutputCollector collector = new SpoutOutputCollector(mockCollector);
    TopologyContext context = mock(TopologyContext.class);
    when(context.getThisComponentId()).thenReturn("test-spout-" + methodName);
    when(context.getThisTaskId()).thenReturn(0);
    spout.open(Maps.newHashMap(), context, collector);
    producer = pulsarClient.createProducer(topic);
}
Also used : SpoutOutputCollector(backtype.storm.spout.SpoutOutputCollector) ConsumerConfiguration(com.yahoo.pulsar.client.api.ConsumerConfiguration) TopologyContext(backtype.storm.task.TopologyContext) ClientConfiguration(com.yahoo.pulsar.client.api.ClientConfiguration)

Example 7 with SpoutOutputCollector

use of backtype.storm.spout.SpoutOutputCollector 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 8 with SpoutOutputCollector

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

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 9 with SpoutOutputCollector

use of backtype.storm.spout.SpoutOutputCollector in project kafka-spout by HolmesNL.

the class KafkaSpoutConstructorTest method testOpenWithDefaultTopicName.

/**
     * Using the default constructor, a topic name must be in the storm config.
     */
@Test
public void testOpenWithDefaultTopicName() {
    KafkaSpout spout = spy(new KafkaSpout());
    TopologyContext topology = mock(TopologyContext.class);
    SpoutOutputCollector collector = mock(SpoutOutputCollector.class);
    Map<String, Object> config = new HashMap<String, Object>();
    doNothing().when(spout).createConsumer(config);
    spout.open(config, topology, collector);
    assertEquals("Wrong Topic Name", spout._topic, ConfigUtils.DEFAULT_TOPIC);
}
Also used : HashMap(java.util.HashMap) SpoutOutputCollector(backtype.storm.spout.SpoutOutputCollector) TopologyContext(backtype.storm.task.TopologyContext) Test(org.junit.Test)

Example 10 with SpoutOutputCollector

use of backtype.storm.spout.SpoutOutputCollector in project kafka-spout by HolmesNL.

the class KafkaSpoutConstructorTest method testOpenWithOverloadedConstructor.

/**
     * If we use the overloaded constructor, do not even look at the storm config for the topic name.
     */
@Test
public void testOpenWithOverloadedConstructor() {
    KafkaSpout spout = spy(new KafkaSpout("OVERLOAD"));
    TopologyContext topology = mock(TopologyContext.class);
    SpoutOutputCollector collector = mock(SpoutOutputCollector.class);
    Map<String, Object> config = new HashMap<String, Object>();
    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)

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