forked from Azure/azure-sdk-for-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
annie-mac
committed
Nov 25, 2024
1 parent
1ea81e4
commit 1a7890e
Showing
9 changed files
with
203 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
123 changes: 123 additions & 0 deletions
123
sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/Http2ConnectionConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
package com.azure.cosmos; | ||
|
||
import com.azure.cosmos.implementation.Configs; | ||
import com.azure.cosmos.util.Beta; | ||
|
||
@Beta(value = Beta.SinceVersion.V4_66_0, warningText = Beta.PREVIEW_SUBJECT_TO_CHANGE_WARNING) | ||
public class Http2ConnectionConfig { | ||
private static final int DEFAULT_MAX_CONCURRENT_STREAMS = 30; | ||
private static final int DEFAULT_MIN_CONNECTION_POOL_SIZE = 1; | ||
|
||
private int maxConnectionPoolSize; | ||
private int minConnectionPoolSize; | ||
private int maxConcurrentStreams; | ||
private boolean enabled; | ||
|
||
@Beta(value = Beta.SinceVersion.V4_66_0, warningText = Beta.PREVIEW_SUBJECT_TO_CHANGE_WARNING) | ||
public Http2ConnectionConfig() { | ||
this.maxConnectionPoolSize = Configs.getDefaultHttpPoolSize(); // overlapping with the maxConnectionPoolSize in gateway connection config | ||
this.minConnectionPoolSize = DEFAULT_MIN_CONNECTION_POOL_SIZE; | ||
this.maxConcurrentStreams = DEFAULT_MAX_CONCURRENT_STREAMS; | ||
this.enabled = Configs.isHttp2Enabled(); | ||
} | ||
|
||
/*** | ||
* Get the maximum number of live connections to keep in the pool. | ||
* | ||
* @return the configured max number of live connections to keep in the pool. | ||
*/ | ||
@Beta(value = Beta.SinceVersion.V4_66_0, warningText = Beta.PREVIEW_SUBJECT_TO_CHANGE_WARNING) | ||
public Integer getMaxConnectionPoolSize() { | ||
return maxConnectionPoolSize; | ||
} | ||
|
||
/*** | ||
* Configures the maximum number of live connections to keep in the pool. | ||
* If not configured, will be default to 1000. | ||
* | ||
* @param maxConnectionPoolSize the maximum number of live connections to keep in the pool. | ||
* @return the current {@link Http2ConnectionConfig}. | ||
*/ | ||
@Beta(value = Beta.SinceVersion.V4_66_0, warningText = Beta.PREVIEW_SUBJECT_TO_CHANGE_WARNING) | ||
public Http2ConnectionConfig setMaxConnectionPoolSize(int maxConnectionPoolSize) { | ||
this.maxConnectionPoolSize = maxConnectionPoolSize; | ||
return this; | ||
} | ||
|
||
/*** | ||
* Get the maximum number of the concurrent streams that can be opened to the remote peer. | ||
* @return the maximum number of the concurrent streams that can be opened to the remote peer. | ||
*/ | ||
@Beta(value = Beta.SinceVersion.V4_66_0, warningText = Beta.PREVIEW_SUBJECT_TO_CHANGE_WARNING) | ||
public int getMaxConcurrentStreams() { | ||
return maxConcurrentStreams; | ||
} | ||
|
||
/*** | ||
* Configures the maximum number of the concurrent streams that can be opened to the remote peer. | ||
* When evaluating how many streams can be opened to the remote peer, the minimum of this configuration and the remote peer configuration is taken (unless -1 is used). | ||
* Default to 30. | ||
* | ||
* @param maxConcurrentStreams the maximum number of the concurrent streams that can be opened to the remote peer. | ||
* @return the current {@link Http2ConnectionConfig}. | ||
*/ | ||
@Beta(value = Beta.SinceVersion.V4_66_0, warningText = Beta.PREVIEW_SUBJECT_TO_CHANGE_WARNING) | ||
public Http2ConnectionConfig setMaxConcurrentStreams(int maxConcurrentStreams) { | ||
this.maxConcurrentStreams = maxConcurrentStreams; | ||
return this; | ||
} | ||
|
||
/*** | ||
* Get the minimum number of live connections to keep in the pool (can be the best effort). | ||
* @return the minimum number of live connections to keep in the pool (can be the best effort). | ||
*/ | ||
@Beta(value = Beta.SinceVersion.V4_66_0, warningText = Beta.PREVIEW_SUBJECT_TO_CHANGE_WARNING) | ||
public int getMinConnectionPoolSize() { | ||
return minConnectionPoolSize; | ||
} | ||
|
||
/*** | ||
* Configures the minimum number of live connections to keep in the pool (can be the best effort). Default to 1. | ||
* @param minConnectionPoolSize the minimum number of live connections to keep in the pool (can be the best effort). | ||
* @return the current {@link Http2ConnectionConfig}. | ||
*/ | ||
@Beta(value = Beta.SinceVersion.V4_66_0, warningText = Beta.PREVIEW_SUBJECT_TO_CHANGE_WARNING) | ||
public Http2ConnectionConfig setMinConnectionPoolSize(int minConnectionPoolSize) { | ||
this.minConnectionPoolSize = minConnectionPoolSize; | ||
return this; | ||
} | ||
|
||
/*** | ||
* return the flag to indicate whether http2 is enabled. | ||
* @return the flag to indicate whether http2 is enabled. | ||
*/ | ||
@Beta(value = Beta.SinceVersion.V4_66_0, warningText = Beta.PREVIEW_SUBJECT_TO_CHANGE_WARNING) | ||
public boolean isEnabled() { | ||
return enabled; | ||
} | ||
|
||
/*** | ||
* Configure the flag to indicate whether http2 is enabled. | ||
* @param enabled the flag to indicate whether http2 is enabled. | ||
* @return the current {@link Http2ConnectionConfig}. | ||
*/ | ||
@Beta(value = Beta.SinceVersion.V4_66_0, warningText = Beta.PREVIEW_SUBJECT_TO_CHANGE_WARNING) | ||
public Http2ConnectionConfig setEnabled(boolean enabled) { | ||
this.enabled = enabled; | ||
return this; | ||
} | ||
|
||
@Beta(value = Beta.SinceVersion.V4_66_0, warningText = Beta.PREVIEW_SUBJECT_TO_CHANGE_WARNING) | ||
@Override | ||
public String toString() { | ||
return "Http2ConnectionConfig{" + | ||
"isEnabled=" + enabled + | ||
", maxConnectionPoolSize=" + maxConnectionPoolSize + | ||
", minConnectionPoolSize=" + minConnectionPoolSize + | ||
", maxConcurrentStreams=" + maxConcurrentStreams + | ||
'}'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -101,6 +101,8 @@ public enum SinceVersion { | |
/** v4.64.0 */ | ||
V4_64_0, | ||
/** v4.65.0 */ | ||
V4_65_0 | ||
V4_65_0, | ||
/** v4.66.0 */ | ||
V4_66_0 | ||
} | ||
} |