Skip to content
This repository was archived by the owner on Sep 26, 2023. It is now read-only.

Moving new Batcher API to existing Batching package#771

Merged
igorbernstein2 merged 3 commits intogoogleapis:masterfrom
rahulKQL:moveBatcher
Aug 13, 2019
Merged

Moving new Batcher API to existing Batching package#771
igorbernstein2 merged 3 commits intogoogleapis:masterfrom
rahulKQL:moveBatcher

Conversation

@rahulKQL
Copy link
Copy Markdown
Contributor

@rahulKQL rahulKQL commented Aug 8, 2019

To provide backward compatibility to stable clients( eg. google-cloud-PubSub), we are moving the new Batcher API into the existing batching package. Now BatcherImpl will also adapt to existing configuration classesBatchingSettings & FlowControlSettings.

What this change contains

  • Moved files related to new Batcher API.
  • Renamed to v2.RequestBuilder to BatchingRequestBuilder.
  • Adapted BatcherImpl to existing BatchingSettings.
  • In case elementCountThreshold or requestByteCountThreshold is null, then using 0 as threshold level.
  • In case delayThreshold value is unset, we are not setting any scheduler to auto flush the accumulated elements.

cc: @igorbernstein2

 - Renamed to `v2.RequestBuilder` to `BatchingRequestBuilder`.
 - Adapted to existing BatchingSettings.
 - In case ElementCountThreshold or RequestByteCountThreshold is null, then using 0 as threshold level.
 - Defaulting to 1ms in case delayThreshold value is unset.
@rahulKQL rahulKQL requested a review from igorbernstein2 August 8, 2019 15:25
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Aug 8, 2019
Comment thread gax/src/main/java/com/google/api/gax/batching/BatcherImpl.java Outdated
 - Cancelling the auto flush in case delaythreshold is unset by user.
@codecov
Copy link
Copy Markdown

codecov Bot commented Aug 8, 2019

Codecov Report

Merging #771 into master will increase coverage by <.01%.
The diff coverage is 85.71%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #771      +/-   ##
============================================
+ Coverage     78.15%   78.15%   +<.01%     
+ Complexity     1101     1099       -2     
============================================
  Files           198      197       -1     
  Lines          4833     4825       -8     
  Branches        383      381       -2     
============================================
- Hits           3777     3771       -6     
  Misses          886      886              
+ Partials        170      168       -2
Impacted Files Coverage Δ Complexity Δ
.../java/com/google/api/gax/batching/BatcherImpl.java 99.07% <85.71%> (ø) 13 <0> (?)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update abccf48...7c9482e. Read the comment docs.

@codecov
Copy link
Copy Markdown

codecov Bot commented Aug 8, 2019

Codecov Report

Merging #771 into master will increase coverage by 0.04%.
The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #771      +/-   ##
============================================
+ Coverage     78.15%   78.19%   +0.04%     
+ Complexity     1101     1100       -1     
============================================
  Files           198      197       -1     
  Lines          4833     4825       -8     
  Branches        383      380       -3     
============================================
- Hits           3777     3773       -4     
  Misses          886      886              
+ Partials        170      166       -4
Impacted Files Coverage Δ Complexity Δ
.../java/com/google/api/gax/batching/BatcherImpl.java 100% <100%> (ø) 14 <0> (?)
.../com/google/api/gax/batching/BatchingSettings.java 85.71% <0%> (+4.76%) 2% <0%> (ø) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update abccf48...6e1e461. Read the comment docs.

@rahulKQL
Copy link
Copy Markdown
Contributor Author

rahulKQL commented Aug 9, 2019

@vam-google Please have a look and let us know your thoughts.

@rahulKQL rahulKQL requested a review from igorbernstein2 August 9, 2019 14:34
Copy link
Copy Markdown
Contributor

@igorbernstein2 igorbernstein2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, @vam-google please take a look

.setElementCountThreshold(0)
.setRequestByteThreshold(0)
.setDelayThreshold(Duration.ofMillis(1))
.setElementCountThreshold(null)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For my understanding, what is the difference between 0 and null? What is the behavior if you don't call any of these setters?

Copy link
Copy Markdown
Contributor Author

@rahulKQL rahulKQL Aug 12, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Behaviorwise there is no difference, Both of these values are to disable the thresholds.

Earlier we were using v2.BatchingSettings which had primitive long that's why we used 0 for disabling, Now that we are utilizing existing BatchingSettings which allows null or greater than 0 values only So we kept the disabling with null value.

If we don't call any setter than the default values provided in the BatchingSettings will be used which is 1 element, 1 byte or 1 millisecond. Although each google-cloud-client will have their own default values.

Copy link
Copy Markdown
Contributor

@vam-google vam-google left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM but with one question (can be either important or no, depending on the answer =).

.setElementCountThreshold(1000L)
.setRequestByteThreshold(1000L)
.setElementCountThreshold(1000)
.setDelayThreshold(Duration.ofSeconds(1))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mybe it is a wrong place to looks at it, but PR description says:
"Defaulting to 1ms in case delayThreshold value is unset."
Here is seems like it defaults to 1 sec. Is something wrong here or am I just looking in a wrong place?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think rahul forgot to update the description of the PR :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am really sorry, Have updated the description now.
We are not scheduling any auto flush if the delayThreshold is unset.

@igorbernstein2 igorbernstein2 merged commit 0de16d5 into googleapis:master Aug 13, 2019
This was referenced Aug 16, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

cla: yes This human has signed the Contributor License Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants