本文整理匯總了Java中backtype.storm.LocalCluster.shutdown方法的典型用法代碼示例。如果您正苦於以下問題:Java LocalCluster.shutdown方法的具體用法?Java LocalCluster.shutdown怎麽用?Java LocalCluster.shutdown使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類backtype.storm.LocalCluster
的用法示例。
在下文中一共展示了LocalCluster.shutdown方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: main
import backtype.storm.LocalCluster; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
Config conf = new Config();
conf.setMaxSpoutPending(5);
if (args.length == 1) {
LocalCluster cluster = new LocalCluster();
cluster.submitTopology("wordCounter", conf, buildTopology(args[0]));
Thread.sleep(60 * 1000);
cluster.killTopology("wordCounter");
cluster.shutdown();
System.exit(0);
}
else if(args.length == 2) {
conf.setNumWorkers(3);
StormSubmitter.submitTopology(args[1], conf, buildTopology(args[0]));
} else{
System.out.println("Usage: TridentFileTopology <hdfs url> [topology name]");
}
}
示例2: main
import backtype.storm.LocalCluster; //導入方法依賴的package包/類
public static void main(String[] args) throws SQLException {
// tableName is the name of the table in splice to insert records to
// server is the server instance running splice
String tableName = "students";
String server = "localhost";
TopologyBuilder builder = new TopologyBuilder();
// set the spout for the topology
builder.setSpout("seedDataFromMySql", new MySqlSpout());
// dump the stream data into splice
builder.setBolt("dbRowProcessing", new MySqlSpliceBolt(server, tableName), 1).shuffleGrouping("seedDataFromMySql");
Config conf = new Config();
conf.setDebug(true);
LocalCluster cluster = new LocalCluster();
cluster.submitTopology("mysql-splice-topology", conf, builder.createTopology());
Utils.sleep(3000);
cluster.shutdown();
}
示例3: main
import backtype.storm.LocalCluster; //導入方法依賴的package包/類
public static void main(String[] args) {
TopologyBuilder builder = new TopologyBuilder();
builder.setSpout("spout", new KafkaSpoutTest(""), 1);
builder.setBolt("bolt1", new Bolt1(), 2).shuffleGrouping("spout");
builder.setBolt("bolt2", new Bolt2(), 2).fieldsGrouping("bolt1",new Fields("word"));
Map conf = new HashMap();
conf.put(Config.TOPOLOGY_WORKERS, 1);
conf.put(Config.TOPOLOGY_DEBUG, true);
LocalCluster cluster = new LocalCluster();
cluster.submitTopology("flume-kafka-storm-integration", conf, builder.createTopology());
Utils.sleep(1000*60*5);
cluster.shutdown();
}
示例4: submitTopology
import backtype.storm.LocalCluster; //導入方法依賴的package包/類
private static void submitTopology(TopologyBuilder builder) {
try {
if (local_mode(conf)) {
LocalCluster cluster = new LocalCluster();
cluster.submitTopology(
String.valueOf(conf.get("topology.name")), conf,
builder.createTopology());
Thread.sleep(200000);
cluster.shutdown();
} else {
StormSubmitter.submitTopology(
String.valueOf(conf.get("topology.name")), conf,
builder.createTopology());
}
} catch (Exception e) {
LOG.error(e.getMessage(), e.getCause());
}
}
示例5: main
import backtype.storm.LocalCluster; //導入方法依賴的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());
}
}
示例6: main
import backtype.storm.LocalCluster; //導入方法依賴的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());
}
}
示例7: main
import backtype.storm.LocalCluster; //導入方法依賴的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();
}
示例8: main
import backtype.storm.LocalCluster; //導入方法依賴的package包/類
public static void main(String[] args) {
NginxSplitBolt nginxBolt = new NginxSplitBolt();
ServiceLogBolt serviceBolt = new ServiceLogBolt();
TopologyBuilder builder = new TopologyBuilder();
builder.setSpout("nginx", new KafkaSpoutTest("log.accesslog"), 1);
builder.setSpout("service", new KafkaSpoutTest("log.servicelog"), 1);
builder.setBolt("nginxlog", nginxBolt).shuffleGrouping("nginx");
builder.setBolt("servicelog", serviceBolt).shuffleGrouping("service");
builder.setBolt("join", new SingleJoinBolt(new Fields("method", "time", "usetime", "params")))
.fieldsGrouping("nginxlog", new Fields("ip", "utime"))
.fieldsGrouping("servicelog", new Fields("ip", "utime"));
Config conf = new Config();
conf.setDebug(true);
LocalCluster cluster = new LocalCluster();
cluster.submitTopology("log - join", conf, builder.createTopology());
Utils.sleep(2000);
cluster.shutdown();
}
示例9: main
import backtype.storm.LocalCluster; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
TopologyBuilder builder = new TopologyBuilder();
builder.setSpout("word", new TestWordSpout(), 10);
builder.setBolt("exclaim1", new ExclamationBolt(), 3).shuffleGrouping("word");
builder.setBolt("exclaim2", new ExclamationBolt(), 2).shuffleGrouping("exclaim1");
Config conf = new Config();
conf.setDebug(true);
if (args != null && args.length > 0) {
conf.setNumWorkers(3);
StormSubmitter.submitTopologyWithProgressBar(args[0], conf, builder.createTopology());
}
else {
LocalCluster cluster = new LocalCluster();
cluster.submitTopology("test", conf, builder.createTopology());
Utils.sleep(10000);
cluster.killTopology("test");
cluster.shutdown();
}
}
示例10: main
import backtype.storm.LocalCluster; //導入方法依賴的package包/類
public static void main(String[] args) throws AlreadyAliveException,
InvalidTopologyException {
TopologyBuilder builder = new TopologyBuilder();
List<String> zks = new ArrayList<String>();
zks.add("192.168.41.122");
List<String> cFs = new ArrayList<String>();
cFs.add("personal");
cFs.add("company");
// set the spout class
builder.setSpout("spout", new SampleSpout(), 2);
// set the bolt class
builder.setBolt("bolt", new StormRedisBolt("192.168.41.122",2181), 2).shuffleGrouping("spout");
Config conf = new Config();
conf.setDebug(true);
// create an instance of LocalCluster class for
// executing topology in local mode.
LocalCluster cluster = new LocalCluster();
// LearningStormTopolgy is the name of submitted topology.
cluster.submitTopology("StormRedisTopology", conf,
builder.createTopology());
try {
Thread.sleep(10000);
} catch (Exception exception) {
System.out.println("Thread interrupted exception : " + exception);
}
// kill the LearningStormTopology
cluster.killTopology("StormRedisTopology");
// shutdown the storm test cluster
cluster.shutdown();
}
示例11: main
import backtype.storm.LocalCluster; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
LOG.info("Reading JSON file configuration...");
JSONProperties config = new JSONProperties("/topology.json");
TopologyBuilder builder = new TopologyBuilder();
/* Spout Configuration */
JSONArray spouts = config.getSpouts();
configureSpouts(builder, spouts);
/* Bolt Configuration */
JSONArray bolts = config.getBolts();
configureBolts(builder, bolts);
/* Drain Configuration */
JSONArray drains = config.getDrains();
configureDrains(builder, drains);
/* Configure more Storm options */
Config conf = setTopologyStormConfig(config.getProperties());
if(config.getProperty("name") != null){
StormSubmitter.submitTopology((String)config.getProperty("name"), conf, builder.createTopology());
} else {
conf.setDebug(true);
LocalCluster cluster = new LocalCluster();
cluster.submitTopology("test", conf, builder.createTopology());
Utils.sleep(1000000); // Alive for 100 seconds = 100000 ms
cluster.killTopology("test");
cluster.shutdown();
}
}
示例12: main
import backtype.storm.LocalCluster; //導入方法依賴的package包/類
public static void main(String[] args) throws SQLException {
ArrayList<String> columnNames = new ArrayList<String>();
ArrayList<String> columnTypes = new ArrayList<String>();
// this table must exist in splice
// create table testTable (word varchar(100), number int);
String tableName = "testTable";
String server = "localhost";
// add the column names and the respective types in the two arraylists
columnNames.add("word");
columnNames.add("number");
// add the types
columnTypes.add("varchar (100)");
columnTypes.add("int");
TopologyBuilder builder = new TopologyBuilder();
// set the spout for the topology
builder.setSpout("spout", new SpliceIntegerSpout(), 10);
// dump the stream data into splice
SpliceDumperBolt dumperBolt = new SpliceDumperBolt(server, tableName);
builder.setBolt("dumperBolt", dumperBolt, 1).shuffleGrouping("spout");
Config conf = new Config();
conf.setDebug(true);
LocalCluster cluster = new LocalCluster();
cluster.submitTopology("splice-topology", conf, builder.createTopology());
Utils.sleep(10000);
cluster.shutdown();
}
示例13: main
import backtype.storm.LocalCluster; //導入方法依賴的package包/類
public static void main(String[] args) {
LocalCluster cluster = new LocalCluster();
/* begin young-define*/
Config conf = new Config();
TopologyBuilder builder = new TopologyBuilder();
builder.setSpout("spout", new SpoutLocal(), 1);
builder.setBolt("split", new SplitSentenceLocal(), 1).shuffleGrouping("spout");
builder.setBolt("count", new WordCountLocal(), 1).fieldsGrouping("split", new Fields("word"));
/* end young-define */
//建議加上這行,使得每個bolt/spout的並發度都為1
conf.put(Config.TOPOLOGY_MAX_TASK_PARALLELISM, 1);
//提交拓撲
cluster.submitTopology("SequenceTest", conf, builder.createTopology());
//等待1分鍾, 1分鍾後會停止拓撲和集群, 視調試情況可增大該數值
try {
Thread.sleep(60000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//結束拓撲
cluster.killTopology("SequenceTest");
cluster.shutdown();
}
示例14: main
import backtype.storm.LocalCluster; //導入方法依賴的package包/類
/**
* @param args
* http://www.programcreek.com/java-api-examples/index.php?api=storm.kafka.KafkaSpout
*/
public static void main(String[] args) {
try{
//設置噴發節點並分配並發數,該並發數將會控製該對象在集群中的線程數(6個)
String zkhost = "wxb-1:2181,wxb-2:2181,wxb-3:2181";
String topic = "order";
String groupId = "id";
int spoutNum = 3;
int boltNum = 1;
ZkHosts zkHosts = new ZkHosts(zkhost);//kafaka所在的zookeeper
SpoutConfig spoutConfig = new SpoutConfig(zkHosts, topic, "/order", groupId); // create /order /id
spoutConfig.scheme = new SchemeAsMultiScheme(new StringScheme());
KafkaSpout kafkaSpout = new KafkaSpout(spoutConfig);
TopologyBuilder builder = new TopologyBuilder();
builder.setSpout("spout", kafkaSpout, spoutNum);
builder.setBolt("check", new CheckOrderBolt(), boltNum).shuffleGrouping("spout");
builder.setBolt("counter", new CounterBolt(),boltNum).shuffleGrouping("check");
Config config = new Config();
config.setDebug(true);
if(args!=null && args.length > 0) {
config.setNumWorkers(2);
StormSubmitter.submitTopology(args[0], config, builder.createTopology());
} else {
config.setMaxTaskParallelism(2);
LocalCluster cluster = new LocalCluster();
cluster.submitTopology("Wordcount-Topology", config, builder.createTopology());
Thread.sleep(500000);
cluster.shutdown();
}
}catch (Exception e) {
e.printStackTrace();
}
}
示例15: main
import backtype.storm.LocalCluster; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
TopologyBuilder builder = new TopologyBuilder();
builder.setSpout("spout", new RandomSpout());
builder.setBolt("exclaim", new ProxyBolt()).shuffleGrouping("spout");
builder.setBolt("print", new PrintBolt()).shuffleGrouping("exclaim");
Config conf = new Config();
conf.setDebug(false);
/* Config裏封裝了Redis的配置 */
conf.put("ip","127.0.0.1");
conf.put("port","6379");
conf.put("password","password");
if (args != null && args.length > 0) {
conf.setNumWorkers(1);
StormSubmitter.submitTopology(args[0], conf, builder.createTopology());
} else {
LocalCluster cluster = new LocalCluster();
cluster.submitTopology("test", conf, builder.createTopology());
Utils.sleep(10*1000);
cluster.killTopology("test");
cluster.shutdown();
}
}