當前位置: 首頁>>代碼示例>>Java>>正文


Java Duration.seconds方法代碼示例

本文整理匯總了Java中io.dropwizard.util.Duration.seconds方法的典型用法代碼示例。如果您正苦於以下問題:Java Duration.seconds方法的具體用法?Java Duration.seconds怎麽用?Java Duration.seconds使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在io.dropwizard.util.Duration的用法示例。


在下文中一共展示了Duration.seconds方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setUp

import io.dropwizard.util.Duration; //導入方法依賴的package包/類
@Before
public void setUp() throws Exception {
    namespace = UUID.randomUUID().toString();
    metadataStorage = spy(getMetadataStorage());
    localStorage = spy(new LocalFileStorage(new LocalFileStorageConfiguration(localTestFolder.getRoot())));
    offsiteStorage = spy(getOffsiteStorage());
    final FileStorage logStorage = spy(new LocalFileStorage(new LocalFileStorageConfiguration(localLogFolder.getRoot())));
    final ExecutorService workerExecutor = MoreExecutors.sameThreadExecutor();
    listener = mock(BackupProcessorListener.class);

    final DistributedLockManager distributedLockManager = new MockDistributedLockManager(Duration.seconds(10));

    final CodecFactory codecFactory = mock(CodecFactory.class);
    when(codecFactory.get(any(CompressionCodec.class), anyBoolean())).thenReturn(new NullStreamCodec());

    processor = new BackupProcessor(distributedLockManager, metadataStorage, localStorage, offsiteStorage, codecFactory,
        workerExecutor, BackupConfiguration.DEFAULT_CHUNK_SIZE, logStorage, "localhost", ImmutableSet.of(".gz"), new MetricRegistry(), ImmutableList.of(listener));
    processor.start();
}
 
開發者ID:yammer,項目名稱:backups,代碼行數:20,代碼來源:BackupProcessorTest.java

示例2: testMultipleErrors

import io.dropwizard.util.Duration; //導入方法依賴的package包/類
@Test
public void testMultipleErrors() {
    Logger log = mock(Logger.class);
    ScheduledExecutorService executor = mock(ScheduledExecutorService.class);
    Duration seconds = Duration.seconds(30);
    RateLimitedLog rateLimitedLog =
            new DefaultRateLimitedLogFactory(executor, seconds)
                    .from(log);
    verify(executor).scheduleWithFixedDelay(Matchers.<Runnable>any(), eq(1L), eq(1L), eq(TimeUnit.MINUTES));
    Throwable t1 = new Throwable();
    Throwable t2 = new Throwable();
    Throwable t3 = new Throwable();

    rateLimitedLog.error(t1, "Test error: {}", "first!");
    rateLimitedLog.error(t2, "Test error: {}", "second!");
    rateLimitedLog.error(t3, "Test error: {}", "third!");

    // Check that the first error gets logged immediately.
    verify(log).error("Test error: first!", t1);
    ArgumentCaptor<Runnable> captor1 = ArgumentCaptor.forClass(Runnable.class);
    verify(executor).schedule(captor1.capture(), eq(30L), eq(TimeUnit.SECONDS));
    verifyNoMoreInteractions(log, executor);
    reset(executor);

    // Simulate the scheduled executor service running at the scheduled time after accumulating two more errors.
    captor1.getValue().run();

    verify(log).error("Encountered {} {} within the last {}: {}", 2L, "errors", Duration.seconds(30), "Test error: third!", t3);
    ArgumentCaptor<Runnable> captor2 = ArgumentCaptor.forClass(Runnable.class);
    verify(executor).schedule(captor2.capture(), eq(30L), eq(TimeUnit.SECONDS));
    verifyNoMoreInteractions(log, executor);

    // Simulate the scheduled executor service running at the scheduled time, this time with no errors to report.
    captor2.getValue().run();

    verifyNoMoreInteractions(log, executor);
}
 
開發者ID:bazaarvoice,項目名稱:emodb,代碼行數:38,代碼來源:DefaultRateLimitedLogFactoryTest.java

示例3: init

import io.dropwizard.util.Duration; //導入方法依賴的package包/類
@Before
public void init() {
    when(jdbi.open()).thenReturn(h);
    healthCheck = new JdbiHealthCheck(MoreExecutors.newDirectExecutorService(), Duration.seconds(5), jdbi,
            "select 1");
}
 
開發者ID:arteam,項目名稱:dropwizard-jdbi3,代碼行數:7,代碼來源:HealthCheckTest.java

示例4: SessionFactoryHealthCheck

import io.dropwizard.util.Duration; //導入方法依賴的package包/類
public SessionFactoryHealthCheck(final SessionFactory sessionFactory,
                                 final String validationQuery) {
    this(MoreExecutors.newDirectExecutorService(), Duration.seconds(0), sessionFactory, validationQuery);
}
 
開發者ID:mtakaki,項目名稱:CredentialStorageService-dw-hibernate,代碼行數:5,代碼來源:SessionFactoryHealthCheck.java

示例5: DefaultRateLimitedLogFactory

import io.dropwizard.util.Duration; //導入方法依賴的package包/類
@Inject
public DefaultRateLimitedLogFactory(LifeCycleRegistry lifeCycle) {
    this(defaultExecutor(lifeCycle), Duration.seconds(30));
}
 
開發者ID:bazaarvoice,項目名稱:emodb,代碼行數:5,代碼來源:DefaultRateLimitedLogFactory.java

示例6: ManagedGrpcChannel

import io.dropwizard.util.Duration; //導入方法依賴的package包/類
public ManagedGrpcChannel(final ManagedChannel channel) {
    this(channel, Duration.seconds(5));
}
 
開發者ID:msteinhoff,項目名稱:dropwizard-grpc,代碼行數:4,代碼來源:ManagedGrpcChannel.java

示例7: ManagedGrpcServer

import io.dropwizard.util.Duration; //導入方法依賴的package包/類
public ManagedGrpcServer(final Server server) {
    this(server, Duration.seconds(5));
}
 
開發者ID:msteinhoff,項目名稱:dropwizard-grpc,代碼行數:4,代碼來源:ManagedGrpcServer.java

示例8: EntityManagerFactoryHealthCheck

import io.dropwizard.util.Duration; //導入方法依賴的package包/類
EntityManagerFactoryHealthCheck(EntityManagerFactory entityManagerFactory,
                                       String validationQuery) {
    this(MoreExecutors.newDirectExecutorService(), Duration.seconds(0), entityManagerFactory, validationQuery);
}
 
開發者ID:scottescue,項目名稱:dropwizard-entitymanager,代碼行數:5,代碼來源:EntityManagerFactoryHealthCheck.java

示例9: setUp

import io.dropwizard.util.Duration; //導入方法依賴的package包/類
@Before
public void setUp() throws Exception {
    when(cluster.connect()).thenReturn(session);
    healthCheck = new CassandraHealthCheck(cluster, validationQuery, Duration.seconds(1));
}
 
開發者ID:composable-systems,項目名稱:dropwizard-cassandra,代碼行數:6,代碼來源:CassandraHealthCheckTest.java

示例10: QueryClient

import io.dropwizard.util.Duration; //導入方法依賴的package包/類
public QueryClient(QueryRunner queryRunner, String query)
{
    this(queryRunner, Duration.seconds(60 * 30), query);
}
 
開發者ID:airbnb,項目名稱:airpal,代碼行數:5,代碼來源:QueryClient.java

示例11: AtomixHealthCheck

import io.dropwizard.util.Duration; //導入方法依賴的package包/類
/**
 * Constructor with a default ping timeout of 1 second
 *
 * @param atomix
 *            Atomix instance
 */
public AtomixHealthCheck(@Nonnull final Atomix atomix) {
    this(atomix, Duration.seconds(1));
}
 
開發者ID:smoketurner,項目名稱:dropwizard-atomix,代碼行數:10,代碼來源:AtomixHealthCheck.java


注:本文中的io.dropwizard.util.Duration.seconds方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。