当前位置: 首页>>代码示例>>Java>>正文


Java Utils.sleep方法代码示例

本文整理汇总了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);
  }
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:20,代码来源:MesosSupervisor.java

示例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);
    }
}
 
开发者ID:uzh,项目名称:storm-scheduler,代码行数:21,代码来源:UuidFixedRatePayloadSpout.java

示例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));
}
 
开发者ID:splicemachine,项目名称:splice-community-sample-code,代码行数:19,代码来源:SpliceIntegerSpout.java

示例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);
    }
}
 
开发者ID:splicemachine,项目名称:splice-community-sample-code,代码行数:19,代码来源:MySqlSpout.java

示例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();
	}
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:22,代码来源:LocalTopologyMode.java

示例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();

}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:20,代码来源:StormPlayground.java

示例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);
	}
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:21,代码来源:KestrelThriftSpout.java

示例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();
}
 
开发者ID:linkshare,项目名称:cdh-storm,代码行数:27,代码来源:PrintSampleStream.java

示例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);
    }
}
 
开发者ID:uzh,项目名称:storm-scheduler,代码行数:14,代码来源:UuidSpout.java

示例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);
    }
}
 
开发者ID:uzh,项目名称:storm-scheduler,代码行数:14,代码来源:UuidPayloadSpout.java

示例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();
        }

    }
 
开发者ID:telefonicaid,项目名称:fiware-sinfonier,代码行数:35,代码来源:DynamicTopology.java

示例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();
    }
 
开发者ID:splicemachine,项目名称:splice-community-sample-code,代码行数:33,代码来源:SpliceDumperTopology.java

示例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);

  }

}
 
开发者ID:techysoul,项目名称:java,代码行数:33,代码来源:TradeReportPersistenceBolt.java

示例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();
}
 
开发者ID:yangliguang,项目名称:preliminary.demo,代码行数:10,代码来源:RaceSentenceSpout.java

示例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);
        }
    }
 
开发者ID:cutoutsy,项目名称:miner,代码行数:11,代码来源:EmitMessageSpout.java


注:本文中的backtype.storm.utils.Utils.sleep方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。