本文整理汇总了Java中backtype.storm.LocalCluster.killTopology方法的典型用法代码示例。如果您正苦于以下问题:Java LocalCluster.killTopology方法的具体用法?Java LocalCluster.killTopology怎么用?Java LocalCluster.killTopology使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类backtype.storm.LocalCluster
的用法示例。
在下文中一共展示了LocalCluster.killTopology方法的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 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();
}
}
示例3: 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("www_nginx_accesslog_stat", conf, builder.createTopology());
Utils.sleep(10000);
cluster.killTopology("www_nginx_accesslog_stat");
cluster.shutdown();
}
}
示例4: 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();
}
示例5: 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();
}
}
示例6: 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();
}
示例7: 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();
}
}
示例8: main
import backtype.storm.LocalCluster; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
Config config = new Config();
RandomJsonTestSpout spout = new RandomJsonTestSpout().withComplexJson(false);
String2ByteArrayTupleMapper tuppleMapper = new String2ByteArrayTupleMapper();
tuppleMapper.configure(CmnStormCons.TUPLE_FIELD_MSG);
MorphlinesBolt morphBolt = new MorphlinesBolt()
.withTupleMapper(tuppleMapper)
.withMorphlineId("json_terminal_log")
.withMorphlineConfFile("target/test-classes/morphline_confs/json_terminal_log.conf");
TopologyBuilder builder = new TopologyBuilder();
builder.setSpout("WORD_SPOUT", spout, 1);
builder.setBolt("MORPH_BOLT", morphBolt, 1).shuffleGrouping("WORD_SPOUT");
if (args.length == 0) {
LocalCluster cluster = new LocalCluster();
cluster.submitTopology("MyDummyJsonTerminalLogTopology", config, builder.createTopology());
Thread.sleep(10000);
cluster.killTopology("MyDummyJsonTerminalLogTopology");
cluster.shutdown();
System.exit(0);
} else if (args.length == 1) {
StormSubmitter.submitTopology(args[0], config, builder.createTopology());
} else {
System.out.println("Usage: DummyJsonTerminalLogTopology <topology_name>");
}
}
示例9: main
import backtype.storm.LocalCluster; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
Config config = new Config();
RandomJsonTestSpout spout = new RandomJsonTestSpout().withComplexJson(false);
String2ByteArrayTupleMapper tuppleMapper = new String2ByteArrayTupleMapper();
tuppleMapper.configure(CmnStormCons.TUPLE_FIELD_MSG);
/*PairNode<String, IRecordHandler<?, ?>>[] resultRecordHandlers = new PairNode[] { new PairNode(
CmnStormCons.TUPLE_FIELD_MSG,
RecordHandlerFactory.createMyObject(String.class, new JsonNode2StringResultMapper())) };*/
MorphlinesBolt morphBolt = new MorphlinesBolt()
.withTupleMapper(tuppleMapper)
.withMorphlineId("json2string")
.withMorphlineConfFile("target/test-classes/morphline_confs/json2string.conf")
//.withOutputProcessors(Arrays.asList(resultRecordHandlers));
.withOutputFields(CmnStormCons.TUPLE_FIELD_MSG)
.withRecordMapper(RecordHandlerFactory.genDefaultRecordHandler(String.class, new JsonNode2StringResultMapper()));
LoggingBolt printBolt = new LoggingBolt().withFields(CmnStormCons.TUPLE_FIELD_MSG);
TopologyBuilder builder = new TopologyBuilder();
builder.setSpout("WORD_SPOUT", spout, 1);
builder.setBolt("MORPH_BOLT", morphBolt, 1).shuffleGrouping("WORD_SPOUT");
builder.setBolt("PRINT_BOLT", printBolt, 1).shuffleGrouping("MORPH_BOLT");
if (args.length == 0) {
LocalCluster cluster = new LocalCluster();
cluster.submitTopology("MyDummyJson2StringTopology", config, builder.createTopology());
Thread.sleep(10000);
cluster.killTopology("MyDummyJson2StringTopology");
cluster.shutdown();
System.exit(0);
} else if (args.length == 1) {
StormSubmitter.submitTopology(args[0], config, builder.createTopology());
} else {
System.out.println("Usage: DummyJson2StringTopology <topology_name>");
}
}
示例10: main
import backtype.storm.LocalCluster; //导入方法依赖的package包/类
public static void main(String[] args) throws AlreadyAliveException, InvalidTopologyException {
TopologyBuilder builder = new TopologyBuilder();
LOGGER.info("Starting..");
builder.setSpout("trade", new DeliveryCheckSpout(), 1);
builder.setBolt("eligibility", new DeliveryCheckBolt(), 10).shuffleGrouping("trade");
builder.setBolt("odd", new DeliveryCheckOddBolt(), 10).shuffleGrouping("eligibility",
"oddstream");
builder.setBolt("even", new DeliveryCheckEvenBolt(), 10).shuffleGrouping("eligibility",
"evenstream");
Config conf = new Config();
conf.setDebug(false);
conf.setMaxSpoutPending(5);
if (args != null && args.length > 0) {
conf.setNumWorkers(1);
LOGGER.info("Submitting DeliveryTopology");
StormSubmitter.submitTopologyWithProgressBar(args[0], conf, builder.createTopology());
} else {
LocalCluster cluster = new LocalCluster();
cluster.submitTopology("DeliveryTopology", conf, builder.createTopology());
Utils.sleep(100000000);
cluster.killTopology("DeliveryTopology");
cluster.shutdown();
}
}
示例11: run
import backtype.storm.LocalCluster; //导入方法依赖的package包/类
/**
* Builds and runs a StormTopology in the configured environment (development|staging|production)
*/
public void run() throws Exception {
log.info(String.format("Running %s in %s mode.", topo.getName(), env));
String topologyName = topo.getName();
if (ENV.development == env) {
int localRunSecs = Integer.parseInt(cli.getOptionValue("localRunSecs", "30"));
try {
LocalCluster cluster = new LocalCluster();
stormConf.put("topology.tick.tuple.freq.secs", 5);
cluster.submitTopology(topologyName, stormConf, topo.build(this));
log.info("Submitted " + topologyName + " to LocalCluster at " + timestamp() + " ... sleeping for " +
localRunSecs + " seconds before terminating.");
try {
Thread.sleep(localRunSecs * 1000);
} catch (InterruptedException ie) {
Thread.interrupted();
}
log.info("Killing " + topologyName);
cluster.killTopology(topologyName);
cluster.shutdown();
log.info("Shut down LocalCluster at " + timestamp());
} catch (Exception exc) {
Throwable rootCause = getRootCause(exc);
log.error("Storm topology " + topologyName + " failed due to: " + rootCause, rootCause);
throw exc;
} finally {
cleanup();
}
System.exit(0);
} else {
StormSubmitter.submitTopology(topologyName, stormConf, topo.build(this));
}
}
示例12: runTopologyLocally
import backtype.storm.LocalCluster; //导入方法依赖的package包/类
public static void runTopologyLocally(StormTopology topology,
String topologyName, Config conf, int runtimeInSeconds)
throws InterruptedException {
LocalCluster cluster = new LocalCluster();
cluster.submitTopology(topologyName, conf, topology);
System.out
.println("\n\n==================================\n STORM TOPOLOGY INITIALIZING \n==================================\n\n");
// If the runtime is 0, it will run indefinitely
if (runtimeInSeconds != 0) {
Thread.sleep((long) runtimeInSeconds * MILLIS_IN_SEC);
cluster.killTopology(topologyName);
cluster.shutdown();
}
}
示例13: main
import backtype.storm.LocalCluster; //导入方法依赖的package包/类
public static void main(String[] args) {
StormTopology topology = CreditCardTopologyBuilder.build();
Config config = new Config();
config.setDebug(true);
LocalCluster cluster = new LocalCluster();
cluster.submitTopology("local-topology", config, topology);
Utils.sleep(30000);
cluster.killTopology("local-topology");
cluster.shutdown();
}
示例14: testShuffle
import backtype.storm.LocalCluster; //导入方法依赖的package包/类
@SuppressWarnings("rawtypes")
@Test(timeout = 30000)
public void testShuffle() {
final String topologyName = "testTopology";
final int maxValue = 1000;
final int batchSize = 1 + this.r.nextInt(5);
final int numberOfAttributes = 1;
final Integer spoutDop = new Integer(1);
final Integer boltDop = new Integer(1);
LocalCluster cluster = new LocalCluster();
TopologyBuilder builder = new TopologyBuilder();
builder.setSpout(VerifyBolt.SPOUT_ID, new RandomSpout(numberOfAttributes, maxValue, new String[] {"stream1"},
this.seed), spoutDop);
builder.setSpout(VerifyBolt.BATCHING_SPOUT_ID, new SpoutOutputBatcher(new RandomSpout(numberOfAttributes,
maxValue, new String[] {"stream2"}, this.seed), batchSize), spoutDop);
builder.setBolt("Bolt", new InputDebatcher(new VerifyBolt(new Fields("a"), null)), boltDop)
.shuffleGrouping(VerifyBolt.SPOUT_ID, "stream1").shuffleGrouping(VerifyBolt.BATCHING_SPOUT_ID, "stream2");
cluster.submitTopology(topologyName, new HashMap(), builder.createTopology());
Utils.sleep(10 * 1000);
cluster.killTopology(topologyName);
Utils.sleep(5 * 1000); // give "kill" some time to clean up; otherwise, test might hang and time out
cluster.shutdown();
Assert.assertEquals(new LinkedList<String>(), VerifyBolt.errorMessages);
Assert.assertTrue(VerifyBolt.matchedTuples > 0);
}
示例15: runTopologyLocally
import backtype.storm.LocalCluster; //导入方法依赖的package包/类
public static void runTopologyLocally(StormTopology topology, String topologyName, Config conf, int runtimeInSeconds)
throws InterruptedException {
LocalCluster cluster = new LocalCluster();
cluster.submitTopology(topologyName, conf, topology);
Thread.sleep((long) runtimeInSeconds * MILLIS_IN_SEC);
cluster.killTopology(topologyName);
cluster.shutdown();
}