Search in sources :

Example 1 with RocketMqStateUpdater

use of org.apache.storm.rocketmq.trident.state.RocketMqStateUpdater in project storm by apache.

the class WordCountTrident method buildTopology.

public static StormTopology buildTopology(String nameserverAddr, String topic) {
    Fields fields = new Fields("word", "count");
    FixedBatchSpout spout = new FixedBatchSpout(fields, 4, new Values("storm", 1), new Values("trident", 1), new Values("needs", 1), new Values("javadoc", 1));
    spout.setCycle(true);
    TupleToMessageMapper mapper = new FieldNameBasedTupleToMessageMapper("word", "count");
    TopicSelector selector = new DefaultTopicSelector(topic);
    Properties properties = new Properties();
    properties.setProperty(RocketMqConfig.NAME_SERVER_ADDR, nameserverAddr);
    RocketMqState.Options options = new RocketMqState.Options().withMapper(mapper).withSelector(selector).withProperties(properties);
    StateFactory factory = new RocketMqStateFactory(options);
    TridentTopology topology = new TridentTopology();
    Stream stream = topology.newStream("spout1", spout);
    stream.partitionPersist(factory, fields, new RocketMqStateUpdater(), new Fields());
    return topology.build();
}
Also used : FieldNameBasedTupleToMessageMapper(org.apache.storm.rocketmq.common.mapper.FieldNameBasedTupleToMessageMapper) TopicSelector(org.apache.storm.rocketmq.common.selector.TopicSelector) DefaultTopicSelector(org.apache.storm.rocketmq.common.selector.DefaultTopicSelector) Values(org.apache.storm.tuple.Values) Properties(java.util.Properties) FixedBatchSpout(org.apache.storm.trident.testing.FixedBatchSpout) Fields(org.apache.storm.tuple.Fields) StateFactory(org.apache.storm.trident.state.StateFactory) RocketMqStateFactory(org.apache.storm.rocketmq.trident.state.RocketMqStateFactory) TupleToMessageMapper(org.apache.storm.rocketmq.common.mapper.TupleToMessageMapper) FieldNameBasedTupleToMessageMapper(org.apache.storm.rocketmq.common.mapper.FieldNameBasedTupleToMessageMapper) TridentTopology(org.apache.storm.trident.TridentTopology) DefaultTopicSelector(org.apache.storm.rocketmq.common.selector.DefaultTopicSelector) Stream(org.apache.storm.trident.Stream) RocketMqStateUpdater(org.apache.storm.rocketmq.trident.state.RocketMqStateUpdater) RocketMqState(org.apache.storm.rocketmq.trident.state.RocketMqState) RocketMqStateFactory(org.apache.storm.rocketmq.trident.state.RocketMqStateFactory)

Aggregations

Properties (java.util.Properties)1 FieldNameBasedTupleToMessageMapper (org.apache.storm.rocketmq.common.mapper.FieldNameBasedTupleToMessageMapper)1 TupleToMessageMapper (org.apache.storm.rocketmq.common.mapper.TupleToMessageMapper)1 DefaultTopicSelector (org.apache.storm.rocketmq.common.selector.DefaultTopicSelector)1 TopicSelector (org.apache.storm.rocketmq.common.selector.TopicSelector)1 RocketMqState (org.apache.storm.rocketmq.trident.state.RocketMqState)1 RocketMqStateFactory (org.apache.storm.rocketmq.trident.state.RocketMqStateFactory)1 RocketMqStateUpdater (org.apache.storm.rocketmq.trident.state.RocketMqStateUpdater)1 Stream (org.apache.storm.trident.Stream)1 TridentTopology (org.apache.storm.trident.TridentTopology)1 StateFactory (org.apache.storm.trident.state.StateFactory)1 FixedBatchSpout (org.apache.storm.trident.testing.FixedBatchSpout)1 Fields (org.apache.storm.tuple.Fields)1 Values (org.apache.storm.tuple.Values)1