Skip to content
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

Direct: Adds direct version 3.19 which includes improvements and fixes #2400

Merged
merged 8 commits into from
Apr 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<ClientOfficialVersion>3.17.1</ClientOfficialVersion>
<ClientPreviewVersion>3.18.0</ClientPreviewVersion>
<ClientPreviewSuffixVersion>preview</ClientPreviewSuffixVersion>
<DirectVersion>3.18.0</DirectVersion>
<DirectVersion>3.19.0</DirectVersion>
<EncryptionVersion>1.0.0-previewV13</EncryptionVersion>
<HybridRowVersion>1.1.0-preview3</HybridRowVersion>
<AboveDirBuildProps>$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)../'))</AboveDirBuildProps>
Expand Down
22 changes: 20 additions & 2 deletions Microsoft.Azure.Cosmos/src/DocumentClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ internal partial class DocumentClient : IDisposable, IAuthorizationTokenProvider
private const string RntbdReceiveHangDetectionTimeConfig = "CosmosDbTcpReceiveHangDetectionTimeSeconds";
private const string RntbdSendHangDetectionTimeConfig = "CosmosDbTcpSendHangDetectionTimeSeconds";
private const string EnableCpuMonitorConfig = "CosmosDbEnableCpuMonitor";
// Env variable
private const string RntbdMaxConcurrentOpeningConnectionCountConfig = "AZURE_COSMOS_TCP_MAX_CONCURRENT_OPENING_CONNECTION_COUNT";

private const int MaxConcurrentConnectionOpenRequestsPerProcessor = 25;
private const int DefaultMaxRequestsPerRntbdChannel = 30;
Expand Down Expand Up @@ -128,6 +130,7 @@ internal partial class DocumentClient : IDisposable, IAuthorizationTokenProvider
private int rntbdReceiveHangDetectionTimeSeconds = DefaultRntbdReceiveHangDetectionTimeSeconds;
private int rntbdSendHangDetectionTimeSeconds = DefaultRntbdSendHangDetectionTimeSeconds;
private bool enableCpuMonitor = DefaultEnableCpuMonitor;
private int rntbdMaxConcurrentOpeningConnectionCount = 5;

//Consistency
private Documents.ConsistencyLevel? desiredConsistencyLevel;
Expand Down Expand Up @@ -818,8 +821,22 @@ internal virtual void Initialize(Uri serviceEndpoint,
}
#if NETSTANDARD20
}
#endif
#endif
#endif

string rntbdMaxConcurrentOpeningConnectionCountOverrideString = Environment.GetEnvironmentVariable(RntbdMaxConcurrentOpeningConnectionCountConfig);
if (!string.IsNullOrEmpty(rntbdMaxConcurrentOpeningConnectionCountOverrideString))
xinlian12 marked this conversation as resolved.
Show resolved Hide resolved
{
if (Int32.TryParse(rntbdMaxConcurrentOpeningConnectionCountOverrideString, out int rntbdMaxConcurrentOpeningConnectionCountOverrideInt))
{
if (rntbdMaxConcurrentOpeningConnectionCountOverrideInt <= 0)
{
throw new ArgumentException("RntbdMaxConcurrentOpeningConnectionCountConfig should be larger than 0");
}

this.rntbdMaxConcurrentOpeningConnectionCount = rntbdMaxConcurrentOpeningConnectionCountOverrideInt;
}
}

// ConnectionPolicy always overrides appconfig
if (connectionPolicy != null)
Expand Down Expand Up @@ -6490,7 +6507,8 @@ private void InitializeDirectConnectivity(IStoreClientFactory storeClientFactory
enableCpuMonitor: this.enableCpuMonitor,
retryWithConfiguration: this.ConnectionPolicy.RetryOptions?.GetRetryWithConfiguration(),
enableTcpConnectionEndpointRediscovery: this.ConnectionPolicy.EnableTcpConnectionEndpointRediscovery,
addressResolver: this.AddressResolver);
addressResolver: this.AddressResolver,
rntbdMaxConcurrentOpeningConnectionCount: this.rntbdMaxConcurrentOpeningConnectionCount);

if (this.transportClientHandlerFactory != null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,9 +266,9 @@ private TransportClient GetMockTransportClient(AddressInformation[] addressInfor

mockTransportClient.Setup(
client => client.InvokeResourceOperationAsync(
It.IsAny<Uri>(),
It.IsAny<TransportAddressUri>(),
It.Is<DocumentServiceRequest>(e => this.IsValidDsr(e))))
.Returns((Uri uri, DocumentServiceRequest documentServiceRequest) => Task.FromResult(MockRequestHelper.GetStoreResponse(documentServiceRequest)));
.Returns((TransportAddressUri uri, DocumentServiceRequest documentServiceRequest) => Task.FromResult(MockRequestHelper.GetStoreResponse(documentServiceRequest)));

return mockTransportClient.Object;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ async Task<HttpResponseMessage> sendFunc(HttpRequestMessage httpRequest)
});
}

StoreResponse sendDirectFunc(Uri uri, DocumentServiceRequest request)
StoreResponse sendDirectFunc(TransportAddressUri uri, DocumentServiceRequest request)
{
return new StoreResponse()
{
Expand Down Expand Up @@ -254,13 +254,13 @@ StoreResponse sendDirectFunc(Uri uri, DocumentServiceRequest request)

private static ServerStoreModel MockServerStoreModel(
object sessionContainer,
Func<Uri, DocumentServiceRequest, StoreResponse> sendDirectFunc)
Func<TransportAddressUri, DocumentServiceRequest, StoreResponse> sendDirectFunc)
{
Mock<TransportClient> mockTransportClient = new Mock<TransportClient>();

mockTransportClient.Setup(
client => client.InvokeResourceOperationAsync(
It.IsAny<Uri>(), It.IsAny<DocumentServiceRequest>()))
It.IsAny<TransportAddressUri>(), It.IsAny<DocumentServiceRequest>()))
.ReturnsAsync(sendDirectFunc);

AddressInformation[] addressInformation = GetMockAddressInformation();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ private StoreClient GetMockStoreClient()
TransportClient mockTransportClient = this.GetMockTransportClient();
ISessionContainer sessionContainer = new SessionContainer(string.Empty);

StoreReader storeReader = new StoreReader(mockTransportClient, addressSelector, sessionContainer);
StoreReader storeReader = new StoreReader(mockTransportClient, addressSelector, new AddressEnumerator(), sessionContainer);

Mock<IAuthorizationTokenProvider> mockAuthorizationTokenProvider = new Mock<IAuthorizationTokenProvider>();
mockAuthorizationTokenProvider.Setup(provider => provider.AddSystemAuthorizationHeaderAsync(
Expand Down Expand Up @@ -118,7 +118,7 @@ private TransportClient GetMockTransportClient()
};
mockTransportClient.Setup(
client => client.InvokeResourceOperationAsync(
It.IsAny<Uri>(),
It.IsAny<TransportAddressUri>(),
It.IsAny<DocumentServiceRequest>()))
.ReturnsAsync(mockStoreResponse);

Expand Down
Loading