Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
84a37ab
Port from v4
Nov 7, 2019
d218925
Merge branch 'master' of https://github.com/Azure/azure-sdk-for-java
Nov 8, 2019
11cbbf3
Merge branch 'master' of github.com:David-Noble-at-work/azure-sdk-for…
Nov 8, 2019
05c7e05
Corrected package misspelling in log4j.properties and removed System.…
Nov 9, 2019
8dfa3db
Merge branch 'master' of github.com:David-Noble-at-work/azure-sdk-for…
Nov 9, 2019
e6e71f5
Merge branch 'master' of https://github.com/Azure/azure-sdk-for-java
Nov 9, 2019
e082d81
Merge branch 'master' of github.com:David-Noble-at-work/azure-sdk-for…
Nov 17, 2019
069c822
Merge branch 'master' of github.com:David-Noble-at-work/azure-sdk-for…
Nov 23, 2019
3ead1cc
Merge branch 'master' of https://github.com/Azure/azure-sdk-for-java
Dec 3, 2019
669ba8b
Merge branch 'master' of https://github.com/Azure/azure-sdk-for-java
Dec 4, 2019
735f572
Responded to code review comments
Dec 4, 2019
6db330d
Merge branch 'master' of https://github.com/Azure/azure-sdk-for-java
Jan 4, 2020
43f5ffb
Ported direct tcp options from azure-cosmosdb-java-2.6.X
Jan 4, 2020
84e3a1a
Fixed POM issue detected by Central SDK build pipeline
Jan 4, 2020
be5ba8c
Updated change log
Jan 4, 2020
bcf0f9c
Fixed POM issue detected by Central SDK build pipeline
Jan 4, 2020
618684c
Fixed POM issue detected by Central SDK build pipeline
Jan 4, 2020
a8d28e1
Removed christopheranderson and added David-Noble-at-work to sdk/cosm…
Jan 4, 2020
b81949d
Added kiran to sdk/cosmos/CODEOWNERS and renamed long duration fields…
Jan 4, 2020
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 sdk/cosmos/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
# https://help.github.com/articles/about-codeowners/

# Default owner for repo
* @moderakh @christopheranderson @kushagraThapar
* @moderakh @kushagraThapar @David-Noble-at-work @kirankumarkolli
25 changes: 24 additions & 1 deletion sdk/cosmos/changelog/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,28 @@
## Changelog

### unreleased
- Added the ability to select default Direct TCP options

In priority order we will take default Direct TCP options from:

- The string value of system property `"azure.cosmos.directTcp.options"`

Example:
```
-Dazure.cosmos.directTcp.defaultOptions={\"idleEndpointTimeout\":"PT1M10S",\"maxChannelsPerEndpoint\":10,\"maxRequestsPerChannel\":30}
```
- The contents of the file located by the system property "azure.cosmos.directTcp.defaultOptionsFile".

Example:
```
-Dazure.cosmos.directTcp.defaultOptionsFile=/path/to/default/options/file
```

- The contents of the resource file named `"azure.cosmos.directTcp.options.json"`

Otherwise, if none of these values are set or an error occurs we create default options based on a set of hard-wired
values defined in the default private parameterless constructor for `RntbdTransportClient.Options` as we did before
this release.

### 3.5.0
- Changefeed bug fixes (includes all the bug fixes released in 3.3.3)
- Disaster Recovery related bug fixes
Expand Down
6 changes: 6 additions & 0 deletions sdk/cosmos/microsoft-azure-cosmos/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ Licensed under the MIT License.
<version>2.10.0</version> <!-- {x-version-update;com.fasterxml.jackson.core:jackson-databind;external_dependency} -->
</dependency>

<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
<version>2.10.0</version> <!-- {x-version-update;com.fasterxml.jackson.datatype:jackson-datatype-jsr310;external_dependency} -->
</dependency>

<dependency>
<groupId>com.fasterxml.uuid</groupId>
<artifactId>java-uuid-generator</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import com.azure.data.cosmos.internal.directconnectivity.rntbd.RntbdRequestArgs;
import com.azure.data.cosmos.internal.directconnectivity.rntbd.RntbdRequestRecord;
import com.azure.data.cosmos.internal.directconnectivity.rntbd.RntbdServiceEndpoint;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
Expand All @@ -23,7 +25,9 @@
import reactor.core.publisher.Mono;
import reactor.core.publisher.SignalType;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import java.time.Duration;
import java.util.Iterator;
Expand Down Expand Up @@ -158,42 +162,88 @@ public static final class Options {

// region Fields

@JsonProperty()
private final int bufferPageSize;
private final String certificateHostNameOverride;

@JsonProperty()
private final Duration connectionTimeout;

@JsonProperty()
private final Duration idleChannelTimeout;

@JsonProperty()
private final Duration idleEndpointTimeout;

@JsonProperty()
private final int maxBufferCapacity;

@JsonProperty()
private final int maxChannelsPerEndpoint;

@JsonProperty()
private final int maxRequestsPerChannel;
private final int partitionCount;

@JsonProperty()
private final Duration receiveHangDetectionTime;

@JsonProperty()
private final Duration requestExpiryInterval;

@JsonProperty()
private final Duration requestTimeout;

@JsonProperty()
private final Duration requestTimerResolution;

@JsonProperty()
private final Duration sendHangDetectionTime;

@JsonProperty()
private final Duration shutdownTimeout;

@JsonIgnore()
private final UserAgentContainer userAgent;

// endregion

// region Constructors

private Options() {
this.bufferPageSize = 8192;
this.connectionTimeout = null;
this.idleChannelTimeout = Duration.ZERO;
this.idleEndpointTimeout = Duration.ofSeconds(70L);
this.maxBufferCapacity = 8192 << 10;
this.maxChannelsPerEndpoint = 10;
this.maxRequestsPerChannel = 30;
this.receiveHangDetectionTime = Duration.ofSeconds(65L);
this.requestExpiryInterval = Duration.ofSeconds(5L);
this.requestTimeout = null;
this.requestTimerResolution = Duration.ofMillis(5L);
this.sendHangDetectionTime = Duration.ofSeconds(10L);
this.shutdownTimeout = Duration.ofSeconds(15L);
this.userAgent = new UserAgentContainer();
}

private Options(Builder builder) {

this.bufferPageSize = builder.bufferPageSize;
this.certificateHostNameOverride = builder.certificateHostNameOverride;
this.connectionTimeout = builder.connectionTimeout == null ? builder.requestTimeout : builder.connectionTimeout;
this.idleChannelTimeout = builder.idleChannelTimeout;
this.idleEndpointTimeout = builder.idleEndpointTimeout;
this.maxBufferCapacity = builder.maxBufferCapacity;
this.maxChannelsPerEndpoint = builder.maxChannelsPerEndpoint;
this.maxRequestsPerChannel = builder.maxRequestsPerChannel;
this.partitionCount = builder.partitionCount;
this.receiveHangDetectionTime = builder.receiveHangDetectionTime;
this.requestExpiryInterval = builder.requestExpiryInterval;
this.requestTimeout = builder.requestTimeout;
this.requestTimerResolution = builder.requestTimerResolution;
this.sendHangDetectionTime = builder.sendHangDetectionTime;
this.shutdownTimeout = builder.shutdownTimeout;
this.userAgent = builder.userAgent;

this.connectionTimeout = builder.connectionTimeout == null
? builder.requestTimeout
: builder.connectionTimeout;
}

// endregion
Expand All @@ -204,10 +254,6 @@ public int bufferPageSize() {
return this.bufferPageSize;
}

public String certificateHostNameOverride() {
return this.certificateHostNameOverride;
}

public Duration connectionTimeout() {
return this.connectionTimeout;
}
Expand All @@ -232,10 +278,6 @@ public int maxRequestsPerChannel() {
return this.maxRequestsPerChannel;
}

public int partitionCount() {
return this.partitionCount;
}

public Duration receiveHangDetectionTime() {
return this.receiveHangDetectionTime;
}
Expand All @@ -248,6 +290,10 @@ public Duration requestTimeout() {
return this.requestTimeout;
}

public Duration requestTimerResolution() {
return this.requestTimerResolution;
}

public Duration sendHangDetectionTime() {
return this.sendHangDetectionTime;
}
Expand All @@ -273,39 +319,110 @@ public String toString() {

// region Types

@SuppressWarnings("UnusedReturnValue")
public static class Builder {

// region Fields

private static final UserAgentContainer DEFAULT_USER_AGENT_CONTAINER = new UserAgentContainer();
private static final Duration FIFTEEN_SECONDS = Duration.ofSeconds(15L);
private static final Duration FIVE_SECONDS =Duration.ofSeconds(5L);
private static final Duration SEVENTY_SECONDS = Duration.ofSeconds(70L);
private static final Duration SIXTY_FIVE_SECONDS = Duration.ofSeconds(65L);
private static final Duration TEN_SECONDS = Duration.ofSeconds(10L);

private int bufferPageSize = 8192;
private String certificateHostNameOverride = null;
private Duration connectionTimeout = null;
private Duration idleChannelTimeout = Duration.ZERO;
private Duration idleEndpointTimeout = SEVENTY_SECONDS;
private int maxBufferCapacity = 8192 << 10;
private int maxChannelsPerEndpoint = 10;
private int maxRequestsPerChannel = 30;
private int partitionCount = 1;
private Duration receiveHangDetectionTime = SIXTY_FIVE_SECONDS;
private Duration requestExpiryInterval = FIVE_SECONDS;
private static final String DEFAULT_OPTIONS_PROPERTY_NAME = "azure.cosmos.directTcp.defaultOptions";
private static final Options DEFAULT_OPTIONS;

static {

// In priority order we take default Direct TCP options from:
//
// 1. the string value of system property "azure.cosmos.directTcp.options", or
// 2. the contents of the file located by the system property "azure.cosmos.directTcp.optionsFile", or
// 3. the contents of the resource file named "azure.cosmos.directTcp.options.json"
//
// Otherwise, if none of these values are set or an error occurs we create default options based on a
// set of hard-wired values defined in the default private parameterless constructor for
// RntbdTransportClient.Options.

Options options = null;

try {
final String string = System.getProperty(DEFAULT_OPTIONS_PROPERTY_NAME);

if (string != null) {
// Attempt to set default options based on the JSON string value of "{propertyName}"
try {
options = RntbdObjectMapper.readValue(string, Options.class);
} catch (IOException error) {
logger.error("failed to parse default Direct TCP options {} due to ", string, error);
}
}

if (options == null) {

final String path = System.getProperty(DEFAULT_OPTIONS_PROPERTY_NAME + "File");

if (path != null) {
// Attempt to load default options from the JSON file on the path specified by
// "{propertyName}File"
try {
options = RntbdObjectMapper.readValue(new File(path), Options.class);
} catch (IOException error) {
logger.error("failed to load default Direct TCP options from {} due to ", path, error);
}
}
}

if (options == null) {

final ClassLoader loader = RntbdTransportClient.class.getClassLoader();
final String name = DEFAULT_OPTIONS_PROPERTY_NAME + ".json";

try (final InputStream stream = loader.getResourceAsStream(name)) {
if (stream != null) {
// Attempt to load default options from the JSON resource file "{propertyName}.json"
options = RntbdObjectMapper.readValue(stream, Options.class);
}
} catch (IOException error) {
logger.error("failed to load Direct TCP options from resource {} due to ", name, error);
}
}
} finally {
DEFAULT_OPTIONS = options != null ? options : new Options();
}
}

private int bufferPageSize;
private Duration connectionTimeout;
private Duration idleChannelTimeout;
private Duration idleEndpointTimeout;
private int maxBufferCapacity;
private int maxChannelsPerEndpoint;
private int maxRequestsPerChannel;
private Duration receiveHangDetectionTime;
private Duration requestExpiryInterval;
private Duration requestTimeout;
private Duration sendHangDetectionTime = TEN_SECONDS;
private Duration shutdownTimeout = FIFTEEN_SECONDS;
private UserAgentContainer userAgent = DEFAULT_USER_AGENT_CONTAINER;
private Duration requestTimerResolution;
private Duration sendHangDetectionTime;
private Duration shutdownTimeout;
private UserAgentContainer userAgent;

// endregion

// region Constructors

public Builder(Duration requestTimeout) {

this.requestTimeout(requestTimeout);

this.bufferPageSize = DEFAULT_OPTIONS.bufferPageSize;
this.connectionTimeout = DEFAULT_OPTIONS.connectionTimeout;
this.idleChannelTimeout = DEFAULT_OPTIONS.idleChannelTimeout;
this.idleEndpointTimeout = DEFAULT_OPTIONS.idleEndpointTimeout;
this.maxBufferCapacity = DEFAULT_OPTIONS.maxBufferCapacity;
this.maxChannelsPerEndpoint = DEFAULT_OPTIONS.maxChannelsPerEndpoint;
this.maxRequestsPerChannel = DEFAULT_OPTIONS.maxRequestsPerChannel;
this.receiveHangDetectionTime = DEFAULT_OPTIONS.receiveHangDetectionTime;
this.requestExpiryInterval = DEFAULT_OPTIONS.requestExpiryInterval;
this.requestTimerResolution = DEFAULT_OPTIONS.requestTimerResolution;
this.sendHangDetectionTime = DEFAULT_OPTIONS.sendHangDetectionTime;
this.shutdownTimeout = DEFAULT_OPTIONS.shutdownTimeout;
this.userAgent = DEFAULT_OPTIONS.userAgent;
}

public Builder(int requestTimeoutInSeconds) {
Expand All @@ -332,11 +449,6 @@ public Options build() {
return new Options(this);
}

public Builder certificateHostNameOverride(final String value) {
this.certificateHostNameOverride = value;
return this;
}

public Builder connectionTimeout(final Duration value) {
checkArgument(value == null || value.compareTo(Duration.ZERO) > 0,
"expected positive value, not %s",
Expand Down Expand Up @@ -379,12 +491,6 @@ public Builder maxRequestsPerChannel(final int value) {
return this;
}

public Builder partitionCount(final int value) {
checkArgument(value > 0, "expected positive value, not %s", value);
this.partitionCount = value;
return this;
}

public Builder receiveHangDetectionTime(final Duration value) {
checkArgument(value != null && value.compareTo(Duration.ZERO) > 0,
"expected positive value, not %s",
Expand All @@ -409,6 +515,14 @@ public Builder requestTimeout(final Duration value) {
return this;
}

public Builder requestTimerResolution(final Duration value) {
checkArgument(value != null && value.compareTo(Duration.ZERO) > 0,
"expected positive value, not %s",
value);
this.requestTimerResolution = value;
return this;
}

public Builder sendHangDetectionTime(final Duration value) {
checkArgument(value != null && value.compareTo(Duration.ZERO) > 0,
"expected positive value, not %s",
Expand Down
Loading