Skip to content

Commit

Permalink
gcs: Migration to java.time.Duration
Browse files Browse the repository at this point in the history
  • Loading branch information
AnatolyPopov committed Nov 16, 2024
1 parent 5d3450b commit 4b51bfb
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package io.aiven.kafka.connect.gcs;

import java.time.Duration;
import java.time.ZoneId;
import java.time.ZoneOffset;
import java.util.ArrayList;
Expand Down Expand Up @@ -45,7 +46,6 @@
import com.google.cloud.NoCredentials;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.threeten.bp.Duration;

public final class GcsSinkConfig extends AivenCommonConfig {
private static final Logger LOG = LoggerFactory.getLogger(GcsSinkConfig.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@ public void start(final Map<String, String> props) {
.setCredentials(config.getCredentials())
.setHeaderProvider(FixedHeaderProvider.create(USER_AGENT_HEADER_KEY, config.getUserAgent()))
.setRetrySettings(RetrySettings.newBuilder()
.setInitialRetryDelay(config.getGcsRetryBackoffInitialDelay())
.setMaxRetryDelay(config.getGcsRetryBackoffMaxDelay())
.setInitialRetryDelayDuration(config.getGcsRetryBackoffInitialDelay())
.setMaxRetryDelayDuration(config.getGcsRetryBackoffMaxDelay())
.setRetryDelayMultiplier(config.getGcsRetryBackoffDelayMultiplier())
.setTotalTimeout(config.getGcsRetryBackoffTotalTimeout())
.setTotalTimeoutDuration(config.getGcsRetryBackoffTotalTimeout())
.setMaxAttempts(config.getGcsRetryBackoffMaxAttempts())
.build())
.build()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import static org.mockito.Mockito.verify;

import java.nio.charset.StandardCharsets;
import java.time.Duration;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
Expand Down Expand Up @@ -66,7 +67,6 @@
import org.junit.jupiter.params.provider.CsvSource;
import org.junit.jupiter.params.provider.ValueSource;
import org.mockito.ArgumentCaptor;
import org.threeten.bp.Duration;

final class GcsSinkTaskTest {

Expand Down Expand Up @@ -429,13 +429,13 @@ void setupDefaultRetryPolicy() {

assertThat(headers).containsExactly(entry("user-agent", "Google GCS Sink/test-version (GPN: Aiven;)"));
assertThat(retrySettings.isJittered()).isTrue();
assertThat(retrySettings.getInitialRetryDelay())
assertThat(retrySettings.getInitialRetryDelayDuration())
.isEqualTo(Duration.ofMillis(GcsSinkConfig.GCS_RETRY_BACKOFF_INITIAL_DELAY_MS_DEFAULT));
assertThat(retrySettings.getMaxRetryDelay())
assertThat(retrySettings.getMaxRetryDelayDuration())
.isEqualTo(Duration.ofMillis(GcsSinkConfig.GCS_RETRY_BACKOFF_MAX_DELAY_MS_DEFAULT));
assertThat(retrySettings.getRetryDelayMultiplier())
.isEqualTo(GcsSinkConfig.GCS_RETRY_BACKOFF_DELAY_MULTIPLIER_DEFAULT);
assertThat(retrySettings.getTotalTimeout())
assertThat(retrySettings.getTotalTimeoutDuration())
.isEqualTo(Duration.ofMillis(GcsSinkConfig.GCS_RETRY_BACKOFF_TOTAL_TIMEOUT_MS_DEFAULT));
assertThat(retrySettings.getMaxAttempts()).isEqualTo(GcsSinkConfig.GCS_RETRY_BACKOFF_MAX_ATTEMPTS_DEFAULT);
}
Expand Down Expand Up @@ -469,10 +469,10 @@ void setupCustomRetryPolicy() {
assertThat(headers).containsExactly(entry("user-agent", "foo"));
assertThat(retrySettings.isJittered()).isTrue();
assertThat(kafkaBackoffMsCaptor.getValue()).isEqualTo(1L);
assertThat(retrySettings.getInitialRetryDelay()).isEqualTo(Duration.ofMillis(2L));
assertThat(retrySettings.getMaxRetryDelay()).isEqualTo(Duration.ofMillis(3L));
assertThat(retrySettings.getInitialRetryDelayDuration()).isEqualTo(Duration.ofMillis(2L));
assertThat(retrySettings.getMaxRetryDelayDuration()).isEqualTo(Duration.ofMillis(3L));
assertThat(retrySettings.getRetryDelayMultiplier()).isEqualTo(4.0D);
assertThat(retrySettings.getTotalTimeout()).isEqualTo(Duration.ofMillis(5L));
assertThat(retrySettings.getTotalTimeoutDuration()).isEqualTo(Duration.ofMillis(5L));
assertThat(retrySettings.getMaxAttempts()).isEqualTo(6);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.time.Duration;
import java.time.ZoneId;
import java.time.ZoneOffset;
import java.util.Arrays;
Expand Down Expand Up @@ -52,7 +53,6 @@
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.NullSource;
import org.junit.jupiter.params.provider.ValueSource;
import org.threeten.bp.Duration;

/**
* Tests {@link GcsSinkConfig} class.
Expand Down

0 comments on commit 4b51bfb

Please sign in to comment.