本文整理汇总了Java中backtype.storm.utils.Utils.sleep方法的典型用法代码示例。如果您正苦于以下问题:Java Utils.sleep方法的具体用法?Java Utils.sleep怎么用?Java Utils.sleep使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类backtype.storm.utils.Utils
的用法示例。
在下文中一共展示了Utils.sleep方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: run
import backtype.storm.utils.Utils; //导入方法依赖的package包/类
@Override
public void run() {
try {
while (true) {
long now = System.currentTimeMillis();
if (!_supervisorViewOfAssignedPorts.get().isEmpty()) {
_lastTime = now;
}
if ((now - _lastTime) > 1000L * _timeoutSecs) {
LOG.info("Supervisor has not had anything assigned for {} secs. Committing suicide...", _timeoutSecs);
Runtime.getRuntime().halt(0);
}
Utils.sleep(5000);
}
} catch (Throwable t) {
LOG.error(t.getMessage());
Runtime.getRuntime().halt(2);
}
}
示例2: nextTuple
import backtype.storm.utils.Utils; //导入方法依赖的package包/类
@Override
public void nextTuple() {
long thisSecond;
// find out if a new second has started and if so
thisSecond = System.currentTimeMillis() / 1000;
if (thisSecond != this.lastSecond) {
// a new second has started
this.lastSecond = thisSecond;
this.tuplesRemainingThisSecond = this.tuplesPerSecond;
}
this.tuplesRemainingThisSecond--; // bookkeeping
if (this.tuplesRemainingThisSecond > 0) { // emit if possible
super.nextTuple();
} else { // throttle if necessary
/** we should wait 1ms. {@see backtype.storm.spout.ISpout#nextTuple()} */
Utils.sleep(1);
}
}
示例3: nextTuple
import backtype.storm.utils.Utils; //导入方法依赖的package包/类
@Override
public void nextTuple() {
Utils.sleep(1000);
String[] words = new String[]{"splice", "machine", "hadoop", "rdbms", "acid", "sql", "transactions"};
Integer[] numbers = new Integer[]{
1, 2, 3, 4, 5, 6, 7
};
if (count == numbers.length - 1) {
count = 0;
}
count++;
int number = numbers[count];
String word = words[count];
int randomNum = (int) (Math.random() * 1000);
System.out.println("Random Number: " + randomNum);
System.out.println("SpliceIntegerSpout emitting: " + number);
_collector.emit(new Values(word, number));
}
示例4: nextTuple
import backtype.storm.utils.Utils; //导入方法依赖的package包/类
public void nextTuple() {
if (bufferQueue.isEmpty()) {
// pass in mysql server, db name, user, password
seedBufferQueue("localhost", "test", "root", "");
Utils.sleep(100);
} else {
// Replace name with the data being extracted.
// This example expects only name to be returned in the sql/and thus is only item output by the spout.
// To add additional data add them to the values using new Values(value1, value2, etc) then emit the values
String name = bufferQueue.poll();
if (name != null) {
Values values = new Values();
values.add(name);
_collector.emit(values);
}
Utils.sleep(50);
}
}
示例5: finish
import backtype.storm.utils.Utils; //导入方法依赖的package包/类
@Override
public void finish(StormToolOptions options) throws Exception {
try {
if (sleepTime < 0) {
logger.debug("Waiting forever");
while (true) {
Utils.sleep(DEFAULT_SLEEP_TIME);
}
} else {
logger.debug("Waiting " + sleepTime + " milliseconds");
Utils.sleep(sleepTime);
}
} finally {
logger.debug("Killing topology");
cluster.killTopology(options.topologyName());
logger.debug("Shutting down cluster");
cluster.shutdown();
options.topologyCleanup();
}
}
示例6: main
import backtype.storm.utils.Utils; //导入方法依赖的package包/类
public static void main(String[] args) {
final Config conf = new Config();
conf.setDebug(false);
conf.setNumWorkers(2);
conf.setMaxSpoutPending(1);
conf.setFallBackOnJavaSerialization(false);
conf.setSkipMissingKryoRegistrations(false);
final LocalCluster cluster = new LocalCluster();
final TopologyBuilder builder = new TopologyBuilder();
builder.setSpout("randomSpout1", new RandomFieldSpout(2, 0, 0, 1)); // (nfields,seed,min,max)
builder.setSpout("randomSpout2", new RandomFieldSpout(2, 10, 0, 1)); // (nfields,seed,min,max)
JoinBolt.connectNewBolt(builder);
final StormTopology topology = builder.createTopology();
cluster.submitTopology("playTopology", conf, topology);
Utils.sleep(10000);
cluster.killTopology("playTopology");
cluster.shutdown();
}
示例7: nextTuple
import backtype.storm.utils.Utils; //导入方法依赖的package包/类
@Override
public void nextTuple() {
if (_emitBuffer.isEmpty())
tryEachKestrelUntilBufferFilled();
if (countTriples % 1000 == 0 && countTriples != lastEmit) {
LOG.debug("Number of triples emitted: " + countTriples);
LOG.debug("Number of empty iterations: " + emptyIterations);
emptyIterations = 0;
lastEmit = countTriples;
}
final EmitItem item = _emitBuffer.poll();
if (item != null) {
countTriples += 1;
_collector.emit(item.tuple, item.sourceId);
} else { // If buffer is still empty here, then every kestrel Q is also
// empty.
emptyIterations++;
Utils.sleep(10);
}
}
示例8: main
import backtype.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("spoutId", new TwitterSampleSpout(consumerKey, consumerSecret,
accessToken, accessTokenSecret, keyWords));
builder.setBolt("print", new PrinterBolt())
.shuffleGrouping("spout");
Config conf = new Config();
LocalCluster cluster = new LocalCluster();
cluster.submitTopology("test", conf, builder.createTopology());
Utils.sleep(10000);
cluster.shutdown();
}
示例9: nextTuple
import backtype.storm.utils.Utils; //导入方法依赖的package包/类
@Override
public void nextTuple() {
if (!this.disableAniello) {
taskMonitor.checkThreadId();
}
this.emitCount++; // we start with msgId = 1
this.collector.emit(new Values(this.uuid), this.emitCount);
if ((emitCount % (100 * 1000)) == 0) {
LOG.info("Emitted {} tuples", this.emitCount);
Utils.sleep(1);
}
}
示例10: nextTuple
import backtype.storm.utils.Utils; //导入方法依赖的package包/类
@Override
public void nextTuple() {
if (!this.disableAniello) {
taskMonitor.checkThreadId();
}
this.emitCount++; // we start with msgId = 1
this.collector.emit(new Values(this.uuid, this.payload), this.emitCount);
if ((emitCount % (100 * 1000) ) == 0) {
LOG.info("Emitted {} tuples", this.emitCount);
Utils.sleep(1);
}
}
示例11: main
import backtype.storm.utils.Utils; //导入方法依赖的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.utils.Utils; //导入方法依赖的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: execute
import backtype.storm.utils.Utils; //导入方法依赖的package包/类
@Override
public void execute(Tuple tuple) {
LOGGER.info("Processing ELIGIBLE Trade");
long newTime = 0;
try {
if (CONFIG.is("REPORTING_TIME_DELAY_ON")) {
Utils.sleep(CONFIG.getLong("REPORTING_PERSISTENCE_TIME"));
}
FileWriter fileWriter = new FileWriter(CONFIG.get("REPT_PERSISTENCE_PATH"), true);
BufferedWriter bufferedWriter = new BufferedWriter(fileWriter);
bufferedWriter.write(tuple.getString(0));
bufferedWriter.write(COMMA_SEPARATOR);
bufferedWriter.write(String.valueOf(new Date()));
bufferedWriter.write(COMMA_SEPARATOR);
newTime = new Date().getTime();
bufferedWriter.write(String.valueOf(newTime));
bufferedWriter.write(COMMA_SEPARATOR);
bufferedWriter.write(
String.valueOf(newTime - Long.parseLong(tuple.getString(0).split(COMMA_SEPARATOR)[4])));
bufferedWriter.newLine();
bufferedWriter.close();
// Checking and Performing Ack
if (CONFIG.is("ACK_ON")) {
_collector.ack(tuple);
}
} catch (Throwable e) {
LOGGER.error(EXEC_EXCP_MSG, e);
_collector.fail(tuple);
}
}
示例14: nextTuple
import backtype.storm.utils.Utils; //导入方法依赖的package包/类
public void nextTuple() {
int n = sendNumPerNexttuple;
while (--n >= 0) {
Utils.sleep(10);
String sentence = CHOICES[_rand.nextInt(CHOICES.length)];
_collector.emit(new Values(sentence));
}
updateSendTps();
}
示例15: nextTuple
import backtype.storm.utils.Utils; //导入方法依赖的package包/类
public void nextTuple() {
Utils.sleep(5000);
for(int i = 22; i<= 30; i++) {
Utils.sleep(1000);
String url = "https://account.wandoujia.com/v4/api/simple/profile?uid="+String.valueOf(i);
// String message = Crawl4HttpClient.downLoadPage(url);
// System.out.println(message);
_collector.emit(new Values(url), i);
}
}