Search in sources :

Example 71 with Fields

use of backtype.storm.tuple.Fields in project storm by nathanmarz.

the class ClojureSpout method declareOutputFields.

@Override
public void declareOutputFields(OutputFieldsDeclarer declarer) {
    for (String stream : _fields.keySet()) {
        StreamInfo info = _fields.get(stream);
        declarer.declareStream(stream, info.is_direct(), new Fields(info.get_output_fields()));
    }
}
Also used : Fields(backtype.storm.tuple.Fields) StreamInfo(backtype.storm.generated.StreamInfo)

Example 72 with Fields

use of backtype.storm.tuple.Fields in project storm by nathanmarz.

the class CoordinatedBolt method declareOutputFields.

public void declareOutputFields(OutputFieldsDeclarer declarer) {
    _delegate.declareOutputFields(declarer);
    declarer.declareStream(Constants.COORDINATED_STREAM_ID, true, new Fields("id", "count"));
}
Also used : Fields(backtype.storm.tuple.Fields)

Example 73 with Fields

use of backtype.storm.tuple.Fields in project visitante by pranab.

the class UniqueVisitorTopology method main.

/**
 * @param args
 * @throws Exception
 */
public static void main(String[] args) throws Exception {
    if (args.length != 2) {
        throw new IllegalArgumentException("Need two arguments: topology name and config file path");
    }
    String topologyName = args[0];
    String configFilePath = args[1];
    Config conf = RealtimeUtil.buildStormConfig(configFilePath);
    boolean debugOn = ConfigUtility.getBoolean(conf, "debug.on", false);
    System.out.println("config file:" + configFilePath + " debugOn:" + debugOn);
    conf.put(Config.TOPOLOGY_DEBUG, debugOn);
    // spout
    TopologyBuilder builder = new TopologyBuilder();
    int spoutThreads = ConfigUtility.getInt(conf, "spout.threads", 1);
    UniqueVisitorSpout spout = new UniqueVisitorSpout();
    spout.withTupleFields(PART_ID, USER_ID);
    builder.setSpout("unqueVisitorSpout", spout, spoutThreads);
    // unique count bolt
    int uniqueCountTickFreqInSec = ConfigUtility.getInt(conf, "unique.user.tick.freq.sec", 1);
    UniqueVisitorCounterBolt uniqueCountBolt = new UniqueVisitorCounterBolt(uniqueCountTickFreqInSec);
    uniqueCountBolt.withTupleFields(BOLT_ID, UNIQUE_COUNT);
    int boltThreads = ConfigUtility.getInt(conf, "unique.count.bolt.threads", 1);
    builder.setBolt("uniqueCountBolt", uniqueCountBolt, boltThreads).fieldsGrouping("unqueVisitorSpout", new Fields(PART_ID));
    // unique count aggregation bolt
    UniqueVisitorAggregatorBolt uniqueCountAggrBolt = new UniqueVisitorAggregatorBolt();
    boltThreads = ConfigUtility.getInt(conf, "unique.count.aggr.bolt.threads", 1);
    builder.setBolt("uniqueCountAggrBolt", uniqueCountAggrBolt, boltThreads).shuffleGrouping("uniqueCountBolt");
    // submit
    RealtimeUtil.submitStormTopology(topologyName, conf, builder);
}
Also used : Fields(backtype.storm.tuple.Fields) TopologyBuilder(backtype.storm.topology.TopologyBuilder) Config(backtype.storm.Config)

Example 74 with Fields

use of backtype.storm.tuple.Fields in project beymani by pranab.

the class OutlierPredictor method main.

public static void main(String[] args) throws Exception {
    String topologyName = args[0];
    String configFilePath = args[1];
    FileInputStream fis = new FileInputStream(configFilePath);
    Properties configProps = new Properties();
    configProps.load(fis);
    // intialize config
    Config conf = new Config();
    conf.setDebug(true);
    for (Object key : configProps.keySet()) {
        String keySt = key.toString();
        String val = configProps.getProperty(keySt);
        conf.put(keySt, val);
    }
    // spout
    TopologyBuilder builder = new TopologyBuilder();
    int spoutThreads = Integer.parseInt(configProps.getProperty("predictor.spout.threads"));
    builder.setSpout("predictorSpout", new PredictorSpout(), spoutThreads);
    // detector bolt
    int boltThreads = Integer.parseInt(configProps.getProperty("predictor.bolt.threads"));
    builder.setBolt("predictor", new PredictorBolt(), boltThreads).fieldsGrouping("predictorSpout", new Fields("entityID"));
    // submit topology
    int numWorkers = Integer.parseInt(configProps.getProperty("num.workers"));
    conf.setNumWorkers(numWorkers);
    StormSubmitter.submitTopology(topologyName, conf, builder.createTopology());
}
Also used : Fields(backtype.storm.tuple.Fields) TopologyBuilder(backtype.storm.topology.TopologyBuilder) Config(backtype.storm.Config) Properties(java.util.Properties) FileInputStream(java.io.FileInputStream)

Example 75 with Fields

use of backtype.storm.tuple.Fields in project storm-hbase by jrkinley.

the class HBaseTridentValueTopology method main.

/**
 * @param args
 * @throws InterruptedException
 */
@SuppressWarnings({ "unchecked", "rawtypes" })
public static void main(String[] args) throws InterruptedException {
    List<Object> v0 = HBaseCountersBatchTopology.values.get(0).get(0);
    List<Object> v1 = HBaseCountersBatchTopology.values.get(0).get(1);
    List<Object> v2 = HBaseCountersBatchTopology.values.get(0).get(2);
    List<Object> v3 = HBaseCountersBatchTopology.values.get(0).get(3);
    List<Object> v4 = HBaseCountersBatchTopology.values.get(0).get(4);
    FixedBatchSpout spout = new FixedBatchSpout(new Fields("shortid", "url", "user", "date"), 3, v0, v1, v2, v3, v4);
    spout.setCycle(true);
    // Trident updater
    TridentConfig updateConfig = new TridentConfig("shorturl", "shortid");
    updateConfig.setBatch(false);
    updateConfig.addColumn("data", "url");
    updateConfig.addColumn("data", "user");
    updateConfig.addColumn("data", "date");
    TridentTopology topology = new TridentTopology();
    topology.newStream("shorturls", spout).partitionPersist(new HBaseValueFactory(updateConfig), new Fields("shortid", "url", "user", "date"), new HBaseValueUpdater());
    Config conf = new Config();
    LocalCluster cluster = new LocalCluster();
    cluster.submitTopology("hbase-trident-updater", conf, topology.build());
    Utils.sleep(10000);
    cluster.shutdown();
}
Also used : FixedBatchSpout(storm.trident.testing.FixedBatchSpout) LocalCluster(backtype.storm.LocalCluster) Fields(backtype.storm.tuple.Fields) HBaseValueUpdater(backtype.storm.contrib.hbase.trident.HBaseValueUpdater) TridentTopology(storm.trident.TridentTopology) Config(backtype.storm.Config) TridentConfig(backtype.storm.contrib.hbase.utils.TridentConfig) HBaseValueFactory(backtype.storm.contrib.hbase.trident.HBaseValueFactory) TridentConfig(backtype.storm.contrib.hbase.utils.TridentConfig)

Aggregations

Fields (backtype.storm.tuple.Fields)130 TopologyBuilder (backtype.storm.topology.TopologyBuilder)41 Config (backtype.storm.Config)24 TridentTopology (storm.trident.TridentTopology)21 Map (java.util.Map)20 HashMap (java.util.HashMap)18 Test (org.junit.Test)17 JStormHelper (com.alibaba.starter.utils.JStormHelper)16 Values (backtype.storm.tuple.Values)15 ArrayList (java.util.ArrayList)13 LocalCluster (backtype.storm.LocalCluster)12 Stream (storm.trident.Stream)12 StreamInfo (backtype.storm.generated.StreamInfo)10 FixedBatchSpout (storm.trident.testing.FixedBatchSpout)9 HashSet (java.util.HashSet)8 LocalDRPC (backtype.storm.LocalDRPC)7 TridentState (storm.trident.TridentState)7 Count (storm.trident.operation.builtin.Count)7 GroupedStream (storm.trident.fluent.GroupedStream)6 IAggregatableStream (storm.trident.fluent.IAggregatableStream)6