本文整理汇总了Java中backtype.storm.StormSubmitter.submitTopology方法的典型用法代码示例。如果您正苦于以下问题:Java StormSubmitter.submitTopology方法的具体用法?Java StormSubmitter.submitTopology怎么用?Java StormSubmitter.submitTopology使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类backtype.storm.StormSubmitter
的用法示例。
在下文中一共展示了StormSubmitter.submitTopology方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import backtype.storm.StormSubmitter; //导入方法依赖的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.StormSubmitter; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
Config conf = new Config();
int spout_Parallelism_hint = 1;
int split_Parallelism_hint = 2;
int count_Parallelism_hint = 2;
TopologyBuilder builder = new TopologyBuilder();
builder.setSpout("spout", new RaceSentenceSpout(), spout_Parallelism_hint);
builder.setBolt("split", new SplitSentence(), split_Parallelism_hint).shuffleGrouping("spout");
builder.setBolt("count", new WordCount(), count_Parallelism_hint).fieldsGrouping("split", new Fields("word"));
String topologyName = RaceConfig.JstormTopologyName;
try {
StormSubmitter.submitTopology(topologyName, conf, builder.createTopology());
//begin by Young
//end by Young
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
示例3: main
import backtype.storm.StormSubmitter; //导入方法依赖的package包/类
public static void main(String[] args) {
Config config = new Config();
HdfsBolt hdfsBolt = makeHdfsBolt();
KafkaSpout kafkaSpout = makeKafkaSpout(TOPIC, TOPOLOGY_NAME);
LOG.info("Topology name is {}", TOPOLOGY_NAME);
TopologyBuilder topologyBuilder = new TopologyBuilder();
topologyBuilder.setSpout(KAFKA_SPOUT_ID, kafkaSpout, 10);
topologyBuilder.setBolt(CROP_BOLT_ID, new CropBolt(), 10).shuffleGrouping(KAFKA_SPOUT_ID);
topologyBuilder.setBolt(SPLIT_FIELDS_BOLT_ID, new SplitFieldsBolt(), 10).shuffleGrouping(CROP_BOLT_ID);
topologyBuilder.setBolt(STORM_HDFS_BOLT_ID, hdfsBolt, 4).fieldsGrouping(SPLIT_FIELDS_BOLT_ID, new Fields("timestamp", "fieldvalues"));
if (args != null && args.length > 0) {
config.setDebug(false);
config.setNumWorkers(3);
try {
StormSubmitter.submitTopology(args[0], config, topologyBuilder.createTopology());
} catch (InvalidTopologyException | AlreadyAliveException | AuthorizationException e) {
e.printStackTrace();
}
}
}
示例4: buildAndSubmit
import backtype.storm.StormSubmitter; //导入方法依赖的package包/类
public void buildAndSubmit() throws Exception {
TopologyBuilder builder = new TopologyBuilder();
Config config = new Config();
config.setDebug(true);
// String nimbusHost = topologyConfig.getProperty("nimbus.host");
config.put(Config.NIMBUS_HOST, "localhost");
configureKafkaSpout(builder);
configureRouteBolt(builder);
configureInsertBolt(builder);
//builder.setBolt("submitter", new SubmitBolt())
// .shuffleGrouping(ROUTE_BOLT);
try {
StormSubmitter.submitTopology("realestate-topology", config, builder.createTopology());
} catch (Exception e) {
LOG.error("Error submiting Topology", e);
}
}
示例5: SetRemoteTopology
import backtype.storm.StormSubmitter; //导入方法依赖的package包/类
public void SetRemoteTopology() throws AlreadyAliveException,
InvalidTopologyException, TopologyAssignException {
Config conf = getConf();
StormTopology topology = buildTopology();
conf.put(Config.STORM_CLUSTER_MODE, "distributed");
String streamName = (String) conf.get(Config.TOPOLOGY_NAME);
if (streamName == null) {
streamName = "SequenceTest";
}
if (streamName.contains("zeromq")) {
conf.put(Config.STORM_MESSAGING_TRANSPORT,
"com.alibaba.jstorm.message.zeroMq.MQContext");
} else {
conf.put(Config.STORM_MESSAGING_TRANSPORT,
"com.alibaba.jstorm.message.netty.NettyContext");
}
StormSubmitter.submitTopology(streamName, conf,topology);
}
示例6: main
import backtype.storm.StormSubmitter; //导入方法依赖的package包/类
/**
* Main method
*/
public static void main(String[] args) throws AlreadyAliveException, InvalidTopologyException {
if (args.length < 1) {
throw new RuntimeException("Specify topology name");
}
int parallelism = 1;
if (args.length > 1) {
parallelism = Integer.parseInt(args[1]);
}
TopologyBuilder builder = new TopologyBuilder();
builder.setSpout("word", new WordSpout(), parallelism);
builder.setBolt("consumer", new ConsumerBolt(), parallelism)
.fieldsGrouping("word", new Fields("word"));
Config conf = new Config();
conf.setNumWorkers(parallelism);
StormSubmitter.submitTopology(args[0], conf, builder.createTopology());
}
示例7: submit
import backtype.storm.StormSubmitter; //导入方法依赖的package包/类
protected int submit(String name, Config conf, TopologyBuilder builder) {
// register Metadata for serialization with FieldsSerializer
Config.registerSerialization(conf, Metadata.class);
if (isLocal) {
LocalCluster cluster = new LocalCluster();
cluster.submitTopology(name, conf, builder.createTopology());
if (ttl != -1) {
Utils.sleep(ttl * 1000);
cluster.shutdown();
}
}
else {
try {
StormSubmitter.submitTopology(name, conf,
builder.createTopology());
} catch (Exception e) {
e.printStackTrace();
return -1;
}
}
return 0;
}
示例8: submitTopology
import backtype.storm.StormSubmitter; //导入方法依赖的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) {
e.printStackTrace();
}
}
示例9: main
import backtype.storm.StormSubmitter; //导入方法依赖的package包/类
/**
* Get data from db and send message and email for someone or group.
* @param args
* @throws InvalidTopologyException
* @throws AlreadyAliveException
*/
public static void main(String[] args) throws AlreadyAliveException, InvalidTopologyException {
TopologyBuilder builder=new TopologyBuilder();
builder.setSpout("Log-VisitAlarm-Spout", new AppVisitAlarmSpout(),10);
//�����ʼ�
builder.setBolt("Log-Alarm-VisitErrorStatusCode-Bolt",new VisitErrorStatusBolt(), 10)
.shuffleGrouping("Log-VisitAlarm-Spout");
Config conf=new Config();
conf.setDebug(false);
conf.setNumWorkers(4);
if (args != null && args.length > 0) {
StormSubmitter.submitTopology(args[0], conf,builder.createTopology());
} else {
conf.setMaxTaskParallelism(1);
LocalCluster cluster = new LocalCluster();
cluster.submitTopology("AlarmErrorStatusCode", conf,builder.createTopology());
}
}
示例10: main
import backtype.storm.StormSubmitter; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
Config conf = ConfigUtil.readConfig(new File(args[1]));
if (conf == null) {
throw new RuntimeException("cannot find conf file " + args[1]);
}
TopologyBuilder builder = new TopologyBuilder();
if (!ConfigUtil.getBoolean(conf, "spout.redis", false)) {
builder.setSpout("say", new RandomSentenceSpout(), ConfigUtil.getInt(conf, "spout.parallelism", 1));
} else {
String host = (String) conf.get("redis.host");
int port = ((Number) conf.get("redis.port")).intValue();
String queue = (String) conf.get("redis.queue");
builder.setSpout("say", new RedisSentenceSpout(host, port, queue),
ConfigUtil.getInt(conf, "spout.parallelism", 1));
}
builder.setBolt("split", new SplitSentence(), ConfigUtil.getInt(conf, "split.parallelism", 1))
.shuffleGrouping("say");
builder.setBolt("counter", new WordCount(), ConfigUtil.getInt(conf, "counter.parallelism", 1))
.fieldsGrouping("split", new Fields("word"));
StormSubmitter.submitTopology(args[0], conf, builder.createTopology());
}
示例11: main
import backtype.storm.StormSubmitter; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception
{
BasicConfigurator.configure();
if (args != null && args.length > 0)
{
StormSubmitter.submitTopology(
args[0],
createConfig(false),
createTopology());
}
else
{
LocalCluster cluster = new LocalCluster();
cluster.submitTopology(
"sentiment-analysis",
createConfig(true),
createTopology());
Thread.sleep(60000);
cluster.shutdown();
}
}
示例12: main
import backtype.storm.StormSubmitter; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
Config conf = readConfig(new File(args[1]));
if (conf == null) {
throw new RuntimeException("cannot find conf file " + args[1]);
}
ResaConfig resaConfig = ResaConfig.create();
resaConfig.putAll(conf);
StormTopology topology = createTopology(resaConfig);
if (args[0].equals("[local]")) {
resaConfig.setDebug(false);
LocalCluster localCluster = new LocalCluster();
localCluster.submitTopology("local", resaConfig, topology);
} else {
// resaConfig.addDrsSupport();
resaConfig.registerMetricsConsumer(RedisMetricsCollector.class);
StormSubmitter.submitTopology(args[0], resaConfig, topology);
}
}
示例13: main
import backtype.storm.StormSubmitter; //导入方法依赖的package包/类
public static void main(String[] args) throws AlreadyAliveException,
InvalidTopologyException {
Config conf = new Config();
// conf.setDebug(true);
if (args == null || args.length == 0) {
// local mode
LocalCluster cluster = new LocalCluster();
cluster.submitTopology(TOPOLOGY_NAME, conf, buildTopology());
} else {
// distributed mode
conf.put(Config.STORM_CLUSTER_MODE, new String("distributed"));
conf.setNumWorkers(1);
StormSubmitter.submitTopology(args[0], conf, buildTopology());
}
}
示例14: main
import backtype.storm.StormSubmitter; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
Config conf = readConfig(new File(args[1]));
if (conf == null) {
throw new RuntimeException("cannot find conf file " + args[1]);
}
ResaConfig resaConfig = ResaConfig.create();
resaConfig.putAll(conf);
StormTopology topology = createTopology(resaConfig);
if (args[0].equals("[local]")) {
resaConfig.setDebug(false);
LocalCluster localCluster = new LocalCluster();
localCluster.submitTopology("local", resaConfig, topology);
} else {
// resaConfig.addDrsSupport();
resaConfig.registerMetricsConsumer(RedisMetricsCollector.class);
List<Double> dataSizes = Files.readAllLines(Paths.get(args[2])).stream().map(String::trim)
.filter(s -> !s.isEmpty()).map(Double::valueOf).collect(Collectors.toList());
resaConfig.put("dataSizes", dataSizes);
StormSubmitter.submitTopology(args[0], resaConfig, topology);
}
}
示例15: main
import backtype.storm.StormSubmitter; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
Config conf = new Config();
if (args.length == 2) {
// Ready & submit the topology
String name = args[0];
BrokerHosts hosts = new ZkHosts(args[1]);
TransactionalTridentKafkaSpout kafkaSpout = TestUtils.testTweetSpout(hosts);
StormSubmitter.submitTopology(name, conf, buildTopology(kafkaSpout));
}else{
System.err.println("<topologyName> <zookeeperHost>");
}
}