org.apache.hadoop.hdfs.server.common.Util.now()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(3.5k)|赞(0)|评价(0)|浏览(153)

本文整理了Java中org.apache.hadoop.hdfs.server.common.Util.now()方法的一些代码示例,展示了Util.now()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Util.now()方法的具体详情如下:
包路径:org.apache.hadoop.hdfs.server.common.Util
类名称:Util
方法名:now

Util.now介绍

[英]Current system time.
[中]当前系统时间。

代码示例

代码示例来源:origin: com.facebook.hadoop/hadoop-core

/**
 * Load an edit log, and apply the changes to the in-memory structure
 * This is where we apply edits that we've been writing to disk all
 * along.
 */
int loadFSEdits(EditLogInputStream edits, long expectedStartingTxId)
throws IOException {
 long startTime = now();
 currentTxId = expectedStartingTxId;
 int numEdits = loadFSEdits(edits, true);
 FSImage.LOG.info("Edits file " + edits.getName() 
   + " of size " + edits.length() + " edits # " + numEdits 
   + " loaded in " + (now()-startTime)/1000 + " seconds.");
 return numEdits;
}

代码示例来源:origin: com.facebook.hadoop/hadoop-core

private long dispatchBlockMoves() throws InterruptedException {
 long bytesLastMoved = bytesMoved.get();
 Future<?>[] futures = new Future<?>[sources.size()];
 int i=0;
 for (Source source : sources) {
  futures[i++] = dispatcherExecutor.submit(
           source.new BlockMoveDispatcher(Util.now()));
 }
 // wait for all dispatcher threads to finish
 for (Future<?> future : futures) {
  try {
   future.get();
  } catch (ExecutionException e) {
   LOG.warn("Dispatcher thread failed", e.getCause());
  }
 }
 // wait for all block moving to be done
 waitForMoveCompletion();
 return bytesMoved.get()-bytesLastMoved;
}

代码示例来源:origin: com.facebook.hadoop/hadoop-core

public int run(String[] args) throws Exception {
 final long startTime = Util.now();
 try {
  checkReplicationPolicyCompatibility(conf);
  final List<InetSocketAddress> namenodes = DFSUtil.getClientRpcAddresses(conf, null);
  parse(args);
  return Balancer.run(namenodes, conf);
 } catch (IOException e) {
  System.out.println(e + ".  Exiting ...");
  return IO_EXCEPTION;
 } catch (InterruptedException e) {
  System.out.println(e + ".  Exiting ...");
  return INTERRUPTED;
 } catch (Exception e) {
  e.printStackTrace();
  return ILLEGAL_ARGS; 
 } finally {
  System.out.println("Balancing took " + time2Str(Util.now()-startTime));
 }
}

代码示例来源:origin: org.jvnet.hudson.hadoop/hadoop-core

private void dispatchBlocks() {
 long startTime = Util.now();
 this.blocksToReceive = 2*scheduledSize;
 boolean isTimeUp = false;
  if (Util.now()-startTime > MAX_ITERATION_TIME) {
   isTimeUp = true;
   continue;

代码示例来源:origin: org.apache.hadoop/hadoop-hdfs-test

public void testThrottler() throws IOException {
 Configuration conf = new HdfsConfiguration();
 FileSystem.setDefaultUri(conf, "hdfs://localhost:0");
 long bandwidthPerSec = 1024*1024L;
 final long TOTAL_BYTES =6*bandwidthPerSec; 
 long bytesToSend = TOTAL_BYTES; 
 long start = Util.now();
 DataTransferThrottler throttler = new DataTransferThrottler(bandwidthPerSec);
 long totalBytes = 0L;
 long bytesSent = 1024*512L; // 0.5MB
 throttler.throttle(bytesSent);
 bytesToSend -= bytesSent;
 bytesSent = 1024*768L; // 0.75MB
 throttler.throttle(bytesSent);
 bytesToSend -= bytesSent;
 try {
  Thread.sleep(1000);
 } catch (InterruptedException ignored) {}
 throttler.throttle(bytesToSend);
 long end = Util.now();
 assertTrue(totalBytes*1000/(end-start)<=bandwidthPerSec);
}

代码示例来源:origin: com.facebook.hadoop/hadoop-core

long startTime = now();
  + " saved in " + (now() - startTime)/1000 + " seconds.");

代码示例来源:origin: com.facebook.hadoop/hadoop-core

if (Util.now()-startTime > maxIterationTime) {
 isTimeUp = true;
 continue;

代码示例来源:origin: org.jvnet.hudson.hadoop/hadoop-core

long startTime = Util.now();
OutputStream out = null;
try {
   time2Str(Util.now()-startTime));

代码示例来源:origin: com.facebook.hadoop/hadoop-core

assert curFile != null : "curFile is null";
long startTime = now();
  + (now() - startTime)/1000 + " seconds.");

相关文章