-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added idle tcp connection timeout #12974
Merged
kushagraThapar
merged 2 commits into
Azure:master
from
kushagraThapar:fix_idle_connection_timeout_bug
Jul 10, 2020
Merged
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,7 +27,6 @@ public final class ConnectionPolicy { | |
|
||
private ConnectionMode connectionMode; | ||
private boolean endpointDiscoveryEnabled; | ||
private Duration idleConnectionTimeout; | ||
private boolean multipleWriteRegionsEnabled; | ||
private List<String> preferredRegions; | ||
private boolean readRequestsFallbackEnabled; | ||
|
@@ -38,19 +37,21 @@ public final class ConnectionPolicy { | |
private int maxConnectionPoolSize; | ||
private Duration requestTimeout; | ||
private ProxyOptions proxy; | ||
private Duration idleHttpConnectionTimeout; | ||
|
||
// Direct connection config properties | ||
private Duration connectTimeout; | ||
private Duration idleEndpointTimeout; | ||
private int maxConnectionsPerEndpoint; | ||
private int maxRequestsPerConnection; | ||
private Duration idleTcpConnectionTimeout; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. as we discussed. thanks. |
||
|
||
/** | ||
* Constructor. | ||
*/ | ||
public ConnectionPolicy(GatewayConnectionConfig gatewayConnectionConfig) { | ||
this(ConnectionMode.GATEWAY); | ||
this.idleConnectionTimeout = gatewayConnectionConfig.getIdleConnectionTimeout(); | ||
this.idleHttpConnectionTimeout = gatewayConnectionConfig.getIdleConnectionTimeout(); | ||
this.maxConnectionPoolSize = gatewayConnectionConfig.getMaxConnectionPoolSize(); | ||
this.requestTimeout = BridgeInternal.getRequestTimeoutFromGatewayConnectionConfig(gatewayConnectionConfig); | ||
this.proxy = gatewayConnectionConfig.getProxy(); | ||
|
@@ -59,7 +60,7 @@ public ConnectionPolicy(GatewayConnectionConfig gatewayConnectionConfig) { | |
public ConnectionPolicy(DirectConnectionConfig directConnectionConfig) { | ||
this(ConnectionMode.DIRECT); | ||
this.connectTimeout = directConnectionConfig.getConnectTimeout(); | ||
this.idleConnectionTimeout = directConnectionConfig.getIdleConnectionTimeout(); | ||
this.idleTcpConnectionTimeout = directConnectionConfig.getIdleConnectionTimeout(); | ||
this.idleEndpointTimeout = directConnectionConfig.getIdleEndpointTimeout(); | ||
this.maxConnectionsPerEndpoint = directConnectionConfig.getMaxConnectionsPerEndpoint(); | ||
this.maxRequestsPerConnection = directConnectionConfig.getMaxRequestsPerConnection(); | ||
|
@@ -149,24 +150,54 @@ public ConnectionPolicy setMaxConnectionPoolSize(int maxConnectionPoolSize) { | |
} | ||
|
||
/** | ||
* Gets the value of the timeout for an idle connection, the default is 60 | ||
* Gets the value of the timeout for an idle http connection, the default is 60 | ||
* seconds. | ||
* | ||
* @return Idle connection timeout duration. | ||
*/ | ||
public Duration getIdleConnectionTimeout() { | ||
return this.idleConnectionTimeout; | ||
public Duration getIdleHttpConnectionTimeout() { | ||
return this.idleHttpConnectionTimeout; | ||
} | ||
|
||
/** | ||
* sets the value of the timeout for an idle connection. After that time, | ||
* sets the value of the timeout for an idle http connection. After that time, | ||
* the connection will be automatically closed. | ||
* | ||
* @param idleConnectionTimeout the duration for an idle connection. | ||
* @param idleHttpConnectionTimeout the duration for an idle connection. | ||
* @return the ConnectionPolicy. | ||
*/ | ||
public ConnectionPolicy setIdleConnectionTimeout(Duration idleConnectionTimeout) { | ||
this.idleConnectionTimeout = idleConnectionTimeout; | ||
public ConnectionPolicy setIdleHttpConnectionTimeout(Duration idleHttpConnectionTimeout) { | ||
this.idleHttpConnectionTimeout = idleHttpConnectionTimeout; | ||
return this; | ||
} | ||
|
||
/** | ||
* Gets the idle tcp connection timeout for direct client | ||
* | ||
* Default value is {@link Duration#ZERO} | ||
* | ||
* Direct client doesn't close a single connection to an endpoint | ||
* by default unless specified. | ||
* | ||
* @return idle tcp connection timeout | ||
*/ | ||
public Duration getIdleTcpConnectionTimeout() { | ||
return idleTcpConnectionTimeout; | ||
} | ||
|
||
/** | ||
* Sets the idle tcp connection timeout | ||
* | ||
* Default value is {@link Duration#ZERO} | ||
* | ||
* Direct client doesn't close a single connection to an endpoint | ||
* by default unless specified. | ||
* | ||
* @param idleTcpConnectionTimeout idle connection timeout | ||
* @return the {@link ConnectionPolicy} | ||
*/ | ||
public ConnectionPolicy setIdleTcpConnectionTimeout(Duration idleTcpConnectionTimeout) { | ||
this.idleTcpConnectionTimeout = idleTcpConnectionTimeout; | ||
return this; | ||
} | ||
|
||
|
@@ -451,7 +482,8 @@ public String toString() { | |
"requestTimeout=" + requestTimeout + | ||
", connectionMode=" + connectionMode + | ||
", maxConnectionPoolSize=" + maxConnectionPoolSize + | ||
", idleConnectionTimeout=" + idleConnectionTimeout + | ||
", idleHttpConnectionTimeout=" + idleHttpConnectionTimeout + | ||
", idleTcpConnectionTimeout=" + idleTcpConnectionTimeout + | ||
", userAgentSuffix='" + userAgentSuffix + '\'' + | ||
", throttlingRetryOptions=" + throttlingRetryOptions + | ||
", endpointDiscoveryEnabled=" + endpointDiscoveryEnabled + | ||
|
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thumbs up. thanks.