本文整理汇总了Java中org.apache.storm.testing.FeederSpout.feed方法的典型用法代码示例。如果您正苦于以下问题:Java FeederSpout.feed方法的具体用法?Java FeederSpout.feed怎么用?Java FeederSpout.feed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.storm.testing.FeederSpout
的用法示例。
在下文中一共展示了FeederSpout.feed方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: BasicTickTest
import org.apache.storm.testing.FeederSpout; //导入方法依赖的package包/类
@Test
public void BasicTickTest() throws IOException {
System.out.println("==> Starting BasicTickTest");
String spoutId = "feeder.spout";
String boltId = "tick.bolt";
String topoId = "TestTopology";
TopologyBuilder builder = new TopologyBuilder();
FeederSpout spout = TickBoltTest.createFeeder();
builder.setSpout(spoutId, spout);
SimpleStatefulTick tickBolt = new SimpleStatefulTick();
builder.setBolt(boltId, tickBolt).shuffleGrouping(spoutId);
LocalCluster cluster = new LocalCluster();
cluster.submitTopology(topoId, TestUtils.stormConfig(), builder.createTopology());
/* Let's Submit Stuff! */
Uninterruptibles.sleepUninterruptibly(1, TimeUnit.SECONDS);
spout.feed(Arrays.asList(new String[]{"key1", "msg1"}));
/* And sleep some more */
Uninterruptibles.sleepUninterruptibly(6, TimeUnit.SECONDS);
// TODO: this test isn't great .. the number of lines in the file from ticks could vary
int expectedLines = 3;
Assert.assertTrue("We should have at least " + expectedLines + " lines in the test file.",
expectedLines <= tickBolt.tickFile.numLines());
Assert.assertEquals(1, tickBolt.workFile.numLines());
cluster.killTopology(topoId);
Utils.sleep(4 * 1000);
}
示例2: generateGenderData
import org.apache.storm.testing.FeederSpout; //导入方法依赖的package包/类
private static void generateGenderData(FeederSpout genderSpout) {
for (int i = 0; i < 10; i++) {
String gender;
if (i % 2 == 0) {
gender = "male";
}
else {
gender = "female";
}
genderSpout.feed(new Values(i, gender));
}
}
示例3: main
import org.apache.storm.testing.FeederSpout; //导入方法依赖的package包/类
public static void main(String[] args) {
FeederSpout genderSpout = new FeederSpout(new Fields("id", "gender"));
FeederSpout ageSpout = new FeederSpout(new Fields("id", "age"));
TopologyBuilder builder = new TopologyBuilder();
builder.setSpout("gender", genderSpout);
builder.setSpout("age", ageSpout);
builder.setBolt("join", new SingleJoinBolt(new Fields("gender", "age"))).fieldsGrouping("gender", new Fields("id"))
.fieldsGrouping("age", new Fields("id"));
Config conf = new Config();
conf.setDebug(true);
LocalCluster cluster = new LocalCluster();
cluster.submitTopology("join-example", conf, builder.createTopology());
for (int i = 0; i < 10; i++) {
String gender;
if (i % 2 == 0) {
gender = "male";
}
else {
gender = "female";
}
genderSpout.feed(new Values(i, gender));
}
for (int i = 9; i >= 0; i--) {
ageSpout.feed(new Values(i, i + 20));
}
Utils.sleep(2000);
cluster.shutdown();
}
示例4: main
import org.apache.storm.testing.FeederSpout; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
final FeederSpout genderSpout = new FeederSpout(new Fields("id", "gender", "hobbies"));
final FeederSpout ageSpout = new FeederSpout(new Fields("id", "age"));
Config conf = new Config();
TopologyBuilder builder = new TopologyBuilder();
// only required to stabilize integration test
conf.put(FlinkLocalCluster.SUBMIT_BLOCKING, true);
final NullTerminatingSpout finalGenderSpout = new NullTerminatingSpout(genderSpout);
final NullTerminatingSpout finalAgeSpout = new NullTerminatingSpout(ageSpout);
builder.setSpout("gender", finalGenderSpout);
builder.setSpout("age", finalAgeSpout);
builder.setBolt("join", new SingleJoinBolt(new Fields("gender", "age")))
.fieldsGrouping("gender", new Fields("id"))
.fieldsGrouping("age", new Fields("id"));
// emit result
if (args.length > 0) {
// read the text file from given input path
builder.setBolt("fileOutput", new BoltFileSink(args[0], new TupleOutputFormatter()))
.shuffleGrouping("join");
} else {
builder.setBolt("print", new PrinterBolt()).shuffleGrouping("join");
}
String[] hobbies = new String[] {"reading", "biking", "travelling", "watching tv"};
for (int i = 0; i < 10; i++) {
String gender;
if (i % 2 == 0) {
gender = "male";
}
else {
gender = "female";
}
genderSpout.feed(new Values(i, gender, hobbies[i % hobbies.length]));
}
for (int i = 9; i >= 0; i--) {
ageSpout.feed(new Values(i, i + 20));
}
final FlinkLocalCluster cluster = FlinkLocalCluster.getLocalCluster();
cluster.submitTopology("joinTopology", conf, FlinkTopology.createTopology(builder));
cluster.shutdown();
}
示例5: generateAgeData
import org.apache.storm.testing.FeederSpout; //导入方法依赖的package包/类
private static void generateAgeData(FeederSpout ageSpout) {
for (int i = 9; i >= 0; i--) {
ageSpout.feed(new Values(i, i + 20));
}
}