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()));
}
}
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"));
}
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);
}
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());
}
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();
}
Aggregations