Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import io.netty.handler.ssl.SslContext;
import org.testng.annotations.Test;

import java.net.URI;
import java.util.EnumSet;

import static org.assertj.core.api.Assertions.assertThat;
Expand Down Expand Up @@ -144,4 +145,26 @@ public void http2MaxConcurrentStreams() {

System.clearProperty("COSMOS.HTTP2_MAX_CONCURRENT_STREAMS");
}

@Test(groups = { "unit" })
public void thinClientEnabledTest() {
Configs config = new Configs();
assertThat(config.getThinclientEnabled()).isFalse();

System.setProperty("COSMOS.THINCLIENT_ENABLED", "true");
assertThat(config.getThinclientEnabled()).isTrue();

System.clearProperty("COSMOS.THINCLIENT_ENABLED");
}

@Test(groups = { "unit" })
public void thinClientEndpointTest() {
Configs config = new Configs();
assertThat(config.getThinclientEndpoint()).isEqualTo(URI.create(""));

System.setProperty("COSMOS.THINCLIENT_ENDPOINT", "testThinClientEndpoint");
assertThat(config.getThinclientEndpoint()).isEqualTo(URI.create("testThinClientEndpoint"));

System.clearProperty("COSMOS.THINCLIENT_ENDPOINT");
}
}
1 change: 1 addition & 0 deletions sdk/cosmos/azure-cosmos/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#### Bugs Fixed

#### Other Changes
* Added temporary internal-only option to enable thin client mode with system property COSMOS.THINCLIENT_ENABLED, setting the thin client endpoint with system property COSMOS.THINCLIENT_ENDPOINT, and default thin client endpoint with system property COSMOS.DEFAULT_THINCLIENT_ENDPOINT while the thin-client transport is still under development. This transport mode is not yet supported or ready to be used by external customers. Please don't use these configs in any production scenario yet. - [PR 43188](https://github.com/Azure/azure-sdk-for-java/pull/43188)
* Added client vmId info to Rntbd health check logs - See [43079](https://github.com/Azure/azure-sdk-for-java/pull/43079)
* Added support to enable http2 for gateway mode with system property `COSMOS.HTTP2_ENABLED` and system variable `COSMOS_HTTP2_ENABLED`. - [PR 42947](https://github.com/Azure/azure-sdk-for-java/pull/42947)
* Added support to allow changing http2 max connection pool size with system property `COSMOS.HTTP2_MAX_CONNECTION_POOL_SIZE` and system variable `COSMOS_HTTP2_MAX_CONNECTION_POOL_SIZE`. - [PR 42947](https://github.com/Azure/azure-sdk-for-java/pull/42947)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@
import org.slf4j.LoggerFactory;

import javax.net.ssl.SSLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.time.Duration;
import java.util.Locale;
import java.util.Objects;

import static com.azure.cosmos.implementation.guava25.base.MoreObjects.firstNonNull;
import static com.azure.cosmos.implementation.guava25.base.Strings.emptyToNull;
Expand Down Expand Up @@ -44,6 +47,12 @@ public class Configs {

private static final String UNAVAILABLE_LOCATIONS_EXPIRATION_TIME_IN_SECONDS = "COSMOS.UNAVAILABLE_LOCATIONS_EXPIRATION_TIME_IN_SECONDS";
private static final String GLOBAL_ENDPOINT_MANAGER_INITIALIZATION_TIME_IN_SECONDS = "COSMOS.GLOBAL_ENDPOINT_MANAGER_MAX_INIT_TIME_IN_SECONDS";
private static final String DEFAULT_THINCLIENT_ENDPOINT = "";
private static final String THINCLIENT_ENDPOINT = "COSMOS.THINCLIENT_ENDPOINT";
private static final String THINCLIENT_ENDPOINT_VARIABLE = "COSMOS_THINCLIENT_ENDPOINT";
private static final boolean DEFAULT_THINCLIENT_ENABLED = false;
private static final String THINCLIENT_ENABLED = "COSMOS.THINCLIENT_ENABLED";
private static final String THINCLIENT_ENABLED_VARIABLE = "COSMOS_THINCLIENT_ENABLED";

private static final String MAX_HTTP_BODY_LENGTH_IN_BYTES = "COSMOS.MAX_HTTP_BODY_LENGTH_IN_BYTES";
private static final String MAX_HTTP_INITIAL_LINE_LENGTH_IN_BYTES = "COSMOS.MAX_HTTP_INITIAL_LINE_LENGTH_IN_BYTES";
Expand Down Expand Up @@ -405,6 +414,34 @@ public int getGlobalEndpointManagerMaxInitializationTimeInSeconds() {
return getJVMConfigAsInt(GLOBAL_ENDPOINT_MANAGER_INITIALIZATION_TIME_IN_SECONDS, DEFAULT_GLOBAL_ENDPOINT_MANAGER_INITIALIZATION_TIME_IN_SECONDS);
}

public URI getThinclientEndpoint() {
String valueFromSystemProperty = System.getProperty(THINCLIENT_ENDPOINT);
if (valueFromSystemProperty != null && !valueFromSystemProperty.isEmpty()) {
return URI.create(valueFromSystemProperty);
}

String valueFromEnvVariable = System.getenv(THINCLIENT_ENDPOINT_VARIABLE);
if (valueFromEnvVariable != null && !valueFromEnvVariable.isEmpty()) {
return URI.create(valueFromEnvVariable);
}

return URI.create(DEFAULT_THINCLIENT_ENDPOINT);
}

public static boolean getThinclientEnabled() {
String valueFromSystemProperty = System.getProperty(THINCLIENT_ENABLED);
if (valueFromSystemProperty != null && !valueFromSystemProperty.isEmpty()) {
return Boolean.parseBoolean(valueFromSystemProperty);
}

String valueFromEnvVariable = System.getenv(THINCLIENT_ENABLED_VARIABLE);
if (valueFromEnvVariable != null && !valueFromEnvVariable.isEmpty()) {
return Boolean.parseBoolean(valueFromEnvVariable);
}

return DEFAULT_THINCLIENT_ENABLED;
}

public int getUnavailableLocationsExpirationTimeInSeconds() {
return getJVMConfigAsInt(UNAVAILABLE_LOCATIONS_EXPIRATION_TIME_IN_SECONDS, DEFAULT_UNAVAILABLE_LOCATIONS_EXPIRATION_TIME_IN_SECONDS);
}
Expand Down
Loading