当前位置: 首页>>代码示例>>Java>>正文


Java FeederSpout.feed方法代码示例

本文整理汇总了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);
}
 
开发者ID:telstra,项目名称:open-kilda,代码行数:34,代码来源:TickBoltTest.java

示例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));
    }
}
 
开发者ID:hortonworks,项目名称:streamline,代码行数:13,代码来源:RTJoinExampleTopology.java

示例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();
}
 
开发者ID:ziyunhx,项目名称:storm-net-adapter,代码行数:35,代码来源:SingleJoinExample.java

示例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();
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:49,代码来源:SingleJoinExample.java

示例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));
    }
}
 
开发者ID:hortonworks,项目名称:streamline,代码行数:6,代码来源:RTJoinExampleTopology.java


注:本文中的org.apache.storm.testing.FeederSpout.feed方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。