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


Java LocalDRPC类代码示例

本文整理汇总了Java中backtype.storm.LocalDRPC的典型用法代码示例。如果您正苦于以下问题:Java LocalDRPC类的具体用法?Java LocalDRPC怎么用?Java LocalDRPC使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


LocalDRPC类属于backtype.storm包,在下文中一共展示了LocalDRPC类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import backtype.storm.LocalDRPC; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
  LinearDRPCTopologyBuilder builder = construct();


  Config conf = new Config();

  if (args == null || args.length == 0) {
    conf.setMaxTaskParallelism(3);
    LocalDRPC drpc = new LocalDRPC();
    LocalCluster cluster = new LocalCluster();
    cluster.submitTopology("reach-drpc", conf, builder.createLocalTopology(drpc));

    String[] urlsToTry = new String[]{ "foo.com/blog/1", "engineering.twitter.com/blog/5", "notaurl.com" };
    for (String url : urlsToTry) {
      System.out.println("Reach of " + url + ": " + drpc.execute("reach", url));
    }

    cluster.shutdown();
    drpc.shutdown();
  }
  else {
    conf.setNumWorkers(6);
    StormSubmitter.submitTopologyWithProgressBar(args[0], conf, builder.createRemoteTopology());
  }
}
 
开发者ID:desp0916,项目名称:LearnStorm,代码行数:26,代码来源:ReachTopology.java

示例2: main

import backtype.storm.LocalDRPC; //导入依赖的package包/类
public static void main(String[] args) throws Exception {

        if(args.length < 1){
            System.err.println("[ERROR] Configuration File Required");
        }
        Config conf = new Config();

        // Store all the configuration in the Storm conf object
        conf.putAll(readConfigFile(args[0]));

        //Second arg should be local in order to run locally
        if(args.length  < 2 || (args.length  == 2 && !args[1].equals("local"))) {
            StormSubmitter.submitTopologyWithProgressBar("crawler_topology", conf, buildTopology(conf, null));
        }
        else {
            LocalDRPC drpc = new LocalDRPC();
            LocalCluster localcluster = new LocalCluster();
            localcluster.submitTopology("crawler_topology",conf,buildTopology(conf, drpc));

            String searchQuery = "elasticsearch";
            System.out.println("---* Result (search): " + drpc.execute("search",  searchQuery));
        }
    }
 
开发者ID:skalmadka,项目名称:web-crawler,代码行数:24,代码来源:WebCrawlerTopology.java

示例3: buildTopology

import backtype.storm.LocalDRPC; //导入依赖的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();
}
 
开发者ID:luozhaoyu,项目名称:big-data-system,代码行数:17,代码来源:TridentWordCount.java

示例4: main

import backtype.storm.LocalDRPC; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
  Config conf = new Config();
  conf.setMaxSpoutPending(20);
  if (args.length == 0) {
    LocalDRPC drpc = new LocalDRPC();
    LocalCluster cluster = new LocalCluster();
    cluster.submitTopology("wordCounter", conf, buildTopology(drpc));
    for (int i = 0; i < 100; i++) {
      System.out.println("DRPC RESULT: " + drpc.execute("words", "cat the dog jumped"));
      Thread.sleep(1000);
    }
  }
  else {
    conf.setNumWorkers(3);
    StormSubmitter.submitTopologyWithProgressBar(args[0], conf, buildTopology(null));
  }
}
 
开发者ID:luozhaoyu,项目名称:big-data-system,代码行数:18,代码来源:TridentWordCount.java

示例5: main

import backtype.storm.LocalDRPC; //导入依赖的package包/类
public static void main(String[] args) {
  TopologyBuilder builder = new TopologyBuilder();
  LocalDRPC drpc = new LocalDRPC();

  DRPCSpout spout = new DRPCSpout("exclamation", drpc);
  builder.setSpout("drpc", spout);
  builder.setBolt("exclaim", new ExclamationBolt(), 3).shuffleGrouping("drpc");
  builder.setBolt("return", new ReturnResults(), 3).shuffleGrouping("exclaim");

  LocalCluster cluster = new LocalCluster();
  Config conf = new Config();
  cluster.submitTopology("exclaim", conf, builder.createTopology());

  System.out.println(drpc.execute("exclamation", "aaa"));
  System.out.println(drpc.execute("exclamation", "bbb"));

}
 
开发者ID:luozhaoyu,项目名称:big-data-system,代码行数:18,代码来源:ManualDRPC.java

示例6: main

import backtype.storm.LocalDRPC; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
  LinearDRPCTopologyBuilder builder = new LinearDRPCTopologyBuilder("exclamation");
  builder.addBolt(new ExclaimBolt(), 3);

  Config conf = new Config();

  if (args == null || args.length == 0) {
    LocalDRPC drpc = new LocalDRPC();
    LocalCluster cluster = new LocalCluster();

    cluster.submitTopology("drpc-demo", conf, builder.createLocalTopology(drpc));

    for (String word : new String[]{ "hello", "goodbye" }) {
      System.out.println("Result for \"" + word + "\": " + drpc.execute("exclamation", word));
    }

    cluster.shutdown();
    drpc.shutdown();
  }
  else {
    conf.setNumWorkers(3);
    StormSubmitter.submitTopologyWithProgressBar(args[0], conf, builder.createRemoteTopology());
  }
}
 
开发者ID:luozhaoyu,项目名称:big-data-system,代码行数:25,代码来源:BasicDRPCTopology.java

示例7: main

import backtype.storm.LocalDRPC; //导入依赖的package包/类
public static void main(String args[]) throws Exception {
	LinearDRPCTopologyBuilder builder = new LinearDRPCTopologyBuilder("exclamation");
	builder.addBolt(new ExclaimBolt(), 3);

	Config conf = new Config();

	if (args == null || args.length == 0) {
		LocalDRPC drpc = new LocalDRPC();
		LocalCluster cluster = new LocalCluster();
		cluster.submitTopology("drpc-demo", conf, builder.createLocalTopology(drpc));
		for (String word : new String[] { "hello", "goodbye" }) {
			System.out.println("Result for \"" + word + "\": " + drpc.execute("exclamation", word));
		}

		Thread.sleep(10000);
		drpc.shutdown();
		cluster.shutdown();
	} else {
		conf.setNumWorkers(3);
		StormSubmitter.submitTopologyWithProgressBar(args[0], conf, builder.createRemoteTopology());
	}
}
 
开发者ID:desp0916,项目名称:LearnStorm,代码行数:23,代码来源:DRPCTest.java

示例8: buildTopology

import backtype.storm.LocalDRPC; //导入依赖的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();
}
 
开发者ID:desp0916,项目名称:LearnStorm,代码行数:26,代码来源:TridentWordCount.java

示例9: main

import backtype.storm.LocalDRPC; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
	Config conf = new Config();
	conf.setMaxSpoutPending(20);
	if (args.length == 0) {
		LocalDRPC drpc = new LocalDRPC();
		LocalCluster cluster = new LocalCluster();
		cluster.submitTopology("wordCounter", conf, buildTopology(drpc));
		for (int i = 0; i < 100; i++) {
			// The query takes as input a whitespace separated list of words
			// and return the sum of the counts for those words.
			System.out.println("DRPC RESULT: " + drpc.execute("words", "cat$$dog$$the$$man"));
			Thread.sleep(1000);
		}
	} else {
		conf.setNumWorkers(3);
		StormSubmitter.submitTopologyWithProgressBar(args[0], conf, buildTopology(null));
	}
}
 
开发者ID:desp0916,项目名称:LearnStorm,代码行数:19,代码来源:TridentWordCount.java

示例10: main

import backtype.storm.LocalDRPC; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
	LocalDRPC drpc = new LocalDRPC();

	Config conf = new Config();
	LocalCluster cluster = new LocalCluster();

	cluster.submitTopology("reach", conf, buildTopology(drpc));

	Thread.sleep(2000);

	System.out.println("REACH: " + drpc.execute("reach", "aaa"));
	System.out.println("REACH: " + drpc.execute("reach", "foo.com/blog/1"));
	System.out.println("REACH: " + drpc.execute("reach", "engineering.twitter.com/blog/5"));

	cluster.shutdown();
	drpc.shutdown();
}
 
开发者ID:desp0916,项目名称:LearnStorm,代码行数:18,代码来源:TridentReach.java

示例11: main

import backtype.storm.LocalDRPC; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
  LinearDRPCTopologyBuilder builder = new LinearDRPCTopologyBuilder("exclamation");
  builder.addBolt(new ExclaimBolt(), 3);

  Config conf = new Config();

  if (args == null || args.length == 0) {
    LocalDRPC drpc = new LocalDRPC();
    LocalCluster cluster = new LocalCluster();

    cluster.submitTopology("drpc-demo", conf, builder.createLocalTopology(drpc));

    for (String word : new String[]{ "hello", "goodbye", "apple", "orange", "banana" }) {
      System.out.println("Result for \"" + word + "\": " + drpc.execute("exclamation", word));
    }

    Thread.sleep(10000);
    drpc.shutdown();
    cluster.shutdown();
  }
  else {
    conf.setNumWorkers(3);
    StormSubmitter.submitTopologyWithProgressBar(args[0], conf, builder.createRemoteTopology());
  }
}
 
开发者ID:desp0916,项目名称:LearnStorm,代码行数:26,代码来源:BasicDRPCTopology.java

示例12: main

import backtype.storm.LocalDRPC; //导入依赖的package包/类
public static void main(String[] args) throws AlreadyAliveException, InvalidTopologyException {
	Config conf = new Config();
	conf.setDebug(true);

	if (args != null && args.length > 0) {
		conf.setNumWorkers(3);

		StormSubmitter.submitTopologyWithProgressBar(args[0], conf, buildTopology(null));
	} else {
		conf.setMaxTaskParallelism(3);
		LocalDRPC drpc = new LocalDRPC();
		LocalCluster cluster = new LocalCluster();
		cluster.submitTopology(SmashBrosTwitterTopology.class.getSimpleName(), conf, buildTopology(drpc));

		Utils.sleep(10 * 60 * 1000); // 10 minutes
		cluster.shutdown();
	}
}
 
开发者ID:danielgimenes,项目名称:SmashBrosTwitterAnalytics,代码行数:19,代码来源:SmashBrosTwitterTopology.java

示例13: main

import backtype.storm.LocalDRPC; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
  Config conf = new Config();
  conf.setMaxSpoutPending(20);
  if (args.length == 0) {
    LocalDRPC drpc = new LocalDRPC();
    LocalCluster cluster = new LocalCluster();
    cluster.submitTopology("wordCounter", conf, buildTopology(drpc));
    for (int i = 0; i < 100; i++) {
      System.out.println("DRPC RESULT: " + drpc.execute("words", "cat the dog jumped"));
      Thread.sleep(1000);
    }
  }
  else {
    conf.setNumWorkers(3);
    StormSubmitter.submitTopology(args[0], conf, buildTopology(null));
  }
}
 
开发者ID:metamx,项目名称:incubator-storm,代码行数:18,代码来源:TridentWordCount.java

示例14: main

import backtype.storm.LocalDRPC; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
  LinearDRPCTopologyBuilder builder = construct();


  Config conf = new Config();

  if (args == null || args.length == 0) {
    conf.setMaxTaskParallelism(3);
    LocalDRPC drpc = new LocalDRPC();
    LocalCluster cluster = new LocalCluster();
    cluster.submitTopology("reach-drpc", conf, builder.createLocalTopology(drpc));

    String[] urlsToTry = new String[]{ "foo.com/blog/1", "engineering.twitter.com/blog/5", "notaurl.com" };
    for (String url : urlsToTry) {
      System.out.println("Reach of " + url + ": " + drpc.execute("reach", url));
    }

    cluster.shutdown();
    drpc.shutdown();
  }
  else {
    conf.setNumWorkers(6);
    StormSubmitter.submitTopology(args[0], conf, builder.createRemoteTopology());
  }
}
 
开发者ID:metamx,项目名称:incubator-storm,代码行数:26,代码来源:ReachTopology.java

示例15: main

import backtype.storm.LocalDRPC; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
  LinearDRPCTopologyBuilder builder = new LinearDRPCTopologyBuilder("exclamation");
  builder.addBolt(new ExclaimBolt(), 3);

  Config conf = new Config();

  if (args == null || args.length == 0) {
    LocalDRPC drpc = new LocalDRPC();
    LocalCluster cluster = new LocalCluster();

    cluster.submitTopology("drpc-demo", conf, builder.createLocalTopology(drpc));

    for (String word : new String[]{ "hello", "goodbye" }) {
      System.out.println("Result for \"" + word + "\": " + drpc.execute("exclamation", word));
    }

    cluster.shutdown();
    drpc.shutdown();
  }
  else {
    conf.setNumWorkers(3);
    StormSubmitter.submitTopology(args[0], conf, builder.createRemoteTopology());
  }
}
 
开发者ID:metamx,项目名称:incubator-storm,代码行数:25,代码来源:BasicDRPCTopology.java


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