本文整理汇总了Java中org.apache.storm.utils.Utils.sleep方法的典型用法代码示例。如果您正苦于以下问题:Java Utils.sleep方法的具体用法?Java Utils.sleep怎么用?Java Utils.sleep使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.storm.utils.Utils
的用法示例。
在下文中一共展示了Utils.sleep方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setupOnce
import org.apache.storm.utils.Utils; //导入方法依赖的package包/类
@BeforeClass
public static void setupOnce() throws Exception {
AbstractStormTest.setupOnce();
////////
Properties overlay = new Properties();
overlay.setProperty("filter.directory", server.tempDir.getAbsolutePath());
LaunchEnvironment env = makeLaunchEnvironment(overlay);
manager = new OFEventWFMTopology(env);
cluster.submitTopology(manager.makeTopologyName(), stormConfig(), manager.createTopology());
discoFiler = new KafkaFilerTopology(env, manager.getConfig().getKafkaTopoDiscoTopic());
cluster.submitTopology("utils-1", stormConfig(), discoFiler.createTopology());
Utils.sleep(5 * 1000);
////////
}
示例2: main
import org.apache.storm.utils.Utils; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
TopologyBuilder builder = new TopologyBuilder();
builder.setSpout("integer", new RandomIntegerSpout(), 1);
builder.setBolt("slidingsum", new SlidingWindowSumBolt().withWindow(new Count(30), new Count(10)), 1)
.shuffleGrouping("integer");
builder.setBolt("tumblingavg", new TumblingWindowAvgBolt().withTumblingWindow(new Count(3)), 1)
.shuffleGrouping("slidingsum");
builder.setBolt("printer", new PrinterBolt(), 1).shuffleGrouping("tumblingavg");
Config conf = new Config();
conf.setDebug(true);
if (args != null && args.length > 0) {
conf.setNumWorkers(1);
StormSubmitter.submitTopologyWithProgressBar(args[0], conf, builder.createTopology());
} else {
LocalCluster cluster = new LocalCluster();
cluster.submitTopology("test", conf, builder.createTopology());
Utils.sleep(40000);
cluster.killTopology("test");
cluster.shutdown();
}
}
示例3: main
import org.apache.storm.utils.Utils; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
TopologyBuilder builder = new TopologyBuilder();
builder.setSpout("word", new WordSpout(), 1);
builder.setBolt("exclaim", new ExclamationBolt(), 1).shuffleGrouping("word"); // Tuple流向:word 》 exclaim
builder.setBolt("print", new PrintBolt(), 1).shuffleGrouping("exclaim"); // exclaim 》 print
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(); // storm依赖,<scope>provided</scope>--> 本地开发是注释掉 -->
cluster.submitTopology("test3", conf, builder.createTopology());
Utils.sleep(60 * 1000);
cluster.killTopology("test3");
cluster.shutdown();
}
}
示例4: nextTuple
import org.apache.storm.utils.Utils; //导入方法依赖的package包/类
@Override
public void nextTuple() {
// Sleep for 1 second so the data rate
// is slower.
Utils.sleep(1000);
// Randomly emit device info
int temperature = _rand.nextInt(11) + 68; // There is a war over whether it's warm or cool in the house
int humidity = _rand.nextInt(11) + 35; // 35-45 being the recommended humitity in a house
int co2 = _rand.nextInt(600); // Indoor CO2 range
//Create a JSON document to send to Event Hub
// BECAUSE, I learned the hard way that if you don't
// put it in a nice format that things can interop with,
// then you have problems later when someone wants
// to read it into a C# app that uses a framework that
// expects JSON.
JSONObject message = new JSONObject();
message.put("temperature", temperature);
message.put("humidity", humidity);
message.put("co2level", co2);
//Emit the device
_collector.emit(new Values(message.toString()));
}
示例5: main
import org.apache.storm.utils.Utils; //导入方法依赖的package包/类
public static void main(String[] args){
TopologyBuilder topologyBuilder = new TopologyBuilder();
topologyBuilder.setSpout(SPOUT_ID,new SentenceSpout());
topologyBuilder.setBolt(BOLT_ID_SENTENCE_SPLIT,new SentenceSplitBolt()).shuffleGrouping(SPOUT_ID);
topologyBuilder.setBolt(BOLT_ID_WORD_COUNT,new WordCountBlot()).fieldsGrouping(BOLT_ID_SENTENCE_SPLIT,new Fields("word"));
topologyBuilder.setBolt(BOLT_ID_COUNT_REPORT,new WordsReportBolt()).globalGrouping(BOLT_ID_WORD_COUNT);
Config config = new Config();
LocalCluster localCluster = new LocalCluster();
localCluster.submitTopology(TOPOLOGY_ID,config,topologyBuilder.createTopology());
//
Utils.sleep(10000);
localCluster.killTopology(TOPOLOGY_ID);
localCluster.shutdown();
}
示例6: main
import org.apache.storm.utils.Utils; //导入方法依赖的package包/类
public static void main(final String[] args) throws AlreadyAliveException, InvalidTopologyException,
NotAliveException {
if (!WordCountTopology.parseParameters(args)) {
return;
}
// build Topology the Storm way
final TopologyBuilder builder = WordCountTopology.buildTopology();
// execute program on Flink cluster
final Config conf = new Config();
// can be changed to remote address
conf.put(Config.NIMBUS_HOST, "localhost");
// use default flink jobmanger.rpc.port
conf.put(Config.NIMBUS_THRIFT_PORT, 6123);
final FlinkClient cluster = FlinkClient.getConfiguredClient(conf);
cluster.submitTopology(topologyId, uploadedJarLocation, FlinkTopology.createTopology(builder));
Utils.sleep(5 * 1000);
cluster.killTopology(topologyId);
}
示例7: testProgram
import org.apache.storm.utils.Utils; //导入方法依赖的package包/类
@Override
protected void testProgram() throws Exception {
final TopologyBuilder builder = new TopologyBuilder();
builder.setSpout(spoutId, new MetaDataSpout(), 2);
builder.setBolt(boltId1, new VerifyMetaDataBolt(), 2).localOrShuffleGrouping(spoutId,
MetaDataSpout.STREAM_ID);
builder.setBolt(boltId2, new VerifyMetaDataBolt()).shuffleGrouping(boltId1,
VerifyMetaDataBolt.STREAM_ID);
final FlinkLocalCluster cluster = FlinkLocalCluster.getLocalCluster();
cluster.submitTopology(topologyId, null, FlinkTopology.createTopology(builder));
// run topology for 5 seconds
Utils.sleep(5 * 1000);
cluster.shutdown();
Assert.assertFalse(VerifyMetaDataBolt.errorOccured);
}
示例8: main
import org.apache.storm.utils.Utils; //导入方法依赖的package包/类
public static void main(final String[] args) throws Exception {
if (!SplitBoltTopology.parseParameters(args)) {
return;
}
// build Topology the Storm way
final TopologyBuilder builder = SplitBoltTopology.buildTopology();
final FlinkLocalCluster cluster = FlinkLocalCluster.getLocalCluster();
cluster.submitTopology(topologyId, null, FlinkTopology.createTopology(builder));
// run topology for 5 seconds
Utils.sleep(5 * 1000);
cluster.shutdown();
}
示例9: main
import org.apache.storm.utils.Utils; //导入方法依赖的package包/类
public static void main(String[] args) {
String consumerKey = args[0];
String consumerSecret = args[1];
String accessToken = args[2];
String accessTokenSecret = args[3];
String[] arguments = args.clone();
String[] keyWords = Arrays.copyOfRange(arguments, 4, arguments.length);
TopologyBuilder builder = new TopologyBuilder();
builder.setSpout("twitter", new TwitterSampleSpout(consumerKey, consumerSecret,
accessToken, accessTokenSecret, keyWords));
builder.setBolt("print", new PrinterBolt())
.shuffleGrouping("twitter");
Config conf = new Config();
LocalCluster cluster = new LocalCluster();
cluster.submitTopology("test", conf, builder.createTopology());
Utils.sleep(10000);
cluster.shutdown();
}
示例10: nextTuple
import org.apache.storm.utils.Utils; //导入方法依赖的package包/类
@Override
public void nextTuple() {
Utils.sleep(_delay);
if(cnt < jsons.size())
{
byte[] value;
if (_converter != null) {
value = _converter.convert(jsons.get(cnt));
} else {
value = jsons.get(cnt).getBytes();
}
_collector.emit(new Values(value));
}
cnt ++;
if(_repeating && cnt == jsons.size() -1 )
cnt = 0;
}
示例11: main
import org.apache.storm.utils.Utils; //导入方法依赖的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();
}
}
示例12: main
import org.apache.storm.utils.Utils; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
TopologyBuilder builder = new TopologyBuilder();
builder.setSpout("word0", new TestWordSpout(), 2);
builder.setSpout("word1", new TestWordSpout(), 2);
builder.setSpout("word2", new TestWordSpout(), 2);
builder.setBolt("exclaim1", new ExclamationBolt(), 2)
.shuffleGrouping("word0")
.shuffleGrouping("word1")
.shuffleGrouping("word2");
Config conf = new Config();
conf.setDebug(true);
conf.setMaxSpoutPending(10);
conf.put(Config.TOPOLOGY_WORKER_CHILDOPTS, "-XX:+HeapDumpOnOutOfMemoryError");
if (args != null && args.length > 0) {
conf.setNumWorkers(3);
StormSubmitter.submitTopology(args[0], conf, builder.createTopology());
} else {
LocalCluster cluster = new LocalCluster();
cluster.submitTopology("test", conf, builder.createTopology());
Utils.sleep(10000);
cluster.killTopology("test");
cluster.shutdown();
}
}
示例13: main
import org.apache.storm.utils.Utils; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
StormTopology topology = buildDevicesTopology();
Config conf = new Config();
conf.setMaxSpoutPending(20);
if (args.length == 0) {
LocalCluster cluster = new LocalCluster();
cluster.submitTopology("devices-topology", conf, topology);
Utils.sleep(60 * 1000);
cluster.shutdown();
System.exit(0);
} else {
conf.setNumWorkers(3);
StormSubmitter.submitTopologyWithProgressBar("devices-topology", conf, topology);
}
}
示例14: main
import org.apache.storm.utils.Utils; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
Config conf = new Config();
conf.setMaxSpoutPending(20);
conf.put(Config.TOPOLOGY_TRIDENT_WINDOWING_INMEMORY_CACHE_LIMIT, 100);
// window-state table should already be created with cf:tuples column
HBaseWindowsStoreFactory windowStoreFactory = new HBaseWindowsStoreFactory(new HashMap<String, Object>(), "window-state", "cf".getBytes("UTF-8"), "tuples".getBytes("UTF-8"));
if (args.length == 0) {
LocalCluster cluster = new LocalCluster();
String topologyName = "wordCounterWithWindowing";
cluster.submitTopology(topologyName, conf, buildTopology(windowStoreFactory));
Utils.sleep(120 * 1000);
cluster.killTopology(topologyName);
cluster.shutdown();
System.exit(0);
} else {
conf.setNumWorkers(3);
StormSubmitter.submitTopologyWithProgressBar(args[0], conf, buildTopology(windowStoreFactory));
}
}
示例15: main
import org.apache.storm.utils.Utils; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
TopologyBuilder builder = new TopologyBuilder();
builder.setSpout("word", new TestWordSpout(), 10);
builder.setBolt("exclaim1", new ExclamationLoggingBolt(), 3).shuffleGrouping("word");
builder.setBolt("exclaim2", new ExclamationLoggingBolt(), 2).shuffleGrouping("exclaim1");
Config conf = new Config();
conf.setDebug(true);
if (args != null && args.length > 0) {
conf.setNumWorkers(2);
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();
}
}