feat: introduce java.time#2415
Conversation
…ava-bigtable into introduce-java-time
…ds + nanos)" This reverts commit a7746ad.
google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/common/Type.java
Show resolved
Hide resolved
google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/models/sql/SqlType.java
Outdated
Show resolved
Hide resolved
google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/models/sql/Statement.java
Outdated
Show resolved
Hide resolved
...rc/main/java/com/google/cloud/bigtable/data/v2/stub/RateLimitingServerStreamingCallable.java
Show resolved
Hide resolved
mutianf
left a comment
There was a problem hiding this comment.
I reviewed the following:
- common/Type.java
- data/v2/BigtableDataSettings.java
- data/v2/stub
- data/v2/metrics
- gaxx/retrying
- and tests related to these changes.
| } | ||
| } | ||
|
|
||
| public void attemptFailed(Throwable error, Duration delay) { |
There was a problem hiding this comment.
Instead of deleting this method, should attemptFailled call attemptFailedDuration?
There was a problem hiding this comment.
We moved all references in gax to attemptFailedDuration
googleapis/sdk-platform-java#1872
However it still makes sense to keep both. I'll push a commit with this.
There was a problem hiding this comment.
I noticed our tracking sheet has a new comment in there. Confirmed it should be as you pointed out.
| BatchingSettings.newBuilder() | ||
| .setElementCountThreshold(10L) | ||
| .setRequestByteThreshold(20L) | ||
| .setDelayThreshold(Duration.ofMillis(5)) |
There was a problem hiding this comment.
Im wondering if we should keep the test code the same so that we can verify these settings are ported to the new settings correctly? We can leave a todo to update them in a separate PR.
| public void testAttemptFailed() { | ||
| RuntimeException error = new RuntimeException(); | ||
| Duration delay = Duration.ofMillis(10); | ||
| compositeTracer.attemptFailed(error, delay); |
There was a problem hiding this comment.
same here, I think we should keep calling attemptFailed and verify attemptFailedDuration gets called?
jackdingilian
left a comment
There was a problem hiding this comment.
I reviewed the following files and their corresponding tests:
internal/AbstractProtoStructReader.java
internal/ResultSetImpl.java
models/ChangeStreamMutation.java
models/ChangeStreamRecordAdapter.java
models/Heartbeat.java
models/ReadChangeStreamQuery.java
models/sql/SqlType.java
models/sql/Statement.java
models/sql/StructReader.java
changestream/ChangeStreamStateMachine.java
|
|
||
| /** This method is obsolete. Use {@link #setCommitTime(java.time.Instant)} instead. */ | ||
| @ObsoleteApi("Use setCommitTime(java.time.Instant) instead") | ||
| abstract Builder setCommitTimestamp(org.threeten.bp.Instant commitTimestamp); |
There was a problem hiding this comment.
I think it would be better to remove the threeten setter, only store it as java.time.Instant, and then reverse the overload of getCommitTime(stamp) above.
The builder is fully internal, we just need to maintain backwards compatibility for the getter
There was a problem hiding this comment.
Thanks for the catch. This was indeed stated in the tracking sheet. I'll update this as an internal class.
| abstract Builder setToken(@Nonnull String token); | ||
|
|
||
| abstract Builder setEstimatedLowWatermark(Instant estimatedLowWatermark); | ||
| Builder setLowWatermarkTime(java.time.Instant estimatedLowWatermark) { |
There was a problem hiding this comment.
Same question as for commit time. Also if we need to keep both setters this should be 'setEstimatedLowWatermarkTime'
| } | ||
|
|
||
| /** This method is obsolete. Use {@link #setLowWatermarkTime(java.time.Instant)} instead. */ | ||
| @ObsoleteApi("Use setEstimatedLowWatermarkInstant(java.time.Instant) instead") |
There was a problem hiding this comment.
setEstimatedLowWatermarkInstant should be setEstimatedLowWatermarkTime
There was a problem hiding this comment.
This will be removed since it's an internal api change as per #2415 (comment)
|
|
||
| /** This method is obsolete. Use {@link #getEstimatedLowWatermarkInstant()} instead. */ | ||
| @ObsoleteApi("Use getEstimatedLowWatermarkInstant() instead") | ||
| public abstract org.threeten.bp.Instant getEstimatedLowWatermark(); |
There was a problem hiding this comment.
Same question as in ChangeStreamMutation. Wouldn't it be better to store this as java.time.Instant?
|
|
||
| @InternalApi("Intended for use by the BigtableIO in apache/beam only.") | ||
| public abstract Instant getEstimatedLowWatermark(); | ||
| public java.time.Instant getEstimatedLowWatermarkInstant() { |
There was a problem hiding this comment.
In ChangeStreamMutation we call this getEstimatedLowWatermarkTime. We should be consistent w that naming here
There was a problem hiding this comment.
Removed as this is an internal api. I only kept the java.time version
|
|
||
| /** Get the commit timestamp of the current mutation. */ | ||
| public abstract Instant getCommitTimestamp(); | ||
| public abstract java.time.Instant getCommitTimestamp(); |
There was a problem hiding this comment.
We still need the threeten getter here, since this is used by beam users. Same for Heartbeat below
There was a problem hiding this comment.
And for estimatedLowWatermark
|
@jackdingilian thanks for the review and apologies for the misunderstanding. This time I got it right:
|
This PR introduces
java.timealternatives to existingorg.threeten.bp.*methods, as well as switching internal variables (if any) tojava.timeThe main constraint is to keep the changes backwards compatible, so for each existing threeten method "
method1(org.threeten.bp.Duration)" we will add an alternative with a Duration (or Timestamp when applicable) suffix: "method1Duration(java.time.Duration)".For most cases, the implementation will be held in the
java.timemethod and the old threeten method will just delegate the call to it. However, for the case of abstract classes, the implementation will be kept in the threeten method to avoid breaking changes (i.e. users that already overloaded the method in their user code).Note: https://cloud.google.com/bigtable/docs/reference/sql/data-types#timestamp_type implies that nanosecond precision will be ignored.