Skip to content

Commit

Permalink
Renaming new SessionRetryOptionsBuilder settings (#37240)
Browse files Browse the repository at this point in the history
* Renaming new SessionRetryOptionsBuilder settings

* Update CHANGELOG.md
  • Loading branch information
FabianMeiswinkel authored Oct 19, 2023
1 parent 1f57b9f commit 7a7670d
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4181,7 +4181,7 @@ private static CosmosAsyncClient buildCosmosClient(
.regionSwitchHint(effectiveRegionSwitchHint);

if (customMinRetryTimeInLocalRegionForWrites != null) {
retryOptionsBuilder.minInRegionRetryTime(customMinRetryTimeInLocalRegionForWrites);
retryOptionsBuilder.minTimeoutPerRegion(customMinRetryTimeInLocalRegionForWrites);
}

CosmosClientBuilder builder = new CosmosClientBuilder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ public void SessionRetryOptionsBuilder_defaultValues() {
public void SessionRetryOptionsBuilder_customValues() {
SessionRetryOptions optionsWithDefaultValues = new SessionRetryOptionsBuilder()
.regionSwitchHint(CosmosRegionSwitchHint.REMOTE_REGION_PREFERRED)
.minInRegionRetryTime(Duration.ofSeconds(1))
.maxInRegionRetryCount(3)
.minTimeoutPerRegion(Duration.ofSeconds(1))
.maxRetriesPerRegion(3)
.build();

assertThat(sessionRetryOptionsAccessor.getMaxInRegionRetryCount(optionsWithDefaultValues))
Expand All @@ -144,7 +144,7 @@ public void SessionRetryOptionsBuilder_customValues() {
public void SessionRetryOptionsBuilder_minimum_maxRetryCountEnforced() {
SessionRetryOptionsBuilder builder = new SessionRetryOptionsBuilder()
.regionSwitchHint(CosmosRegionSwitchHint.REMOTE_REGION_PREFERRED)
.maxInRegionRetryCount(0);
.maxRetriesPerRegion(0);

try {
builder.build();
Expand All @@ -159,7 +159,7 @@ public void SessionRetryOptionsBuilder_minimum_maxRetryCountEnforced() {
public void SessionRetryOptionsBuilder_minimum_minRetryTimeEnforced() {
SessionRetryOptionsBuilder builder = new SessionRetryOptionsBuilder()
.regionSwitchHint(CosmosRegionSwitchHint.REMOTE_REGION_PREFERRED)
.minInRegionRetryTime(Duration.ofMillis(99));
.minTimeoutPerRegion(Duration.ofMillis(99));

try {
builder.build();
Expand All @@ -174,7 +174,7 @@ public void SessionRetryOptionsBuilder_minimum_minRetryTimeEnforced() {
public void SessionRetryOptionsBuilder_minRetryTimeRequired() {
SessionRetryOptionsBuilder builder = new SessionRetryOptionsBuilder()
.regionSwitchHint(CosmosRegionSwitchHint.REMOTE_REGION_PREFERRED)
.minInRegionRetryTime(null);
.minTimeoutPerRegion(null);

try {
builder.build();
Expand Down
1 change: 1 addition & 0 deletions sdk/cosmos/azure-cosmos/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
### 4.52.0-beta.1 (Unreleased)

#### Features Added
* Added an option to configure the minimum retry duration for 404/1002 session not available. - See [PR 37143](https://github.com/Azure/azure-sdk-for-java/pull/37143) and [PR 37240](https://github.com/Azure/azure-sdk-for-java/pull/37240)

#### Breaking Changes

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,23 +44,23 @@ public SessionRetryOptionsBuilder regionSwitchHint(CosmosRegionSwitchHint region
* value is 100ms - this minimum is enforced to provide a way for the local region to catch-up on replication lag.
* The default value is 500ms - as a recommendation ensure that this value is higher than the steady-state
* replication latency between the regions you chose.
* @param minRetryTime the min retry time to be used with-in each region
* @param minTimeoutPerRegion the min retry time to be used with-in each region
* @return This instance of {@link SessionRetryOptionsBuilder}
*/
public SessionRetryOptionsBuilder minInRegionRetryTime(Duration minRetryTime) {
this.minInRegionRetryTime = minRetryTime;
public SessionRetryOptionsBuilder minTimeoutPerRegion(Duration minTimeoutPerRegion) {
this.minInRegionRetryTime = minTimeoutPerRegion;
return this;
}

/**
* Sets the maximum number of retries within each region for read and write operations. The minimum
* value is 1 - the backoff time for the last in-region retry will ensure that the total retry time within the
* region is at least the min. in-region retry time.
* @param maxInRegionRetryCount the max. number of retries with-in each region
* @param maxRetriesPerRegion the max. number of retries with-in each region
* @return This instance of {@link SessionRetryOptionsBuilder}
*/
public SessionRetryOptionsBuilder maxInRegionRetryCount(int maxInRegionRetryCount) {
this.maxInRegionRetryCount = maxInRegionRetryCount;
public SessionRetryOptionsBuilder maxRetriesPerRegion(int maxRetriesPerRegion) {
this.maxInRegionRetryCount = maxRetriesPerRegion;
return this;
}

Expand Down

0 comments on commit 7a7670d

Please sign in to comment.