From 71aa9a870db67b99631557c2364a3cb7c4f1842e Mon Sep 17 00:00:00 2001 From: Diego Alonso Marquez Palacios Date: Thu, 14 Nov 2024 11:21:20 -0500 Subject: [PATCH] feat: introduce java.time to java-bigtable --- .../bigtable/admin/v2/models/Backup.java | 45 ++++++++-- .../admin/v2/models/CopyBackupRequest.java | 12 ++- .../admin/v2/models/CreateBackupRequest.java | 22 ++++- .../admin/v2/models/CreateTableRequest.java | 18 +++- .../bigtable/admin/v2/models/GCRules.java | 32 +++++-- .../cloud/bigtable/admin/v2/models/Table.java | 20 +++-- .../admin/v2/models/UpdateBackupRequest.java | 21 ++++- .../admin/v2/models/UpdateTableRequest.java | 17 +++- .../google/cloud/bigtable/common/Type.java | 2 +- .../data/v2/BigtableDataSettings.java | 9 +- .../internal/AbstractProtoStructReader.java | 24 +++-- .../data/v2/internal/ResultSetImpl.java | 24 +++-- .../data/v2/models/ChangeStreamMutation.java | 50 +++++++++-- .../v2/models/ChangeStreamRecordAdapter.java | 50 +++++++++-- .../DefaultChangeStreamRecordAdapter.java | 30 +++++-- .../bigtable/data/v2/models/Heartbeat.java | 17 +++- .../data/v2/models/ReadChangeStreamQuery.java | 31 ++++++- .../bigtable/data/v2/models/sql/SqlType.java | 3 +- .../data/v2/models/sql/Statement.java | 14 +-- .../data/v2/models/sql/StructReader.java | 24 +++-- .../RateLimitingServerStreamingCallable.java | 4 +- .../ChangeStreamStateMachine.java | 13 ++- .../BigtableCloudMonitoringExporter.java | 5 +- .../v2/stub/metrics/BuiltinMetricsTracer.java | 17 +++- .../data/v2/stub/metrics/CompositeTracer.java | 19 +++- .../data/v2/stub/metrics/MetricsTracer.java | 16 +++- .../metrics/TracedBatcherUnaryCallable.java | 4 +- .../gaxx/retrying/AttemptCallable.java | 5 +- .../retrying/RetryInfoRetryAlgorithm.java | 10 +-- .../v2/BigtableInstanceAdminSettingsTest.java | 4 +- .../v2/BigtableTableAdminClientTests.java | 78 ++++++++-------- .../v2/BigtableTableAdminSettingsTest.java | 5 +- .../admin/v2/it/BigtableBackupIT.java | 28 +++--- .../bigtable/admin/v2/it/BigtableCmekIT.java | 6 +- .../v2/it/BigtableTableAdminClientIT.java | 17 ++-- .../bigtable/admin/v2/models/BackupTest.java | 11 +-- .../v2/models/CopyBackupRequestTest.java | 46 +++++----- .../v2/models/CreateBackupRequestTest.java | 40 ++++----- .../v2/models/CreateTableRequestTest.java | 6 +- .../bigtable/admin/v2/models/GCRulesTest.java | 38 ++++---- .../v2/models/UpdateBackupRequestTest.java | 36 ++++---- .../v2/models/UpdateTableRequestTest.java | 6 +- .../v2/stub/AwaitConsistencyCallableTest.java | 12 +-- .../AbstractProtoStructReaderTest.java | 10 +-- .../data/v2/internal/ProtoStructTest.java | 7 +- .../data/v2/internal/ResultSetImplTest.java | 6 +- .../bigtable/data/v2/it/BuiltinMetricsIT.java | 4 +- .../bigtable/data/v2/it/BulkMutateIT.java | 6 +- .../bigtable/data/v2/it/ExecuteQueryIT.java | 12 +-- .../v2/models/ChangeStreamMutationTest.java | 26 +++--- .../v2/models/ChangeStreamRecordTest.java | 4 +- .../DefaultChangeStreamRecordAdapterTest.java | 83 +++++++++-------- .../v2/models/ReadChangeStreamQueryTest.java | 46 +++++----- .../data/v2/models/sql/StatementTest.java | 4 +- .../BigtableBatchingCallSettingsTest.java | 6 +- .../BigtableBulkReadRowsCallSettingsTest.java | 6 +- .../data/v2/stub/CookiesHolderTest.java | 10 +-- .../EnhancedBigtableStubSettingsTest.java | 90 ++++++++++--------- .../v2/stub/EnhancedBigtableStubTest.java | 24 ++--- .../v2/stub/RateLimitingCallableTest.java | 18 ++-- ...ChangeStreamRecordMergingCallableTest.java | 4 +- .../ReadChangeStreamRetryTest.java | 4 +- .../ReadChangeStreamUserCallableTest.java | 10 +-- .../v2/stub/metrics/CompositeTracerTest.java | 12 +-- .../MutateRowsAttemptCallableTest.java | 13 +-- .../v2/stub/sql/ExecuteQueryCallableTest.java | 6 +- .../test_helpers/env/PrefixGenerator.java | 2 +- .../test_helpers/env/TestEnvRule.java | 4 +- .../bigtable/testproxy/CbtTestProxy.java | 15 ++-- .../testproxy/ResultSetSerializer.java | 1 - .../testproxy/StatementDeserializer.java | 1 - 71 files changed, 830 insertions(+), 495 deletions(-) diff --git a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/models/Backup.java b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/models/Backup.java index 1c340910a0..b0f093c7de 100644 --- a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/models/Backup.java +++ b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/models/Backup.java @@ -16,7 +16,10 @@ package com.google.cloud.bigtable.admin.v2.models; +import static com.google.api.gax.util.TimeConversionUtils.toThreetenInstant; + import com.google.api.core.InternalApi; +import com.google.api.core.ObsoleteApi; import com.google.bigtable.admin.v2.BackupName; import com.google.cloud.bigtable.admin.v2.internal.NameUtil; import com.google.common.base.Objects; @@ -24,7 +27,6 @@ import com.google.protobuf.util.Timestamps; import javax.annotation.Nonnull; import javax.annotation.Nullable; -import org.threeten.bp.Instant; /** * A backup lets you save a copy of a table's schema and data and restore the backup to a new table @@ -166,23 +168,41 @@ public String getInstanceId() { return instanceId; } + /** This method is obsolete. Use {@link #getExpireTimeInstant()} instead. */ + @ObsoleteApi("Use getExpireTimeInstant() instead") + public org.threeten.bp.Instant getExpireTime() { + return toThreetenInstant(getExpireTimeInstant()); + } + /** Get the expire time of this backup. */ - public Instant getExpireTime() { - return Instant.ofEpochMilli(Timestamps.toMillis(proto.getExpireTime())); + public java.time.Instant getExpireTimeInstant() { + return java.time.Instant.ofEpochMilli(Timestamps.toMillis(proto.getExpireTime())); + } + + /** This method is obsolete. Use {@link #getStartTimeInstant()} instead. */ + @ObsoleteApi("Use getStartTimeInstant() instead") + public @Nullable org.threeten.bp.Instant getStartTime() { + return toThreetenInstant(getStartTimeInstant()); } /** Get the start time when this backup is taken. */ - public @Nullable Instant getStartTime() { + public @Nullable java.time.Instant getStartTimeInstant() { if (proto.hasStartTime()) { - return Instant.ofEpochMilli(Timestamps.toMillis(proto.getStartTime())); + return java.time.Instant.ofEpochMilli(Timestamps.toMillis(proto.getStartTime())); } return null; } + /** This method is obsolete. Use {@link #getStartTimeInstant()} instead. */ + @ObsoleteApi("Use getStartTimeInstant() instead") + public @Nullable org.threeten.bp.Instant getEndTime() { + return toThreetenInstant(getEndTimeInstant()); + } + /** Get the end time when the creation of this backup has completed. */ - public @Nullable Instant getEndTime() { + public @Nullable java.time.Instant getEndTimeInstant() { if (proto.hasEndTime()) { - return Instant.ofEpochMilli(Timestamps.toMillis(proto.getEndTime())); + return java.time.Instant.ofEpochMilli(Timestamps.toMillis(proto.getEndTime())); } return null; } @@ -202,11 +222,18 @@ public BackupType getBackupType() { return BackupType.fromProto(proto.getBackupType()); } + /** This method is obsolete. Use {@link #getHotToStandardTimeInstant()} instead. */ + @ObsoleteApi("Use getHotToStandardTimeInstant() instead.") + @Nullable + public org.threeten.bp.Instant getHotToStandardTime() { + return toThreetenInstant(getHotToStandardTimeInstant()); + } + /** Get the time at which this backup will be converted from a hot backup to a standard backup. */ @Nullable - public Instant getHotToStandardTime() { + public java.time.Instant getHotToStandardTimeInstant() { if (proto.hasHotToStandardTime()) { - return Instant.ofEpochMilli(Timestamps.toMillis(proto.getHotToStandardTime())); + return java.time.Instant.ofEpochMilli(Timestamps.toMillis(proto.getHotToStandardTime())); } return null; } diff --git a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/models/CopyBackupRequest.java b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/models/CopyBackupRequest.java index 88b50376be..c42ec5ffa7 100644 --- a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/models/CopyBackupRequest.java +++ b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/models/CopyBackupRequest.java @@ -15,13 +15,15 @@ */ package com.google.cloud.bigtable.admin.v2.models; +import static com.google.api.gax.util.TimeConversionUtils.toJavaTimeInstant; + import com.google.api.core.InternalApi; +import com.google.api.core.ObsoleteApi; import com.google.cloud.bigtable.admin.v2.internal.NameUtil; import com.google.common.base.Objects; import com.google.common.base.Preconditions; import com.google.protobuf.util.Timestamps; import javax.annotation.Nonnull; -import org.threeten.bp.Instant; /** Build CopyBackupRequest for {@link com.google.bigtable.admin.v2.CopyBackupRequest}. */ public final class CopyBackupRequest { @@ -75,7 +77,13 @@ public CopyBackupRequest setDestination(String clusterId, String backupId) { return this; } - public CopyBackupRequest setExpireTime(Instant expireTime) { + /** This method is obsolete. Use {@link #setExpireTimeInstant(java.time.Instant)} instead. */ + @ObsoleteApi("Use setExpireTimeInstant(java.time.Instant) instead.") + public CopyBackupRequest setExpireTime(org.threeten.bp.Instant expireTime) { + return setExpireTimeInstant(toJavaTimeInstant(expireTime)); + } + + public CopyBackupRequest setExpireTimeInstant(java.time.Instant expireTime) { Preconditions.checkNotNull(expireTime); requestBuilder.setExpireTime(Timestamps.fromMillis(expireTime.toEpochMilli())); return this; diff --git a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/models/CreateBackupRequest.java b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/models/CreateBackupRequest.java index 542ba8da20..d4c6f315ec 100644 --- a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/models/CreateBackupRequest.java +++ b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/models/CreateBackupRequest.java @@ -15,13 +15,15 @@ */ package com.google.cloud.bigtable.admin.v2.models; +import static com.google.api.gax.util.TimeConversionUtils.toJavaTimeInstant; + import com.google.api.core.InternalApi; +import com.google.api.core.ObsoleteApi; import com.google.cloud.bigtable.admin.v2.internal.NameUtil; import com.google.common.base.Objects; import com.google.common.base.Preconditions; import com.google.protobuf.util.Timestamps; import javax.annotation.Nonnull; -import org.threeten.bp.Instant; /** Fluent wrapper for {@link com.google.bigtable.admin.v2.CreateBackupRequest} */ public final class CreateBackupRequest { @@ -50,7 +52,13 @@ public CreateBackupRequest setSourceTableId(String sourceTableId) { return this; } - public CreateBackupRequest setExpireTime(Instant expireTime) { + /** This method is obsolete. Use {@link #setExpireTimeInstant(java.time.Instant)} instead. */ + @ObsoleteApi("Use setExpireTimeInstant(java.time.Instant) instead.") + public CreateBackupRequest setExpireTime(org.threeten.bp.Instant expireTime) { + return setExpireTimeInstant(toJavaTimeInstant(expireTime)); + } + + public CreateBackupRequest setExpireTimeInstant(java.time.Instant expireTime) { Preconditions.checkNotNull(expireTime); requestBuilder .getBackupBuilder() @@ -64,10 +72,18 @@ public CreateBackupRequest setBackupType(Backup.BackupType backupType) { return this; } + /** + * This method is obsolete. Use {@link #setHotToStandardTimeInstant(java.time.Instant)} instead. + */ + @ObsoleteApi("Use setHotToStandardTimeInstant(java.time.Instant) instead.") + public CreateBackupRequest setHotToStandardTime(org.threeten.bp.Instant hotToStandardTime) { + return setHotToStandardTimeInstant(toJavaTimeInstant(hotToStandardTime)); + } + // The time at which this backup will be converted from a hot backup to a standard backup. Only // applicable for hot backups. If not set, the backup will remain as a hot backup until it is // deleted. - public CreateBackupRequest setHotToStandardTime(Instant hotToStandardTime) { + public CreateBackupRequest setHotToStandardTimeInstant(java.time.Instant hotToStandardTime) { Preconditions.checkNotNull(hotToStandardTime); requestBuilder .getBackupBuilder() diff --git a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/models/CreateTableRequest.java b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/models/CreateTableRequest.java index 0fbffcb190..0e28798d82 100644 --- a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/models/CreateTableRequest.java +++ b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/models/CreateTableRequest.java @@ -15,7 +15,10 @@ */ package com.google.cloud.bigtable.admin.v2.models; +import static com.google.api.gax.util.TimeConversionUtils.toJavaTimeDuration; + import com.google.api.core.InternalApi; +import com.google.api.core.ObsoleteApi; import com.google.bigtable.admin.v2.ChangeStreamConfig; import com.google.bigtable.admin.v2.ColumnFamily; import com.google.cloud.bigtable.admin.v2.internal.NameUtil; @@ -23,8 +26,8 @@ import com.google.common.base.Objects; import com.google.common.base.Preconditions; import com.google.protobuf.ByteString; +import com.google.protobuf.Duration; import javax.annotation.Nonnull; -import org.threeten.bp.Duration; /** * Fluent wrapper for {@link com.google.bigtable.admin.v2.CreateTableRequest} @@ -107,15 +110,24 @@ public CreateTableRequest addSplit(ByteString key) { return this; } + /** + * This method is obsolete. Use {@link #addChangeStreamRetentionDuration(java.time.Duration)} + * instead. + */ + @ObsoleteApi("Use addChangeStreamRetentionDuration(java.time.Duration) instead.") + public CreateTableRequest addChangeStreamRetention(org.threeten.bp.Duration retention) { + return addChangeStreamRetentionDuration(toJavaTimeDuration(retention)); + } + /** Add change stream retention period between 1 day and 7 days */ - public CreateTableRequest addChangeStreamRetention(Duration retention) { + public CreateTableRequest addChangeStreamRetentionDuration(java.time.Duration retention) { Preconditions.checkNotNull(retention); requestBuilder .getTableBuilder() .setChangeStreamConfig( ChangeStreamConfig.newBuilder() .setRetentionPeriod( - com.google.protobuf.Duration.newBuilder() + Duration.newBuilder() .setSeconds(retention.getSeconds()) .setNanos(retention.getNano()) .build()) diff --git a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/models/GCRules.java b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/models/GCRules.java index 35f48c5260..6971967f0a 100644 --- a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/models/GCRules.java +++ b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/models/GCRules.java @@ -15,8 +15,12 @@ */ package com.google.cloud.bigtable.admin.v2.models; +import static com.google.api.gax.util.TimeConversionUtils.toJavaTimeDuration; +import static com.google.api.gax.util.TimeConversionUtils.toThreetenDuration; + import com.google.api.core.BetaApi; import com.google.api.core.InternalApi; +import com.google.api.core.ObsoleteApi; import com.google.bigtable.admin.v2.GcRule; import com.google.bigtable.admin.v2.GcRule.Intersection; import com.google.bigtable.admin.v2.GcRule.Union; @@ -26,7 +30,6 @@ import java.util.List; import java.util.concurrent.TimeUnit; import javax.annotation.Nonnull; -import org.threeten.bp.Duration; // TODO(igorbernstein2): the distinction between GcRule & GCRule is too subtle, use fully qualified // names for the protos. @@ -70,15 +73,21 @@ public VersionRule maxVersions(int maxVersion) { * @param timeUnit - timeunit for the age */ public DurationRule maxAge(long maxAge, TimeUnit timeUnit) { - return maxAge(Duration.ofNanos(TimeUnit.NANOSECONDS.convert(maxAge, timeUnit))); + return maxAgeDuration( + java.time.Duration.ofNanos(TimeUnit.NANOSECONDS.convert(maxAge, timeUnit))); } + /** This method is obsolete. Use {@link #maxAgeDuration(java.time.Duration)} instead. */ + @ObsoleteApi("Use maxAgeDuration(java.time.Duration) instead.") + public DurationRule maxAge(org.threeten.bp.Duration duration) { + return maxAgeDuration(toJavaTimeDuration(duration)); + } /** * Creates a new instance of the DurationRule * * @param duration - age expressed as duration */ - public DurationRule maxAge(Duration duration) { + public DurationRule maxAgeDuration(java.time.Duration duration) { return new DurationRule(duration); } @@ -91,8 +100,9 @@ public DefaultRule defaultRule() { public GCRule fromProto(GcRule source) { switch (source.getRuleCase()) { case MAX_AGE: - return GCRULES.maxAge( - Duration.ofSeconds(source.getMaxAge().getSeconds(), source.getMaxAge().getNanos())); + return GCRULES.maxAgeDuration( + java.time.Duration.ofSeconds( + source.getMaxAge().getSeconds(), source.getMaxAge().getNanos())); case MAX_NUM_VERSIONS: return GCRULES.maxVersions(source.getMaxNumVersions()); @@ -287,16 +297,22 @@ public GcRule toProto() { public static final class DurationRule implements GCRule { private final com.google.protobuf.Duration.Builder builder; - private DurationRule(Duration duration) { + private DurationRule(java.time.Duration duration) { this.builder = com.google.protobuf.Duration.newBuilder() .setSeconds(duration.getSeconds()) .setNanos(duration.getNano()); } + /** This method is obsolete. Use {@link #getMaxAgeDuration()} instead. */ + @ObsoleteApi("Use getMaxAgeDuration() instead.") + public org.threeten.bp.Duration getMaxAge() { + return toThreetenDuration(getMaxAgeDuration()); + } + /** Gets the configured maximum age */ - public Duration getMaxAge() { - return Duration.ofSeconds(builder.getSeconds(), builder.getNanos()); + public java.time.Duration getMaxAgeDuration() { + return java.time.Duration.ofSeconds(builder.getSeconds(), builder.getNanos()); } @Override diff --git a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/models/Table.java b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/models/Table.java index 31aa612f18..28d260ccd0 100644 --- a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/models/Table.java +++ b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/models/Table.java @@ -15,7 +15,10 @@ */ package com.google.cloud.bigtable.admin.v2.models; +import static com.google.api.gax.util.TimeConversionUtils.toThreetenDuration; + import com.google.api.core.InternalApi; +import com.google.api.core.ObsoleteApi; import com.google.bigtable.admin.v2.TableName; import com.google.common.base.Objects; import com.google.common.base.Preconditions; @@ -25,7 +28,6 @@ import java.util.Map; import java.util.Map.Entry; import javax.annotation.Nonnull; -import org.threeten.bp.Duration; /** Wrapper for {@link Table} protocol buffer object */ public final class Table { @@ -104,7 +106,7 @@ public com.google.bigtable.admin.v2.Table.ClusterState.ReplicationState toProto( private final Map replicationStatesByClusterId; private final List columnFamilies; - private final Duration changeStreamRetention; + private final java.time.Duration changeStreamRetention; @InternalApi public static Table fromProto(@Nonnull com.google.bigtable.admin.v2.Table proto) { @@ -123,10 +125,10 @@ public static Table fromProto(@Nonnull com.google.bigtable.admin.v2.Table proto) columnFamilies.add(ColumnFamily.fromProto(entry.getKey(), entry.getValue())); } - Duration changeStreamConfig = null; + java.time.Duration changeStreamConfig = null; if (proto.hasChangeStreamConfig()) { changeStreamConfig = - Duration.ofSeconds( + java.time.Duration.ofSeconds( proto.getChangeStreamConfig().getRetentionPeriod().getSeconds(), proto.getChangeStreamConfig().getRetentionPeriod().getNanos()); } @@ -142,7 +144,7 @@ private Table( TableName tableName, Map replicationStatesByClusterId, List columnFamilies, - Duration changeStreamRetention) { + java.time.Duration changeStreamRetention) { this.instanceId = tableName.getInstance(); this.id = tableName.getTable(); this.replicationStatesByClusterId = replicationStatesByClusterId; @@ -168,7 +170,13 @@ public List getColumnFamilies() { return columnFamilies; } - public Duration getChangeStreamRetention() { + /** This method is obsolete. Use {@link #getChangeStreamRetentionDuration()} instead. */ + @ObsoleteApi("Use getChangeStreamRetention() instead.") + public org.threeten.bp.Duration getChangeStreamRetention() { + return toThreetenDuration(getChangeStreamRetentionDuration()); + } + + public java.time.Duration getChangeStreamRetentionDuration() { return changeStreamRetention; } diff --git a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/models/UpdateBackupRequest.java b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/models/UpdateBackupRequest.java index 9bf9076b0c..565dbac61c 100644 --- a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/models/UpdateBackupRequest.java +++ b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/models/UpdateBackupRequest.java @@ -15,7 +15,10 @@ */ package com.google.cloud.bigtable.admin.v2.models; +import static com.google.api.gax.util.TimeConversionUtils.toJavaTimeInstant; + import com.google.api.core.InternalApi; +import com.google.api.core.ObsoleteApi; import com.google.bigtable.admin.v2.Backup; import com.google.cloud.bigtable.admin.v2.internal.NameUtil; import com.google.common.base.Objects; @@ -24,7 +27,6 @@ import com.google.protobuf.util.FieldMaskUtil; import com.google.protobuf.util.Timestamps; import javax.annotation.Nonnull; -import org.threeten.bp.Instant; /** Fluent wrapper for {@link com.google.bigtable.admin.v2.UpdateBackupRequest} */ public final class UpdateBackupRequest { @@ -50,7 +52,13 @@ private void updateFieldMask(int fieldNumber) { requestBuilder.setUpdateMask(FieldMaskUtil.union(requestBuilder.getUpdateMask(), newMask)); } - public UpdateBackupRequest setExpireTime(Instant expireTime) { + /** This method is obsolete. Use {@link #setExpireTimeInstant(java.time.Instant)} instead. */ + @ObsoleteApi("Use setExpireTimeInstant(java.time.Instant) instead.") + public UpdateBackupRequest setExpireTime(org.threeten.bp.Instant expireTime) { + return setExpireTimeInstant(toJavaTimeInstant(expireTime)); + } + + public UpdateBackupRequest setExpireTimeInstant(java.time.Instant expireTime) { Preconditions.checkNotNull(expireTime); requestBuilder .getBackupBuilder() @@ -58,11 +66,18 @@ public UpdateBackupRequest setExpireTime(Instant expireTime) { updateFieldMask(Backup.EXPIRE_TIME_FIELD_NUMBER); return this; } + /** + * This method is obsolete. Use {@link #setHotToStandardTimeInstant(java.time.Instant)} instead. + */ + @ObsoleteApi("Use setHotToStandardTimeInstant(java.time.Instant) instead.") + public UpdateBackupRequest setHotToStandardTime(org.threeten.bp.Instant hotToStandardTime) { + return setHotToStandardTimeInstant(toJavaTimeInstant(hotToStandardTime)); + } // The time at which this backup will be converted from a hot backup to a standard backup. Only // applicable for hot backups. If not set, the backup will remain as a hot backup until it is // deleted. - public UpdateBackupRequest setHotToStandardTime(Instant hotToStandardTime) { + public UpdateBackupRequest setHotToStandardTimeInstant(java.time.Instant hotToStandardTime) { Preconditions.checkNotNull(hotToStandardTime); requestBuilder .getBackupBuilder() diff --git a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/models/UpdateTableRequest.java b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/models/UpdateTableRequest.java index 034736aa56..4f9622d47e 100644 --- a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/models/UpdateTableRequest.java +++ b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/admin/v2/models/UpdateTableRequest.java @@ -16,12 +16,14 @@ package com.google.cloud.bigtable.admin.v2.models; +import static com.google.api.gax.util.TimeConversionUtils.toJavaTimeDuration; + import com.google.api.core.InternalApi; +import com.google.api.core.ObsoleteApi; import com.google.bigtable.admin.v2.ChangeStreamConfig; import com.google.cloud.bigtable.admin.v2.internal.NameUtil; import com.google.common.base.Preconditions; import java.util.Objects; -import org.threeten.bp.Duration; /** * Wrapper for {@link com.google.bigtable.admin.v2.UpdateTableRequest} @@ -47,8 +49,17 @@ private UpdateTableRequest(String tableId) { this.tableId = tableId; } + /** + * This method is obsolete. Use {@link #addChangeStreamRetentionDuration(java.time.Duration + * retention)} instead. + */ + @ObsoleteApi("Use addChangeStreamRetentionDuration(java.time.Duration) instead.") + public UpdateTableRequest addChangeStreamRetention(org.threeten.bp.Duration retention) { + return addChangeStreamRetentionDuration(toJavaTimeDuration(retention)); + } + /** Update change stream retention period between 1 day and 7 days. */ - public UpdateTableRequest addChangeStreamRetention(Duration retention) { + public UpdateTableRequest addChangeStreamRetentionDuration(java.time.Duration retention) { Preconditions.checkNotNull(retention); if (!retention.isZero()) { requestBuilder @@ -71,7 +82,7 @@ public UpdateTableRequest addChangeStreamRetention(Duration retention) { /** Disable change stream for table */ public UpdateTableRequest disableChangeStreamRetention() { - return addChangeStreamRetention(Duration.ZERO); + return addChangeStreamRetentionDuration(java.time.Duration.ZERO); } @InternalApi diff --git a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/common/Type.java b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/common/Type.java index df5c6dcd95..cd6a0a5407 100644 --- a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/common/Type.java +++ b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/common/Type.java @@ -23,8 +23,8 @@ import com.google.common.base.Objects; import com.google.common.collect.ImmutableList; import com.google.protobuf.ByteString; +import java.time.Instant; import java.util.List; -import org.threeten.bp.Instant; /** * Shared type implementations. Right now this is only used by SqlType but this will become a shared diff --git a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/BigtableDataSettings.java b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/BigtableDataSettings.java index 928159aa6d..f21639d57a 100644 --- a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/BigtableDataSettings.java +++ b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/BigtableDataSettings.java @@ -38,7 +38,6 @@ import java.util.logging.Logger; import javax.annotation.Nonnull; import javax.annotation.Nullable; -import org.threeten.bp.Duration; /** * Settings class to configure an instance of {@link BigtableDataClient}. @@ -132,9 +131,11 @@ public static Builder newBuilderForEmulator(String hostname, int port) { .setMaxInboundMessageSize(256 * 1024 * 1024) .setChannelPoolSettings(ChannelPoolSettings.staticallySized(1)) .setChannelConfigurator(ManagedChannelBuilder::usePlaintext) - .setKeepAliveTime(Duration.ofSeconds(61)) // sends ping in this interval - .setKeepAliveTimeout( - Duration.ofSeconds(10)) // wait this long before considering the connection dead + .setKeepAliveTimeDuration( + java.time.Duration.ofSeconds(61)) // sends ping in this interval + .setKeepAliveTimeoutDuration( + java.time.Duration.ofSeconds( + 10)) // wait this long before considering the connection dead .build()); LOGGER.info("Connecting to the Bigtable emulator at " + hostname + ":" + port); diff --git a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/internal/AbstractProtoStructReader.java b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/internal/AbstractProtoStructReader.java index dff4d4e0b2..f6e611c878 100644 --- a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/internal/AbstractProtoStructReader.java +++ b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/internal/AbstractProtoStructReader.java @@ -15,7 +15,10 @@ */ package com.google.cloud.bigtable.data.v2.internal; +import static com.google.api.gax.util.TimeConversionUtils.toThreetenInstant; + import com.google.api.core.InternalApi; +import com.google.api.core.ObsoleteApi; import com.google.bigtable.v2.Value; import com.google.bigtable.v2.Value.KindCase; import com.google.cloud.Date; @@ -30,7 +33,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import org.threeten.bp.Instant; @InternalApi public abstract class AbstractProtoStructReader implements StructReader { @@ -166,14 +168,26 @@ public boolean getBoolean(String columnName) { } @Override - public Instant getTimestamp(int columnIndex) { + @ObsoleteApi("Use getTimestampInstant(int) instead") + public org.threeten.bp.Instant getTimestamp(int columnIndex) { + return toThreetenInstant(getTimestampInstant(columnIndex)); + } + + @Override + public java.time.Instant getTimestampInstant(int columnIndex) { checkNonNullOfType(columnIndex, SqlType.timestamp(), columnIndex); Value value = values().get(columnIndex); return toInstant(value.getTimestampValue()); } @Override - public Instant getTimestamp(String columnName) { + @ObsoleteApi("Use getTimestampInstant(String) instead") + public org.threeten.bp.Instant getTimestamp(String columnName) { + return toThreetenInstant(getTimestampInstant(columnName)); + } + + @Override + public java.time.Instant getTimestampInstant(String columnName) { int columnIndex = getColumnIndex(columnName); checkNonNullOfType(columnIndex, SqlType.timestamp(), columnName); Value value = values().get(columnIndex); @@ -329,8 +343,8 @@ private void checkNonNullOfType( } } - private Instant toInstant(Timestamp timestamp) { - return Instant.ofEpochSecond(timestamp.getSeconds(), timestamp.getNanos()); + private java.time.Instant toInstant(Timestamp timestamp) { + return java.time.Instant.ofEpochSecond(timestamp.getSeconds(), timestamp.getNanos()); } private Date fromProto(com.google.type.Date proto) { diff --git a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/internal/ResultSetImpl.java b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/internal/ResultSetImpl.java index 1d2bd37f2d..5dd242d64b 100644 --- a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/internal/ResultSetImpl.java +++ b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/internal/ResultSetImpl.java @@ -15,8 +15,11 @@ */ package com.google.cloud.bigtable.data.v2.internal; +import static com.google.api.gax.util.TimeConversionUtils.toThreetenInstant; + import com.google.api.core.ApiFuture; import com.google.api.core.InternalApi; +import com.google.api.core.ObsoleteApi; import com.google.api.gax.rpc.ApiExceptions; import com.google.api.gax.rpc.ServerStream; import com.google.cloud.Date; @@ -31,7 +34,6 @@ import java.util.Iterator; import java.util.List; import java.util.Map; -import org.threeten.bp.Instant; /** * The primary implementation of a ResultSet. @@ -167,13 +169,25 @@ public boolean getBoolean(String columnName) { } @Override - public Instant getTimestamp(int columnIndex) { - return getCurrentRow().getTimestamp(columnIndex); + @ObsoleteApi("Use getTimestampInstant(int) instead") + public org.threeten.bp.Instant getTimestamp(int columnIndex) { + return toThreetenInstant(getTimestampInstant(columnIndex)); + } + + @Override + public java.time.Instant getTimestampInstant(int columnIndex) { + return getCurrentRow().getTimestampInstant(columnIndex); + } + + @Override + @ObsoleteApi("Use getTimestampInstant(String) instead") + public org.threeten.bp.Instant getTimestamp(String columnName) { + return toThreetenInstant(getTimestampInstant(columnName)); } @Override - public Instant getTimestamp(String columnName) { - return getCurrentRow().getTimestamp(columnName); + public java.time.Instant getTimestampInstant(String columnName) { + return getCurrentRow().getTimestampInstant(columnName); } @Override diff --git a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/models/ChangeStreamMutation.java b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/models/ChangeStreamMutation.java index 23fb47bd82..1afa8a2358 100644 --- a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/models/ChangeStreamMutation.java +++ b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/models/ChangeStreamMutation.java @@ -15,7 +15,11 @@ */ package com.google.cloud.bigtable.data.v2.models; +import static com.google.api.gax.util.TimeConversionUtils.toJavaTimeInstant; +import static com.google.api.gax.util.TimeConversionUtils.toThreetenInstant; + import com.google.api.core.InternalApi; +import com.google.api.core.ObsoleteApi; import com.google.auto.value.AutoValue; import com.google.cloud.bigtable.data.v2.models.Range.TimestampRange; import com.google.cloud.bigtable.data.v2.stub.changestream.ChangeStreamRecordMerger; @@ -23,7 +27,6 @@ import com.google.protobuf.ByteString; import java.io.Serializable; import javax.annotation.Nonnull; -import org.threeten.bp.Instant; /** * A ChangeStreamMutation represents a list of mods(represented by List<{@link Entry}>) targeted at @@ -73,13 +76,13 @@ public enum MutationType { static Builder createUserMutation( @Nonnull ByteString rowKey, @Nonnull String sourceClusterId, - Instant commitTimestamp, + java.time.Instant commitTimestamp, int tieBreaker) { return builder() .setRowKey(rowKey) .setType(MutationType.USER) .setSourceClusterId(sourceClusterId) - .setCommitTimestamp(commitTimestamp) + .setCommitTimestampInstant(commitTimestamp) .setTieBreaker(tieBreaker); } @@ -89,12 +92,12 @@ static Builder createUserMutation( * mutation. */ static Builder createGcMutation( - @Nonnull ByteString rowKey, Instant commitTimestamp, int tieBreaker) { + @Nonnull ByteString rowKey, java.time.Instant commitTimestamp, int tieBreaker) { return builder() .setRowKey(rowKey) .setType(MutationType.GARBAGE_COLLECTION) .setSourceClusterId("") - .setCommitTimestamp(commitTimestamp) + .setCommitTimestampInstant(commitTimestamp) .setTieBreaker(tieBreaker); } @@ -110,8 +113,14 @@ static Builder createGcMutation( @Nonnull public abstract String getSourceClusterId(); + /** This method is obsolete. Use {@link #getCommitTimestampInstant()} instead. */ + @ObsoleteApi("Use getCommitTimestampInstant() instead") + public org.threeten.bp.Instant getCommitTimestamp() { + return toThreetenInstant(getCommitTimestampInstant()); + } + /** Get the commit timestamp of the current mutation. */ - public abstract Instant getCommitTimestamp(); + public abstract java.time.Instant getCommitTimestampInstant(); /** * Get the tie breaker of the current mutation. This is used to resolve conflicts when multiple @@ -123,8 +132,14 @@ static Builder createGcMutation( @Nonnull public abstract String getToken(); + /** This method is obsolete. Use {@link #getCommitTimestampInstant()} instead. */ + @ObsoleteApi("Use getEstimatedLowWatermarkInstant() instead") + public org.threeten.bp.Instant getEstimatedLowWatermark() { + return toThreetenInstant(getEstimatedLowWatermarkInstant()); + } + /** Get the low watermark of the current mutation. */ - public abstract Instant getEstimatedLowWatermark(); + public abstract java.time.Instant getEstimatedLowWatermarkInstant(); /** Get the list of mods of the current mutation. */ @Nonnull @@ -145,7 +160,15 @@ abstract static class Builder { abstract Builder setSourceClusterId(@Nonnull String sourceClusterId); - abstract Builder setCommitTimestamp(Instant commitTimestamp); + abstract Builder setCommitTimestampInstant(java.time.Instant commitTimestamp); + + /** + * This method is obsolete. Use {@link #setCommitTimestampInstant(java.time.Instant)} instead. + */ + @ObsoleteApi("Use setCommitTimestampInstant(java.time.Instant) instead") + Builder setCommitTimestamp(org.threeten.bp.Instant commitTimestamp) { + return setCommitTimestampInstant(toJavaTimeInstant(commitTimestamp)); + } abstract Builder setTieBreaker(int tieBreaker); @@ -153,7 +176,16 @@ abstract static class Builder { abstract Builder setToken(@Nonnull String token); - abstract Builder setEstimatedLowWatermark(Instant estimatedLowWatermark); + abstract Builder setEstimatedLowWatermarkInstant(java.time.Instant estimatedLowWatermark); + + /** + * This method is obsolete. Use {@link #setEstimatedLowWatermarkInstant(java.time.Instant)} + * instead. + */ + @ObsoleteApi("Use setEstimatedLowWatermarkInstant(java.time.Instant) instead") + Builder setEstimatedLowWatermark(org.threeten.bp.Instant estimatedLowWatermark) { + return setEstimatedLowWatermarkInstant(toJavaTimeInstant(estimatedLowWatermark)); + } Builder setCell( @Nonnull String familyName, diff --git a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/models/ChangeStreamRecordAdapter.java b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/models/ChangeStreamRecordAdapter.java index 40a71b1d3c..e7ec59d070 100644 --- a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/models/ChangeStreamRecordAdapter.java +++ b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/models/ChangeStreamRecordAdapter.java @@ -15,12 +15,14 @@ */ package com.google.cloud.bigtable.data.v2.models; +import static com.google.api.gax.util.TimeConversionUtils.toThreetenInstant; + import com.google.api.core.InternalApi; +import com.google.api.core.ObsoleteApi; import com.google.bigtable.v2.ReadChangeStreamResponse; import com.google.cloud.bigtable.data.v2.models.Range.TimestampRange; import com.google.protobuf.ByteString; import javax.annotation.Nonnull; -import org.threeten.bp.Instant; /** * An extension point that allows end users to plug in a custom implementation of logical change @@ -108,23 +110,47 @@ interface ChangeStreamRecordBuilder { */ ChangeStreamRecordT onCloseStream(ReadChangeStreamResponse.CloseStream closeStream); + /** + * This method is obsolete. Use {@link #startUserMutationInstant(ByteString, String, + * java.time.Instant, int)} instead. + */ + @ObsoleteApi("Use startUserMutationInstant(ByteString, String, java.time.Instant, int) instead") + void startUserMutation( + @Nonnull ByteString rowKey, + @Nonnull String sourceClusterId, + org.threeten.bp.Instant commitTimestamp, + int tieBreaker); + /** * Called to start a new user initiated ChangeStreamMutation. This will be called at most once. * If called, the current change stream record must not include any close stream message or * heartbeat. */ - void startUserMutation( + default void startUserMutationInstant( @Nonnull ByteString rowKey, @Nonnull String sourceClusterId, - Instant commitTimestamp, - int tieBreaker); + java.time.Instant commitTimestamp, + int tieBreaker) { + startUserMutation(rowKey, sourceClusterId, toThreetenInstant(commitTimestamp), tieBreaker); + } + + /** + * This method is obsolete. Use {@link #startGcMutationInstant(ByteString, java.time.Instant, + * int)} instead. + */ + @ObsoleteApi("Use startGcMutationInstant(ByteString, java.time.Instant, int) instead") + void startGcMutation( + @Nonnull ByteString rowKey, org.threeten.bp.Instant commitTimestamp, int tieBreaker); /** * Called to start a new Garbage Collection ChangeStreamMutation. This will be called at most * once. If called, the current change stream record must not include any close stream message * or heartbeat. */ - void startGcMutation(@Nonnull ByteString rowKey, Instant commitTimestamp, int tieBreaker); + default void startGcMutationInstant( + @Nonnull ByteString rowKey, java.time.Instant commitTimestamp, int tieBreaker) { + startGcMutation(rowKey, toThreetenInstant(commitTimestamp), tieBreaker); + } /** Called to add a DeleteFamily mod. */ void deleteFamily(@Nonnull String familyName); @@ -175,9 +201,19 @@ void mergeToCell( /** Called once per cell to signal the end of the value (unless reset). */ void finishCell(); - /** Called once per stream record to signal that all mods have been processed (unless reset). */ + /** + * This method is obsolete. Use {@link #finishChangeStreamMutationInstant(String, + * java.time.Instant)} instead. + */ + @ObsoleteApi("Use finishChangeStreamMutationInstant(String, java.time.Instant) instead") ChangeStreamRecordT finishChangeStreamMutation( - @Nonnull String token, Instant estimatedLowWatermark); + @Nonnull String token, org.threeten.bp.Instant estimatedLowWatermark); + + /** Called once per stream record to signal that all mods have been processed (unless reset). */ + default ChangeStreamRecordT finishChangeStreamMutationInstant( + @Nonnull String token, java.time.Instant estimatedLowWatermark) { + return finishChangeStreamMutation(token, toThreetenInstant(estimatedLowWatermark)); + } /** Called when the current in progress change stream record should be dropped */ void reset(); diff --git a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/models/DefaultChangeStreamRecordAdapter.java b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/models/DefaultChangeStreamRecordAdapter.java index d40ad7621c..b8ef0a3b11 100644 --- a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/models/DefaultChangeStreamRecordAdapter.java +++ b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/models/DefaultChangeStreamRecordAdapter.java @@ -15,6 +15,8 @@ */ package com.google.cloud.bigtable.data.v2.models; +import static com.google.api.gax.util.TimeConversionUtils.toJavaTimeInstant; + import com.google.api.core.InternalApi; import com.google.bigtable.v2.ReadChangeStreamResponse; import com.google.cloud.bigtable.data.v2.models.Range.TimestampRange; @@ -22,7 +24,6 @@ import com.google.protobuf.ByteString; import javax.annotation.Nonnull; import javax.annotation.Nullable; -import org.threeten.bp.Instant; /** * Default implementation of a {@link ChangeStreamRecordAdapter} that uses {@link @@ -103,17 +104,23 @@ public ChangeStreamRecord onCloseStream(ReadChangeStreamResponse.CloseStream clo public void startUserMutation( @Nonnull ByteString rowKey, @Nonnull String sourceClusterId, - Instant commitTimestamp, + org.threeten.bp.Instant commitTimestamp, int tieBreaker) { - this.changeStreamMutationBuilder = - ChangeStreamMutation.createUserMutation( - rowKey, sourceClusterId, commitTimestamp, tieBreaker); + startUserMutationInstant( + rowKey, sourceClusterId, toJavaTimeInstant(commitTimestamp), tieBreaker); } /** {@inheritDoc} */ @Override public void startGcMutation( - @Nonnull ByteString rowKey, Instant commitTimestamp, int tieBreaker) { + @Nonnull ByteString rowKey, org.threeten.bp.Instant commitTimestamp, int tieBreaker) { + startGcMutationInstant(rowKey, toJavaTimeInstant(commitTimestamp), tieBreaker); + } + + /** {@inheritDoc} */ + @Override + public void startGcMutationInstant( + ByteString rowKey, java.time.Instant commitTimestamp, int tieBreaker) { this.changeStreamMutationBuilder = ChangeStreamMutation.createGcMutation(rowKey, commitTimestamp, tieBreaker); } @@ -176,9 +183,16 @@ public void finishCell() { /** {@inheritDoc} */ @Override public ChangeStreamRecord finishChangeStreamMutation( - @Nonnull String token, Instant estimatedLowWatermark) { + @Nonnull String token, org.threeten.bp.Instant estimatedLowWatermark) { + return finishChangeStreamMutationInstant(token, toJavaTimeInstant(estimatedLowWatermark)); + } + + /** {@inheritDoc} */ + @Override + public ChangeStreamRecord finishChangeStreamMutationInstant( + String token, java.time.Instant estimatedLowWatermark) { this.changeStreamMutationBuilder.setToken(token); - this.changeStreamMutationBuilder.setEstimatedLowWatermark(estimatedLowWatermark); + this.changeStreamMutationBuilder.setEstimatedLowWatermarkInstant(estimatedLowWatermark); return this.changeStreamMutationBuilder.build(); } diff --git a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/models/Heartbeat.java b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/models/Heartbeat.java index 8e3d865790..66888cce20 100644 --- a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/models/Heartbeat.java +++ b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/models/Heartbeat.java @@ -15,12 +15,14 @@ */ package com.google.cloud.bigtable.data.v2.models; +import static com.google.api.gax.util.TimeConversionUtils.toThreetenInstant; + import com.google.api.core.InternalApi; +import com.google.api.core.ObsoleteApi; import com.google.auto.value.AutoValue; import com.google.bigtable.v2.ReadChangeStreamResponse; import java.io.Serializable; import javax.annotation.Nonnull; -import org.threeten.bp.Instant; /** A simple wrapper for {@link ReadChangeStreamResponse.Heartbeat}. */ @InternalApi("Intended for use by the BigtableIO in apache/beam only.") @@ -29,7 +31,8 @@ public abstract class Heartbeat implements ChangeStreamRecord, Serializable { private static final long serialVersionUID = 7316215828353608504L; private static Heartbeat create( - ChangeStreamContinuationToken changeStreamContinuationToken, Instant estimatedLowWatermark) { + ChangeStreamContinuationToken changeStreamContinuationToken, + java.time.Instant estimatedLowWatermark) { return new AutoValue_Heartbeat(changeStreamContinuationToken, estimatedLowWatermark); } @@ -37,7 +40,7 @@ private static Heartbeat create( static Heartbeat fromProto(@Nonnull ReadChangeStreamResponse.Heartbeat heartbeat) { return create( ChangeStreamContinuationToken.fromProto(heartbeat.getContinuationToken()), - Instant.ofEpochSecond( + java.time.Instant.ofEpochSecond( heartbeat.getEstimatedLowWatermark().getSeconds(), heartbeat.getEstimatedLowWatermark().getNanos())); } @@ -45,6 +48,12 @@ static Heartbeat fromProto(@Nonnull ReadChangeStreamResponse.Heartbeat heartbeat @InternalApi("Intended for use by the BigtableIO in apache/beam only.") public abstract ChangeStreamContinuationToken getChangeStreamContinuationToken(); + /** This method is obsolete. Use {@link #getEstimatedLowWatermarkInstant()} instead. */ + @ObsoleteApi("Use getEstimatedLowWatermarkInstant() instead") + public org.threeten.bp.Instant getEstimatedLowWatermark() { + return toThreetenInstant(getEstimatedLowWatermarkInstant()); + } + @InternalApi("Intended for use by the BigtableIO in apache/beam only.") - public abstract Instant getEstimatedLowWatermark(); + public abstract java.time.Instant getEstimatedLowWatermarkInstant(); } diff --git a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/models/ReadChangeStreamQuery.java b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/models/ReadChangeStreamQuery.java index a6dfb7666d..e6ae9e526f 100644 --- a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/models/ReadChangeStreamQuery.java +++ b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/models/ReadChangeStreamQuery.java @@ -15,7 +15,11 @@ */ package com.google.cloud.bigtable.data.v2.models; +import static com.google.api.gax.util.TimeConversionUtils.toJavaTimeDuration; +import static com.google.api.gax.util.TimeConversionUtils.toJavaTimeInstant; + import com.google.api.core.InternalApi; +import com.google.api.core.ObsoleteApi; import com.google.bigtable.v2.ReadChangeStreamRequest; import com.google.bigtable.v2.RowRange; import com.google.bigtable.v2.StreamContinuationTokens; @@ -36,7 +40,6 @@ import java.util.List; import javax.annotation.Nonnull; import javax.annotation.Nullable; -import org.threeten.bp.Instant; /** A simple wrapper to construct a query for the ReadChangeStream RPC. */ @InternalApi("Intended for use by the BigtableIO in apache/beam only.") @@ -143,8 +146,14 @@ public ReadChangeStreamQuery streamPartition(ByteStringRange range) { return streamPartition(rangeBuilder.build()); } + /** This method is obsolete. Use {@link #startTimeInstant(java.time.Instant)} instead. */ + @ObsoleteApi("Use startTimeInstant(java.time.Instant) instead") + public ReadChangeStreamQuery startTime(org.threeten.bp.Instant value) { + return startTimeInstant(toJavaTimeInstant(value)); + } + /** Sets the startTime to read the change stream. */ - public ReadChangeStreamQuery startTime(Instant value) { + public ReadChangeStreamQuery startTimeInstant(java.time.Instant value) { Preconditions.checkState( !builder.hasContinuationTokens(), "startTime and continuationTokens can't be specified together"); @@ -156,8 +165,14 @@ public ReadChangeStreamQuery startTime(Instant value) { return this; } + /** This method is obsolete. Use {@link #endTimeInstant(java.time.Instant)} instead. */ + @ObsoleteApi("Use endTimeInstant(java.time.Instant) instead") + public ReadChangeStreamQuery endTime(org.threeten.bp.Instant value) { + return endTimeInstant(toJavaTimeInstant(value)); + } + /** Sets the endTime to read the change stream. */ - public ReadChangeStreamQuery endTime(Instant value) { + public ReadChangeStreamQuery endTimeInstant(java.time.Instant value) { builder.setEndTime( Timestamp.newBuilder() .setSeconds(value.getEpochSecond()) @@ -181,8 +196,16 @@ public ReadChangeStreamQuery continuationTokens( return this; } - /** Sets the heartbeat duration for the change stream. */ + /** + * This method is obsolete. Use {@link #heartbeatDurationDuration(java.time.Duration)} instead. + */ + @ObsoleteApi("Use heartbeatDurationDuration(java.time.Duration) instead") public ReadChangeStreamQuery heartbeatDuration(org.threeten.bp.Duration duration) { + return heartbeatDurationDuration(toJavaTimeDuration(duration)); + } + + /** Sets the heartbeat duration for the change stream. */ + public ReadChangeStreamQuery heartbeatDurationDuration(java.time.Duration duration) { builder.setHeartbeatDuration( Duration.newBuilder() .setSeconds(duration.getSeconds()) diff --git a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/models/sql/SqlType.java b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/models/sql/SqlType.java index 50146f292a..697bfd1f04 100644 --- a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/models/sql/SqlType.java +++ b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/models/sql/SqlType.java @@ -24,7 +24,6 @@ import com.google.protobuf.ByteString; import java.io.Serializable; import java.util.List; -import org.threeten.bp.Instant; /** * Represents a data type in a SQL query. @@ -150,7 +149,7 @@ static SqlType bool() { } /** returns a {@link SqlType} for the {@code TIMESTAMP} type. */ - static SqlType timestamp() { + static SqlType timestamp() { return Type.Timestamp.create(); } diff --git a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/models/sql/Statement.java b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/models/sql/Statement.java index 58c16e2c5c..117ae1ae09 100644 --- a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/models/sql/Statement.java +++ b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/models/sql/Statement.java @@ -15,6 +15,8 @@ */ package com.google.cloud.bigtable.data.v2.models.sql; +import static com.google.api.gax.util.TimeConversionUtils.toJavaTimeInstant; + import com.google.api.core.BetaApi; import com.google.api.core.InternalApi; import com.google.bigtable.v2.ArrayValue; @@ -31,7 +33,6 @@ import java.util.List; import java.util.Map; import javax.annotation.Nullable; -import org.threeten.bp.Instant; /** * A SQL statement that can be executed by calling {@link @@ -163,11 +164,14 @@ public Builder setBooleanParam(String paramName, @Nullable Boolean value) { return this; } + public Builder setTimestampParam(String paramName, @Nullable org.threeten.bp.Instant value) { + return setTimestampParamInstant(paramName, toJavaTimeInstant(value)); + } /** * Sets a query parameter with the name {@code paramName} and the TIMESTAMP typed value {@code * value} */ - public Builder setTimestampParam(String paramName, @Nullable Instant value) { + public Builder setTimestampParamInstant(String paramName, @Nullable java.time.Instant value) { params.put(paramName, timestampParamOf(value)); return this; } @@ -239,7 +243,7 @@ private static Value booleanParamOf(@Nullable Boolean value) { return builder.build(); } - private static Value timestampParamOf(@Nullable Instant value) { + private static Value timestampParamOf(@Nullable java.time.Instant value) { Value.Builder builder = nullValueWithType(TIMESTAMP_TYPE); if (value != null) { builder.setTimestampValue(toTimestamp(value)); @@ -325,7 +329,7 @@ private static ArrayValue arrayValueOf(List value, SqlType.Array arrayType valueBuilder.addValues(Value.newBuilder().setBoolValue(boolElem).build()); break; case TIMESTAMP: - Instant timestampElem = (Instant) element; + java.time.Instant timestampElem = (java.time.Instant) element; valueBuilder.addValues( Value.newBuilder().setTimestampValue(toTimestamp(timestampElem)).build()); break; @@ -341,7 +345,7 @@ private static ArrayValue arrayValueOf(List value, SqlType.Array arrayType return valueBuilder.build(); } - private static Timestamp toTimestamp(Instant instant) { + private static Timestamp toTimestamp(java.time.Instant instant) { return Timestamp.newBuilder() .setSeconds(instant.getEpochSecond()) .setNanos(instant.getNano()) diff --git a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/models/sql/StructReader.java b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/models/sql/StructReader.java index 8f450bbd92..fc3e286cf4 100644 --- a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/models/sql/StructReader.java +++ b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/models/sql/StructReader.java @@ -15,12 +15,14 @@ */ package com.google.cloud.bigtable.data.v2.models.sql; +import static com.google.api.gax.util.TimeConversionUtils.toJavaTimeInstant; + import com.google.api.core.BetaApi; +import com.google.api.core.ObsoleteApi; import com.google.cloud.Date; import com.google.protobuf.ByteString; import java.util.List; import java.util.Map; -import org.threeten.bp.Instant; /** * An interface for reading the columns of a {@code Struct} or {@code @@ -131,17 +133,29 @@ public interface StructReader { */ boolean getBoolean(String columnName); + /** This method is obsolete. Use {@link #getTimestampInstant(int)} instead. */ + @ObsoleteApi("Use getTimestampInstant(int) instead") + org.threeten.bp.Instant getTimestamp(int columnIndex); + /** * @param columnIndex index of the column - * @return {@link Instant} type value of a non-{@code NULL} column + * @return {@link java.time.Instant} type value of a non-{@code NULL} column */ - Instant getTimestamp(int columnIndex); + default java.time.Instant getTimestampInstant(int columnIndex) { + return toJavaTimeInstant(getTimestamp(columnIndex)); + } + + /** This method is obsolete. Use {@link #getTimestampInstant(String)} instead. */ + @ObsoleteApi("Use getTimestampInstant(String) instead") + org.threeten.bp.Instant getTimestamp(String columnName); /** * @param columnName name of the column - * @return {@link Instant} type value of a non-{@code NULL} column + * @return {@link java.time.Instant} type value of a non-{@code NULL} column */ - Instant getTimestamp(String columnName); + default java.time.Instant getTimestampInstant(String columnName) { + return toJavaTimeInstant(getTimestamp(columnName)); + } /** * @param columnIndex index of the column diff --git a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/RateLimitingServerStreamingCallable.java b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/RateLimitingServerStreamingCallable.java index 62f8b5abf6..c3b0f94ec7 100644 --- a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/RateLimitingServerStreamingCallable.java +++ b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/RateLimitingServerStreamingCallable.java @@ -30,13 +30,13 @@ import com.google.common.base.Preconditions; import com.google.common.base.Stopwatch; import com.google.common.util.concurrent.RateLimiter; +import java.time.Duration; +import java.time.Instant; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicReference; import java.util.logging.Logger; import javax.annotation.Nonnull; -import org.threeten.bp.Duration; -import org.threeten.bp.Instant; class RateLimitingServerStreamingCallable extends ServerStreamingCallable { diff --git a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/changestream/ChangeStreamStateMachine.java b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/changestream/ChangeStreamStateMachine.java index b41acc4ac3..7627fb4751 100644 --- a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/changestream/ChangeStreamStateMachine.java +++ b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/changestream/ChangeStreamStateMachine.java @@ -22,7 +22,6 @@ import com.google.cloud.bigtable.data.v2.models.Range.TimestampRange; import com.google.cloud.bigtable.data.v2.models.Value; import com.google.common.base.Preconditions; -import org.threeten.bp.Instant; /** * A state machine to produce change stream records from a stream of {@link @@ -332,9 +331,9 @@ State handleDataChange(ReadChangeStreamResponse.DataChange dataChange) { validate( dataChange.getSourceClusterId().isEmpty(), "AWAITING_NEW_STREAM_RECORD: GC mutation shouldn't have source cluster id."); - builder.startGcMutation( + builder.startGcMutationInstant( dataChange.getRowKey(), - Instant.ofEpochSecond( + java.time.Instant.ofEpochSecond( dataChange.getCommitTimestamp().getSeconds(), dataChange.getCommitTimestamp().getNanos()), dataChange.getTiebreaker()); @@ -342,10 +341,10 @@ State handleDataChange(ReadChangeStreamResponse.DataChange dataChange) { validate( !dataChange.getSourceClusterId().isEmpty(), "AWAITING_NEW_STREAM_RECORD: User initiated data change missing source cluster id."); - builder.startUserMutation( + builder.startUserMutationInstant( dataChange.getRowKey(), dataChange.getSourceClusterId(), - Instant.ofEpochSecond( + java.time.Instant.ofEpochSecond( dataChange.getCommitTimestamp().getSeconds(), dataChange.getCommitTimestamp().getNanos()), dataChange.getTiebreaker()); @@ -576,9 +575,9 @@ private State checkAndFinishMutationIfNeeded(ReadChangeStreamResponse.DataChange validate(!dataChange.getToken().isEmpty(), "Last data change missing token"); validate(dataChange.hasEstimatedLowWatermark(), "Last data change missing lowWatermark"); completeChangeStreamRecord = - builder.finishChangeStreamMutation( + builder.finishChangeStreamMutationInstant( dataChange.getToken(), - Instant.ofEpochSecond( + java.time.Instant.ofEpochSecond( dataChange.getEstimatedLowWatermark().getSeconds(), dataChange.getEstimatedLowWatermark().getNanos())); return AWAITING_STREAM_RECORD_CONSUME; diff --git a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/metrics/BigtableCloudMonitoringExporter.java b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/metrics/BigtableCloudMonitoringExporter.java index 8aa53fa198..cddb523c6a 100644 --- a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/metrics/BigtableCloudMonitoringExporter.java +++ b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/metrics/BigtableCloudMonitoringExporter.java @@ -64,7 +64,6 @@ import java.util.logging.Logger; import java.util.stream.Collectors; import javax.annotation.Nullable; -import org.threeten.bp.Duration; /** * Bigtable Cloud Monitoring OpenTelemetry Exporter. @@ -145,10 +144,10 @@ public static BigtableCloudMonitoringExporter create( settingsBuilder.setEndpoint(endpoint); } - org.threeten.bp.Duration timeout = Duration.ofMinutes(1); + java.time.Duration timeout = java.time.Duration.ofMinutes(1); // TODO: createServiceTimeSeries needs special handling if the request failed. Leaving // it as not retried for now. - settingsBuilder.createServiceTimeSeriesSettings().setSimpleTimeoutNoRetries(timeout); + settingsBuilder.createServiceTimeSeriesSettings().setSimpleTimeoutNoRetriesDuration(timeout); // Detect the resource that the client application is running on. For example, // this could be a GCE instance or a GKE pod. Currently, we only support GCE instance and diff --git a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/metrics/BuiltinMetricsTracer.java b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/metrics/BuiltinMetricsTracer.java index e639ea5627..5da062b9f3 100644 --- a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/metrics/BuiltinMetricsTracer.java +++ b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/metrics/BuiltinMetricsTracer.java @@ -16,6 +16,7 @@ package com.google.cloud.bigtable.data.v2.stub.metrics; import static com.google.api.gax.tracing.ApiTracerFactory.OperationType; +import static com.google.api.gax.util.TimeConversionUtils.toJavaTimeDuration; import static com.google.cloud.bigtable.data.v2.stub.metrics.BuiltinMetricsConstants.CLIENT_NAME_KEY; import static com.google.cloud.bigtable.data.v2.stub.metrics.BuiltinMetricsConstants.CLUSTER_ID_KEY; import static com.google.cloud.bigtable.data.v2.stub.metrics.BuiltinMetricsConstants.METHOD_KEY; @@ -24,6 +25,7 @@ import static com.google.cloud.bigtable.data.v2.stub.metrics.BuiltinMetricsConstants.TABLE_ID_KEY; import static com.google.cloud.bigtable.data.v2.stub.metrics.BuiltinMetricsConstants.ZONE_ID_KEY; +import com.google.api.core.ObsoleteApi; import com.google.api.gax.retrying.ServerStreamingAttemptException; import com.google.api.gax.tracing.SpanName; import com.google.cloud.bigtable.Version; @@ -40,7 +42,6 @@ import java.util.concurrent.atomic.AtomicLong; import java.util.logging.Logger; import javax.annotation.Nullable; -import org.threeten.bp.Duration; /** * A {@link BigtableTracer} that records built-in metrics and publish under the @@ -200,8 +201,18 @@ public void attemptCancelled() { recordAttemptCompletion(new CancellationException()); } + /** + * This method is obsolete. Use {@link #attemptFailedDuration(Throwable, java.time.Duration)} + * instead. + */ + @ObsoleteApi("Use attemptFailedDuration(Throwable, java.time.Duration) instead") @Override - public void attemptFailed(Throwable error, Duration delay) { + public void attemptFailed(Throwable error, org.threeten.bp.Duration delay) { + attemptFailedDuration(error, toJavaTimeDuration(delay)); + } + + @Override + public void attemptFailedDuration(Throwable error, java.time.Duration delay) { recordAttemptCompletion(error); } @@ -291,7 +302,7 @@ public void setLocations(String zone, String cluster) { @Override public void batchRequestThrottled(long throttledTimeNanos) { - totalClientBlockingTime.addAndGet(Duration.ofNanos(throttledTimeNanos).toMillis()); + totalClientBlockingTime.addAndGet(java.time.Duration.ofNanos(throttledTimeNanos).toMillis()); } @Override diff --git a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/metrics/CompositeTracer.java b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/metrics/CompositeTracer.java index 7882c82d93..cb846f19b7 100644 --- a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/metrics/CompositeTracer.java +++ b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/metrics/CompositeTracer.java @@ -15,12 +15,14 @@ */ package com.google.cloud.bigtable.data.v2.stub.metrics; +import static com.google.api.gax.util.TimeConversionUtils.toJavaTimeDuration; + +import com.google.api.core.ObsoleteApi; import com.google.api.gax.tracing.ApiTracer; import com.google.common.collect.ImmutableList; import java.util.ArrayList; import java.util.List; import javax.annotation.Nullable; -import org.threeten.bp.Duration; /** * Combines multiple {@link ApiTracer}s and {@link BigtableTracer}s into a single {@link ApiTracer}. @@ -124,9 +126,20 @@ public void attemptCancelled() { } } - public void attemptFailed(Throwable error, Duration delay) { + /** + * This method is obsolete. Use {@link #attemptFailedDuration(Throwable, java.time.Duration)} + * instead. + */ + @ObsoleteApi("Use attemptFailedDuration(Throwable, java.time.Duration) instead") + @Override + public void attemptFailed(Throwable error, org.threeten.bp.Duration delay) { + attemptFailedDuration(error, toJavaTimeDuration(delay)); + } + + @Override + public void attemptFailedDuration(Throwable error, java.time.Duration delay) { for (ApiTracer child : children) { - child.attemptFailed(error, delay); + child.attemptFailedDuration(error, delay); } } diff --git a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/metrics/MetricsTracer.java b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/metrics/MetricsTracer.java index a2c5bdac1f..dda7707af7 100644 --- a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/metrics/MetricsTracer.java +++ b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/metrics/MetricsTracer.java @@ -15,6 +15,9 @@ */ package com.google.cloud.bigtable.data.v2.stub.metrics; +import static com.google.api.gax.util.TimeConversionUtils.toJavaTimeDuration; + +import com.google.api.core.ObsoleteApi; import com.google.api.gax.retrying.ServerStreamingAttemptException; import com.google.api.gax.tracing.ApiTracerFactory.OperationType; import com.google.api.gax.tracing.SpanName; @@ -32,7 +35,6 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; import javax.annotation.Nullable; -import org.threeten.bp.Duration; class MetricsTracer extends BigtableTracer { @@ -152,8 +154,18 @@ public void attemptCancelled() { recordAttemptCompletion(new CancellationException()); } + /** + * This method is obsolete. Use {@link #attemptFailedDuration(Throwable, java.time.Duration)} + * instead. + */ + @ObsoleteApi("Use attemptFailedDuration(Throwable, java.time.Duration) instead") + @Override + public void attemptFailed(Throwable throwable, org.threeten.bp.Duration duration) { + attemptFailedDuration(throwable, toJavaTimeDuration(duration)); + } + @Override - public void attemptFailed(Throwable throwable, Duration duration) { + public void attemptFailedDuration(Throwable throwable, java.time.Duration duration) { recordAttemptCompletion(throwable); } diff --git a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/metrics/TracedBatcherUnaryCallable.java b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/metrics/TracedBatcherUnaryCallable.java index ce73d75dc1..44ba688d55 100644 --- a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/metrics/TracedBatcherUnaryCallable.java +++ b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/metrics/TracedBatcherUnaryCallable.java @@ -21,7 +21,6 @@ import com.google.api.gax.rpc.ApiCallContext; import com.google.api.gax.rpc.UnaryCallable; import com.google.api.gax.tracing.ApiTracer; -import org.threeten.bp.Duration; /** * This callable will extract total throttled time from {@link ApiCallContext} and add it to {@link @@ -44,7 +43,8 @@ public ApiFuture futureCall(RequestT request, ApiCallContext context) if (tracer instanceof BigtableTracer) { ((BigtableTracer) tracer) .batchRequestThrottled( - Duration.ofMillis(context.getOption(Batcher.THROTTLED_TIME_KEY)).toNanos()); + java.time.Duration.ofMillis(context.getOption(Batcher.THROTTLED_TIME_KEY)) + .toNanos()); } } return innerCallable.futureCall(request, context); diff --git a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/gaxx/retrying/AttemptCallable.java b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/gaxx/retrying/AttemptCallable.java index 3599e1e4df..6d5c75ea99 100644 --- a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/gaxx/retrying/AttemptCallable.java +++ b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/gaxx/retrying/AttemptCallable.java @@ -24,7 +24,6 @@ import com.google.api.gax.rpc.UnaryCallable; import com.google.common.base.Preconditions; import java.util.concurrent.Callable; -import org.threeten.bp.Duration; // TODO: remove this once ApiResultRetryAlgorithm is added to gax. /** @@ -59,9 +58,9 @@ public ResponseT call() { try { // Set the RPC timeout if the caller did not provide their own. - Duration rpcTimeout = externalFuture.getAttemptSettings().getRpcTimeout(); + java.time.Duration rpcTimeout = externalFuture.getAttemptSettings().getRpcTimeoutDuration(); if (!rpcTimeout.isZero() && callContext.getTimeout() == null) { - callContext = callContext.withTimeout(rpcTimeout); + callContext = callContext.withTimeoutDuration(rpcTimeout); } externalFuture.setAttemptFuture(new NonCancellableFuture()); diff --git a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/gaxx/retrying/RetryInfoRetryAlgorithm.java b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/gaxx/retrying/RetryInfoRetryAlgorithm.java index 085b48bbb5..dd131f2498 100644 --- a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/gaxx/retrying/RetryInfoRetryAlgorithm.java +++ b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/gaxx/retrying/RetryInfoRetryAlgorithm.java @@ -23,7 +23,6 @@ import com.google.protobuf.util.Durations; import com.google.rpc.RetryInfo; import org.checkerframework.checker.nullness.qual.Nullable; -import org.threeten.bp.Duration; // TODO move this algorithm to gax /** @@ -36,11 +35,11 @@ public class RetryInfoRetryAlgorithm extends BasicResultRetryAlgorith @Override public TimedAttemptSettings createNextAttempt( Throwable prevThrowable, ResponseT prevResponse, TimedAttemptSettings prevSettings) { - Duration retryDelay = extractRetryDelay(prevThrowable); + java.time.Duration retryDelay = extractRetryDelay(prevThrowable); if (retryDelay != null) { return prevSettings .toBuilder() - .setRandomizedRetryDelay(retryDelay) + .setRandomizedRetryDelayDuration(retryDelay) .setAttemptCount(prevSettings.getAttemptCount() + 1) .setOverallAttemptCount(prevSettings.getAttemptCount() + 1) .build(); @@ -81,8 +80,7 @@ public boolean shouldRetry( && ((ApiException) previousThrowable).isRetryable(); } - @Nullable - static Duration extractRetryDelay(@Nullable Throwable throwable) { + static java.time.Duration extractRetryDelay(@Nullable Throwable throwable) { if (throwable == null) { return null; } @@ -97,6 +95,6 @@ static Duration extractRetryDelay(@Nullable Throwable throwable) { return null; } RetryInfo retryInfo = exception.getErrorDetails().getRetryInfo(); - return Duration.ofMillis(Durations.toMillis(retryInfo.getRetryDelay())); + return java.time.Duration.ofMillis(Durations.toMillis(retryInfo.getRetryDelay())); } } diff --git a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/BigtableInstanceAdminSettingsTest.java b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/BigtableInstanceAdminSettingsTest.java index 7ac632f29b..fbdab21d3f 100644 --- a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/BigtableInstanceAdminSettingsTest.java +++ b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/BigtableInstanceAdminSettingsTest.java @@ -22,11 +22,11 @@ import com.google.api.gax.rpc.StatusCode.Code; import com.google.cloud.bigtable.admin.v2.stub.BigtableInstanceAdminStubSettings; import java.io.IOException; +import java.time.Duration; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; import org.mockito.Mockito; -import org.threeten.bp.Duration; @RunWith(JUnit4.class) public class BigtableInstanceAdminSettingsTest { @@ -139,7 +139,7 @@ public void testToString() throws IOException { stubSettings .getInstanceSettings() .setRetrySettings( - RetrySettings.newBuilder().setTotalTimeout(Duration.ofMinutes(812)).build()); + RetrySettings.newBuilder().setTotalTimeoutDuration(Duration.ofMinutes(812)).build()); BigtableInstanceAdminSettings settings = builder.build(); checkToString(settings); diff --git a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/BigtableTableAdminClientTests.java b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/BigtableTableAdminClientTests.java index 3cf3ded747..a242227647 100644 --- a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/BigtableTableAdminClientTests.java +++ b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/BigtableTableAdminClientTests.java @@ -105,7 +105,6 @@ import org.mockito.junit.MockitoJUnit; import org.mockito.junit.MockitoRule; import org.mockito.stubbing.Answer; -import org.threeten.bp.Instant; @RunWith(JUnit4.class) /** @@ -307,7 +306,7 @@ public void testUpdateTable() { com.google.cloud.bigtable.admin.v2.models.UpdateTableRequest request = com.google.cloud.bigtable.admin.v2.models.UpdateTableRequest.of(TABLE_ID) - .addChangeStreamRetention(org.threeten.bp.Duration.ofHours(24)); + .addChangeStreamRetentionDuration(java.time.Duration.ofHours(24)); com.google.bigtable.admin.v2.Table expectedResponse = com.google.bigtable.admin.v2.Table.newBuilder() @@ -329,8 +328,10 @@ public void testUpdateTable() { // Verify assertThat(actualResult.getId()).isEqualTo(TABLE_ID); - assertThat(actualResult.getChangeStreamRetention()) - .isEqualTo(org.threeten.bp.Duration.ofHours(24)); + assertThat(actualResult.getChangeStreamRetentionDuration()) + .isEqualTo(java.time.Duration.ofHours(24)); + assertThat(actualResult.getChangeStreamRetentionDuration().toMillis()) + .isEqualTo(actualResult.getChangeStreamRetention().toMillis()); } @Test @@ -644,7 +645,7 @@ public void testCreateBackup() { CreateBackupRequest req = CreateBackupRequest.of(CLUSTER_ID, BACKUP_ID) .setSourceTableId(TABLE_ID) - .setExpireTime(Instant.ofEpochMilli(Timestamps.toMillis(expireTime))); + .setExpireTimeInstant(java.time.Instant.ofEpochMilli(Timestamps.toMillis(expireTime))); mockOperationResult( mockCreateBackupOperationCallable, req.toProto(PROJECT_ID, INSTANCE_ID), @@ -668,12 +669,12 @@ public void testCreateBackup() { // Verify assertThat(actualResult.getId()).isEqualTo(BACKUP_ID); assertThat(actualResult.getSourceTableId()).isEqualTo(TABLE_ID); - assertThat(actualResult.getStartTime()) - .isEqualTo(Instant.ofEpochMilli(Timestamps.toMillis(startTime))); - assertThat(actualResult.getEndTime()) - .isEqualTo(Instant.ofEpochMilli(Timestamps.toMillis(endTime))); - assertThat(actualResult.getExpireTime()) - .isEqualTo(Instant.ofEpochMilli(Timestamps.toMillis(expireTime))); + assertThat(actualResult.getStartTimeInstant()) + .isEqualTo(java.time.Instant.ofEpochMilli(Timestamps.toMillis(startTime))); + assertThat(actualResult.getEndTimeInstant()) + .isEqualTo(java.time.Instant.ofEpochMilli(Timestamps.toMillis(endTime))); + assertThat(actualResult.getExpireTimeInstant()) + .isEqualTo(java.time.Instant.ofEpochMilli(Timestamps.toMillis(expireTime))); assertThat(actualResult.getSizeBytes()).isEqualTo(sizeBytes); } @@ -692,9 +693,10 @@ public void testCreateHotBackup() { CreateBackupRequest req = CreateBackupRequest.of(CLUSTER_ID, BACKUP_ID) .setSourceTableId(TABLE_ID) - .setExpireTime(Instant.ofEpochMilli(Timestamps.toMillis(expireTime))) + .setExpireTimeInstant(java.time.Instant.ofEpochMilli(Timestamps.toMillis(expireTime))) .setBackupType(Backup.BackupType.HOT) - .setHotToStandardTime(Instant.ofEpochMilli(Timestamps.toMillis(hotToStandardTime))); + .setHotToStandardTimeInstant( + java.time.Instant.ofEpochMilli(Timestamps.toMillis(hotToStandardTime))); mockOperationResult( mockCreateBackupOperationCallable, req.toProto(PROJECT_ID, INSTANCE_ID), @@ -720,15 +722,15 @@ public void testCreateHotBackup() { // Verify assertThat(actualResult.getId()).isEqualTo(BACKUP_ID); assertThat(actualResult.getSourceTableId()).isEqualTo(TABLE_ID); - assertThat(actualResult.getStartTime()) - .isEqualTo(Instant.ofEpochMilli(Timestamps.toMillis(startTime))); - assertThat(actualResult.getEndTime()) - .isEqualTo(Instant.ofEpochMilli(Timestamps.toMillis(endTime))); - assertThat(actualResult.getExpireTime()) - .isEqualTo(Instant.ofEpochMilli(Timestamps.toMillis(expireTime))); + assertThat(actualResult.getStartTimeInstant()) + .isEqualTo(java.time.Instant.ofEpochMilli(Timestamps.toMillis(startTime))); + assertThat(actualResult.getEndTimeInstant()) + .isEqualTo(java.time.Instant.ofEpochMilli(Timestamps.toMillis(endTime))); + assertThat(actualResult.getExpireTimeInstant()) + .isEqualTo(java.time.Instant.ofEpochMilli(Timestamps.toMillis(expireTime))); assertThat(actualResult.getBackupType()).isEqualTo(Backup.BackupType.HOT); - assertThat(actualResult.getHotToStandardTime()) - .isEqualTo(Instant.ofEpochMilli(Timestamps.toMillis(hotToStandardTime))); + assertThat(actualResult.getHotToStandardTimeInstant()) + .isEqualTo(java.time.Instant.ofEpochMilli(Timestamps.toMillis(hotToStandardTime))); assertThat(actualResult.getSizeBytes()).isEqualTo(sizeBytes); } @@ -767,12 +769,12 @@ public void testGetBackup() { // Verify assertThat(actualResult.getId()).isEqualTo(BACKUP_ID); assertThat(actualResult.getSourceTableId()).isEqualTo(TABLE_ID); - assertThat(actualResult.getExpireTime()) - .isEqualTo(Instant.ofEpochMilli(Timestamps.toMillis(expireTime))); - assertThat(actualResult.getStartTime()) - .isEqualTo(Instant.ofEpochMilli(Timestamps.toMillis(startTime))); - assertThat(actualResult.getEndTime()) - .isEqualTo(Instant.ofEpochMilli(Timestamps.toMillis(endTime))); + assertThat(actualResult.getExpireTimeInstant()) + .isEqualTo(java.time.Instant.ofEpochMilli(Timestamps.toMillis(expireTime))); + assertThat(actualResult.getStartTimeInstant()) + .isEqualTo(java.time.Instant.ofEpochMilli(Timestamps.toMillis(startTime))); + assertThat(actualResult.getEndTimeInstant()) + .isEqualTo(java.time.Instant.ofEpochMilli(Timestamps.toMillis(endTime))); assertThat(actualResult.getSizeBytes()).isEqualTo(sizeBytes); assertThat(actualResult.getState()).isEqualTo(Backup.State.fromProto(state)); assertThat(actualResult.getBackupType()).isEqualTo(Backup.BackupType.STANDARD); @@ -805,10 +807,10 @@ public void testUpdateBackup() { // Verify assertThat(actualResult.getId()).isEqualTo(BACKUP_ID); assertThat(actualResult.getSourceTableId()).isEqualTo(TABLE_ID); - assertThat(actualResult.getExpireTime()) - .isEqualTo(Instant.ofEpochMilli(Timestamps.toMillis(expireTime))); - assertThat(actualResult.getHotToStandardTime()) - .isEqualTo(Instant.ofEpochMilli(Timestamps.toMillis(hotToStandardTime))); + assertThat(actualResult.getExpireTimeInstant()) + .isEqualTo(java.time.Instant.ofEpochMilli(Timestamps.toMillis(expireTime))); + assertThat(actualResult.getHotToStandardTimeInstant()) + .isEqualTo(java.time.Instant.ofEpochMilli(Timestamps.toMillis(hotToStandardTime))); assertThat(actualResult.getSizeBytes()).isEqualTo(sizeBytes); } @@ -978,7 +980,7 @@ public void testCopyBackup() { String srcTableId = "src-table"; String srcClusterId = "src-cluster"; String srcBackupId = "src-backup"; - Instant expireTime = Instant.now().plus(org.threeten.bp.Duration.ofDays(15)); + java.time.Instant expireTime = java.time.Instant.now().plus(java.time.Duration.ofDays(15)); long sizeBytes = 123456789; String dstBackupName = @@ -991,7 +993,7 @@ public void testCopyBackup() { CopyBackupRequest.of(srcClusterId, srcBackupId) .setSourceInstance(srcProjectId, srcInstanceId) .setDestination(CLUSTER_ID, BACKUP_ID) - .setExpireTime(expireTime); + .setExpireTimeInstant(expireTime); mockOperationResult( mockCopyBackupOperationCallable, req.toProto(PROJECT_ID, INSTANCE_ID), @@ -1022,11 +1024,11 @@ public void testCopyBackup() { assertThat(actualResult.getId()).isEqualTo(BACKUP_ID); assertThat(actualResult.getSourceTableId()).isEqualTo(srcTableId); assertThat(actualResult.getSourceBackupId()).isEqualTo(srcBackupId); - assertThat(actualResult.getStartTime()) - .isEqualTo(Instant.ofEpochMilli(Timestamps.toMillis(startTime))); - assertThat(actualResult.getEndTime()) - .isEqualTo(Instant.ofEpochMilli(Timestamps.toMillis(endTime))); - assertThat(actualResult.getExpireTime()).isEqualTo(expireTime); + assertThat(actualResult.getStartTimeInstant()) + .isEqualTo(java.time.Instant.ofEpochMilli(Timestamps.toMillis(startTime))); + assertThat(actualResult.getEndTimeInstant()) + .isEqualTo(java.time.Instant.ofEpochMilli(Timestamps.toMillis(endTime))); + assertThat(actualResult.getExpireTimeInstant()).isEqualTo(expireTime); assertThat(actualResult.getSizeBytes()).isEqualTo(sizeBytes); } diff --git a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/BigtableTableAdminSettingsTest.java b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/BigtableTableAdminSettingsTest.java index 506f73700b..451454c735 100644 --- a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/BigtableTableAdminSettingsTest.java +++ b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/BigtableTableAdminSettingsTest.java @@ -31,7 +31,6 @@ import org.junit.runner.RunWith; import org.junit.runners.JUnit4; import org.mockito.Mockito; -import org.threeten.bp.Duration; @RunWith(JUnit4.class) public class BigtableTableAdminSettingsTest { @@ -165,7 +164,9 @@ public void testToString() throws IOException { stubSettings .getBackupSettings() .setRetrySettings( - RetrySettings.newBuilder().setTotalTimeout(Duration.ofMinutes(812)).build()); + RetrySettings.newBuilder() + .setTotalTimeoutDuration(java.time.Duration.ofMinutes(812)) + .build()); BigtableTableAdminSettings settings = builder.build(); checkToString(settings); diff --git a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/it/BigtableBackupIT.java b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/it/BigtableBackupIT.java index 465bf2d467..9a328185ac 100644 --- a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/it/BigtableBackupIT.java +++ b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/it/BigtableBackupIT.java @@ -45,6 +45,8 @@ import com.google.common.base.Stopwatch; import com.google.protobuf.ByteString; import java.io.IOException; +import java.time.Duration; +import java.time.Instant; import java.util.List; import java.util.Random; import java.util.concurrent.ExecutionException; @@ -59,8 +61,6 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; -import org.threeten.bp.Duration; -import org.threeten.bp.Instant; @RunWith(JUnit4.class) public class BigtableBackupIT { @@ -149,7 +149,7 @@ public void createAndGetBackupTest() { CreateBackupRequest request = CreateBackupRequest.of(targetCluster, backupId) .setSourceTableId(testTable.getId()) - .setExpireTime(expireTime); + .setExpireTimeInstant(expireTime); try { Backup response = tableAdmin.createBackup(request); assertWithMessage("Got wrong backup Id in CreateBackup") @@ -196,9 +196,9 @@ public void createAndGetHotBackupTest() { CreateBackupRequest request = CreateBackupRequest.of(targetClusterHot, backupId) .setSourceTableId(testTableHot.getId()) - .setExpireTime(expireTime) + .setExpireTimeInstant(expireTime) .setBackupType(Backup.BackupType.HOT) - .setHotToStandardTime(hotToStandardTime); + .setHotToStandardTimeInstant(hotToStandardTime); try { Backup response = tableAdminHot.createBackup(request); assertWithMessage("Got wrong backup Id in CreateBackup") @@ -274,14 +274,14 @@ public void updateBackupTest() { tableAdminHot.createBackup( CreateBackupRequest.of(targetClusterHot, backupId) .setSourceTableId(testTableHot.getId()) - .setExpireTime(Instant.now().plus(Duration.ofDays(15))) + .setExpireTimeInstant(Instant.now().plus(Duration.ofDays(15))) .setBackupType(Backup.BackupType.HOT) - .setHotToStandardTime(Instant.now().plus(Duration.ofDays(10)))); + .setHotToStandardTimeInstant(Instant.now().plus(Duration.ofDays(10)))); Instant expireTime = Instant.now().plus(Duration.ofDays(20)); UpdateBackupRequest req = UpdateBackupRequest.of(targetClusterHot, backupId) - .setExpireTime(expireTime) + .setExpireTimeInstant(expireTime) .clearHotToStandardTime(); try { Backup backup = tableAdminHot.updateBackup(req); @@ -347,7 +347,7 @@ public void crossInstanceRestoreTest() tableAdmin.createBackup( CreateBackupRequest.of(targetCluster, backupId) .setSourceTableId(testTable.getId()) - .setExpireTime(Instant.now().plus(Duration.ofHours(6)))); + .setExpireTimeInstant(Instant.now().plus(Duration.ofHours(6)))); Stopwatch stopwatch = Stopwatch.createStarted(); @@ -407,13 +407,13 @@ public void copyBackupTest() tableAdmin.createBackup( CreateBackupRequest.of(targetCluster, backupId) .setSourceTableId(testTable.getId()) - .setExpireTime(expireTime)); + .setExpireTimeInstant(expireTime)); try { CopyBackupRequest req = CopyBackupRequest.of(targetCluster, backupId) .setDestination(targetCluster, copiedBackupId) - .setExpireTime(expireTime); + .setExpireTimeInstant(expireTime); Backup result = tableAdmin.copyBackup(req); assertWithMessage("Got wrong copied backup id in CopyBackup API") .that(result.getId()) @@ -448,7 +448,7 @@ public void crossInstanceCopyBackupTest() tableAdmin.createBackup( CreateBackupRequest.of(targetCluster, backupId) .setSourceTableId(testTable.getId()) - .setExpireTime(expireTime)); + .setExpireTimeInstant(expireTime)); // Set up a new instance to test cross-instance copy. The backup will be copied here String destInstance = prefixGenerator.newPrefix(); @@ -468,7 +468,7 @@ public void crossInstanceCopyBackupTest() CopyBackupRequest.of(targetCluster, backupId) .setSourceInstance(testEnvRule.env().getInstanceId()) .setDestination(destCluster, copiedBackupId) - .setExpireTime(expireTime); + .setExpireTimeInstant(expireTime); Backup result = destTableAdmin.copyBackup(req); assertWithMessage("Got wrong copied backup id in CopyBackup API") .that(result.getId()) @@ -529,7 +529,7 @@ public void backupIamTest() { private CreateBackupRequest createBackupRequest(String backupId) { return CreateBackupRequest.of(targetCluster, backupId) .setSourceTableId(testTable.getId()) - .setExpireTime(Instant.now().plus(Duration.ofDays(15))); + .setExpireTimeInstant(Instant.now().plus(Duration.ofDays(15))); } private static Table createAndPopulateTestTable( diff --git a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/it/BigtableCmekIT.java b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/it/BigtableCmekIT.java index 11f4a99b1c..7f4c179280 100644 --- a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/it/BigtableCmekIT.java +++ b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/it/BigtableCmekIT.java @@ -39,6 +39,8 @@ import com.google.common.collect.ImmutableSet; import com.google.common.collect.Sets; import java.io.IOException; +import java.time.Instant; +import java.time.temporal.ChronoUnit; import java.util.List; import java.util.Map; import java.util.logging.Logger; @@ -50,8 +52,6 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; -import org.threeten.bp.Instant; -import org.threeten.bp.temporal.ChronoUnit; /** * Tests our CMEK offering. It can take up to 5 mins after a CMEK-protected table is created for the @@ -210,7 +210,7 @@ public void backupTest() { // taken tableAdmin.createBackup( CreateBackupRequest.of(clusterId1, BACKUP_ID) - .setExpireTime(Instant.now().plus(6, ChronoUnit.HOURS)) + .setExpireTimeInstant(Instant.now().plus(6, ChronoUnit.HOURS)) .setSourceTableId(TEST_TABLE_ID)); Backup backup = tableAdmin.getBackup(clusterId1, BACKUP_ID); diff --git a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/it/BigtableTableAdminClientIT.java b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/it/BigtableTableAdminClientIT.java index cfcc8d0b42..82965e5ba9 100644 --- a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/it/BigtableTableAdminClientIT.java +++ b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/it/BigtableTableAdminClientIT.java @@ -42,6 +42,7 @@ import com.google.cloud.bigtable.test_helpers.env.TestEnvRule; import com.google.common.collect.Maps; import com.google.protobuf.ByteString; +import java.time.Duration; import java.util.List; import java.util.Map; import org.junit.After; @@ -52,7 +53,6 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; -import org.threeten.bp.Duration; @RunWith(JUnit4.class) public class BigtableTableAdminClientIT { @@ -90,7 +90,7 @@ public void createTable() { .addFamily("cf2", GCRULES.maxVersions(10)) .addSplit(ByteString.copyFromUtf8("b")) .addSplit(ByteString.copyFromUtf8("q")) - .addChangeStreamRetention(Duration.ofDays(2)); + .addChangeStreamRetentionDuration(Duration.ofDays(2)); Table tableResponse = tableAdmin.createTable(createTableReq); assertEquals(tableId, tableResponse.getId()); @@ -121,13 +121,13 @@ public void updateTable() { CreateTableRequest createTableReq = CreateTableRequest.of(tableId) .addFamily("cf1") - .addChangeStreamRetention(Duration.ofDays(2)); + .addChangeStreamRetentionDuration(Duration.ofDays(2)); Table tableResponse = tableAdmin.createTable(createTableReq); assertEquals(tableId, tableResponse.getId()); assertEquals(Duration.ofDays(2), tableResponse.getChangeStreamRetention()); UpdateTableRequest updateTableRequest = - UpdateTableRequest.of(tableId).addChangeStreamRetention(Duration.ofDays(4)); + UpdateTableRequest.of(tableId).addChangeStreamRetentionDuration(Duration.ofDays(4)); tableResponse = tableAdmin.updateTable(updateTableRequest); assertEquals(tableId, tableResponse.getId()); assertEquals(Duration.ofDays(4), tableResponse.getChangeStreamRetention()); @@ -145,20 +145,21 @@ public void modifyFamilies() { ModifyColumnFamiliesRequest modifyFamiliesReq = ModifyColumnFamiliesRequest.of(tableId) .addFamily("mf1") - .addFamily("mf2", GCRULES.maxAge(Duration.ofSeconds(1000, 20000))) + .addFamily("mf2", GCRULES.maxAgeDuration(Duration.ofSeconds(1000, 20000))) .updateFamily( "mf1", GCRULES .union() - .rule(GCRULES.maxAge(Duration.ofSeconds(100))) + .rule(GCRULES.maxAgeDuration(Duration.ofSeconds(100))) .rule(GCRULES.maxVersions(1))) .addFamily( "mf3", GCRULES .intersection() - .rule(GCRULES.maxAge(Duration.ofSeconds(2000))) + .rule(GCRULES.maxAgeDuration(Duration.ofSeconds(2000))) .rule(GCRULES.maxVersions(10))) - .addFamily("mf4", GCRULES.intersection().rule(GCRULES.maxAge(Duration.ofSeconds(360)))) + .addFamily( + "mf4", GCRULES.intersection().rule(GCRULES.maxAgeDuration(Duration.ofSeconds(360)))) .addFamily("mf5") .addFamily("mf6") .dropFamily("mf5") diff --git a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/models/BackupTest.java b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/models/BackupTest.java index 2fc9ad2390..ab87d3bff8 100644 --- a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/models/BackupTest.java +++ b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/models/BackupTest.java @@ -23,11 +23,11 @@ import com.google.protobuf.Timestamp; import com.google.protobuf.util.Timestamps; import com.google.rpc.Code; +import java.time.Instant; import java.util.List; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; -import org.threeten.bp.Instant; @RunWith(JUnit4.class) public class BackupTest { @@ -91,12 +91,13 @@ public void testFromProto() { assertThat(result.getId()).isEqualTo("backup1"); assertThat(result.getSourceTableId()).isEqualTo("table1"); assertThat(result.getSourceBackupId()).isEqualTo("backup2"); - assertThat(result.getExpireTime()) + assertThat(result.getExpireTimeInstant()) .isEqualTo(Instant.ofEpochMilli(Timestamps.toMillis(expireTime))); - assertThat(result.getStartTime()) + assertThat(result.getStartTimeInstant()) .isEqualTo(Instant.ofEpochMilli(Timestamps.toMillis(startTime))); - assertThat(result.getEndTime()).isEqualTo(Instant.ofEpochMilli(Timestamps.toMillis(endTime))); - assertThat(result.getHotToStandardTime()) + assertThat(result.getEndTimeInstant()) + .isEqualTo(Instant.ofEpochMilli(Timestamps.toMillis(endTime))); + assertThat(result.getHotToStandardTimeInstant()) .isEqualTo(Instant.ofEpochMilli(Timestamps.toMillis(hotToStandardTime))); assertThat(result.getSizeBytes()).isEqualTo(123456); assertThat(result.getState()).isEqualTo(Backup.State.READY); diff --git a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/models/CopyBackupRequestTest.java b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/models/CopyBackupRequestTest.java index df8830da8e..27300b1a24 100644 --- a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/models/CopyBackupRequestTest.java +++ b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/models/CopyBackupRequestTest.java @@ -19,11 +19,11 @@ import com.google.cloud.bigtable.admin.v2.internal.NameUtil; import com.google.protobuf.util.Timestamps; +import java.time.Duration; +import java.time.Instant; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; -import org.threeten.bp.Duration; -import org.threeten.bp.Instant; @RunWith(JUnit4.class) public class CopyBackupRequestTest { @@ -43,7 +43,7 @@ public void testToProto() { CopyBackupRequest request = CopyBackupRequest.of(SOURCE_CLUSTER_ID, SOURCE_BACKUP_ID) .setDestination(CLUSTER_ID, BACKUP_ID) - .setExpireTime(EXPIRE_TIME); + .setExpireTimeInstant(EXPIRE_TIME); com.google.bigtable.admin.v2.CopyBackupRequest requestProto = com.google.bigtable.admin.v2.CopyBackupRequest.newBuilder() @@ -63,7 +63,7 @@ public void testToProtoCrossInstance() { CopyBackupRequest.of(SOURCE_CLUSTER_ID, SOURCE_BACKUP_ID) .setSourceInstance(SOURCE_INSTANCE_ID) .setDestination(CLUSTER_ID, BACKUP_ID) - .setExpireTime(EXPIRE_TIME); + .setExpireTimeInstant(EXPIRE_TIME); com.google.bigtable.admin.v2.CopyBackupRequest requestProto = com.google.bigtable.admin.v2.CopyBackupRequest.newBuilder() @@ -83,7 +83,7 @@ public void testToProtoCrossProject() { CopyBackupRequest.of(SOURCE_CLUSTER_ID, SOURCE_BACKUP_ID) .setSourceInstance(SOURCE_PROJECT_ID, SOURCE_INSTANCE_ID) .setDestination(CLUSTER_ID, BACKUP_ID) - .setExpireTime(EXPIRE_TIME); + .setExpireTimeInstant(EXPIRE_TIME); com.google.bigtable.admin.v2.CopyBackupRequest requestProto = com.google.bigtable.admin.v2.CopyBackupRequest.newBuilder() @@ -102,18 +102,18 @@ public void testEquality() { CopyBackupRequest request = CopyBackupRequest.of(SOURCE_CLUSTER_ID, SOURCE_BACKUP_ID) .setDestination(CLUSTER_ID, BACKUP_ID) - .setExpireTime(EXPIRE_TIME); + .setExpireTimeInstant(EXPIRE_TIME); assertThat(request) .isEqualTo( CopyBackupRequest.of(SOURCE_CLUSTER_ID, SOURCE_BACKUP_ID) .setDestination(CLUSTER_ID, BACKUP_ID) - .setExpireTime(EXPIRE_TIME)); + .setExpireTimeInstant(EXPIRE_TIME)); assertThat(request) .isNotEqualTo( CopyBackupRequest.of(SOURCE_CLUSTER_ID, SOURCE_BACKUP_ID) .setDestination(CLUSTER_ID, "another-backup") - .setExpireTime(EXPIRE_TIME)); + .setExpireTimeInstant(EXPIRE_TIME)); } @Test @@ -122,20 +122,20 @@ public void testEqualityCrossInstance() { CopyBackupRequest.of(SOURCE_CLUSTER_ID, SOURCE_BACKUP_ID) .setSourceInstance(SOURCE_INSTANCE_ID) .setDestination(CLUSTER_ID, BACKUP_ID) - .setExpireTime(EXPIRE_TIME); + .setExpireTimeInstant(EXPIRE_TIME); assertThat(request) .isEqualTo( CopyBackupRequest.of(SOURCE_CLUSTER_ID, SOURCE_BACKUP_ID) .setSourceInstance(SOURCE_INSTANCE_ID) .setDestination(CLUSTER_ID, BACKUP_ID) - .setExpireTime(EXPIRE_TIME)); + .setExpireTimeInstant(EXPIRE_TIME)); assertThat(request) .isNotEqualTo( CopyBackupRequest.of(SOURCE_CLUSTER_ID, SOURCE_BACKUP_ID) .setSourceInstance(SOURCE_INSTANCE_ID) .setDestination(CLUSTER_ID, "another-backup") - .setExpireTime(EXPIRE_TIME)); + .setExpireTimeInstant(EXPIRE_TIME)); } @Test @@ -144,20 +144,20 @@ public void testEqualityCrossProject() { CopyBackupRequest.of(SOURCE_CLUSTER_ID, SOURCE_BACKUP_ID) .setSourceInstance(SOURCE_PROJECT_ID, SOURCE_INSTANCE_ID) .setDestination(CLUSTER_ID, BACKUP_ID) - .setExpireTime(EXPIRE_TIME); + .setExpireTimeInstant(EXPIRE_TIME); assertThat(request) .isEqualTo( CopyBackupRequest.of(SOURCE_CLUSTER_ID, SOURCE_BACKUP_ID) .setSourceInstance(SOURCE_PROJECT_ID, SOURCE_INSTANCE_ID) .setDestination(CLUSTER_ID, BACKUP_ID) - .setExpireTime(EXPIRE_TIME)); + .setExpireTimeInstant(EXPIRE_TIME)); assertThat(request) .isNotEqualTo( CopyBackupRequest.of(SOURCE_CLUSTER_ID, SOURCE_BACKUP_ID) .setSourceInstance(SOURCE_PROJECT_ID, SOURCE_INSTANCE_ID) .setDestination(CLUSTER_ID, "another-backup") - .setExpireTime(EXPIRE_TIME)); + .setExpireTimeInstant(EXPIRE_TIME)); } @Test @@ -165,19 +165,19 @@ public void testHashCode() { CopyBackupRequest request = CopyBackupRequest.of(SOURCE_CLUSTER_ID, SOURCE_BACKUP_ID) .setDestination(CLUSTER_ID, BACKUP_ID) - .setExpireTime(EXPIRE_TIME); + .setExpireTimeInstant(EXPIRE_TIME); assertThat(request.hashCode()) .isEqualTo( CopyBackupRequest.of(SOURCE_CLUSTER_ID, SOURCE_BACKUP_ID) .setDestination(CLUSTER_ID, BACKUP_ID) - .setExpireTime(EXPIRE_TIME) + .setExpireTimeInstant(EXPIRE_TIME) .hashCode()); assertThat(request.hashCode()) .isNotEqualTo( CopyBackupRequest.of(SOURCE_CLUSTER_ID, SOURCE_BACKUP_ID) .setDestination(CLUSTER_ID, "another-backup") - .setExpireTime(EXPIRE_TIME) + .setExpireTimeInstant(EXPIRE_TIME) .hashCode()); } @@ -187,21 +187,21 @@ public void testHashCodeCrossInstance() { CopyBackupRequest.of(SOURCE_CLUSTER_ID, SOURCE_BACKUP_ID) .setSourceInstance(SOURCE_INSTANCE_ID) .setDestination(CLUSTER_ID, BACKUP_ID) - .setExpireTime(EXPIRE_TIME); + .setExpireTimeInstant(EXPIRE_TIME); assertThat(request.hashCode()) .isEqualTo( CopyBackupRequest.of(SOURCE_CLUSTER_ID, SOURCE_BACKUP_ID) .setSourceInstance(SOURCE_INSTANCE_ID) .setDestination(CLUSTER_ID, BACKUP_ID) - .setExpireTime(EXPIRE_TIME) + .setExpireTimeInstant(EXPIRE_TIME) .hashCode()); assertThat(request.hashCode()) .isNotEqualTo( CopyBackupRequest.of(SOURCE_CLUSTER_ID, SOURCE_BACKUP_ID) .setSourceInstance(SOURCE_INSTANCE_ID) .setDestination(CLUSTER_ID, "another-backup") - .setExpireTime(EXPIRE_TIME) + .setExpireTimeInstant(EXPIRE_TIME) .hashCode()); } @@ -211,21 +211,21 @@ public void testHashCodeCrossProject() { CopyBackupRequest.of(SOURCE_CLUSTER_ID, SOURCE_BACKUP_ID) .setSourceInstance(SOURCE_PROJECT_ID, SOURCE_INSTANCE_ID) .setDestination(CLUSTER_ID, BACKUP_ID) - .setExpireTime(EXPIRE_TIME); + .setExpireTimeInstant(EXPIRE_TIME); assertThat(request.hashCode()) .isEqualTo( CopyBackupRequest.of(SOURCE_CLUSTER_ID, SOURCE_BACKUP_ID) .setSourceInstance(SOURCE_PROJECT_ID, SOURCE_INSTANCE_ID) .setDestination(CLUSTER_ID, BACKUP_ID) - .setExpireTime(EXPIRE_TIME) + .setExpireTimeInstant(EXPIRE_TIME) .hashCode()); assertThat(request.hashCode()) .isNotEqualTo( CopyBackupRequest.of(SOURCE_CLUSTER_ID, SOURCE_BACKUP_ID) .setSourceInstance(SOURCE_PROJECT_ID, SOURCE_INSTANCE_ID) .setDestination(CLUSTER_ID, "another-backup") - .setExpireTime(EXPIRE_TIME) + .setExpireTimeInstant(EXPIRE_TIME) .hashCode()); } } diff --git a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/models/CreateBackupRequestTest.java b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/models/CreateBackupRequestTest.java index 821919264e..8f8b0747cf 100644 --- a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/models/CreateBackupRequestTest.java +++ b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/models/CreateBackupRequestTest.java @@ -21,11 +21,11 @@ import com.google.cloud.bigtable.admin.v2.internal.NameUtil; import com.google.cloud.bigtable.admin.v2.models.Backup.BackupType; import com.google.protobuf.util.Timestamps; +import java.time.Duration; +import java.time.Instant; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; -import org.threeten.bp.Duration; -import org.threeten.bp.Instant; @RunWith(JUnit4.class) public class CreateBackupRequestTest { @@ -43,9 +43,9 @@ public void testToProto() { CreateBackupRequest request = CreateBackupRequest.of(CLUSTER_ID, BACKUP_ID) .setSourceTableId(TABLE_ID) - .setExpireTime(EXPIRE_TIME) + .setExpireTimeInstant(EXPIRE_TIME) .setBackupType(BackupType.HOT) - .setHotToStandardTime(HOT_TO_STANDARD_TIME); + .setHotToStandardTimeInstant(HOT_TO_STANDARD_TIME); com.google.bigtable.admin.v2.CreateBackupRequest requestProto = com.google.bigtable.admin.v2.CreateBackupRequest.newBuilder() @@ -68,33 +68,33 @@ public void testEquality() { CreateBackupRequest request = CreateBackupRequest.of(CLUSTER_ID, BACKUP_ID) .setSourceTableId(TABLE_ID) - .setExpireTime(EXPIRE_TIME) + .setExpireTimeInstant(EXPIRE_TIME) .setBackupType(BackupType.HOT) - .setHotToStandardTime(HOT_TO_STANDARD_TIME); + .setHotToStandardTimeInstant(HOT_TO_STANDARD_TIME); assertThat(request) .isEqualTo( CreateBackupRequest.of(CLUSTER_ID, BACKUP_ID) .setSourceTableId(TABLE_ID) - .setExpireTime(EXPIRE_TIME) + .setExpireTimeInstant(EXPIRE_TIME) .setBackupType(BackupType.HOT) - .setHotToStandardTime(HOT_TO_STANDARD_TIME)); + .setHotToStandardTimeInstant(HOT_TO_STANDARD_TIME)); assertThat(request) .isNotEqualTo( CreateBackupRequest.of(CLUSTER_ID, BACKUP_ID) .setSourceTableId("another-table") - .setExpireTime(EXPIRE_TIME) + .setExpireTimeInstant(EXPIRE_TIME) .setBackupType(BackupType.HOT) - .setHotToStandardTime(HOT_TO_STANDARD_TIME)); + .setHotToStandardTimeInstant(HOT_TO_STANDARD_TIME)); assertThat(request) .isNotEqualTo( CreateBackupRequest.of(CLUSTER_ID, BACKUP_ID) .setSourceTableId(TABLE_ID) - .setExpireTime(EXPIRE_TIME) + .setExpireTimeInstant(EXPIRE_TIME) .setBackupType(BackupType.STANDARD) - .setHotToStandardTime(HOT_TO_STANDARD_TIME)); + .setHotToStandardTimeInstant(HOT_TO_STANDARD_TIME)); } @Test @@ -102,35 +102,35 @@ public void testHashCode() { CreateBackupRequest request = CreateBackupRequest.of(CLUSTER_ID, BACKUP_ID) .setSourceTableId(TABLE_ID) - .setExpireTime(EXPIRE_TIME) + .setExpireTimeInstant(EXPIRE_TIME) .setBackupType(BackupType.HOT) - .setHotToStandardTime(HOT_TO_STANDARD_TIME); + .setHotToStandardTimeInstant(HOT_TO_STANDARD_TIME); assertThat(request.hashCode()) .isEqualTo( CreateBackupRequest.of(CLUSTER_ID, BACKUP_ID) .setSourceTableId(TABLE_ID) - .setExpireTime(EXPIRE_TIME) + .setExpireTimeInstant(EXPIRE_TIME) .setBackupType(BackupType.HOT) - .setHotToStandardTime(HOT_TO_STANDARD_TIME) + .setHotToStandardTimeInstant(HOT_TO_STANDARD_TIME) .hashCode()); assertThat(request.hashCode()) .isNotEqualTo( CreateBackupRequest.of(CLUSTER_ID, BACKUP_ID) .setSourceTableId("another-table") - .setExpireTime(EXPIRE_TIME) + .setExpireTimeInstant(EXPIRE_TIME) .setBackupType(BackupType.HOT) - .setHotToStandardTime(HOT_TO_STANDARD_TIME) + .setHotToStandardTimeInstant(HOT_TO_STANDARD_TIME) .hashCode()); assertThat(request.hashCode()) .isNotEqualTo( CreateBackupRequest.of(CLUSTER_ID, BACKUP_ID) .setSourceTableId(TABLE_ID) - .setExpireTime(EXPIRE_TIME) + .setExpireTimeInstant(EXPIRE_TIME) .setBackupType(BackupType.BACKUP_TYPE_UNSPECIFIED) - .setHotToStandardTime(HOT_TO_STANDARD_TIME) + .setHotToStandardTimeInstant(HOT_TO_STANDARD_TIME) .hashCode()); } } diff --git a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/models/CreateTableRequestTest.java b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/models/CreateTableRequestTest.java index 0f7a58c078..07ab421114 100644 --- a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/models/CreateTableRequestTest.java +++ b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/models/CreateTableRequestTest.java @@ -24,11 +24,11 @@ import com.google.bigtable.admin.v2.Table; import com.google.cloud.bigtable.admin.v2.internal.NameUtil; import com.google.protobuf.ByteString; +import java.time.Duration; import java.util.concurrent.TimeUnit; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; -import org.threeten.bp.Duration; @RunWith(JUnit4.class) public class CreateTableRequestTest { @@ -48,7 +48,7 @@ public void testToProto() { .addFamily("another-family", GCRULES.maxAge(100, TimeUnit.HOURS)) .addSplit(splitKey) .addSplit(secondSplitKey) - .addChangeStreamRetention(Duration.ofHours(24)); + .addChangeStreamRetentionDuration(Duration.ofHours(24)); com.google.bigtable.admin.v2.CreateTableRequest requestProto = com.google.bigtable.admin.v2.CreateTableRequest.newBuilder() @@ -140,7 +140,7 @@ public void testEquality() { .isEqualTo( CreateTableRequest.of(TABLE_ID) .addFamily("family-id") - .addFamily("another-family", GCRULES.maxAge(Duration.ofHours(100))) + .addFamily("another-family", GCRULES.maxAgeDuration(Duration.ofHours(100))) .addSplit(splitKey)); assertThat(request) diff --git a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/models/GCRulesTest.java b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/models/GCRulesTest.java index 61a1527a34..b9994fa24b 100644 --- a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/models/GCRulesTest.java +++ b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/models/GCRulesTest.java @@ -27,18 +27,18 @@ import com.google.cloud.bigtable.admin.v2.models.GCRules.IntersectionRule; import com.google.cloud.bigtable.admin.v2.models.GCRules.UnionRule; import com.google.cloud.bigtable.admin.v2.models.GCRules.VersionRule; +import java.time.Duration; import java.util.concurrent.TimeUnit; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; -import org.threeten.bp.Duration; @RunWith(JUnit4.class) public class GCRulesTest { @Test public void duration() { - DurationRule actual = GCRULES.maxAge(Duration.ofSeconds(61, 9)); + DurationRule actual = GCRULES.maxAgeDuration(Duration.ofSeconds(61, 9)); GcRule expected = buildAgeRule(61, 9); assertNotNull(actual.getMaxAge()); assertThat(actual.toProto()).isEqualTo(expected); @@ -46,14 +46,14 @@ public void duration() { @Test public void durationSeconds() { - GcRule actual = GCRULES.maxAge(Duration.ofSeconds(1)).toProto(); + GcRule actual = GCRULES.maxAgeDuration(Duration.ofSeconds(1)).toProto(); GcRule expected = buildAgeRule(1, 0); assertThat(actual).isEqualTo(expected); } @Test public void durationNanos() { - GcRule actual = GCRULES.maxAge(Duration.ofNanos(11)).toProto(); + GcRule actual = GCRULES.maxAgeDuration(Duration.ofNanos(11)).toProto(); GcRule expected = buildAgeRule(0, 11); assertThat(actual).isEqualTo(expected); } @@ -114,7 +114,7 @@ public void unionTwo() { GCRULES .union() .rule(GCRULES.maxVersions(1)) - .rule(GCRULES.maxAge(Duration.ofSeconds(1))) + .rule(GCRULES.maxAgeDuration(Duration.ofSeconds(1))) .toProto(); GcRule expected = @@ -132,8 +132,8 @@ public void unionThree() { GCRULES .union() .rule(GCRULES.maxVersions(1)) - .rule(GCRULES.maxAge(Duration.ofSeconds(1))) - .rule(GCRULES.maxAge(Duration.ofNanos(1))) + .rule(GCRULES.maxAgeDuration(Duration.ofSeconds(1))) + .rule(GCRULES.maxAgeDuration(Duration.ofNanos(1))) .toProto(); GcRule expected = @@ -168,7 +168,7 @@ public void intersectionTwo() { GCRULES .intersection() .rule(GCRULES.maxVersions(1)) - .rule(GCRULES.maxAge(Duration.ofSeconds(1))) + .rule(GCRULES.maxAgeDuration(Duration.ofSeconds(1))) .toProto(); GcRule expected = @@ -188,8 +188,8 @@ public void intersectionThree() { GCRULES .intersection() .rule(GCRULES.maxVersions(1)) - .rule(GCRULES.maxAge(Duration.ofSeconds(1))) - .rule(GCRULES.maxAge(Duration.ofNanos(1))) + .rule(GCRULES.maxAgeDuration(Duration.ofSeconds(1))) + .rule(GCRULES.maxAgeDuration(Duration.ofNanos(1))) .toProto(); GcRule expected = @@ -213,12 +213,12 @@ public void unionOfIntersections() { GCRULES .intersection() .rule(GCRULES.maxVersions(1)) - .rule(GCRULES.maxAge(Duration.ofSeconds(1)))) + .rule(GCRULES.maxAgeDuration(Duration.ofSeconds(1)))) .rule( GCRULES .intersection() .rule(GCRULES.maxVersions(1)) - .rule(GCRULES.maxAge(Duration.ofSeconds(1)))); + .rule(GCRULES.maxAgeDuration(Duration.ofSeconds(1)))); GcRule expected = GcRule.newBuilder() @@ -251,12 +251,12 @@ public void intersectionOfUnions() { GCRULES .union() .rule(GCRULES.maxVersions(1)) - .rule(GCRULES.maxAge(Duration.ofSeconds(1)))) + .rule(GCRULES.maxAgeDuration(Duration.ofSeconds(1)))) .rule( GCRULES .union() .rule(GCRULES.maxVersions(1)) - .rule(GCRULES.maxAge(Duration.ofSeconds(1)))); + .rule(GCRULES.maxAgeDuration(Duration.ofSeconds(1)))); GcRule expected = GcRule.newBuilder() @@ -294,9 +294,9 @@ public void unionOfRules() { GCRules.GCRule modelGCRule = GCRULES .union() - .rule(GCRULES.maxAge(Duration.ofSeconds(10))) + .rule(GCRULES.maxAgeDuration(Duration.ofSeconds(10))) .rule(GCRULES.maxVersions(1)) - .rule(GCRULES.maxAge(Duration.ofSeconds(20, 2))); + .rule(GCRULES.maxAgeDuration(Duration.ofSeconds(20, 2))); assertThat(GCRULES.fromProto(protoGCRule)).isEqualTo(modelGCRule); } @@ -314,7 +314,7 @@ public void intersectionWithFromProto() { GCRules.GCRule modelGCRule = GCRules.GCRULES .intersection() - .rule(GCRULES.maxAge(org.threeten.bp.Duration.ofSeconds(10, 5))) + .rule(GCRULES.maxAgeDuration(java.time.Duration.ofSeconds(10, 5))) .rule(GCRULES.maxVersions(1)) .rule(GCRULES.maxVersions(2)); assertThat(GCRULES.fromProto(protoGCRule)).isEqualTo(modelGCRule); @@ -351,12 +351,12 @@ public void unionOfIntersectionFromProto() { GCRULES .intersection() .rule(GCRULES.maxVersions(10)) - .rule(GCRULES.maxAge(Duration.ofSeconds(2, 4)))) + .rule(GCRULES.maxAgeDuration(Duration.ofSeconds(2, 4)))) .rule( GCRULES .intersection() .rule(GCRULES.maxVersions(1)) - .rule(GCRULES.maxAge(Duration.ofSeconds(1, 1)))); + .rule(GCRULES.maxAgeDuration(Duration.ofSeconds(1, 1)))); assertThat(GCRules.GCRULES.fromProto(protoGCRule)).isEqualTo(modelGCRule); } diff --git a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/models/UpdateBackupRequestTest.java b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/models/UpdateBackupRequestTest.java index 9551fd70c4..54f3b53142 100644 --- a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/models/UpdateBackupRequestTest.java +++ b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/models/UpdateBackupRequestTest.java @@ -21,11 +21,11 @@ import com.google.cloud.bigtable.admin.v2.internal.NameUtil; import com.google.protobuf.FieldMask; import com.google.protobuf.util.Timestamps; +import java.time.Duration; +import java.time.Instant; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; -import org.threeten.bp.Duration; -import org.threeten.bp.Instant; @RunWith(JUnit4.class) public class UpdateBackupRequestTest { @@ -43,8 +43,8 @@ public class UpdateBackupRequestTest { public void testToProto() { UpdateBackupRequest request = UpdateBackupRequest.of(CLUSTER_ID, BACKUP_ID) - .setExpireTime(EXPIRE_TIME) - .setHotToStandardTime(HOT_TO_STANDARD_TIME); + .setExpireTimeInstant(EXPIRE_TIME) + .setHotToStandardTimeInstant(HOT_TO_STANDARD_TIME); com.google.bigtable.admin.v2.UpdateBackupRequest requestProto = com.google.bigtable.admin.v2.UpdateBackupRequest.newBuilder() @@ -69,22 +69,22 @@ public void testToProto() { public void testEquality() { UpdateBackupRequest request = UpdateBackupRequest.of(CLUSTER_ID, BACKUP_ID) - .setExpireTime(EXPIRE_TIME) - .setHotToStandardTime(HOT_TO_STANDARD_TIME); + .setExpireTimeInstant(EXPIRE_TIME) + .setHotToStandardTimeInstant(HOT_TO_STANDARD_TIME); assertThat(request) .isEqualTo( UpdateBackupRequest.of(CLUSTER_ID, BACKUP_ID) - .setExpireTime(EXPIRE_TIME) - .setHotToStandardTime(HOT_TO_STANDARD_TIME)); + .setExpireTimeInstant(EXPIRE_TIME) + .setHotToStandardTimeInstant(HOT_TO_STANDARD_TIME)); assertThat(request) .isNotEqualTo( UpdateBackupRequest.of(CLUSTER_ID, BACKUP_ID) - .setExpireTime(EXPIRE_TIME_2) - .setHotToStandardTime(HOT_TO_STANDARD_TIME)); + .setExpireTimeInstant(EXPIRE_TIME_2) + .setHotToStandardTimeInstant(HOT_TO_STANDARD_TIME)); assertThat(request) .isNotEqualTo( UpdateBackupRequest.of(CLUSTER_ID, BACKUP_ID) - .setExpireTime(EXPIRE_TIME) + .setExpireTimeInstant(EXPIRE_TIME) .clearHotToStandardTime()); } @@ -92,24 +92,24 @@ public void testEquality() { public void testHashCode() { UpdateBackupRequest request = UpdateBackupRequest.of(CLUSTER_ID, BACKUP_ID) - .setExpireTime(EXPIRE_TIME) - .setHotToStandardTime(HOT_TO_STANDARD_TIME); + .setExpireTimeInstant(EXPIRE_TIME) + .setHotToStandardTimeInstant(HOT_TO_STANDARD_TIME); assertThat(request.hashCode()) .isEqualTo( UpdateBackupRequest.of(CLUSTER_ID, BACKUP_ID) - .setExpireTime(EXPIRE_TIME) - .setHotToStandardTime(HOT_TO_STANDARD_TIME) + .setExpireTimeInstant(EXPIRE_TIME) + .setHotToStandardTimeInstant(HOT_TO_STANDARD_TIME) .hashCode()); assertThat(request.hashCode()) .isNotEqualTo( UpdateBackupRequest.of(CLUSTER_ID, BACKUP_ID) - .setExpireTime(EXPIRE_TIME_2) - .setHotToStandardTime(HOT_TO_STANDARD_TIME) + .setExpireTimeInstant(EXPIRE_TIME_2) + .setHotToStandardTimeInstant(HOT_TO_STANDARD_TIME) .hashCode()); assertThat(request.hashCode()) .isNotEqualTo( UpdateBackupRequest.of(CLUSTER_ID, BACKUP_ID) - .setExpireTime(EXPIRE_TIME) + .setExpireTimeInstant(EXPIRE_TIME) .clearHotToStandardTime() .hashCode()); } diff --git a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/models/UpdateTableRequestTest.java b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/models/UpdateTableRequestTest.java index fabebdccbf..b3515364e1 100644 --- a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/models/UpdateTableRequestTest.java +++ b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/models/UpdateTableRequestTest.java @@ -22,10 +22,10 @@ import com.google.bigtable.admin.v2.Table; import com.google.cloud.bigtable.admin.v2.internal.NameUtil; import com.google.protobuf.FieldMask; +import java.time.Duration; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; -import org.threeten.bp.Duration; @RunWith(JUnit4.class) public class UpdateTableRequestTest { @@ -36,7 +36,7 @@ public class UpdateTableRequestTest { @Test public void testEnableChangeStreamToProto() { UpdateTableRequest request = - UpdateTableRequest.of(TABLE_ID).addChangeStreamRetention(Duration.ofHours(24)); + UpdateTableRequest.of(TABLE_ID).addChangeStreamRetentionDuration(Duration.ofHours(24)); com.google.bigtable.admin.v2.UpdateTableRequest requestProto = com.google.bigtable.admin.v2.UpdateTableRequest.newBuilder() @@ -57,7 +57,7 @@ public void testEnableChangeStreamToProto() { @Test public void testDisableChangeStreamToProto() { UpdateTableRequest request = - UpdateTableRequest.of(TABLE_ID).addChangeStreamRetention(Duration.ofHours(0)); + UpdateTableRequest.of(TABLE_ID).addChangeStreamRetentionDuration(Duration.ofHours(0)); com.google.bigtable.admin.v2.UpdateTableRequest requestProto = com.google.bigtable.admin.v2.UpdateTableRequest.newBuilder() diff --git a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/stub/AwaitConsistencyCallableTest.java b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/stub/AwaitConsistencyCallableTest.java index 2628cdf224..db199950ce 100644 --- a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/stub/AwaitConsistencyCallableTest.java +++ b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/admin/v2/stub/AwaitConsistencyCallableTest.java @@ -35,6 +35,7 @@ import com.google.bigtable.admin.v2.TableName; import com.google.cloud.bigtable.admin.v2.models.ConsistencyRequest; import com.google.cloud.bigtable.data.v2.internal.TableAdminRequestContext; +import java.time.Duration; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import org.junit.Before; @@ -47,7 +48,6 @@ import org.mockito.junit.MockitoJUnit; import org.mockito.junit.MockitoRule; import org.mockito.quality.Strictness; -import org.threeten.bp.Duration; @RunWith(JUnit4.class) public class AwaitConsistencyCallableTest { @@ -80,14 +80,14 @@ public void setUp() { RetrySettings retrySettings = RetrySettings.newBuilder() - .setTotalTimeout(Duration.ofMillis(100)) + .setTotalTimeoutDuration(Duration.ofMillis(100)) // Delay settings: 1 ms const - .setInitialRetryDelay(Duration.ofMillis(1)) - .setMaxRetryDelay(Duration.ofMillis(1)) + .setInitialRetryDelayDuration(Duration.ofMillis(1)) + .setMaxRetryDelayDuration(Duration.ofMillis(1)) .setRetryDelayMultiplier(1.0) // RPC timeout: ignored const 1 s - .setInitialRpcTimeout(Duration.ofSeconds(1)) - .setMaxRpcTimeout(Duration.ofSeconds(1)) + .setInitialRpcTimeoutDuration(Duration.ofSeconds(1)) + .setMaxRpcTimeoutDuration(Duration.ofSeconds(1)) .setRpcTimeoutMultiplier(1.0) .build(); diff --git a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/internal/AbstractProtoStructReaderTest.java b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/internal/AbstractProtoStructReaderTest.java index 95955bab94..9a848e38d4 100644 --- a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/internal/AbstractProtoStructReaderTest.java +++ b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/internal/AbstractProtoStructReaderTest.java @@ -57,6 +57,7 @@ import com.google.cloud.bigtable.data.v2.models.sql.Struct; import com.google.cloud.bigtable.data.v2.stub.sql.SqlProtoFactory; import com.google.protobuf.ByteString; +import java.time.Instant; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -71,7 +72,6 @@ import org.junit.runners.JUnit4; import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameter; -import org.threeten.bp.Instant; @RunWith(Enclosed.class) public class AbstractProtoStructReaderTest { @@ -311,8 +311,8 @@ public static List parameters() { Collections.singletonList(timestampValue(1000000, 100)), 0, "testField", - (BiFunction) TestProtoStruct::getTimestamp, - (BiFunction) TestProtoStruct::getTimestamp, + (BiFunction) TestProtoStruct::getTimestampInstant, + (BiFunction) TestProtoStruct::getTimestampInstant, Instant.ofEpochSecond(1000000, 100) }, // MAX long timestamp - bigtable allows users to set timestamp micros to any long @@ -323,8 +323,8 @@ public static List parameters() { Collections.singletonList(timestampValue(MAX_TS_SECONDS, 0)), 0, "testField", - (BiFunction) TestProtoStruct::getTimestamp, - (BiFunction) TestProtoStruct::getTimestamp, + (BiFunction) TestProtoStruct::getTimestampInstant, + (BiFunction) TestProtoStruct::getTimestampInstant, Instant.ofEpochSecond(MAX_TS_SECONDS) }, // Date diff --git a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/internal/ProtoStructTest.java b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/internal/ProtoStructTest.java index 6fa71e7fff..a4b364cf9d 100644 --- a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/internal/ProtoStructTest.java +++ b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/internal/ProtoStructTest.java @@ -47,13 +47,13 @@ import com.google.cloud.Date; import com.google.cloud.bigtable.data.v2.models.sql.SqlType; import com.google.protobuf.ByteString; +import java.time.Instant; import java.util.Arrays; import java.util.HashMap; import java.util.List; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; -import org.threeten.bp.Instant; @RunWith(JUnit4.class) public class ProtoStructTest { @@ -101,7 +101,7 @@ public void getByIndex_supportsAllTypes() { assertThat(struct.getDouble(3)).isEqualTo(1.23d); assertThat(struct.getFloat(4)).isEqualTo(1.23f); assertThat(struct.getBoolean(5)).isTrue(); - assertThat(struct.getTimestamp(6)).isEqualTo(Instant.ofEpochSecond(100000, 100)); + assertThat(struct.getTimestampInstant(6)).isEqualTo(Instant.ofEpochSecond(100000, 100)); assertThat(struct.getDate(7)).isEqualTo(Date.fromYearMonthDay(2024, 6, 1)); assertThat(struct.getStruct(8)) .isEqualTo( @@ -129,7 +129,8 @@ public void getByNameSupportsAllTypes() { assertThat(struct.getDouble("doubleField")).isEqualTo(1.23d); assertThat(struct.getFloat("floatField")).isEqualTo(1.23f); assertThat(struct.getBoolean("booleanField")).isTrue(); - assertThat(struct.getTimestamp("timestampField")).isEqualTo(Instant.ofEpochSecond(100000, 100)); + assertThat(struct.getTimestampInstant("timestampField")) + .isEqualTo(Instant.ofEpochSecond(100000, 100)); assertThat(struct.getDate("dateField")).isEqualTo(Date.fromYearMonthDay(2024, 6, 1)); assertThat(struct.getStruct("structField")) .isEqualTo( diff --git a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/internal/ResultSetImplTest.java b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/internal/ResultSetImplTest.java index a5b823b205..115cf1f279 100644 --- a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/internal/ResultSetImplTest.java +++ b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/internal/ResultSetImplTest.java @@ -54,6 +54,7 @@ import com.google.cloud.bigtable.data.v2.stub.sql.SqlServerStreamImpl; import com.google.cloud.bigtable.gaxx.testing.FakeStreamingApi.ServerStreamingStashCallable; import com.google.protobuf.ByteString; +import java.time.Instant; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; @@ -62,7 +63,6 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; -import org.threeten.bp.Instant; @RunWith(JUnit4.class) public class ResultSetImplTest { @@ -126,8 +126,8 @@ public void testSingleRow() throws ExecutionException, InterruptedException { assertThat(resultSet.getFloat("float")).isEqualTo(1.23f); assertThat(resultSet.getBoolean(5)).isTrue(); assertThat(resultSet.getBoolean("boolean")).isTrue(); - assertThat(resultSet.getTimestamp(6)).isEqualTo(Instant.ofEpochSecond(10000000, 100)); - assertThat(resultSet.getTimestamp("timestamp")) + assertThat(resultSet.getTimestampInstant(6)).isEqualTo(Instant.ofEpochSecond(10000000, 100)); + assertThat(resultSet.getTimestampInstant("timestamp")) .isEqualTo(Instant.ofEpochSecond(10000000, 100)); assertThat(resultSet.getDate(7)).isEqualTo(Date.fromYearMonthDay(2024, 6, 5)); assertThat(resultSet.getDate("date")).isEqualTo(Date.fromYearMonthDay(2024, 6, 5)); diff --git a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/it/BuiltinMetricsIT.java b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/it/BuiltinMetricsIT.java index 636042f5d9..41d4b6c0d3 100644 --- a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/it/BuiltinMetricsIT.java +++ b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/it/BuiltinMetricsIT.java @@ -63,6 +63,8 @@ import io.opentelemetry.sdk.metrics.data.MetricData; import io.opentelemetry.sdk.testing.exporter.InMemoryMetricReader; import java.io.IOException; +import java.time.Duration; +import java.time.Instant; import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -78,8 +80,6 @@ import org.junit.rules.Timeout; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; -import org.threeten.bp.Duration; -import org.threeten.bp.Instant; @RunWith(JUnit4.class) public class BuiltinMetricsIT { diff --git a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/it/BulkMutateIT.java b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/it/BulkMutateIT.java index a284f8b7cb..ca580def73 100644 --- a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/it/BulkMutateIT.java +++ b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/it/BulkMutateIT.java @@ -37,13 +37,13 @@ import com.google.cloud.bigtable.test_helpers.env.EmulatorEnv; import com.google.cloud.bigtable.test_helpers.env.TestEnvRule; import java.io.IOException; +import java.time.Duration; import java.util.Objects; import java.util.UUID; import org.junit.ClassRule; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; -import org.threeten.bp.Duration; @RunWith(JUnit4.class) public class BulkMutateIT { @@ -158,7 +158,7 @@ public void testManyMutations() throws IOException, InterruptedException { .stubSettings() .bulkMutateRowsSettings() .setBatchingSettings( - batchingSettings.toBuilder().setDelayThreshold(Duration.ofHours(1)).build()); + batchingSettings.toBuilder().setDelayThresholdDuration(Duration.ofHours(1)).build()); try (BigtableDataClient client = BigtableDataClient.create(settings); BatcherImpl batcher = (BatcherImpl) @@ -207,7 +207,7 @@ public void testManyMutationsOnAuthorizedView() throws IOException, InterruptedE .stubSettings() .bulkMutateRowsSettings() .setBatchingSettings( - batchingSettings.toBuilder().setDelayThreshold(Duration.ofHours(1)).build()); + batchingSettings.toBuilder().setDelayThresholdDuration(Duration.ofHours(1)).build()); try (BigtableDataClient client = BigtableDataClient.create(settings); Batcher batcher = client.newBulkMutationBatcher( diff --git a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/it/ExecuteQueryIT.java b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/it/ExecuteQueryIT.java index 620d290338..b105270472 100644 --- a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/it/ExecuteQueryIT.java +++ b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/it/ExecuteQueryIT.java @@ -31,6 +31,7 @@ import com.google.cloud.bigtable.test_helpers.env.TestEnvRule; import com.google.protobuf.ByteString; import java.io.IOException; +import java.time.Instant; import java.util.Arrays; import java.util.HashMap; import java.util.List; @@ -41,7 +42,6 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; -import org.threeten.bp.Instant; @RunWith(JUnit4.class) public class ExecuteQueryIT { @@ -124,10 +124,10 @@ public void withHistoryQuery() { Struct rowAQual_0 = rowAQual.get(0); assertThat(rowAQual_0.getBytes("value")).isEqualTo(ByteString.copyFromUtf8("val")); // timestamp in micros above so we divide by 1000 - assertThat(rowAQual_0.getTimestamp("timestamp")).isEqualTo(Instant.ofEpochMilli(10)); + assertThat(rowAQual_0.getTimestampInstant("timestamp")).isEqualTo(Instant.ofEpochMilli(10)); Struct rowAQual_1 = rowAQual.get(1); assertThat(rowAQual_1.getBytes("value")).isEqualTo(ByteString.copyFromUtf8("old")); - assertThat(rowAQual_1.getTimestamp("timestamp")).isEqualTo(Instant.ofEpochMilli(1)); + assertThat(rowAQual_1.getTimestampInstant("timestamp")).isEqualTo(Instant.ofEpochMilli(1)); assertThat(rs.next()).isTrue(); assertThat(rs.getBytes("_key")).isEqualTo(ByteString.copyFromUtf8(uniquePrefix + "b")); @@ -169,8 +169,8 @@ public void allTypes() { assertThat(rs.getDouble(4)).isEqualTo(1.3d); assertThat(rs.getBoolean("boolCol")).isTrue(); assertThat(rs.getBoolean(5)).isTrue(); - assertThat(rs.getTimestamp("tsCol")).isEqualTo(Instant.ofEpochMilli(1000)); - assertThat(rs.getTimestamp(6)).isEqualTo(Instant.ofEpochMilli(1000)); + assertThat(rs.getTimestampInstant("tsCol")).isEqualTo(Instant.ofEpochMilli(1000)); + assertThat(rs.getTimestampInstant(6)).isEqualTo(Instant.ofEpochMilli(1000)); assertThat(rs.getDate("dateCol")).isEqualTo(Date.fromYearMonthDay(2024, 6, 1)); assertThat(rs.getDate(7)).isEqualTo(Date.fromYearMonthDay(2024, 6, 1)); assertThat(rs.getStruct("structCol").getLong("a")).isEqualTo(1); @@ -222,7 +222,7 @@ public void allQueryParamsTypes() { .setDoubleParam("doubleParam", 1.3d) .setFloatParam("floatParam", 1.4f) .setBooleanParam("boolParam", true) - .setTimestampParam("tsParam", Instant.ofEpochMilli(1000)) + .setTimestampParamInstant("tsParam", Instant.ofEpochMilli(1000)) .setDateParam("dateParam", Date.fromYearMonthDay(2024, 6, 1)) .setListParam( "byteArrayParam", diff --git a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/models/ChangeStreamMutationTest.java b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/models/ChangeStreamMutationTest.java index 61c028cdb6..676497ddb0 100644 --- a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/models/ChangeStreamMutationTest.java +++ b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/models/ChangeStreamMutationTest.java @@ -29,11 +29,11 @@ import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; +import java.time.Instant; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; -import org.threeten.bp.Instant; @RunWith(JUnit4.class) public class ChangeStreamMutationTest { @@ -73,17 +73,18 @@ public void userInitiatedMutationTest() throws IOException, ClassNotFoundExcepti Value.rawTimestamp(1000), Value.rawValue(ByteString.copyFrom(Longs.toByteArray(1234L)))) .setToken("fake-token") - .setEstimatedLowWatermark(FAKE_LOW_WATERMARK) + .setEstimatedLowWatermarkInstant(FAKE_LOW_WATERMARK) .build(); // Test the getters. assertThat(changeStreamMutation.getRowKey()).isEqualTo(ByteString.copyFromUtf8("key")); assertThat(changeStreamMutation.getType()).isEqualTo(ChangeStreamMutation.MutationType.USER); assertThat(changeStreamMutation.getSourceClusterId()).isEqualTo("fake-source-cluster-id"); - assertThat(changeStreamMutation.getCommitTimestamp()).isEqualTo(FAKE_COMMIT_TIMESTAMP); + assertThat(changeStreamMutation.getCommitTimestampInstant()).isEqualTo(FAKE_COMMIT_TIMESTAMP); assertThat(changeStreamMutation.getTieBreaker()).isEqualTo(0); assertThat(changeStreamMutation.getToken()).isEqualTo("fake-token"); - assertThat(changeStreamMutation.getEstimatedLowWatermark()).isEqualTo(FAKE_LOW_WATERMARK); + assertThat(changeStreamMutation.getEstimatedLowWatermarkInstant()) + .isEqualTo(FAKE_LOW_WATERMARK); // Test serialization. ByteArrayOutputStream bos = new ByteArrayOutputStream(); @@ -112,7 +113,7 @@ public void gcMutationTest() throws IOException, ClassNotFoundException { ByteString.copyFromUtf8("fake-qualifier"), Range.TimestampRange.create(1000L, 2000L)) .setToken("fake-token") - .setEstimatedLowWatermark(FAKE_LOW_WATERMARK) + .setEstimatedLowWatermarkInstant(FAKE_LOW_WATERMARK) .build(); // Test the getters. @@ -120,10 +121,11 @@ public void gcMutationTest() throws IOException, ClassNotFoundException { assertThat(changeStreamMutation.getType()) .isEqualTo(ChangeStreamMutation.MutationType.GARBAGE_COLLECTION); Assert.assertTrue(changeStreamMutation.getSourceClusterId().isEmpty()); - assertThat(changeStreamMutation.getCommitTimestamp()).isEqualTo(FAKE_COMMIT_TIMESTAMP); + assertThat(changeStreamMutation.getCommitTimestampInstant()).isEqualTo(FAKE_COMMIT_TIMESTAMP); assertThat(changeStreamMutation.getTieBreaker()).isEqualTo(0); assertThat(changeStreamMutation.getToken()).isEqualTo("fake-token"); - assertThat(changeStreamMutation.getEstimatedLowWatermark()).isEqualTo(FAKE_LOW_WATERMARK); + assertThat(changeStreamMutation.getEstimatedLowWatermarkInstant()) + .isEqualTo(FAKE_LOW_WATERMARK); // Test serialization. ByteArrayOutputStream bos = new ByteArrayOutputStream(); @@ -161,7 +163,7 @@ public void toRowMutationTest() { Value.rawTimestamp(1000), Value.rawValue(ByteString.copyFrom(Longs.toByteArray(1234L)))) .setToken("fake-token") - .setEstimatedLowWatermark(FAKE_LOW_WATERMARK) + .setEstimatedLowWatermarkInstant(FAKE_LOW_WATERMARK) .build(); // Convert it to a rowMutation and construct a MutateRowRequest. @@ -204,7 +206,7 @@ public void toRowMutationWithoutTokenShouldFailTest() { ChangeStreamMutation.createUserMutation( ByteString.copyFromUtf8("key"), "fake-source-cluster-id", FAKE_COMMIT_TIMESTAMP, 0) .deleteFamily("fake-family") - .setEstimatedLowWatermark(FAKE_LOW_WATERMARK); + .setEstimatedLowWatermarkInstant(FAKE_LOW_WATERMARK); Assert.assertThrows(IllegalStateException.class, builder::build); } @@ -244,7 +246,7 @@ public void toRowMutationEntryTest() { Value.rawTimestamp(1000), Value.rawValue(ByteString.copyFrom(Longs.toByteArray(1234L)))) .setToken("fake-token") - .setEstimatedLowWatermark(FAKE_LOW_WATERMARK) + .setEstimatedLowWatermarkInstant(FAKE_LOW_WATERMARK) .build(); // Convert it to a rowMutationEntry and construct a MutateRowRequest. @@ -284,7 +286,7 @@ public void toRowMutationEntryWithoutTokenShouldFailTest() { ChangeStreamMutation.createUserMutation( ByteString.copyFromUtf8("key"), "fake-source-cluster-id", FAKE_COMMIT_TIMESTAMP, 0) .deleteFamily("fake-family") - .setEstimatedLowWatermark(FAKE_LOW_WATERMARK); + .setEstimatedLowWatermarkInstant(FAKE_LOW_WATERMARK); Assert.assertThrows(IllegalStateException.class, builder::build); } @@ -309,7 +311,7 @@ public void testWithLongValue() { 1000L, ByteString.copyFrom(Longs.toByteArray(1L))) .setToken("fake-token") - .setEstimatedLowWatermark(FAKE_LOW_WATERMARK) + .setEstimatedLowWatermarkInstant(FAKE_LOW_WATERMARK) .build(); RowMutation rowMutation = changeStreamMutation.toRowMutation(TABLE_ID); diff --git a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/models/ChangeStreamRecordTest.java b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/models/ChangeStreamRecordTest.java index 3f09d9b443..14697f430e 100644 --- a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/models/ChangeStreamRecordTest.java +++ b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/models/ChangeStreamRecordTest.java @@ -30,6 +30,7 @@ import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; +import java.time.Instant; import org.junit.Assert; import org.junit.Rule; import org.junit.Test; @@ -37,7 +38,6 @@ import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; -import org.threeten.bp.Instant; @RunWith(JUnit4.class) public class ChangeStreamRecordTest { @@ -129,7 +129,7 @@ public void heartbeatTest() { .build(); Heartbeat actualHeartbeat = Heartbeat.fromProto(heartbeatProto); - assertThat(actualHeartbeat.getEstimatedLowWatermark()) + assertThat(actualHeartbeat.getEstimatedLowWatermarkInstant()) .isEqualTo(Instant.ofEpochSecond(lowWatermark.getSeconds(), lowWatermark.getNanos())); assertThat(actualHeartbeat.getChangeStreamContinuationToken().getPartition()) .isEqualTo(ByteStringRange.create(rowRange.getStartKeyClosed(), rowRange.getEndKeyOpen())); diff --git a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/models/DefaultChangeStreamRecordAdapterTest.java b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/models/DefaultChangeStreamRecordAdapterTest.java index 22270bc269..56701a8e6f 100644 --- a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/models/DefaultChangeStreamRecordAdapterTest.java +++ b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/models/DefaultChangeStreamRecordAdapterTest.java @@ -25,6 +25,7 @@ import com.google.protobuf.ByteString; import com.google.protobuf.Timestamp; import com.google.rpc.Status; +import java.time.Instant; import org.junit.Assert; import org.junit.Before; import org.junit.Rule; @@ -32,7 +33,6 @@ import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; -import org.threeten.bp.Instant; @RunWith(JUnit4.class) public class DefaultChangeStreamRecordAdapterTest { @@ -59,7 +59,7 @@ public void isHeartbeatTest() { ChangeStreamMutation.createGcMutation( ByteString.copyFromUtf8("key"), FAKE_COMMIT_TIMESTAMP, 0) .setToken("token") - .setEstimatedLowWatermark(FAKE_LOW_WATERMARK) + .setEstimatedLowWatermarkInstant(FAKE_LOW_WATERMARK) .build(); Assert.assertTrue(adapter.isHeartbeat(heartbeatRecord)); Assert.assertFalse(adapter.isHeartbeat(closeStreamRecord)); @@ -99,7 +99,7 @@ public void isChangeStreamMutationTest() { ChangeStreamMutation.createGcMutation( ByteString.copyFromUtf8("key"), FAKE_COMMIT_TIMESTAMP, 0) .setToken("token") - .setEstimatedLowWatermark(FAKE_LOW_WATERMARK) + .setEstimatedLowWatermarkInstant(FAKE_LOW_WATERMARK) .build(); Assert.assertFalse(adapter.isChangeStreamMutation(heartbeatRecord)); Assert.assertFalse(adapter.isChangeStreamMutation(closeStreamRecord)); @@ -112,7 +112,7 @@ public void getTokenFromChangeStreamMutationTest() { ChangeStreamMutation.createGcMutation( ByteString.copyFromUtf8("key"), FAKE_COMMIT_TIMESTAMP, 0) .setToken("change-stream-mutation-token") - .setEstimatedLowWatermark(FAKE_LOW_WATERMARK) + .setEstimatedLowWatermarkInstant(FAKE_LOW_WATERMARK) .build(); Assert.assertEquals( adapter.getTokenFromChangeStreamMutation(changeStreamMutationRecord), @@ -161,14 +161,14 @@ public void closeStreamTest() { @Test(expected = IllegalStateException.class) public void createHeartbeatWithExistingMutationShouldFailTest() { - changeStreamRecordBuilder.startGcMutation( + changeStreamRecordBuilder.startGcMutationInstant( ByteString.copyFromUtf8("key"), FAKE_COMMIT_TIMESTAMP, 0); changeStreamRecordBuilder.onHeartbeat(ReadChangeStreamResponse.Heartbeat.getDefaultInstance()); } @Test(expected = IllegalStateException.class) public void createCloseStreamWithExistingMutationShouldFailTest() { - changeStreamRecordBuilder.startGcMutation( + changeStreamRecordBuilder.startGcMutationInstant( ByteString.copyFromUtf8("key"), FAKE_COMMIT_TIMESTAMP, 0); changeStreamRecordBuilder.onCloseStream( ReadChangeStreamResponse.CloseStream.getDefaultInstance()); @@ -186,19 +186,21 @@ public void singleDeleteFamilyTest() { ByteString.copyFromUtf8("key"), "fake-source-cluster-id", FAKE_COMMIT_TIMESTAMP, 0) .deleteFamily("fake-family") .setToken("fake-token") - .setEstimatedLowWatermark(FAKE_LOW_WATERMARK) + .setEstimatedLowWatermarkInstant(FAKE_LOW_WATERMARK) .build(); // Create the ChangeStreamMutation through the ChangeStreamRecordBuilder. - changeStreamRecordBuilder.startUserMutation( + changeStreamRecordBuilder.startUserMutationInstant( ByteString.copyFromUtf8("key"), "fake-source-cluster-id", FAKE_COMMIT_TIMESTAMP, 0); changeStreamRecordBuilder.deleteFamily(deleteFromFamily.getFamilyName()); assertThat( - changeStreamRecordBuilder.finishChangeStreamMutation("fake-token", FAKE_LOW_WATERMARK)) + changeStreamRecordBuilder.finishChangeStreamMutationInstant( + "fake-token", FAKE_LOW_WATERMARK)) .isEqualTo(expectedChangeStreamMutation); // Call again. assertThat( - changeStreamRecordBuilder.finishChangeStreamMutation("fake-token", FAKE_LOW_WATERMARK)) + changeStreamRecordBuilder.finishChangeStreamMutationInstant( + "fake-token", FAKE_LOW_WATERMARK)) .isEqualTo(expectedChangeStreamMutation); } @@ -225,11 +227,11 @@ public void singleDeleteCellTest() { ByteString.copyFromUtf8("fake-qualifier"), Range.TimestampRange.create(1000L, 2000L)) .setToken("fake-token") - .setEstimatedLowWatermark(FAKE_LOW_WATERMARK) + .setEstimatedLowWatermarkInstant(FAKE_LOW_WATERMARK) .build(); // Create the ChangeStreamMutation through the ChangeStreamRecordBuilder. - changeStreamRecordBuilder.startUserMutation( + changeStreamRecordBuilder.startUserMutationInstant( ByteString.copyFromUtf8("key"), "fake-source-cluster-id", FAKE_COMMIT_TIMESTAMP, 0); changeStreamRecordBuilder.deleteCells( deleteFromColumn.getFamilyName(), @@ -238,11 +240,13 @@ public void singleDeleteCellTest() { deleteFromColumn.getTimeRange().getStartTimestampMicros(), deleteFromColumn.getTimeRange().getEndTimestampMicros())); assertThat( - changeStreamRecordBuilder.finishChangeStreamMutation("fake-token", FAKE_LOW_WATERMARK)) + changeStreamRecordBuilder.finishChangeStreamMutationInstant( + "fake-token", FAKE_LOW_WATERMARK)) .isEqualTo(expectedChangeStreamMutation); // Call again. assertThat( - changeStreamRecordBuilder.finishChangeStreamMutation("fake-token", FAKE_LOW_WATERMARK)) + changeStreamRecordBuilder.finishChangeStreamMutationInstant( + "fake-token", FAKE_LOW_WATERMARK)) .isEqualTo(expectedChangeStreamMutation); } @@ -258,23 +262,25 @@ public void singleNonChunkedCellTest() { 100L, ByteString.copyFromUtf8("fake-value")) .setToken("fake-token") - .setEstimatedLowWatermark(FAKE_LOW_WATERMARK) + .setEstimatedLowWatermarkInstant(FAKE_LOW_WATERMARK) .build(); // Create the ChangeStreamMutation through the ChangeStreamRecordBuilder. // Suppose the SetCell is not chunked and the state machine calls `cellValue()` once. - changeStreamRecordBuilder.startUserMutation( + changeStreamRecordBuilder.startUserMutationInstant( ByteString.copyFromUtf8("key"), "fake-source-cluster-id", FAKE_COMMIT_TIMESTAMP, 0); changeStreamRecordBuilder.startCell( "fake-family", ByteString.copyFromUtf8("fake-qualifier"), 100L); changeStreamRecordBuilder.cellValue(ByteString.copyFromUtf8("fake-value")); changeStreamRecordBuilder.finishCell(); assertThat( - changeStreamRecordBuilder.finishChangeStreamMutation("fake-token", FAKE_LOW_WATERMARK)) + changeStreamRecordBuilder.finishChangeStreamMutationInstant( + "fake-token", FAKE_LOW_WATERMARK)) .isEqualTo(expectedChangeStreamMutation); // Call again. assertThat( - changeStreamRecordBuilder.finishChangeStreamMutation("fake-token", FAKE_LOW_WATERMARK)) + changeStreamRecordBuilder.finishChangeStreamMutationInstant( + "fake-token", FAKE_LOW_WATERMARK)) .isEqualTo(expectedChangeStreamMutation); } @@ -290,13 +296,13 @@ public void singleChunkedCellTest() { 100L, ByteString.copyFromUtf8("fake-value1-value2")) .setToken("fake-token") - .setEstimatedLowWatermark(FAKE_LOW_WATERMARK) + .setEstimatedLowWatermarkInstant(FAKE_LOW_WATERMARK) .build(); // Create the ChangeStreamMutation through the ChangeStreamRecordBuilder. // Suppose the SetCell is chunked into two pieces and the state machine calls `cellValue()` // twice. - changeStreamRecordBuilder.startUserMutation( + changeStreamRecordBuilder.startUserMutationInstant( ByteString.copyFromUtf8("key"), "fake-source-cluster-id", FAKE_COMMIT_TIMESTAMP, 0); changeStreamRecordBuilder.startCell( "fake-family", ByteString.copyFromUtf8("fake-qualifier"), 100L); @@ -304,11 +310,13 @@ public void singleChunkedCellTest() { changeStreamRecordBuilder.cellValue(ByteString.copyFromUtf8("-value2")); changeStreamRecordBuilder.finishCell(); assertThat( - changeStreamRecordBuilder.finishChangeStreamMutation("fake-token", FAKE_LOW_WATERMARK)) + changeStreamRecordBuilder.finishChangeStreamMutationInstant( + "fake-token", FAKE_LOW_WATERMARK)) .isEqualTo(expectedChangeStreamMutation); // Call again. assertThat( - changeStreamRecordBuilder.finishChangeStreamMutation("fake-token", FAKE_LOW_WATERMARK)) + changeStreamRecordBuilder.finishChangeStreamMutationInstant( + "fake-token", FAKE_LOW_WATERMARK)) .isEqualTo(expectedChangeStreamMutation); } @@ -327,10 +335,10 @@ public void multipleChunkedCellsTest() { } expectedChangeStreamMutationBuilder .setToken("fake-token") - .setEstimatedLowWatermark(FAKE_LOW_WATERMARK); + .setEstimatedLowWatermarkInstant(FAKE_LOW_WATERMARK); // Create the ChangeStreamMutation through the ChangeStreamRecordBuilder. - changeStreamRecordBuilder.startUserMutation( + changeStreamRecordBuilder.startUserMutationInstant( ByteString.copyFromUtf8("key"), "fake-source-cluster-id", FAKE_COMMIT_TIMESTAMP, 0); for (int i = 0; i < 10; ++i) { changeStreamRecordBuilder.startCell( @@ -342,11 +350,13 @@ public void multipleChunkedCellsTest() { } // Check that they're the same. assertThat( - changeStreamRecordBuilder.finishChangeStreamMutation("fake-token", FAKE_LOW_WATERMARK)) + changeStreamRecordBuilder.finishChangeStreamMutationInstant( + "fake-token", FAKE_LOW_WATERMARK)) .isEqualTo(expectedChangeStreamMutationBuilder.build()); // Call again. assertThat( - changeStreamRecordBuilder.finishChangeStreamMutation("fake-token", FAKE_LOW_WATERMARK)) + changeStreamRecordBuilder.finishChangeStreamMutationInstant( + "fake-token", FAKE_LOW_WATERMARK)) .isEqualTo(expectedChangeStreamMutationBuilder.build()); } @@ -369,10 +379,10 @@ public void multipleDifferentModsTest() { 100L, ByteString.copyFromUtf8("chunked-value")) .setToken("fake-token") - .setEstimatedLowWatermark(FAKE_LOW_WATERMARK); + .setEstimatedLowWatermarkInstant(FAKE_LOW_WATERMARK); // Create the ChangeStreamMutation through the ChangeStreamRecordBuilder. - changeStreamRecordBuilder.startUserMutation( + changeStreamRecordBuilder.startUserMutationInstant( ByteString.copyFromUtf8("key"), "fake-source-cluster-id", FAKE_COMMIT_TIMESTAMP, 0); changeStreamRecordBuilder.deleteFamily("fake-family"); // Add non-chunked cell. @@ -387,7 +397,8 @@ public void multipleDifferentModsTest() { changeStreamRecordBuilder.cellValue(ByteString.copyFromUtf8("-value")); changeStreamRecordBuilder.finishCell(); assertThat( - changeStreamRecordBuilder.finishChangeStreamMutation("fake-token", FAKE_LOW_WATERMARK)) + changeStreamRecordBuilder.finishChangeStreamMutationInstant( + "fake-token", FAKE_LOW_WATERMARK)) .isEqualTo(expectedChangeStreamMutationBuilder.build()); } @@ -418,13 +429,14 @@ public void resetTest() { ByteString.copyFromUtf8("key"), "fake-source-cluster-id", FAKE_COMMIT_TIMESTAMP, 0) .deleteFamily("fake-family") .setToken("fake-token") - .setEstimatedLowWatermark(FAKE_LOW_WATERMARK) + .setEstimatedLowWatermarkInstant(FAKE_LOW_WATERMARK) .build(); - changeStreamRecordBuilder.startUserMutation( + changeStreamRecordBuilder.startUserMutationInstant( ByteString.copyFromUtf8("key"), "fake-source-cluster-id", FAKE_COMMIT_TIMESTAMP, 0); changeStreamRecordBuilder.deleteFamily(deleteFromFamily.getDeleteFromFamily().getFamilyName()); assertThat( - changeStreamRecordBuilder.finishChangeStreamMutation("fake-token", FAKE_LOW_WATERMARK)) + changeStreamRecordBuilder.finishChangeStreamMutationInstant( + "fake-token", FAKE_LOW_WATERMARK)) .isEqualTo(expectedChangeStreamMutation); // Reset a build a cell. @@ -438,10 +450,10 @@ public void resetTest() { 100L, ByteString.copyFromUtf8("fake-value1-value2")) .setToken("fake-token") - .setEstimatedLowWatermark(FAKE_LOW_WATERMARK) + .setEstimatedLowWatermarkInstant(FAKE_LOW_WATERMARK) .build(); - changeStreamRecordBuilder.startUserMutation( + changeStreamRecordBuilder.startUserMutationInstant( ByteString.copyFromUtf8("key"), "fake-source-cluster-id", FAKE_COMMIT_TIMESTAMP, 0); changeStreamRecordBuilder.startCell( "fake-family", ByteString.copyFromUtf8("fake-qualifier"), 100L); @@ -449,7 +461,8 @@ public void resetTest() { changeStreamRecordBuilder.cellValue(ByteString.copyFromUtf8("-value2")); changeStreamRecordBuilder.finishCell(); assertThat( - changeStreamRecordBuilder.finishChangeStreamMutation("fake-token", FAKE_LOW_WATERMARK)) + changeStreamRecordBuilder.finishChangeStreamMutationInstant( + "fake-token", FAKE_LOW_WATERMARK)) .isEqualTo(expectedChangeStreamMutation); } } diff --git a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/models/ReadChangeStreamQueryTest.java b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/models/ReadChangeStreamQueryTest.java index 699f60a8d1..a7d6347488 100644 --- a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/models/ReadChangeStreamQueryTest.java +++ b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/models/ReadChangeStreamQueryTest.java @@ -34,6 +34,7 @@ import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; +import java.time.Instant; import java.util.Collections; import org.junit.Before; import org.junit.Rule; @@ -41,7 +42,6 @@ import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; -import org.threeten.bp.Instant; @RunWith(JUnit4.class) public class ReadChangeStreamQueryTest { @@ -121,7 +121,8 @@ public void streamPartitionTest() { @Test public void startTimeTest() { - ReadChangeStreamQuery query = ReadChangeStreamQuery.create(TABLE_ID).startTime(FAKE_START_TIME); + ReadChangeStreamQuery query = + ReadChangeStreamQuery.create(TABLE_ID).startTimeInstant(FAKE_START_TIME); Builder expectedProto = expectedProtoBuilder() @@ -136,7 +137,8 @@ public void startTimeTest() { @Test public void endTimeTest() { - ReadChangeStreamQuery query = ReadChangeStreamQuery.create(TABLE_ID).endTime(FAKE_END_TIME); + ReadChangeStreamQuery query = + ReadChangeStreamQuery.create(TABLE_ID).endTimeInstant(FAKE_END_TIME); Builder expectedProto = expectedProtoBuilder() @@ -153,7 +155,7 @@ public void endTimeTest() { public void heartbeatDurationTest() { ReadChangeStreamQuery query = ReadChangeStreamQuery.create(TABLE_ID) - .heartbeatDuration(org.threeten.bp.Duration.ofSeconds(5)); + .heartbeatDurationDuration(java.time.Duration.ofSeconds(5)); Builder expectedProto = expectedProtoBuilder().setHeartbeatDuration(Duration.newBuilder().setSeconds(5).build()); @@ -206,7 +208,7 @@ public void createWithStartTimeAndContinuationTokensTest() { ChangeStreamContinuationToken token = ChangeStreamContinuationToken.fromProto(tokenProto); ReadChangeStreamQuery query = ReadChangeStreamQuery.create(TABLE_ID) - .startTime(FAKE_START_TIME) + .startTimeInstant(FAKE_START_TIME) .continuationTokens(Collections.singletonList(token)); expect.expect(IllegalArgumentException.class); expect.expectMessage("startTime and continuationTokens can't be specified together"); @@ -231,8 +233,8 @@ public void serializationTest() throws IOException, ClassNotFoundException { ReadChangeStreamQuery.create(TABLE_ID) .streamPartition("simple-begin", "simple-end") .continuationTokens(Collections.singletonList(token)) - .endTime(FAKE_END_TIME) - .heartbeatDuration(org.threeten.bp.Duration.ofSeconds(5)); + .endTimeInstant(FAKE_END_TIME) + .heartbeatDurationDuration(java.time.Duration.ofSeconds(5)); ByteArrayOutputStream bos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(bos); @@ -300,9 +302,9 @@ public void testEquality() { ReadChangeStreamQuery request = ReadChangeStreamQuery.create(TABLE_ID) .streamPartition("simple-begin", "simple-end") - .startTime(FAKE_START_TIME) - .endTime(FAKE_END_TIME) - .heartbeatDuration(org.threeten.bp.Duration.ofSeconds(5)); + .startTimeInstant(FAKE_START_TIME) + .endTimeInstant(FAKE_END_TIME) + .heartbeatDurationDuration(java.time.Duration.ofSeconds(5)); // ReadChangeStreamQuery#toProto should not change the ReadChangeStreamQuery instance state request.toProto(requestContext); @@ -310,24 +312,26 @@ public void testEquality() { .isEqualTo( ReadChangeStreamQuery.create(TABLE_ID) .streamPartition("simple-begin", "simple-end") - .startTime(FAKE_START_TIME) - .endTime(FAKE_END_TIME) - .heartbeatDuration(org.threeten.bp.Duration.ofSeconds(5))); + .startTimeInstant(FAKE_START_TIME) + .endTimeInstant(FAKE_END_TIME) + .heartbeatDurationDuration(java.time.Duration.ofSeconds(5))); assertThat(ReadChangeStreamQuery.create(TABLE_ID).streamPartition("begin-1", "end-1")) .isNotEqualTo(ReadChangeStreamQuery.create(TABLE_ID).streamPartition("begin-2", "end-1")); - assertThat(ReadChangeStreamQuery.create(TABLE_ID).startTime(FAKE_START_TIME)) + assertThat(ReadChangeStreamQuery.create(TABLE_ID).startTimeInstant(FAKE_START_TIME)) .isNotEqualTo( - ReadChangeStreamQuery.create(TABLE_ID).startTime(Instant.ofEpochSecond(1L, 1001L))); - assertThat(ReadChangeStreamQuery.create(TABLE_ID).endTime(FAKE_END_TIME)) + ReadChangeStreamQuery.create(TABLE_ID) + .startTimeInstant(Instant.ofEpochSecond(1L, 1001L))); + assertThat(ReadChangeStreamQuery.create(TABLE_ID).endTimeInstant(FAKE_END_TIME)) .isNotEqualTo( - ReadChangeStreamQuery.create(TABLE_ID).endTime(Instant.ofEpochSecond(1L, 1001L))); + ReadChangeStreamQuery.create(TABLE_ID) + .endTimeInstant(Instant.ofEpochSecond(1L, 1001L))); assertThat( ReadChangeStreamQuery.create(TABLE_ID) - .heartbeatDuration(org.threeten.bp.Duration.ofSeconds(5))) + .heartbeatDurationDuration(java.time.Duration.ofSeconds(5))) .isNotEqualTo( ReadChangeStreamQuery.create(TABLE_ID) - .heartbeatDuration(org.threeten.bp.Duration.ofSeconds(6))); + .heartbeatDurationDuration(java.time.Duration.ofSeconds(6))); } @Test @@ -349,8 +353,8 @@ public void testClone() { ReadChangeStreamQuery.create(TABLE_ID) .streamPartition("begin", "end") .continuationTokens(Collections.singletonList(token)) - .endTime(FAKE_END_TIME) - .heartbeatDuration(org.threeten.bp.Duration.ofSeconds(5)); + .endTimeInstant(FAKE_END_TIME) + .heartbeatDurationDuration(java.time.Duration.ofSeconds(5)); ReadChangeStreamRequest request = ReadChangeStreamRequest.newBuilder() .setTableName(NameUtil.formatTableName(PROJECT_ID, INSTANCE_ID, TABLE_ID)) diff --git a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/models/sql/StatementTest.java b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/models/sql/StatementTest.java index cb19a7fde9..e2fecffdca 100644 --- a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/models/sql/StatementTest.java +++ b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/models/sql/StatementTest.java @@ -41,12 +41,12 @@ import com.google.cloud.Date; import com.google.cloud.bigtable.data.v2.internal.RequestContext; import com.google.protobuf.ByteString; +import java.time.Instant; import java.util.Arrays; import java.util.Collections; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; -import org.threeten.bp.Instant; @RunWith(JUnit4.class) public class StatementTest { @@ -218,7 +218,7 @@ public void statementWithTimestampParam() { Statement s = Statement.newBuilder( "SELECT * FROM table WHERE PARSE_TIMESTAMP(\"%Y/%m/%dT%H:%M:%S\", CAST(cf[\"ts\"] AS STRING)) < @timeParam") - .setTimestampParam("timeParam", Instant.ofEpochSecond(1000, 100)) + .setTimestampParamInstant("timeParam", Instant.ofEpochSecond(1000, 100)) .build(); assertThat(s.toProto(REQUEST_CONTEXT)) diff --git a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/stub/BigtableBatchingCallSettingsTest.java b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/stub/BigtableBatchingCallSettingsTest.java index dcdef068a5..cf42f07ff8 100644 --- a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/stub/BigtableBatchingCallSettingsTest.java +++ b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/stub/BigtableBatchingCallSettingsTest.java @@ -25,11 +25,11 @@ import com.google.api.gax.rpc.StatusCode; import com.google.cloud.bigtable.data.v2.stub.mutaterows.MutateRowsBatchingDescriptor; import com.google.common.collect.ImmutableSet; +import java.time.Duration; import java.util.Set; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; -import org.threeten.bp.Duration; @RunWith(JUnit4.class) public class BigtableBatchingCallSettingsTest { @@ -38,7 +38,7 @@ public class BigtableBatchingCallSettingsTest { BatchingSettings.newBuilder() .setElementCountThreshold(10L) .setRequestByteThreshold(20L) - .setDelayThreshold(Duration.ofMillis(5)) + .setDelayThresholdDuration(Duration.ofMillis(5)) .setFlowControlSettings( FlowControlSettings.newBuilder() .setMaxOutstandingElementCount(100L) @@ -111,7 +111,7 @@ public void testBuilderFromSettings() { BigtableBatchingCallSettings.Builder builder = BigtableBatchingCallSettings.newBuilder(new MutateRowsBatchingDescriptor()); RetrySettings retrySettings = - RetrySettings.newBuilder().setTotalTimeout(Duration.ofMinutes(1)).build(); + RetrySettings.newBuilder().setTotalTimeoutDuration(Duration.ofMinutes(1)).build(); builder .setBatchingSettings(BATCHING_SETTINGS) .setRetryableCodes(StatusCode.Code.UNAVAILABLE, StatusCode.Code.UNAUTHENTICATED) diff --git a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/stub/BigtableBulkReadRowsCallSettingsTest.java b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/stub/BigtableBulkReadRowsCallSettingsTest.java index a343bf4667..63a6d95858 100644 --- a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/stub/BigtableBulkReadRowsCallSettingsTest.java +++ b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/stub/BigtableBulkReadRowsCallSettingsTest.java @@ -24,11 +24,11 @@ import com.google.api.gax.rpc.StatusCode; import com.google.cloud.bigtable.data.v2.stub.readrows.ReadRowsBatchingDescriptor; import com.google.common.collect.ImmutableSet; +import java.time.Duration; import java.util.Set; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; -import org.threeten.bp.Duration; @RunWith(JUnit4.class) public class BigtableBulkReadRowsCallSettingsTest { @@ -37,7 +37,7 @@ public class BigtableBulkReadRowsCallSettingsTest { BatchingSettings.newBuilder() .setElementCountThreshold(10L) .setRequestByteThreshold(20L) - .setDelayThreshold(Duration.ofMillis(5)) + .setDelayThresholdDuration(Duration.ofMillis(5)) .setFlowControlSettings( FlowControlSettings.newBuilder() .setMaxOutstandingElementCount(100L) @@ -78,7 +78,7 @@ public void testBuilderFromSettings() { BigtableBulkReadRowsCallSettings.Builder builder = BigtableBulkReadRowsCallSettings.newBuilder(new ReadRowsBatchingDescriptor()); RetrySettings retrySettings = - RetrySettings.newBuilder().setTotalTimeout(Duration.ofMinutes(1)).build(); + RetrySettings.newBuilder().setTotalTimeoutDuration(Duration.ofMinutes(1)).build(); builder .setBatchingSettings(BATCHING_SETTINGS) .setRetryableCodes(StatusCode.Code.UNAVAILABLE, StatusCode.Code.UNAUTHENTICATED) diff --git a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/stub/CookiesHolderTest.java b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/stub/CookiesHolderTest.java index 95a807bf76..5f69a3c6cd 100644 --- a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/stub/CookiesHolderTest.java +++ b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/stub/CookiesHolderTest.java @@ -62,6 +62,7 @@ import io.grpc.StatusRuntimeException; import io.grpc.stub.StreamObserver; import java.io.IOException; +import java.time.Duration; import java.util.ArrayList; import java.util.Collections; import java.util.HashSet; @@ -74,7 +75,6 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; -import org.threeten.bp.Duration; @RunWith(JUnit4.class) public class CookiesHolderTest { @@ -145,8 +145,8 @@ public void sendHeaders(Metadata responseHeaders) { .checkAndMutateRowSettings() .setRetrySettings( RetrySettings.newBuilder() - .setInitialRetryDelay(Duration.ofMillis(10)) - .setMaxRetryDelay(Duration.ofMinutes(1)) + .setInitialRetryDelayDuration(Duration.ofMillis(10)) + .setMaxRetryDelayDuration(Duration.ofMinutes(1)) .setMaxAttempts(2) .build()) .setRetryableCodes(StatusCode.Code.UNAVAILABLE); @@ -156,8 +156,8 @@ public void sendHeaders(Metadata responseHeaders) { .readModifyWriteRowSettings() .setRetrySettings( RetrySettings.newBuilder() - .setInitialRetryDelay(Duration.ofMillis(10)) - .setMaxRetryDelay(Duration.ofMinutes(1)) + .setInitialRetryDelayDuration(Duration.ofMillis(10)) + .setMaxRetryDelayDuration(Duration.ofMinutes(1)) .setMaxAttempts(2) .build()) .setRetryableCodes(StatusCode.Code.UNAVAILABLE); diff --git a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/stub/EnhancedBigtableStubSettingsTest.java b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/stub/EnhancedBigtableStubSettingsTest.java index fdc6b5717e..d50175f525 100644 --- a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/stub/EnhancedBigtableStubSettingsTest.java +++ b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/stub/EnhancedBigtableStubSettingsTest.java @@ -42,6 +42,7 @@ import java.lang.reflect.Field; import java.lang.reflect.Modifier; import java.net.URI; +import java.time.Duration; import java.util.Arrays; import java.util.Collections; import java.util.List; @@ -51,7 +52,6 @@ import org.junit.runner.RunWith; import org.junit.runners.JUnit4; import org.mockito.Mockito; -import org.threeten.bp.Duration; @RunWith(JUnit4.class) public class EnhancedBigtableStubSettingsTest { @@ -92,7 +92,7 @@ public void settingsAreNotLostTest() { .setEndpoint(endpoint) .setCredentialsProvider(credentialsProvider) .setStreamWatchdogProvider(watchdogProvider) - .setStreamWatchdogCheckInterval(watchdogInterval) + .setStreamWatchdogCheckIntervalDuration(watchdogInterval) .setEnableRoutingCookie(enableRoutingCookie) .setEnableRetryInfo(enableRetryInfo) .setMetricsEndpoint(metricsEndpoint); @@ -158,7 +158,7 @@ private void verifyBuilder( assertThat(builder.getEndpoint()).isEqualTo(endpoint); assertThat(builder.getCredentialsProvider()).isEqualTo(credentialsProvider); assertThat(builder.getStreamWatchdogProvider()).isSameInstanceAs(watchdogProvider); - assertThat(builder.getStreamWatchdogCheckInterval()).isEqualTo(watchdogInterval); + assertThat(builder.getStreamWatchdogCheckIntervalDuration()).isEqualTo(watchdogInterval); assertThat(builder.getEnableRoutingCookie()).isEqualTo(enableRoutingCookie); assertThat(builder.getEnableRetryInfo()).isEqualTo(enableRetryInfo); assertThat(builder.getMetricsEndpoint()).isEqualTo(metricsEndpoint); @@ -222,16 +222,16 @@ public void readRowsIsNotLostTest() { RetrySettings retrySettings = RetrySettings.newBuilder() .setMaxAttempts(10) - .setTotalTimeout(Duration.ofHours(1)) - .setInitialRpcTimeout(Duration.ofSeconds(10)) + .setTotalTimeoutDuration(Duration.ofHours(1)) + .setInitialRpcTimeoutDuration(Duration.ofSeconds(10)) .setRpcTimeoutMultiplier(1) - .setMaxRpcTimeout(Duration.ofSeconds(10)) + .setMaxRpcTimeoutDuration(Duration.ofSeconds(10)) .setJittered(true) .build(); builder .readRowsSettings() - .setIdleTimeout(Duration.ofMinutes(5)) + .setIdleTimeoutDuration(Duration.ofMinutes(5)) .setRetryableCodes(Code.ABORTED, Code.DEADLINE_EXCEEDED) .setRetrySettings(retrySettings) .build(); @@ -240,18 +240,19 @@ public void readRowsIsNotLostTest() { builder.readRowSettings().setRetryableCodes(Code.ABORTED, Code.DEADLINE_EXCEEDED); builder.bulkReadRowsSettings().setRetryableCodes(Code.ABORTED, Code.DEADLINE_EXCEEDED); - assertThat(builder.readRowsSettings().getIdleTimeout()).isEqualTo(Duration.ofMinutes(5)); + assertThat(builder.readRowsSettings().getIdleTimeoutDuration()) + .isEqualTo(Duration.ofMinutes(5)); assertThat(builder.readRowsSettings().getRetryableCodes()) .containsAtLeast(Code.ABORTED, Code.DEADLINE_EXCEEDED); assertThat(builder.readRowsSettings().getRetrySettings()).isEqualTo(retrySettings); - assertThat(builder.build().readRowsSettings().getIdleTimeout()) + assertThat(builder.build().readRowsSettings().getIdleTimeoutDuration()) .isEqualTo(Duration.ofMinutes(5)); assertThat(builder.build().readRowsSettings().getRetryableCodes()) .containsAtLeast(Code.ABORTED, Code.DEADLINE_EXCEEDED); assertThat(builder.build().readRowsSettings().getRetrySettings()).isEqualTo(retrySettings); - assertThat(builder.build().toBuilder().readRowsSettings().getIdleTimeout()) + assertThat(builder.build().toBuilder().readRowsSettings().getIdleTimeoutDuration()) .isEqualTo(Duration.ofMinutes(5)); assertThat(builder.build().toBuilder().readRowsSettings().getRetryableCodes()) .containsAtLeast(Code.ABORTED, Code.DEADLINE_EXCEEDED); @@ -281,10 +282,10 @@ public void readRowIsNotLostTest() { RetrySettings retrySettings = RetrySettings.newBuilder() .setMaxAttempts(10) - .setTotalTimeout(Duration.ofHours(1)) - .setInitialRpcTimeout(Duration.ofSeconds(10)) + .setTotalTimeoutDuration(Duration.ofHours(1)) + .setInitialRpcTimeoutDuration(Duration.ofSeconds(10)) .setRpcTimeoutMultiplier(1) - .setMaxRpcTimeout(Duration.ofSeconds(10)) + .setMaxRpcTimeoutDuration(Duration.ofSeconds(10)) .setJittered(true) .build(); @@ -369,10 +370,10 @@ public void sampleRowKeysSettingsAreNotLostTest() { RetrySettings retrySettings = RetrySettings.newBuilder() .setMaxAttempts(10) - .setTotalTimeout(Duration.ofHours(1)) - .setInitialRpcTimeout(Duration.ofSeconds(10)) + .setTotalTimeoutDuration(Duration.ofHours(1)) + .setInitialRpcTimeoutDuration(Duration.ofSeconds(10)) .setRpcTimeoutMultiplier(1) - .setMaxRpcTimeout(Duration.ofSeconds(10)) + .setMaxRpcTimeoutDuration(Duration.ofSeconds(10)) .setJittered(true) .build(); @@ -417,10 +418,10 @@ public void mutateRowSettingsAreNotLostTest() { RetrySettings retrySettings = RetrySettings.newBuilder() .setMaxAttempts(10) - .setTotalTimeout(Duration.ofHours(1)) - .setInitialRpcTimeout(Duration.ofSeconds(10)) + .setTotalTimeoutDuration(Duration.ofHours(1)) + .setInitialRpcTimeoutDuration(Duration.ofSeconds(10)) .setRpcTimeoutMultiplier(1) - .setMaxRpcTimeout(Duration.ofSeconds(10)) + .setMaxRpcTimeoutDuration(Duration.ofSeconds(10)) .setJittered(true) .build(); @@ -467,10 +468,10 @@ public void bulkMutateRowsSettingsAreNotLostTest() { RetrySettings retrySettings = RetrySettings.newBuilder() .setMaxAttempts(10) - .setTotalTimeout(Duration.ofHours(1)) - .setInitialRpcTimeout(Duration.ofSeconds(10)) + .setTotalTimeoutDuration(Duration.ofHours(1)) + .setInitialRpcTimeoutDuration(Duration.ofSeconds(10)) .setRpcTimeoutMultiplier(1) - .setMaxRpcTimeout(Duration.ofSeconds(10)) + .setMaxRpcTimeoutDuration(Duration.ofSeconds(10)) .setJittered(true) .build(); @@ -579,10 +580,10 @@ public void bulkReadRowsSettingsAreNotLostTest() { RetrySettings retrySettings = RetrySettings.newBuilder() .setMaxAttempts(10) - .setTotalTimeout(Duration.ofHours(1)) - .setInitialRpcTimeout(Duration.ofSeconds(10)) + .setTotalTimeoutDuration(Duration.ofHours(1)) + .setInitialRpcTimeoutDuration(Duration.ofSeconds(10)) .setRpcTimeoutMultiplier(1) - .setMaxRpcTimeout(Duration.ofSeconds(10)) + .setMaxRpcTimeoutDuration(Duration.ofSeconds(10)) .setJittered(true) .build(); @@ -626,7 +627,7 @@ public void mutateRowsHasSaneDefaultsTest() { verifyRetrySettingAreSane(builder.getRetryableCodes(), builder.getRetrySettings()); - assertThat(builder.getBatchingSettings().getDelayThreshold()) + assertThat(builder.getBatchingSettings().getDelayThresholdDuration()) .isIn(Range.open(Duration.ZERO, Duration.ofMinutes(1))); assertThat(builder.getBatchingSettings().getElementCountThreshold()) .isIn(Range.open(0L, 1_000L)); @@ -768,7 +769,8 @@ public void pingAndWarmRetriesAreDisabled() { EnhancedBigtableStubSettings.newBuilder().pingAndWarmSettings(); assertThat(builder.getRetrySettings().getMaxAttempts()).isAtMost(1); - assertThat(builder.getRetrySettings().getInitialRpcTimeout()).isAtMost(Duration.ofSeconds(30)); + assertThat(builder.getRetrySettings().getInitialRpcTimeoutDuration()) + .isAtMost(Duration.ofSeconds(30)); } @Test @@ -789,34 +791,35 @@ public void executeQuerySettingsAreNotLost() { RetrySettings retrySettings = RetrySettings.newBuilder() .setMaxAttempts(10) - .setTotalTimeout(Duration.ofHours(1)) - .setInitialRpcTimeout(Duration.ofSeconds(10)) + .setTotalTimeoutDuration(Duration.ofHours(1)) + .setInitialRpcTimeoutDuration(Duration.ofSeconds(10)) .setRpcTimeoutMultiplier(1) - .setMaxRpcTimeout(Duration.ofSeconds(10)) + .setMaxRpcTimeoutDuration(Duration.ofSeconds(10)) .setJittered(true) .build(); builder .executeQuerySettings() - .setIdleTimeout(Duration.ofMinutes(5)) + .setIdleTimeoutDuration(Duration.ofMinutes(5)) .setRetryableCodes(Code.ABORTED, Code.DEADLINE_EXCEEDED) .setRetrySettings(retrySettings) .build(); builder.executeQuerySettings().setRetryableCodes(Code.ABORTED, Code.DEADLINE_EXCEEDED); - assertThat(builder.executeQuerySettings().getIdleTimeout()).isEqualTo(Duration.ofMinutes(5)); + assertThat(builder.executeQuerySettings().getIdleTimeoutDuration()) + .isEqualTo(Duration.ofMinutes(5)); assertThat(builder.executeQuerySettings().getRetryableCodes()) .containsAtLeast(Code.ABORTED, Code.DEADLINE_EXCEEDED); assertThat(builder.executeQuerySettings().getRetrySettings()).isEqualTo(retrySettings); - assertThat(builder.build().executeQuerySettings().getIdleTimeout()) + assertThat(builder.build().executeQuerySettings().getIdleTimeoutDuration()) .isEqualTo(Duration.ofMinutes(5)); assertThat(builder.build().executeQuerySettings().getRetryableCodes()) .containsAtLeast(Code.ABORTED, Code.DEADLINE_EXCEEDED); assertThat(builder.build().executeQuerySettings().getRetrySettings()).isEqualTo(retrySettings); - assertThat(builder.build().toBuilder().executeQuerySettings().getIdleTimeout()) + assertThat(builder.build().toBuilder().executeQuerySettings().getIdleTimeoutDuration()) .isEqualTo(Duration.ofMinutes(5)); assertThat(builder.build().toBuilder().executeQuerySettings().getRetryableCodes()) .containsAtLeast(Code.ABORTED, Code.DEADLINE_EXCEEDED); @@ -832,8 +835,10 @@ public void executeQueryHasSaneDefaults() { // Retries aren't supported right now // call verifyRetrySettingAreSane when we do assertThat(builder.getRetryableCodes()).containsExactlyElementsIn(Collections.emptySet()); - assertThat(builder.getRetrySettings().getInitialRpcTimeout()).isEqualTo(Duration.ofSeconds(30)); - assertThat(builder.getRetrySettings().getMaxRpcTimeout()).isEqualTo(Duration.ofSeconds(30)); + assertThat(builder.getRetrySettings().getInitialRpcTimeoutDuration()) + .isEqualTo(Duration.ofSeconds(30)); + assertThat(builder.getRetrySettings().getMaxRpcTimeoutDuration()) + .isEqualTo(Duration.ofSeconds(30)); assertThat(builder.getRetrySettings().getMaxAttempts()).isEqualTo(1); } @@ -843,21 +848,22 @@ public void executeQueryRetriesAreDisabled() { EnhancedBigtableStubSettings.newBuilder().executeQuerySettings(); assertThat(builder.getRetrySettings().getMaxAttempts()).isAtMost(1); - assertThat(builder.getRetrySettings().getInitialRpcTimeout()).isAtMost(Duration.ofSeconds(30)); + assertThat(builder.getRetrySettings().getInitialRpcTimeoutDuration()) + .isAtMost(Duration.ofSeconds(30)); } private void verifyRetrySettingAreSane(Set retryCodes, RetrySettings retrySettings) { assertThat(retryCodes).containsAtLeast(Code.DEADLINE_EXCEEDED, Code.UNAVAILABLE); - assertThat(retrySettings.getTotalTimeout()).isGreaterThan(Duration.ZERO); + assertThat(retrySettings.getTotalTimeoutDuration()).isGreaterThan(Duration.ZERO); - assertThat(retrySettings.getInitialRetryDelay()).isGreaterThan(Duration.ZERO); + assertThat(retrySettings.getInitialRetryDelayDuration()).isGreaterThan(Duration.ZERO); assertThat(retrySettings.getRetryDelayMultiplier()).isAtLeast(1.0); - assertThat(retrySettings.getMaxRetryDelay()).isGreaterThan(Duration.ZERO); + assertThat(retrySettings.getMaxRetryDelayDuration()).isGreaterThan(Duration.ZERO); - assertThat(retrySettings.getInitialRpcTimeout()).isGreaterThan(Duration.ZERO); + assertThat(retrySettings.getInitialRpcTimeoutDuration()).isGreaterThan(Duration.ZERO); assertThat(retrySettings.getRpcTimeoutMultiplier()).isAtLeast(1.0); - assertThat(retrySettings.getMaxRpcTimeout()).isGreaterThan(Duration.ZERO); + assertThat(retrySettings.getMaxRpcTimeoutDuration()).isGreaterThan(Duration.ZERO); } @Test diff --git a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/stub/EnhancedBigtableStubTest.java b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/stub/EnhancedBigtableStubTest.java index 495250fe13..1adf37b6da 100644 --- a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/stub/EnhancedBigtableStubTest.java +++ b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/stub/EnhancedBigtableStubTest.java @@ -118,6 +118,7 @@ import java.security.KeyPair; import java.security.KeyPairGenerator; import java.security.NoSuchAlgorithmException; +import java.time.Duration; import java.util.Base64; import java.util.Collection; import java.util.Iterator; @@ -132,7 +133,6 @@ import org.junit.runner.RunWith; import org.junit.runners.JUnit4; import org.mockito.Mockito; -import org.threeten.bp.Duration; @RunWith(JUnit4.class) public class EnhancedBigtableStubTest { @@ -599,7 +599,7 @@ public void testCallContextPropagatedInMutationBatcher() // Override the timeout GrpcCallContext clientCtx = - GrpcCallContext.createDefault().withTimeout(Duration.ofMinutes(10)); + GrpcCallContext.createDefault().withTimeoutDuration(Duration.ofMinutes(10)); // Send a batch try (Batcher batcher = @@ -630,7 +630,7 @@ public void testCallContextPropagatedInReadBatcher() // Override the timeout GrpcCallContext clientCtx = - GrpcCallContext.createDefault().withTimeout(Duration.ofMinutes(10)); + GrpcCallContext.createDefault().withTimeoutDuration(Duration.ofMinutes(10)); // Send a batch try (Batcher batcher = @@ -692,9 +692,9 @@ public void testBulkMutationFlowControlFeatureFlagIsNotSet() throws Exception { public void testWaitTimeoutIsSet() throws Exception { EnhancedBigtableStubSettings.Builder settings = defaultSettings.toBuilder(); // Set a shorter wait timeout and make watchdog checks more frequently - settings.readRowsSettings().setWaitTimeout(WATCHDOG_CHECK_DURATION.dividedBy(2)); + settings.readRowsSettings().setWaitTimeoutDuration(WATCHDOG_CHECK_DURATION.dividedBy(2)); settings.setStreamWatchdogProvider( - InstantiatingWatchdogProvider.create().withCheckInterval(WATCHDOG_CHECK_DURATION)); + InstantiatingWatchdogProvider.create().withCheckIntervalDuration(WATCHDOG_CHECK_DURATION)); try (EnhancedBigtableStub stub = EnhancedBigtableStub.create(settings.build())) { ServerStream results = stub.readRowsCallable().call(Query.create(WAIT_TIME_TABLE_ID)); @@ -709,9 +709,11 @@ public void testWaitTimeoutIsSet() throws Exception { public void testReadChangeStreamWaitTimeoutIsSet() throws Exception { EnhancedBigtableStubSettings.Builder settings = defaultSettings.toBuilder(); // Set a shorter wait timeout and make watchdog checks more frequently - settings.readChangeStreamSettings().setWaitTimeout(WATCHDOG_CHECK_DURATION.dividedBy(2)); + settings + .readChangeStreamSettings() + .setWaitTimeoutDuration(WATCHDOG_CHECK_DURATION.dividedBy(2)); settings.setStreamWatchdogProvider( - InstantiatingWatchdogProvider.create().withCheckInterval(WATCHDOG_CHECK_DURATION)); + InstantiatingWatchdogProvider.create().withCheckIntervalDuration(WATCHDOG_CHECK_DURATION)); try (EnhancedBigtableStub stub = EnhancedBigtableStub.create(settings.build())) { ServerStream results = @@ -805,9 +807,9 @@ public void testCreateExecuteQueryCallable() throws InterruptedException { public void testExecuteQueryWaitTimeoutIsSet() throws IOException { EnhancedBigtableStubSettings.Builder settings = defaultSettings.toBuilder(); // Set a shorter wait timeout and make watchdog checks more frequently - settings.executeQuerySettings().setWaitTimeout(WATCHDOG_CHECK_DURATION.dividedBy(2)); + settings.executeQuerySettings().setWaitTimeoutDuration(WATCHDOG_CHECK_DURATION.dividedBy(2)); settings.setStreamWatchdogProvider( - InstantiatingWatchdogProvider.create().withCheckInterval(WATCHDOG_CHECK_DURATION)); + InstantiatingWatchdogProvider.create().withCheckIntervalDuration(WATCHDOG_CHECK_DURATION)); EnhancedBigtableStub stub = EnhancedBigtableStub.create(settings.build()); Iterator iterator = @@ -821,9 +823,9 @@ public void testExecuteQueryWaitTimeoutWorksWithMetadataFuture() throws IOException, InterruptedException { EnhancedBigtableStubSettings.Builder settings = defaultSettings.toBuilder(); // Set a shorter wait timeout and make watchdog checks more frequently - settings.executeQuerySettings().setWaitTimeout(WATCHDOG_CHECK_DURATION.dividedBy(2)); + settings.executeQuerySettings().setWaitTimeoutDuration(WATCHDOG_CHECK_DURATION.dividedBy(2)); settings.setStreamWatchdogProvider( - InstantiatingWatchdogProvider.create().withCheckInterval(WATCHDOG_CHECK_DURATION)); + InstantiatingWatchdogProvider.create().withCheckIntervalDuration(WATCHDOG_CHECK_DURATION)); EnhancedBigtableStub stub = EnhancedBigtableStub.create(settings.build()); ApiFuture future = diff --git a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/stub/RateLimitingCallableTest.java b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/stub/RateLimitingCallableTest.java index f2fe77725d..652049b266 100644 --- a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/stub/RateLimitingCallableTest.java +++ b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/stub/RateLimitingCallableTest.java @@ -36,12 +36,12 @@ import com.google.protobuf.Duration; import com.google.rpc.Code; import com.google.rpc.Status; +import java.time.Instant; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; import org.mockito.Mockito; -import org.threeten.bp.Instant; @RunWith(JUnit4.class) public class RateLimitingCallableTest { @@ -72,7 +72,7 @@ public void testUpdateRate() throws Exception { callableToTest.call(request, responseObserver, context); callableToTest.setLimiterEnabled(true); - Instant earlier = Instant.now().minus(org.threeten.bp.Duration.ofHours(1)); + Instant earlier = Instant.now().minus(java.time.Duration.ofHours(1)); // Make sure rate will be updated. callableToTest.getNextRateUpdateTime().set(earlier); @@ -105,7 +105,7 @@ public void testNoRateLimitInfoDoesNotUpdateRate() throws Exception { callableToTest.call(request, responseObserver, context); callableToTest.setLimiterEnabled(true); - Instant earlier = Instant.now().minus(org.threeten.bp.Duration.ofHours(1)); + Instant earlier = Instant.now().minus(java.time.Duration.ofHours(1)); // Make sure rate will be updated. callableToTest.getNextRateUpdateTime().set(earlier); @@ -131,7 +131,7 @@ public void testInvalidRateLimitInfoDoesNotUpdateRate() throws Exception { callableToTest.call(request, responseObserver, context); callableToTest.setLimiterEnabled(true); - Instant earlier = Instant.now().minus(org.threeten.bp.Duration.ofHours(1)); + Instant earlier = Instant.now().minus(java.time.Duration.ofHours(1)); // make sure QPS will be updated callableToTest.getNextRateUpdateTime().set(earlier); @@ -166,7 +166,7 @@ public void testMissingRateLimitInfoFactorDoesNotUpdateRate() throws Exception { callableToTest.call(request, responseObserver, context); callableToTest.setLimiterEnabled(true); - Instant earlier = Instant.now().minus(org.threeten.bp.Duration.ofHours(1)); + Instant earlier = Instant.now().minus(java.time.Duration.ofHours(1)); // Make sure rate can be updated. callableToTest.getNextRateUpdateTime().set(earlier); @@ -199,7 +199,7 @@ public void testNoUpdateBeforeAllowedTime() throws Exception { callableToTest.call(request, responseObserver, context); callableToTest.setLimiterEnabled(true); - Instant later = Instant.now().plus(org.threeten.bp.Duration.ofHours(1)); + Instant later = Instant.now().plus(java.time.Duration.ofHours(1)); // Make sure rate will not be updated. callableToTest.getNextRateUpdateTime().set(later); double oldQps = callableToTest.getCurrentRate(); @@ -232,7 +232,7 @@ public void testDoesNotDisableBeforeAllowedTime() throws Exception { callableToTest.call(request, responseObserver, context); callableToTest.setLimiterEnabled(true); - Instant later = Instant.now().plus(org.threeten.bp.Duration.ofHours(1)); + Instant later = Instant.now().plus(java.time.Duration.ofHours(1)); // Make sure limiter will not be disabled. callableToTest.getNextRateUpdateTime().set(later); double oldQps = callableToTest.getCurrentRate(); @@ -257,7 +257,7 @@ public void testEnableWithinPeriodDoesNotUpdateRate() throws Exception { callableToTest.call(request, responseObserver, context); callableToTest.setRate(1.5); - Instant later = Instant.now().plus(org.threeten.bp.Duration.ofHours(1)); + Instant later = Instant.now().plus(java.time.Duration.ofHours(1)); // Even though the rate update time is far in the future, enable is always allowed. callableToTest.getNextRateUpdateTime().set(later); double oldQps = callableToTest.getCurrentRate(); @@ -289,7 +289,7 @@ public void testEnableWithinPeriodDoesNotUpdateRate() throws Exception { public void testErrorInfoLowerQPS() throws Exception { callableToTest.call(request, responseObserver, context); - Instant earlier = Instant.now().minus(org.threeten.bp.Duration.ofHours(1)); + Instant earlier = Instant.now().minus(java.time.Duration.ofHours(1)); // make sure QPS will be updated callableToTest.getNextRateUpdateTime().set(earlier); diff --git a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/stub/changestream/ChangeStreamRecordMergingCallableTest.java b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/stub/changestream/ChangeStreamRecordMergingCallableTest.java index f0939fb0cf..c34173edea 100644 --- a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/stub/changestream/ChangeStreamRecordMergingCallableTest.java +++ b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/stub/changestream/ChangeStreamRecordMergingCallableTest.java @@ -33,13 +33,13 @@ import com.google.protobuf.ByteString; import com.google.protobuf.Timestamp; import com.google.rpc.Status; +import java.time.Instant; import java.util.Collections; import java.util.List; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; -import org.threeten.bp.Instant; /** * Additional tests in addition to {@link ReadChangeStreamMergingAcceptanceTest}. @@ -80,7 +80,7 @@ public void heartbeatTest() { .isEqualTo(ByteStringRange.create(rowRange.getStartKeyClosed(), rowRange.getEndKeyOpen())); assertThat(heartbeat.getChangeStreamContinuationToken().getToken()) .isEqualTo(heartbeatProto.getContinuationToken().getToken()); - assertThat(heartbeat.getEstimatedLowWatermark()) + assertThat(heartbeat.getEstimatedLowWatermarkInstant()) .isEqualTo( Instant.ofEpochSecond( heartbeatProto.getEstimatedLowWatermark().getSeconds(), diff --git a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/stub/changestream/ReadChangeStreamRetryTest.java b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/stub/changestream/ReadChangeStreamRetryTest.java index 48a62bfee8..cb6d4a9432 100644 --- a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/stub/changestream/ReadChangeStreamRetryTest.java +++ b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/stub/changestream/ReadChangeStreamRetryTest.java @@ -51,6 +51,7 @@ import io.grpc.stub.StreamObserver; import io.grpc.testing.GrpcServerRule; import java.io.IOException; +import java.time.Instant; import java.util.Collections; import java.util.List; import java.util.Queue; @@ -62,7 +63,6 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; -import org.threeten.bp.Instant; @RunWith(JUnit4.class) public class ReadChangeStreamRetryTest { @@ -392,7 +392,7 @@ public void retryRstStreamExceptionTest() { private List getResults() { ReadChangeStreamQuery query = - ReadChangeStreamQuery.create(TABLE_ID).startTime(REQUEST_START_TIME); + ReadChangeStreamQuery.create(TABLE_ID).startTimeInstant(REQUEST_START_TIME); // Always give it this partition. We don't care. ServerStream actualRecords = client.readChangeStream(query.streamPartition(START_KEY_CLOSED, END_KEY_OPEN)); diff --git a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/stub/changestream/ReadChangeStreamUserCallableTest.java b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/stub/changestream/ReadChangeStreamUserCallableTest.java index 84f9765ea6..5eb154ca86 100644 --- a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/stub/changestream/ReadChangeStreamUserCallableTest.java +++ b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/stub/changestream/ReadChangeStreamUserCallableTest.java @@ -21,11 +21,11 @@ import com.google.cloud.bigtable.data.v2.models.ReadChangeStreamQuery; import com.google.cloud.bigtable.gaxx.testing.FakeStreamingApi.ServerStreamingStashCallable; import com.google.common.truth.Truth; +import java.time.Duration; +import java.time.Instant; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; -import org.threeten.bp.Duration; -import org.threeten.bp.Instant; @RunWith(JUnit4.class) public class ReadChangeStreamUserCallableTest { @@ -41,9 +41,9 @@ public void testRequestIsConverted() { ReadChangeStreamQuery query = ReadChangeStreamQuery.create("fake-table") .streamPartition("begin", "end") - .startTime(Instant.ofEpochSecond(0L, 1000L)) - .endTime(Instant.ofEpochSecond(0L, 2000L)) - .heartbeatDuration(Duration.ofSeconds(1)); + .startTimeInstant(Instant.ofEpochSecond(0L, 1000L)) + .endTimeInstant(Instant.ofEpochSecond(0L, 2000L)) + .heartbeatDurationDuration(Duration.ofSeconds(1)); callable.call(query); Truth.assertThat(innerCallable.getActualRequest()).isEqualTo(query.toProto(REQUEST_CONTEXT)); } diff --git a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/stub/metrics/CompositeTracerTest.java b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/stub/metrics/CompositeTracerTest.java index cb0916ad28..2bd4f8fd0e 100644 --- a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/stub/metrics/CompositeTracerTest.java +++ b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/stub/metrics/CompositeTracerTest.java @@ -29,6 +29,7 @@ import io.grpc.Status; import io.grpc.StatusRuntimeException; import java.lang.reflect.Method; +import java.time.Duration; import java.util.Arrays; import org.junit.Assert; import org.junit.Before; @@ -39,7 +40,6 @@ import org.mockito.Mock; import org.mockito.junit.MockitoJUnit; import org.mockito.junit.MockitoRule; -import org.threeten.bp.Duration; @RunWith(JUnit4.class) public class CompositeTracerTest { @@ -149,11 +149,11 @@ public void testAttemptCancelled() { public void testAttemptFailed() { RuntimeException error = new RuntimeException(); Duration delay = Duration.ofMillis(10); - compositeTracer.attemptFailed(error, delay); - verify(child1, times(1)).attemptFailed(error, delay); - verify(child2, times(1)).attemptFailed(error, delay); - verify(child3, times(1)).attemptFailed(error, delay); - verify(child4, times(1)).attemptFailed(error, delay); + compositeTracer.attemptFailedDuration(error, delay); + verify(child1, times(1)).attemptFailedDuration(error, delay); + verify(child2, times(1)).attemptFailedDuration(error, delay); + verify(child3, times(1)).attemptFailedDuration(error, delay); + verify(child4, times(1)).attemptFailedDuration(error, delay); } @Test diff --git a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/stub/mutaterows/MutateRowsAttemptCallableTest.java b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/stub/mutaterows/MutateRowsAttemptCallableTest.java index 6dd1ff9bd0..60ec5193e4 100644 --- a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/stub/mutaterows/MutateRowsAttemptCallableTest.java +++ b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/stub/mutaterows/MutateRowsAttemptCallableTest.java @@ -41,6 +41,7 @@ import com.google.common.collect.Lists; import com.google.protobuf.ByteString; import com.google.rpc.Status; +import java.time.Duration; import java.util.List; import java.util.Set; import java.util.concurrent.Callable; @@ -49,7 +50,6 @@ import org.junit.runner.RunWith; import org.junit.runners.JUnit4; import org.mockito.Mockito; -import org.threeten.bp.Duration; @RunWith(JUnit4.class) public class MutateRowsAttemptCallableTest { @@ -140,7 +140,7 @@ public void missingEntry() throws Exception { @Test public void testNoRpcTimeout() { parentFuture.timedAttemptSettings = - parentFuture.timedAttemptSettings.toBuilder().setRpcTimeout(Duration.ZERO).build(); + parentFuture.timedAttemptSettings.toBuilder().setRpcTimeoutDuration(Duration.ZERO).build(); MutateRowsRequest request = MutateRowsRequest.newBuilder().addEntries(Entry.getDefaultInstance()).build(); @@ -405,12 +405,13 @@ static class MockRetryingFuture extends AbstractApiFuture 0) { - settings.setInitialRpcTimeout(newTimeout).setMaxRpcTimeout(newTimeout); + settings.setInitialRpcTimeout(newTimeout).setMaxRpcTimeoutDuration(newTimeout); } - settings.setTotalTimeout(newTimeout); + settings.setTotalTimeoutDuration(newTimeout); } /** Helper method to get a client object by its id. */ @@ -180,7 +179,7 @@ public synchronized void createClient( .setAppProfileId(request.getAppProfileId()); if (request.hasPerOperationTimeout()) { - Duration newTimeout = Duration.ofMillis(Durations.toMillis(request.getPerOperationTimeout())); + java.time.Duration newTimeout = java.time.Duration.ofMillis(Durations.toMillis(request.getPerOperationTimeout())); settingsBuilder = overrideTimeoutSetting(newTimeout, settingsBuilder); logger.info( String.format( diff --git a/test-proxy/src/main/java/com/google/cloud/bigtable/testproxy/ResultSetSerializer.java b/test-proxy/src/main/java/com/google/cloud/bigtable/testproxy/ResultSetSerializer.java index c138c82a6b..e2ec0307c0 100644 --- a/test-proxy/src/main/java/com/google/cloud/bigtable/testproxy/ResultSetSerializer.java +++ b/test-proxy/src/main/java/com/google/cloud/bigtable/testproxy/ResultSetSerializer.java @@ -35,7 +35,6 @@ import com.google.protobuf.ByteString; import java.util.List; import java.util.concurrent.ExecutionException; -import org.threeten.bp.Instant; public class ResultSetSerializer { public static ExecuteQueryResult toExecuteQueryResult(ResultSet resultSet) diff --git a/test-proxy/src/main/java/com/google/cloud/bigtable/testproxy/StatementDeserializer.java b/test-proxy/src/main/java/com/google/cloud/bigtable/testproxy/StatementDeserializer.java index ae3b50aa7f..9fddbf05c0 100644 --- a/test-proxy/src/main/java/com/google/cloud/bigtable/testproxy/StatementDeserializer.java +++ b/test-proxy/src/main/java/com/google/cloud/bigtable/testproxy/StatementDeserializer.java @@ -24,7 +24,6 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; -import org.threeten.bp.Instant; public class StatementDeserializer {