本文整理匯總了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();
}
示例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);
}
示例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");
}
示例4: SessionFactoryHealthCheck
import io.dropwizard.util.Duration; //導入方法依賴的package包/類
public SessionFactoryHealthCheck(final SessionFactory sessionFactory,
final String validationQuery) {
this(MoreExecutors.newDirectExecutorService(), Duration.seconds(0), sessionFactory, validationQuery);
}
示例5: DefaultRateLimitedLogFactory
import io.dropwizard.util.Duration; //導入方法依賴的package包/類
@Inject
public DefaultRateLimitedLogFactory(LifeCycleRegistry lifeCycle) {
this(defaultExecutor(lifeCycle), Duration.seconds(30));
}
示例6: ManagedGrpcChannel
import io.dropwizard.util.Duration; //導入方法依賴的package包/類
public ManagedGrpcChannel(final ManagedChannel channel) {
this(channel, Duration.seconds(5));
}
示例7: ManagedGrpcServer
import io.dropwizard.util.Duration; //導入方法依賴的package包/類
public ManagedGrpcServer(final Server server) {
this(server, Duration.seconds(5));
}
示例8: EntityManagerFactoryHealthCheck
import io.dropwizard.util.Duration; //導入方法依賴的package包/類
EntityManagerFactoryHealthCheck(EntityManagerFactory entityManagerFactory,
String validationQuery) {
this(MoreExecutors.newDirectExecutorService(), Duration.seconds(0), entityManagerFactory, validationQuery);
}
示例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));
}
示例10: QueryClient
import io.dropwizard.util.Duration; //導入方法依賴的package包/類
public QueryClient(QueryRunner queryRunner, String query)
{
this(queryRunner, Duration.seconds(60 * 30), query);
}
示例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));
}