com.twitter.util.Duration.fromTimeUnit()方法的使用及代码示例

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

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

Duration.fromTimeUnit介绍

暂无

代码示例

代码示例来源:origin: twitter/distributedlog

/**
 * Await for the transmit to be complete
 *
 * @param timeout
 *          wait timeout
 * @param unit
 *          wait timeout unit
 */
int awaitTransmitComplete(long timeout, TimeUnit unit)
  throws Exception {
  return Await.result(transmitComplete,
      Duration.fromTimeUnit(timeout, unit));
}

代码示例来源:origin: twitter/distributedlog

logger.info("Waiting for closing all streams ...");
try {
  Await.result(closeResult, Duration.fromTimeUnit(5, TimeUnit.MINUTES));
  logger.info("Closed all streams in {} millis.",
      closeStreamsStopwatch.elapsed(TimeUnit.MILLISECONDS));

代码示例来源:origin: com.twitter.common/net-http-handlers-pprof

@Override
 protected final void doGet(HttpServletRequest req, HttpServletResponse resp)
   throws ServletException, IOException {

  final int profileDurationSecs = HttpServletRequestParams.getInt(req, "seconds", 10);
  final int profilePollRate = HttpServletRequestParams.getInt(req, "hz", 100);
  LOG.info("Collecting CPU profile for " + profileDurationSecs + " seconds at "
    + profilePollRate + " Hz");

  Duration sampleDuration = Duration.fromTimeUnit(profileDurationSecs, TimeUnit.SECONDS);
  CpuProfile profile =
    CpuProfile.recordInThread(sampleDuration, profilePollRate, stateToProfile).get();
  resp.setHeader("Content-Type", "pprof/raw");
  resp.setStatus(HttpServletResponse.SC_OK);
  OutputStream responseBody = resp.getOutputStream();
  try {
   profile.writeGoogleProfile(responseBody);
  } finally {
   Closeables.close(responseBody, /* swallowIOException */ true);
  }
 }
}

代码示例来源:origin: org.apache.distributedlog/distributedlog-service

logger.info("Waiting for closing all streams ...");
try {
  Await.result(closeResult, Duration.fromTimeUnit(5, TimeUnit.MINUTES));
  logger.info("Closed all streams in {} millis.",
      closeStreamsStopwatch.elapsed(TimeUnit.MILLISECONDS));

代码示例来源:origin: com.twitter/finagle-example

Backoff.exponential(
 Duration.fromTimeUnit(100, TimeUnit.MILLISECONDS),

代码示例来源:origin: pinterest/pinlater

public static void main(String[] args) {
  try {
   String serverHostName = InetAddress.getLocalHost().getHostName();
   PinLaterQueueConfig queueConfig = new PinLaterQueueConfig(CONFIGURATION);
   queueConfig.initialize();
   String backend = CONFIGURATION.getString("PINLATER_BACKEND");
   PinLaterBackendIface backendIFace = getBackendIface(backend, serverHostName);
   PinLaterServiceImpl serviceImpl = new PinLaterServiceImpl(backendIFace, queueConfig);
   PinLater.Service service = new PinLater.Service(serviceImpl, new TBinaryProtocol.Factory());
   ServiceShutdownHook.register(ServerBuilder.safeBuild(
     service,
     ServerBuilder.get()
       .name("PinLaterService")
       .codec(ThriftServerFramedCodec.get())
       .hostConnectionMaxIdleTime(Duration.fromTimeUnit(
         CONFIGURATION.getInt("SERVER_CONN_MAX_IDLE_TIME_MINUTES"), TimeUnit.MINUTES))
       .maxConcurrentRequests(CONFIGURATION.getInt("MAX_CONCURRENT_REQUESTS"))
       .reportTo(new OstrichStatsReceiver(Stats.get("")))
       .bindTo(new InetSocketAddress(CONFIGURATION.getInt("THRIFT_PORT")))));
   new OstrichAdminService(CONFIGURATION.getInt("OSTRICH_PORT")).start();

   LOG.info("\n#######################################"
     + "\n#      Ready To Serve Requests.       #"
     + "\n#######################################");
  } catch (Exception e) {
   LOG.error("Failed to start the pinlater server", e);
   System.exit(1);
  }
 }
}

相关文章