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


Java Duration类代码示例

本文整理汇总了Java中io.airlift.units.Duration的典型用法代码示例。如果您正苦于以下问题:Java Duration类的具体用法?Java Duration怎么用?Java Duration使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Duration类属于io.airlift.units包,在下文中一共展示了Duration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: get

import io.airlift.units.Duration; //导入依赖的package包/类
public ReloadableSslContext get(
        File trustCertificatesFile,
        Optional<File> clientCertificatesFile,
        Optional<File> privateKeyFile,
        Optional<String> privateKeyPassword,
        long sessionCacheSize,
        Duration sessionTimeout,
        List<String> ciphers)
{
    try {
        return cache.getUnchecked(new SslContextConfig(trustCertificatesFile, clientCertificatesFile, privateKeyFile, privateKeyPassword, sessionCacheSize, sessionTimeout, ciphers));
    }
    catch (UncheckedExecutionException | ExecutionError e) {
        throw new RuntimeException("Error initializing SSL context", e.getCause());
    }
}
 
开发者ID:airlift,项目名称:drift,代码行数:17,代码来源:SslContextFactory.java

示例2: ApacheThriftMethodInvoker

import io.airlift.units.Duration; //导入依赖的package包/类
public ApacheThriftMethodInvoker(
        ListeningExecutorService executorService,
        ListeningScheduledExecutorService delayService,
        TTransportFactory transportFactory,
        TProtocolFactory protocolFactory,
        Duration connectTimeout,
        Duration requestTimeout,
        Optional<HostAndPort> socksProxy,
        Optional<SSLContext> sslContext)
{
    this.executorService = requireNonNull(executorService, "executorService is null");
    this.delayService = requireNonNull(delayService, "delayService is null");
    this.transportFactory = requireNonNull(transportFactory, "transportFactory is null");
    this.protocolFactory = requireNonNull(protocolFactory, "protocolFactory is null");
    this.connectTimeoutMillis = Ints.saturatedCast(requireNonNull(connectTimeout, "connectTimeout is null").toMillis());
    this.requestTimeoutMillis = Ints.saturatedCast(requireNonNull(requestTimeout, "requestTimeout is null").toMillis());
    this.socksProxy = requireNonNull(socksProxy, "socksProxy is null");
    this.sslContext = requireNonNull(sslContext, "sslContext is null");
}
 
开发者ID:airlift,项目名称:drift,代码行数:20,代码来源:ApacheThriftMethodInvoker.java

示例3: testDefaults

import io.airlift.units.Duration; //导入依赖的package包/类
@Test
public void testDefaults()
{
    assertRecordedDefaults(recordDefaults(ApacheThriftClientConfig.class)
            .setTransport(FRAMED)
            .setProtocol(BINARY)
            .setConnectTimeout(new Duration(500, MILLISECONDS))
            .setRequestTimeout(new Duration(1, MINUTES))
            .setSocksProxy(null)
            .setMaxFrameSize(new DataSize(16, MEGABYTE))
            .setMaxStringSize(new DataSize(16, MEGABYTE))
            .setSslEnabled(false)
            .setTrustCertificate(null)
            .setKey(null)
            .setKeyPassword(null));
}
 
开发者ID:airlift,项目名称:drift,代码行数:17,代码来源:TestApacheThriftClientConfig.java

示例4: ReloadableSslContext

import io.airlift.units.Duration; //导入依赖的package包/类
public ReloadableSslContext(
        File trustCertificatesFile,
        Optional<File> clientCertificatesFile,
        Optional<File> privateKeyFile,
        Optional<String> privateKeyPassword,
        long sessionCacheSize,
        Duration sessionTimeout,
        List<String> ciphers)
{
    this.trustCertificatesFileWatch = new FileWatch(requireNonNull(trustCertificatesFile, "trustCertificatesFile is null"));
    requireNonNull(clientCertificatesFile, "clientCertificatesFile is null");
    this.clientCertificatesFileWatch = clientCertificatesFile.map(FileWatch::new);
    requireNonNull(privateKeyFile, "privateKeyFile is null");
    this.privateKeyFileWatch = privateKeyFile.map(FileWatch::new);
    this.privateKeyPassword = requireNonNull(privateKeyPassword, "privateKeyPassword is null");
    this.sessionCacheSize = sessionCacheSize;
    this.sessionTimeout = requireNonNull(sessionTimeout, "sessionTimeout is null");
    this.ciphers = ImmutableList.copyOf(requireNonNull(ciphers, "ciphers is null"));
    reload();
}
 
开发者ID:airlift,项目名称:drift,代码行数:21,代码来源:ReloadableSslContext.java

示例5: SslContextConfig

import io.airlift.units.Duration; //导入依赖的package包/类
public SslContextConfig(
        File trustCertificatesFile,
        Optional<File> clientCertificatesFile,
        Optional<File> privateKeyFile,
        Optional<String> privateKeyPassword,
        long sessionCacheSize,
        Duration sessionTimeout, List<String> ciphers)
{
    this.trustCertificatesFile = requireNonNull(trustCertificatesFile, "trustCertificatesFile is null");
    this.clientCertificatesFile = requireNonNull(clientCertificatesFile, "clientCertificatesFile is null");
    this.privateKeyFile = requireNonNull(privateKeyFile, "privateKeyFile is null");
    this.privateKeyPassword = requireNonNull(privateKeyPassword, "privateKeyPassword is null");
    this.sessionCacheSize = sessionCacheSize;
    this.sessionTimeout = requireNonNull(sessionTimeout, "sessionTimeout is null");
    this.ciphers = ImmutableList.copyOf(requireNonNull(ciphers, "ciphers is null"));
}
 
开发者ID:airlift,项目名称:drift,代码行数:17,代码来源:SslContextFactory.java

示例6: testExplicitPropertyMappings

import io.airlift.units.Duration; //导入依赖的package包/类
@Test
public void testExplicitPropertyMappings()
{
    Map<String, String> properties = new ImmutableMap.Builder<String, String>()
            .put("thrift.client.thread-count", "99")
            .put("thrift.client.ssl-context.refresh-time", "33m")
            .put("thrift.client.socks-proxy", "example.com:9876")
            .build();

    DriftNettyConnectionFactoryConfig expected = new DriftNettyConnectionFactoryConfig()
            .setThreadCount(99)
            .setSslContextRefreshTime(new Duration(33, MINUTES))
            .setSocksProxy(HostAndPort.fromParts("example.com", 9876));

    assertFullMapping(properties, expected);
}
 
开发者ID:airlift,项目名称:drift,代码行数:17,代码来源:TestDriftNettyConnectionFactoryConfig.java

示例7: testExplicitPropertyMappings

import io.airlift.units.Duration; //导入依赖的package包/类
@Test
public void testExplicitPropertyMappings()
{
    Map<String, String> properties = new ImmutableMap.Builder<String, String>()
            .put("thrift.client.max-retries", "99")
            .put("thrift.client.min-backoff-delay", "11ms")
            .put("thrift.client.max-backoff-delay", "22m")
            .put("thrift.client.backoff-scale-factor", "2.2")
            .put("thrift.client.max-retry-time", "33m")
            .put("thrift.client.stats.enabled", "false")
            .build();

    DriftClientConfig expected = new DriftClientConfig()
            .setMaxRetries(99)
            .setMinBackoffDelay(new Duration(11, MILLISECONDS))
            .setMaxBackoffDelay(new Duration(22, MINUTES))
            .setBackoffScaleFactor(2.2)
            .setMaxRetryTime(new Duration(33, MINUTES))
            .setStatsEnabled(false);

    assertFullMapping(properties, expected);
}
 
开发者ID:airlift,项目名称:drift,代码行数:23,代码来源:TestDriftClientConfig.java

示例8: RetryPolicy

import io.airlift.units.Duration; //导入依赖的package包/类
public RetryPolicy(int maxRetries,
        Duration minBackoffDelay,
        Duration maxBackoffDelay,
        double backoffScaleFactor,
        Duration maxRetryTime,
        ExceptionClassifier exceptionClassifier)
{
    checkArgument(maxRetries >= 0, "maxRetries must be positive");
    this.maxRetries = maxRetries;
    this.minBackoffDelay = requireNonNull(minBackoffDelay, "minBackoffDelay is null");
    this.maxBackoffDelay = requireNonNull(maxBackoffDelay, "maxBackoffDelay is null");
    checkArgument(backoffScaleFactor >= 1.0, "backoffScaleFactor must be at least 1");
    this.backoffScaleFactor = backoffScaleFactor;
    this.maxRetryTime = requireNonNull(maxRetryTime, "maxRetryTime is null");
    this.exceptionClassifier = requireNonNull(exceptionClassifier, "exceptionClassifier is null");
}
 
开发者ID:airlift,项目名称:drift,代码行数:17,代码来源:RetryPolicy.java

示例9: testMaxFailureInterval

import io.airlift.units.Duration; //导入依赖的package包/类
@Test
public void testMaxFailureInterval()
{
    TestingTicker ticker = new TestingTicker();
    Backoff backoff = new Backoff(new Duration(15, SECONDS), ticker, new Duration(10, MILLISECONDS));
    ticker.increment(10, MICROSECONDS);

    assertEquals(backoff.getFailureCount(), 0);
    assertEquals(backoff.getTimeSinceLastSuccess().roundTo(SECONDS), 0);

    ticker.increment(14, SECONDS);

    assertFalse(backoff.failure());
    assertEquals(backoff.getFailureCount(), 1);
    assertEquals(backoff.getTimeSinceLastSuccess().roundTo(SECONDS), 14);

    ticker.increment(1, SECONDS);

    assertTrue(backoff.failure());
    assertEquals(backoff.getFailureCount(), 2);
    assertEquals(backoff.getTimeSinceLastSuccess().roundTo(SECONDS), 15);
}
 
开发者ID:y-lan,项目名称:presto,代码行数:23,代码来源:BackoffTest.java

示例10: toString

import io.airlift.units.Duration; //导入依赖的package包/类
@Override
public String toString()
{
    return MoreObjects.toStringHelper(this)
            .add("suite", suite.getName())
            .add("benchmarkQuery", benchmarkQuery.getName())
            .add("status", status)
            .add("wallTimeMedian", new Duration(wallTimeNanos.getMedian(), NANOSECONDS).convertToMostSuccinctTimeUnit())
            .add("wallTimeMean", new Duration(wallTimeNanos.getMean(), NANOSECONDS).convertToMostSuccinctTimeUnit())
            .add("wallTimeStd", new Duration(wallTimeNanos.getStandardDeviation(), NANOSECONDS).convertToMostSuccinctTimeUnit())
            .add("processCpuTimeMedian", new Duration(processCpuTimeNanos.getMedian(), NANOSECONDS).convertToMostSuccinctTimeUnit())
            .add("processCpuTimeMean", new Duration(processCpuTimeNanos.getMean(), NANOSECONDS).convertToMostSuccinctTimeUnit())
            .add("processCpuTimeStd", new Duration(processCpuTimeNanos.getStandardDeviation(), NANOSECONDS).convertToMostSuccinctTimeUnit())
            .add("queryCpuTimeMedian", new Duration(queryCpuTimeNanos.getMedian(), NANOSECONDS).convertToMostSuccinctTimeUnit())
            .add("queryCpuTimeMean", new Duration(queryCpuTimeNanos.getMean(), NANOSECONDS).convertToMostSuccinctTimeUnit())
            .add("queryCpuTimeStd", new Duration(queryCpuTimeNanos.getStandardDeviation(), NANOSECONDS).convertToMostSuccinctTimeUnit())
            .add("error", errorMessage)
            .toString();
}
 
开发者ID:y-lan,项目名称:presto,代码行数:20,代码来源:BenchmarkQueryResult.java

示例11: RetryDriver

import io.airlift.units.Duration; //导入依赖的package包/类
private RetryDriver(
        int maxAttempts,
        Duration minSleepTime,
        Duration maxSleepTime,
        double scaleFactor,
        Duration maxRetryTime,
        Function<Exception, Exception> exceptionMapper,
        List<Class<? extends Exception>> exceptionWhiteList,
        Optional<Runnable> retryRunnable)
{
    this.maxAttempts = maxAttempts;
    this.minSleepTime = minSleepTime;
    this.maxSleepTime = maxSleepTime;
    this.scaleFactor = scaleFactor;
    this.maxRetryTime = maxRetryTime;
    this.exceptionMapper = exceptionMapper;
    this.exceptionWhiteList = exceptionWhiteList;
    this.retryRunnable = retryRunnable;
}
 
开发者ID:y-lan,项目名称:presto,代码行数:20,代码来源:RetryDriver.java

示例12: getNextPage

import io.airlift.units.Duration; //导入依赖的package包/类
@Nullable
public Page getNextPage(Duration maxWaitTime)
        throws InterruptedException
{
    checkState(!Thread.holdsLock(this), "Can not get next page while holding a lock on this");

    throwIfFailed();

    if (closed.get()) {
        return null;
    }

    scheduleRequestIfNecessary();

    Page page = pageBuffer.poll();
    // only wait for a page if we have remote clients
    if (page == null && maxWaitTime.toMillis() >= 1 && !allClients.isEmpty()) {
        page = pageBuffer.poll(maxWaitTime.toMillis(), TimeUnit.MILLISECONDS);
    }

    page = postProcessPage(page);
    return page;
}
 
开发者ID:y-lan,项目名称:presto,代码行数:24,代码来源:ExchangeClient.java

示例13: Backoff

import io.airlift.units.Duration; //导入依赖的package包/类
public Backoff(Duration maxFailureInterval, Ticker ticker, Duration... backoffDelayIntervals)
{
    requireNonNull(maxFailureInterval, "maxFailureInterval is null");
    requireNonNull(ticker, "ticker is null");
    requireNonNull(backoffDelayIntervals, "backoffDelayIntervals is null");
    checkArgument(backoffDelayIntervals.length > 0, "backoffDelayIntervals must contain at least one entry");

    this.maxFailureIntervalNanos = maxFailureInterval.roundTo(NANOSECONDS);
    this.ticker = ticker;
    this.backoffDelayIntervalsNanos = new long[backoffDelayIntervals.length];
    for (int i = 0; i < backoffDelayIntervals.length; i++) {
        this.backoffDelayIntervalsNanos[i] = backoffDelayIntervals[i].roundTo(NANOSECONDS);
    }

    this.lastSuccessTime = this.ticker.read();
}
 
开发者ID:y-lan,项目名称:presto,代码行数:17,代码来源:Backoff.java

示例14: testExplicitPropertyMappings

import io.airlift.units.Duration; //导入依赖的package包/类
@Test
public void testExplicitPropertyMappings()
{
    Map<String, String> properties = new ImmutableMap.Builder<String, String>()
            .put("raptor.max-transaction-age", "42m")
            .put("raptor.local-cleaner-interval", "31m")
            .put("raptor.local-clean-time", "32m")
            .put("raptor.local-purge-time", "33m")
            .put("raptor.backup-cleaner-interval", "34m")
            .put("raptor.backup-clean-time", "35m")
            .put("raptor.backup-purge-time", "36m")
            .put("raptor.backup-deletion-threads", "37")
            .build();

    ShardCleanerConfig expected = new ShardCleanerConfig()
            .setMaxTransactionAge(new Duration(42, MINUTES))
            .setLocalCleanerInterval(new Duration(31, MINUTES))
            .setLocalCleanTime(new Duration(32, MINUTES))
            .setLocalPurgeTime(new Duration(33, MINUTES))
            .setBackupCleanerInterval(new Duration(34, MINUTES))
            .setBackupCleanTime(new Duration(35, MINUTES))
            .setBackupPurgeTime(new Duration(36, MINUTES))
            .setBackupDeletionThreads(37);

    assertFullMapping(properties, expected);
}
 
开发者ID:y-lan,项目名称:presto,代码行数:27,代码来源:TestShardCleanerConfig.java

示例15: createCatalog

import io.airlift.units.Duration; //导入依赖的package包/类
@Override
public void createCatalog(String catalogName, String connectorName, Map<String, String> properties)
{
    long start = System.nanoTime();
    for (TestingPrestoServer server : servers) {
        server.createCatalog(catalogName, connectorName, properties);
    }
    log.info("Created catalog %s in %s", catalogName, nanosSince(start).convertToMostSuccinctTimeUnit());

    // wait for all nodes to announce the new catalog
    start = System.nanoTime();
    while (!isConnectionVisibleToAllNodes(catalogName)) {
        Assertions.assertLessThan(nanosSince(start), new Duration(100, SECONDS), "waiting form connector " + connectorName + " to be initialized in every node");
        try {
            MILLISECONDS.sleep(10);
        }
        catch (InterruptedException e) {
            Thread.currentThread().interrupt();
            throw Throwables.propagate(e);
        }
    }
    log.info("Announced catalog %s in %s", catalogName, nanosSince(start).convertToMostSuccinctTimeUnit());
}
 
开发者ID:y-lan,项目名称:presto,代码行数:24,代码来源:DistributedQueryRunner.java


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