Tabnine Logo
Duration.ofMillis
Code IndexAdd Tabnine to your IDE (free)

How to use
ofMillis
method
in
org.threeten.bp.Duration

Best Java code snippets using org.threeten.bp.Duration.ofMillis (Showing top 20 results out of 333)

origin: googleapis/google-cloud-java

private static RetrySettings retrySettings() {
 return RetrySettings.newBuilder()
   .setMaxRetryDelay(Duration.ofMillis(30000L))
   .setTotalTimeout(Duration.ofMillis(120000L))
   .setInitialRetryDelay(Duration.ofMillis(250L))
   .setRetryDelayMultiplier(1.0)
   .setInitialRpcTimeout(Duration.ofMillis(120000L))
   .setRpcTimeoutMultiplier(1.0)
   .setMaxRpcTimeout(Duration.ofMillis(120000L))
   .build();
}
origin: googleapis/google-cloud-java

private static RetrySettings retryParams() {
 return RetrySettings.newBuilder()
   .setMaxAttempts(10)
   .setMaxRetryDelay(Duration.ofMillis(30000L))
   .setTotalTimeout(Duration.ofMillis(120000L))
   .setInitialRetryDelay(Duration.ofMillis(250L))
   .setRetryDelayMultiplier(1.0)
   .setInitialRpcTimeout(Duration.ofMillis(120000L))
   .setRpcTimeoutMultiplier(1.0)
   .setMaxRpcTimeout(Duration.ofMillis(120000L))
   .build();
}
origin: googleapis/google-cloud-java

private static RetrySettings retrySettings() {
 return RetrySettings.newBuilder()
   .setMaxAttempts(10)
   .setMaxRetryDelay(Duration.ofMillis(30000L))
   .setTotalTimeout(Duration.ofMillis(120000L))
   .setInitialRetryDelay(Duration.ofMillis(250L))
   .setRetryDelayMultiplier(1.0)
   .setInitialRpcTimeout(Duration.ofMillis(120000L))
   .setRpcTimeoutMultiplier(1.0)
   .setMaxRpcTimeout(Duration.ofMillis(120000L))
   .build();
}
origin: googleapis/google-cloud-java

private static RetrySettings retrySettings() {
 return RetrySettings.newBuilder()
   .setMaxAttempts(10)
   .setMaxRetryDelay(Duration.ofMillis(30000L))
   .setTotalTimeout(Duration.ofMillis(120000L))
   .setInitialRetryDelay(Duration.ofMillis(250L))
   .setRetryDelayMultiplier(1.0)
   .setInitialRpcTimeout(Duration.ofMillis(120000L))
   .setRpcTimeoutMultiplier(1.0)
   .setMaxRpcTimeout(Duration.ofMillis(120000L))
   .build();
}
origin: googleapis/google-cloud-java

 private static RetrySettings retrySettings() {
  return RetrySettings.newBuilder()
    .setMaxAttempts(10)
    .setMaxRetryDelay(Duration.ofMillis(30000L))
    .setTotalTimeout(Duration.ofMillis(120000L))
    .setInitialRetryDelay(Duration.ofMillis(250L))
    .setRetryDelayMultiplier(1.0)
    .setInitialRpcTimeout(Duration.ofMillis(120000L))
    .setRpcTimeoutMultiplier(1.0)
    .setMaxRpcTimeout(Duration.ofMillis(120000L))
    .build();
 }
}
origin: googleapis/google-cloud-java

private static RetrySettings retrySettings() {
 double retryDelayMultiplier = 1.0;
 int maxAttempts = 10;
 long initialRetryDelay = 250L;
 long maxRetryDelay = 30000L;
 long totalTimeOut = 120000L;
 return RetrySettings.newBuilder()
   .setMaxAttempts(maxAttempts)
   .setMaxRetryDelay(Duration.ofMillis(maxRetryDelay))
   .setTotalTimeout(Duration.ofMillis(totalTimeOut))
   .setInitialRetryDelay(Duration.ofMillis(initialRetryDelay))
   .setRetryDelayMultiplier(retryDelayMultiplier)
   .setInitialRpcTimeout(Duration.ofMillis(totalTimeOut))
   .setRpcTimeoutMultiplier(retryDelayMultiplier)
   .setMaxRpcTimeout(Duration.ofMillis(totalTimeOut))
   .build();
}
origin: googleapis/google-cloud-java

@Override
public <V> ScheduledFuture<V> schedule(Callable<V> callable, long delay, TimeUnit unit) {
 return schedulePendingCallable(
   new PendingCallable<>(
     Duration.ofMillis(unit.toMillis(delay)), callable, PendingCallableType.NORMAL));
}
origin: googleapis/google-cloud-java

@Override
public ScheduledFuture<?> scheduleWithFixedDelay(
  Runnable command, long initialDelay, long delay, TimeUnit unit) {
 return schedulePendingCallable(
   new PendingCallable<>(
     Duration.ofMillis(unit.toMillis(initialDelay)),
     command,
     PendingCallableType.FIXED_DELAY));
}
origin: googleapis/google-cloud-java

@Override
public ScheduledFuture<?> schedule(Runnable command, long delay, TimeUnit unit) {
 return schedulePendingCallable(
   new PendingCallable<>(
     Duration.ofMillis(unit.toMillis(delay)), command, PendingCallableType.NORMAL));
}
origin: googleapis/google-cloud-java

@Override
public ScheduledFuture<?> scheduleAtFixedRate(
  Runnable command, long initialDelay, long period, TimeUnit unit) {
 return schedulePendingCallable(
   new PendingCallable<>(
     Duration.ofMillis(unit.toMillis(initialDelay)),
     command,
     PendingCallableType.FIXED_RATE));
}
origin: googleapis/google-cloud-java

@Test
public void testWaitForCheckingPeriod_Null() throws InterruptedException {
 initializeExpectedOperation(4);
 Compute.OperationOption[] expectedOptions = {
  Compute.OperationOption.fields(Compute.OperationField.STATUS)
 };
 Operation runningOperation =
   Operation.fromPb(
     serviceMockReturnsOptions, globalOperation.toPb().setError(null).setStatus("RUNNING"));
 expect(compute.getOptions()).andReturn(mockOptions);
 expect(mockOptions.getClock()).andReturn(CurrentMillisClock.getDefaultClock());
 expect(compute.getOperation(GLOBAL_OPERATION_ID, expectedOptions)).andReturn(runningOperation);
 expect(compute.getOperation(GLOBAL_OPERATION_ID, expectedOptions)).andReturn(null);
 replay(compute, mockOptions);
 initializeOperation();
 assertNull(operation.waitFor(RetryOption.initialRetryDelay(Duration.ofMillis(1L))));
 verify(compute, mockOptions);
}
origin: googleapis/google-cloud-java

public Publisher getPublisherWithCustomBatchSettings(ProjectTopicName topicName)
  throws Exception {
 // [START pubsub_publisher_batch_settings]
 // Batch settings control how the publisher batches messages
 long requestBytesThreshold = 5000L; // default : 1 byte
 long messageCountBatchSize = 10L; // default : 1 message
 Duration publishDelayThreshold = Duration.ofMillis(100); // default : 1 ms
 // Publish request get triggered based on request size, messages count & time since last publish
 BatchingSettings batchingSettings =
   BatchingSettings.newBuilder()
     .setElementCountThreshold(messageCountBatchSize)
     .setRequestByteThreshold(requestBytesThreshold)
     .setDelayThreshold(publishDelayThreshold)
     .build();
 Publisher publisher =
   Publisher.newBuilder(topicName).setBatchingSettings(batchingSettings).build();
 // [END pubsub_publisher_batch_settings]
 return publisher;
}
origin: googleapis/google-cloud-java

@Test
public void bulkMutationsBatchingCloseTest() throws Exception {
 BulkMutationBatcher batcher = bigtableDataClient.newBulkMutationBatcher();
 RowMutation request =
   RowMutation.create("fake-table", "some-key")
     .setCell("some-family", "fake-qualifier", "fake-value");
 SettableApiFuture<Void> innerResult = SettableApiFuture.create();
 Mockito.when(mockBulkMutateRowsBatchingCallable.futureCall(request)).thenReturn(innerResult);
 batcher.add(request);
 // Close will timeout while the request is outstanding.
 Throwable error = null;
 try {
  batcher.close(Duration.ofMillis(20));
 } catch (Throwable t) {
  error = t;
 }
 assertThat(error).isInstanceOf(TimeoutException.class);
 // Resolve the request
 innerResult.set(null);
 // Now, close will promptly finish
 batcher.close(Duration.ofMillis(20));
}
origin: googleapis/google-cloud-java

@Test
public void testReadRowsSettings() {
 ServerStreamingCallSettings.Builder<ReadRowsRequest, ReadRowsResponse> builder =
   EnhancedBigQueryStorageStubSettings.newBuilder().readRowsSettings();
 assertThat(builder.getRetryableCodes()).containsAllOf(Code.DEADLINE_EXCEEDED, Code.UNAVAILABLE);
 RetrySettings retrySettings = builder.getRetrySettings();
 assertThat(retrySettings.getInitialRetryDelay()).isEqualTo(Duration.ofMillis(100L));
 assertThat(retrySettings.getRetryDelayMultiplier()).isWithin(1e-6).of(1.3);
 assertThat(retrySettings.getMaxRetryDelay()).isEqualTo(Duration.ofMinutes(1L));
 assertThat(retrySettings.getInitialRpcTimeout()).isEqualTo(Duration.ofDays(1L));
 assertThat(retrySettings.getRpcTimeoutMultiplier()).isWithin(1e-6).of(1.0);
 assertThat(retrySettings.getMaxRpcTimeout()).isEqualTo(Duration.ofDays(1L));
 assertThat(retrySettings.getTotalTimeout()).isEqualTo(Duration.ofDays(1L));
 assertThat(builder.getIdleTimeout()).isEqualTo(Duration.ZERO);
}
origin: googleapis/google-cloud-java

@Test
public void bulkMutationsBatchingFailureTest() throws Exception {
 BulkMutationBatcher batcher = bigtableDataClient.newBulkMutationBatcher();
 RowMutation request =
   RowMutation.create("fake-table", "some-key")
     .setCell("some-family", "fake-qualifier", "fake-value");
 SettableApiFuture<Void> innerResult = SettableApiFuture.create();
 Mockito.when(mockBulkMutateRowsBatchingCallable.futureCall(request)).thenReturn(innerResult);
 ApiException innerError = new ApiException(null, GrpcStatusCode.of(Code.INTERNAL), false);
 batcher.add(request);
 innerResult.setException(innerError);
 Throwable outerError = null;
 try {
  batcher.close(Duration.ofMillis(10));
 } catch (Throwable t) {
  outerError = t;
 }
 assertThat(outerError).isInstanceOf(BulkMutationFailure.class);
}
origin: googleapis/google-cloud-java

@Before
public void setUp() {
 ClientContext clientContext =
   ClientContext.newBuilder().setDefaultCallContext(CALL_CONTEXT).build();
 RetrySettings retrySettings =
   RetrySettings.newBuilder()
     .setTotalTimeout(Duration.ofMillis(100))
     // Delay settings: 1 ms const
     .setInitialRetryDelay(Duration.ofMillis(1))
     .setMaxRetryDelay(Duration.ofMillis(1))
     .setRetryDelayMultiplier(1.0)
     // RPC timeout: ignored const 1 s
     .setInitialRpcTimeout(Duration.ofSeconds(1))
     .setMaxRpcTimeout(Duration.ofSeconds(1))
     .setRpcTimeoutMultiplier(1.0)
     .build();
 callable =
   AwaitReplicationCallable.create(
     mockGenerateConsistencyTokenCallable,
     mockCheckConsistencyCallable,
     clientContext,
     retrySettings);
}
origin: googleapis/google-cloud-java

@Test
public void testCreateFromStream() {
 RemoteComputeHelper helper = RemoteComputeHelper.create(PROJECT_ID, JSON_KEY_STREAM);
 ComputeOptions options = helper.getOptions();
 assertEquals(PROJECT_ID, options.getProjectId());
 assertEquals(60000, ((HttpTransportOptions) options.getTransportOptions()).getConnectTimeout());
 assertEquals(60000, ((HttpTransportOptions) options.getTransportOptions()).getReadTimeout());
 assertEquals(10, options.getRetrySettings().getMaxAttempts());
 assertEquals(Duration.ofMillis(30000), options.getRetrySettings().getMaxRetryDelay());
 assertEquals(Duration.ofMillis(120000), options.getRetrySettings().getTotalTimeout());
 assertEquals(Duration.ofMillis(250), options.getRetrySettings().getInitialRetryDelay());
}
origin: googleapis/google-cloud-java

 @Test
 public void testCreateFromStream() {
  RemoteStorageHelper helper = RemoteStorageHelper.create(PROJECT_ID, JSON_KEY_STREAM);
  StorageOptions options = helper.getOptions();
  assertEquals(PROJECT_ID, options.getProjectId());
  assertEquals(60000, ((HttpTransportOptions) options.getTransportOptions()).getConnectTimeout());
  assertEquals(60000, ((HttpTransportOptions) options.getTransportOptions()).getReadTimeout());
  assertEquals(10, options.getRetrySettings().getMaxAttempts());
  assertEquals(Duration.ofMillis(30000), options.getRetrySettings().getMaxRetryDelay());
  assertEquals(Duration.ofMillis(120000), options.getRetrySettings().getTotalTimeout());
  assertEquals(Duration.ofMillis(250), options.getRetrySettings().getInitialRetryDelay());
 }
}
origin: googleapis/google-cloud-java

 @Test
 public void testCreateFromStream() {
  RemoteBigQueryHelper helper = RemoteBigQueryHelper.create(PROJECT_ID, JSON_KEY_STREAM);
  BigQueryOptions options = helper.getOptions();
  assertEquals(PROJECT_ID, options.getProjectId());
  assertEquals(60000, ((HttpTransportOptions) options.getTransportOptions()).getConnectTimeout());
  assertEquals(60000, ((HttpTransportOptions) options.getTransportOptions()).getReadTimeout());
  assertEquals(10, options.getRetrySettings().getMaxAttempts());
  assertEquals(Duration.ofMillis(30000), options.getRetrySettings().getMaxRetryDelay());
  assertEquals(Duration.ofMillis(120000), options.getRetrySettings().getTotalTimeout());
  assertEquals(Duration.ofMillis(250), options.getRetrySettings().getInitialRetryDelay());
 }
}
origin: googleapis/google-cloud-java

@Test
public void testPublisherGetters() throws Exception {
 Publisher.Builder builder = Publisher.newBuilder(TEST_TOPIC);
 builder.setChannelProvider(TEST_CHANNEL_PROVIDER);
 builder.setExecutorProvider(SINGLE_THREAD_EXECUTOR);
 builder.setBatchingSettings(
   BatchingSettings.newBuilder()
     .setRequestByteThreshold(10L)
     .setDelayThreshold(Duration.ofMillis(11))
     .setElementCountThreshold(12L)
     .build());
 builder.setCredentialsProvider(NoCredentialsProvider.create());
 Publisher publisher = builder.build();
 assertEquals(TEST_TOPIC, publisher.getTopicName());
 assertEquals(10, (long) publisher.getBatchingSettings().getRequestByteThreshold());
 assertEquals(Duration.ofMillis(11), publisher.getBatchingSettings().getDelayThreshold());
 assertEquals(12, (long) publisher.getBatchingSettings().getElementCountThreshold());
 publisher.shutdown();
 publisher.awaitTermination(1, TimeUnit.MINUTES);
}
org.threeten.bpDurationofMillis

Javadoc

Obtains an instance of Duration from a number of milliseconds.

The seconds and nanoseconds are extracted from the specified milliseconds.

Popular methods of Duration

  • ofSeconds
    Obtains an instance of Duration from a number of seconds and an adjustment in nanoseconds. This meth
  • toMillis
    Converts this duration to the total length in milliseconds. If this duration is too large to fit in
  • ofMinutes
    Obtains an instance of Duration from a number of standard length minutes. The seconds are calculated
  • compareTo
    Compares this duration to the specified Duration. The comparison is based on the total length of the
  • getSeconds
    Gets the number of seconds in this duration. The length of the duration is stored using two fields -
  • isZero
    Checks if this duration is zero length. A Duration represents a directed distance between two points
  • between
    Obtains an instance of Duration representing the duration between two instants. Obtains a Duration
  • getNano
    Gets the number of nanoseconds within the second in this duration. The length of the duration is sto
  • isNegative
    Checks if this duration is negative, excluding zero. A Duration represents a directed distance betwe
  • toNanos
    Converts this duration to the total length in nanoseconds expressed as a long. If this duration is
  • ofHours
    Obtains an instance of Duration from a number of standard length hours. The seconds are calculated b
  • ofNanos
    Obtains an instance of Duration from a number of nanoseconds. The seconds and nanoseconds are extrac
  • ofHours,
  • ofNanos,
  • equals,
  • of,
  • ofDays,
  • plus,
  • toMinutes,
  • <init>,
  • create

Popular in Java

  • Reactive rest calls using spring rest template
  • scheduleAtFixedRate (Timer)
  • getSharedPreferences (Context)
  • getContentResolver (Context)
  • VirtualMachine (com.sun.tools.attach)
    A Java virtual machine. A VirtualMachine represents a Java virtual machine to which this Java vir
  • SocketTimeoutException (java.net)
    This exception is thrown when a timeout expired on a socket read or accept operation.
  • ArrayList (java.util)
    ArrayList is an implementation of List, backed by an array. All optional operations including adding
  • HashSet (java.util)
    HashSet is an implementation of a Set. All optional operations (adding and removing) are supported.
  • Hashtable (java.util)
    A plug-in replacement for JDK1.5 java.util.Hashtable. This version is based on org.cliffc.high_scale
  • Pattern (java.util.regex)
    Patterns are compiled regular expressions. In many cases, convenience methods such as String#matches
  • Github Copilot alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now