本文整理汇总了Java中storm.trident.testing.FixedBatchSpout类的典型用法代码示例。如果您正苦于以下问题:Java FixedBatchSpout类的具体用法?Java FixedBatchSpout怎么用?Java FixedBatchSpout使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FixedBatchSpout类属于storm.trident.testing包,在下文中一共展示了FixedBatchSpout类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildTopology
import storm.trident.testing.FixedBatchSpout; //导入依赖的package包/类
public static StormTopology buildTopology(LocalDRPC drpc) {
FixedBatchSpout spout = new FixedBatchSpout(new Fields("sentence"), 3, new Values("the cow jumped over the moon"),
new Values("the man went to the store and bought some candy"), new Values("four score and seven years ago"),
new Values("how many apples can you eat"), new Values("to be or not to be the person"));
spout.setCycle(true);
TridentTopology topology = new TridentTopology();
TridentState wordCounts = topology.newStream("spout1", spout).parallelismHint(16).each(new Fields("sentence"),
new Split(), new Fields("word")).groupBy(new Fields("word")).persistentAggregate(new MemoryMapState.Factory(),
new Count(), new Fields("count")).parallelismHint(16);
topology.newDRPCStream("words", drpc).each(new Fields("args"), new Split(), new Fields("word")).groupBy(new Fields(
"word")).stateQuery(wordCounts, new Fields("word"), new MapGet(), new Fields("count")).each(new Fields("count"),
new FilterNull()).aggregate(new Fields("count"), new Sum(), new Fields("sum"));
return topology.build();
}
示例2: buildTopology
import storm.trident.testing.FixedBatchSpout; //导入依赖的package包/类
public static StormTopology buildTopology(LocalDRPC drpc) {
FixedBatchSpout spout = new FixedBatchSpout(new Fields("sentence"), 3,
new Values("the$$cow$$jumped$$over$$the$$moon"),
new Values("the$$man$$went$$to$$the$$store$$and$$bought$$some$$candy"),
new Values("four$$score$$and$$seven$$years$$ago"),
new Values("how$$many$$apples$$can$$you$$eat"),
new Values("to$$be$$or$$not$$to$$be$$the$$person"));
spout.setCycle(true);
TridentTopology topology = new TridentTopology();
TridentState wordCounts = topology.newStream("spout1", spout)
.each(new Fields("sentence"), new Split(), new Fields("word"))
.groupBy(new Fields("word"))
.persistentAggregate(new MemoryMapState.Factory(), new Count(), new Fields("count"))
.parallelismHint(6);
topology.newDRPCStream("words", drpc).each(new Fields("args"), new Split(), new Fields("word"))
.groupBy(new Fields("word"))
.stateQuery(wordCounts, new Fields("word"), new MapGet(), new Fields("count"))
.each(new Fields("count"), new FilterNull())
.aggregate(new Fields("count"), new Sum(), new Fields("sum"));
return topology.build();
}
示例3: buildTopology
import storm.trident.testing.FixedBatchSpout; //导入依赖的package包/类
public static StormTopology buildTopology(Map config) {
FixedBatchSpout spout = new FixedBatchSpout(new Fields("sentence", "key"), 1000, new Values("the cow jumped over the moon", 1l),
new Values("the man went to the store and bought some candy", 2l), new Values("four score and seven years ago", 3l),
new Values("how many apples can you eat", 4l), new Values("to be or not to be the person", 5l));
spout.setCycle(true);
TridentTopology topology = new TridentTopology();
Stream stream = topology.newStream("spout1", spout);
Fields fields = new Fields("sentence", "key");
config.put(PREFIX, "trident");
config.put(EXTENSION, ".txt");
config.put(PATH, "trident");
config.put(OUTPUT_FIELDS, Arrays.asList("sentence"));
config.put(ROTATION_SIZE, 10.0F);
config.put(ROTATION_UNIT, "KB");
config.put(CONTENT_TYPE, "text/plain");
StateFactory factory = new S3StateFactory();
stream.partitionPersist(factory, fields, new S3Updater(), new Fields()).parallelismHint(3);
return topology.build();
}
示例4: buildTopology
import storm.trident.testing.FixedBatchSpout; //导入依赖的package包/类
@Override
protected StormTopology buildTopology() {
FixedBatchSpout spout = new FixedBatchSpout(new Fields("sentence"), 3,
new Values("the cow jumped over the moon"),
new Values("the man went to the store and bought some candy"),
new Values("four score and seven years ago"),
new Values("how many apples can you eat"),
new Values("to be or not to be the person"));
spout.setCycle(true);
ESIndexState.Factory<Tweet> factory = new ESIndexState.Factory<>(getLocalClient(), Tweet.class);
TridentTopology topology = new TridentTopology();
TridentState state = topology.newStream("tweets", spout)
.partitionPersist(factory, new Fields("sentence"), new ESIndexUpdater(new MyTridentTupleMapper()));
topology.newDRPCStream("search", drpc)
.each(new Fields("args"), new ExtractSearchArgs(), new Fields("query", "indices", "types"))
.groupBy(new Fields("query", "indices", "types"))
.stateQuery(state, new Fields("query", "indices", "types"), new QuerySearchIndexQuery(), new Fields("tweet"))
.each(new Fields("tweet"), new FilterNull())
.each(new Fields("tweet"), new CreateJson(), new Fields("json"))
.project(new Fields("json"));
return topology.build();
}
示例5: buildTopology
import storm.trident.testing.FixedBatchSpout; //导入依赖的package包/类
public static StormTopology buildTopology(LocalDRPC drpc) {
FixedBatchSpout spout = new FixedBatchSpout(new Fields("sentence"), 3,
new Values("the cow jumped over the moon"),
new Values("the man went to the store and bought some candy"),
new Values("four score and seven years ago"), new Values("how many apples can you eat"),
new Values("to be or not to be the person"));
spout.setCycle(true);
TridentTopology topology = new TridentTopology();
TridentState wordCounts = topology.newStream("spout1", spout).parallelismHint(16)
.each(new Fields("sentence"), new Split(), new Fields("word")).groupBy(new Fields("word"))
.persistentAggregate(new MemoryMapState.Factory(), new Count(), new Fields("count"))
.parallelismHint(16);
topology.newDRPCStream("words", drpc).each(new Fields("args"), new Split(), new Fields("word"))
.groupBy(new Fields("word"))
.stateQuery(wordCounts, new Fields("word"), new MapGet(), new Fields("count"))
.each(new Fields("count"), new FilterNull())
.aggregate(new Fields("count"), new Sum(), new Fields("sum"));
return topology.build();
}
示例6: buildTopology
import storm.trident.testing.FixedBatchSpout; //导入依赖的package包/类
public static StormTopology buildTopology(LocalDRPC drpc) {
FixedBatchSpout spout = new FixedBatchSpout(new Fields("word"), 3, new Values("the cow jumped over the moon"),
new Values("the man went to the store and bought some candy"),
new Values("four score and seven years ago"), new Values("how many apples can you eat"),
new Values("to be or not to be the person"));
spout.setCycle(true);
TridentTopology topology = new TridentTopology();
TridentState wordCounts = topology.newStream("spout1", spout).parallelismHint(16).flatMap(split).map(toUpper)
.filter(theFilter).peek(new Consumer() {
@Override
public void accept(TridentTuple input) {
System.out.println(input.getString(0));
}
}).groupBy(new Fields("word"))
.persistentAggregate(new MemoryMapState.Factory(), new Count(), new Fields("count"))
.parallelismHint(16);
topology.newDRPCStream("words", drpc).flatMap(split).groupBy(new Fields("args"))
.stateQuery(wordCounts, new Fields("args"), new MapGet(), new Fields("count")).filter(new FilterNull())
.aggregate(new Fields("count"), new Sum(), new Fields("sum"));
return topology.build();
}
示例7: buildTopology
import storm.trident.testing.FixedBatchSpout; //导入依赖的package包/类
public static StormTopology buildTopology(WindowsStoreFactory windowStore, WindowConfig windowConfig)
throws Exception {
FixedBatchSpout spout = new FixedBatchSpout(new Fields("sentence"), 3,
new Values("the cow jumped over the moon"),
new Values("the man went to the store and bought some candy"),
new Values("four score and seven years ago"), new Values("how many apples can you eat"),
new Values("to be or not to be the person"));
spout.setCycle(true);
TridentTopology topology = new TridentTopology();
Stream stream = topology.newStream("spout1", spout).parallelismHint(16)
.each(new Fields("sentence"), new Split(), new Fields("word"))
.window(windowConfig, windowStore, new Fields("word"), new CountAsAggregator(), new Fields("count"))
.peek(new Consumer() {
@Override
public void accept(TridentTuple input) {
LOG.info("Received tuple: [{}]", input);
}
});
return topology.build();
}
示例8: buildVehiclesTopology
import storm.trident.testing.FixedBatchSpout; //导入依赖的package包/类
/**
* Creates a topology which demonstrates min/max operations on tuples of
* stream which contain vehicle and driver fields with values
* {@link TridentMinMaxOfDevicesTopology.Vehicle} and
* {@link TridentMinMaxOfDevicesTopology.Driver} respectively.
*/
public static StormTopology buildVehiclesTopology() {
Fields driverField = new Fields(Driver.FIELD_NAME);
Fields vehicleField = new Fields(Vehicle.FIELD_NAME);
Fields allFields = new Fields(Vehicle.FIELD_NAME, Driver.FIELD_NAME);
FixedBatchSpout spout = new FixedBatchSpout(allFields, 10, Vehicle.generateVehicles(20));
spout.setCycle(true);
TridentTopology topology = new TridentTopology();
Stream vehiclesStream = topology.newStream("spout1", spout).each(allFields, new Debug("##### vehicles"));
Stream slowVehiclesStream = vehiclesStream.min(new SpeedComparator()).each(vehicleField,
new Debug("#### slowest vehicle"));
Stream slowDriversStream = slowVehiclesStream.project(driverField).each(driverField,
new Debug("##### slowest driver"));
vehiclesStream.max(new SpeedComparator()).each(vehicleField, new Debug("#### fastest vehicle"))
.project(driverField).each(driverField, new Debug("##### fastest driver"));
vehiclesStream.max(new EfficiencyComparator()).each(vehicleField, new Debug("#### efficient vehicle"));
return topology.build();
}
示例9: getTopology
import storm.trident.testing.FixedBatchSpout; //导入依赖的package包/类
public StormTopology getTopology(Config config) {
this.spout = new FixedBatchSpout(new Fields("sentence"), 20,
new Values("one two"),
new Values("two three"),
new Values("three four"),
new Values("four five"),
new Values("five six")
);
TridentTopology trident = new TridentTopology();
trident.newStream("wordcount", spout).name("sentence").parallelismHint(1).shuffle()
.each(new Fields("sentence"), new Split(), new Fields("word"))
.parallelismHint(1)
.groupBy(new Fields("word"))
.persistentAggregate(new MemoryMapState.Factory(), new Count(), new Fields("count"))
.parallelismHint(1);
return trident.build();
}
示例10: buildWordCountAndSourceTopology
import storm.trident.testing.FixedBatchSpout; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public static StormTopology buildWordCountAndSourceTopology(LocalDRPC drpc) {
LOG.info("Building topology.");
TridentTopology topology = new TridentTopology();
String source1 = "spout1";
String source2 = "spout2";
FixedBatchSpout spout1 = new FixedBatchSpout(new Fields("sentence", "source"), 3,
new Values("the cow jumped over the moon", source1),
new Values("the man went to the store and bought some candy", source1),
new Values("four score and four years ago", source2),
new Values("how much wood can a wood chuck chuck", source2));
spout1.setCycle(true);
TridentState wordCounts =
topology.newStream("spout1", spout1)
.each(new Fields("sentence"), new Split(), new Fields("word"))
.groupBy(new Fields("word", "source"))
.persistentAggregate(CassandraCqlMapState.nonTransactional(new WordCountAndSourceMapper()),
new IntegerCount(), new Fields("count"))
.parallelismHint(6);
topology.newDRPCStream("words", drpc)
.each(new Fields("args"), new Split(), new Fields("word"))
.groupBy(new Fields("word"))
.stateQuery(wordCounts, new Fields("word"), new MapGet(), new Fields("count"))
.each(new Fields("count"), new FilterNull())
.aggregate(new Fields("count"), new Sum(), new Fields("sum"));
return topology.build();
}
示例11: buildTopology1
import storm.trident.testing.FixedBatchSpout; //导入依赖的package包/类
private static StormTopology buildTopology1(LocalDRPC drpc) {
FixedBatchSpout spout = new FixedBatchSpout(new Fields("sentence"), 100,
new Values("the cow jumped over the moon"),
new Values("the man went to the store and bought some candy"),
new Values("to be or not to be the person"));
spout.setCycle(true);
AerospikeOptions options = new AerospikeOptions();
options.set = "words";
options.keyType = AerospikeOptions.AerospikeKeyType.STRING;
TridentTopology topology = new TridentTopology();
TridentState wordCounts =
topology.newStream("spout1", spout)
.parallelismHint(4)
.each(new Fields("sentence"), new Split(), new Fields("word"))
.groupBy(new Fields("word"))
.persistentAggregate(AerospikeSingleBinMapState.getTransactional("count", options),
new CountAggregator(), new Fields("count"))
.parallelismHint(4);
topology.newDRPCStream("words", drpc)
.each(new Fields("args"), new Split(), new Fields("word"))
.groupBy(new Fields("word"))
.stateQuery(wordCounts, new Fields("word"), new MapGet(), new Fields("count"))
.each(new Fields("count"), new FilterNull())
.aggregate(new Fields("count"), new Sum(), new Fields("sum"));
return topology.build();
}
示例12: buildTopology2
import storm.trident.testing.FixedBatchSpout; //导入依赖的package包/类
private static StormTopology buildTopology2(LocalDRPC drpc) {
FixedBatchSpout spout = new FixedBatchSpout(new Fields("customerid", "fruit"), 100,
new Values(1L, "apple"),
new Values(1L, "apple"),
new Values(1L, "apple"),
new Values(1L, "pear"),
new Values(2L, "pear"),
new Values(2L, "orange"),
new Values(3L, "orange"),
new Values(3L, "orange"),
new Values(3L, "banana"));
spout.setCycle(true);
AerospikeOptions options = new AerospikeOptions();
options.set = "customers";
options.keyType = AerospikeOptions.AerospikeKeyType.LONG;
TridentTopology topology = new TridentTopology();
TridentState fruitCounts =
topology.newStream("spout2", spout)
.parallelismHint(4)
.groupBy(new Fields("customerid", "fruit"))
.persistentAggregate(AerospikeSplitKeySingleBinMapState.getTransactional("fruits", options),
new CountAggregator(), new Fields("count"))
.parallelismHint(4);
topology.newDRPCStream("fruits", drpc)
.each(new Fields("args"), new SplitIntoTwo(), new Fields("customerid", "fruit"))
.groupBy(new Fields("customerid", "fruit"))
.stateQuery(fruitCounts, new Fields("customerid", "fruit"), new MapGet(), new Fields("count"))
.each(new Fields("count"), new FilterNull())
.project(new Fields("count"));
return topology.build();
}
示例13: setUp
import storm.trident.testing.FixedBatchSpout; //导入依赖的package包/类
private void setUp() {
TridentTopology topology = new TridentTopology();
@SuppressWarnings("unchecked")
FixedBatchSpout spout = new FixedBatchSpout(
new Fields("sentence"), 3,
new Values("the cow jumped over the moon"),
new Values("the man went to the store and bought some candy"),
new Values("four score and seven years ago"),
new Values("how many apples can you eat"));
spout.setCycle(true);
Stream stream = topology.newStream("spout1", spout);
}
示例14: buildTopology
import storm.trident.testing.FixedBatchSpout; //导入依赖的package包/类
@Override
public StormTopology buildTopology( ) {
ESIndexMapState.Factory<Tweet> state = ESIndexMapState.nonTransactional(getLocalClient(), Tweet.class);
FixedBatchSpout spout = new FixedBatchSpout(new Fields("sentence"), 3,
new Values("the cow jumped over the moon"),
new Values("the man went to the store and bought some candy"),
new Values("four score and seven years ago"),
new Values("how many apples can you eat"),
new Values("to be or not to be the person"));
spout.setCycle(true);
TridentTopology topology = new TridentTopology();
TridentState staticState = topology.newStaticState(new ESIndexState.Factory<>(getLocalClient(), Tweet.class));
topology.newStream("tweets", spout)
.each(new Fields("sentence"), new DocumentBuilder(), new Fields("document"))
.each(new Fields("document"), new ExtractDocumentInfo(), new Fields("id", "index", "type"))
.groupBy(new Fields("index", "type", "id"))
.persistentAggregate(state, new Fields("document"), new TweetBuilder(), new Fields("tweet"))
.parallelismHint(1);
topology.newDRPCStream("search", drpc)
.each(new Fields("args"), new ExtractSearchArgs(), new Fields("query", "indices", "types"))
.groupBy(new Fields("query", "indices", "types"))
.stateQuery(staticState, new Fields("query", "indices", "types"), new QuerySearchIndexQuery(), new Fields("tweet"))
.each(new Fields("tweet"), new FilterNull())
.each(new Fields("tweet"), new CreateJson(), new Fields("json"))
.project(new Fields("json"));
return topology.build();
}
示例15: buildTopology
import storm.trident.testing.FixedBatchSpout; //导入依赖的package包/类
public static StormTopology buildTopology(LocalDRPC drpc) {
FixedBatchSpout spout = new FixedBatchSpout(new Fields("sentence"), 3,
new Values("the cow jumped over the moon"),
new Values("the man went to the store and bought some candy"),
new Values("four score and seven years ago"),
new Values("how many apples can you eat"),
new Values("to be or not to be the person"));
spout.setCycle(true);
TridentTopology topology = new TridentTopology();
TridentState wordCounts =
topology.newStream("spout1", spout)
.parallelismHint(16)
.each(new Fields("sentence"), new Split(), new Fields("word"))
.groupBy(new Fields("word"))
.persistentAggregate(new MemoryMapState.Factory(),
new Count(), new Fields("count"))
.parallelismHint(16);
topology.newDRPCStream("words", drpc)
.each(new Fields("args"), new Split(), new Fields("word"))
.groupBy(new Fields("word"))
.stateQuery(wordCounts, new Fields("word"), new MapGet(), new Fields("count"))
.each(new Fields("count"), new FilterNull())
.aggregate(new Fields("count"), new Sum(), new Fields("sum"))
;
return topology.build();
}