Skip to content
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
4 changes: 2 additions & 2 deletions sdk/cosmos/azure-cosmos-benchmark/ctl/run_benchmark.sh
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ additional_benchmark_options="-documentDataFieldSize 10 -documentDataFieldCount
additional_benchmark_options="$additional_benchmark_options -maxConnectionPoolSize $gateway_connection_poolsize"

if [ -z "$ctl_graphite_endpoint" ]; then
java -Xmx8g -Xms8g $jvm_opt -Dcosmos.directModeProtocol=$protocol -Dazure.cosmos.directModeProtocol=$protocol -DCOSMOS.ENVIRONMENT_NAME=$ctl_env -DCOSMOS.CLIENT_TELEMETRY_ENDPOINT=$ctl_client_telemetry_endpoint -jar "$jar_file" -serviceEndpoint "$service_endpoint" -masterKey "$master_key" -databaseId "$db_name" -collectionId "$col_name" -readWriteQueryPct "$read_write_query_pct" -diagnosticsThresholdDuration "$diagnostics_threshold_duration" -numberOfCollectionForCtl "$number_Of_collection" -throughput $throughput -consistencyLevel $consistency_level -concurrency $concurrency -numberOfOperations $number_of_operations -operation $operation -connectionMode $connection_mode -maxRunningTimeDuration $max_running_time_duration -numberOfPreCreatedDocuments $number_of_precreated_documents $additional_benchmark_options 2>&1 | tee -a "$log_filename"
java -Xmx8g -Xms8g $jvm_opt -Dcosmos.directModeProtocol=$protocol -Dazure.cosmos.directModeProtocol=$protocol -DCOSMOS.ENVIRONMENT_NAME=$ctl_env -DCOSMOS.CLIENT_TELEMETRY_ENDPOINT=$ctl_client_telemetry_endpoint -jar "$jar_file" -serviceEndpoint "$service_endpoint" -masterKey "$master_key" -databaseId "$db_name" -collectionId "$col_name" -readWriteQueryPct "$read_write_query_pct" -diagnosticsThresholdDuration "$diagnostics_threshold_duration" -numberOfCollectionForCtl "$number_Of_collection" -throughput $throughput -consistencyLevel $consistency_level -concurrency $concurrency -numberOfOperations $number_of_operations -operation $operation -connectionMode $connection_mode -maxRunningTimeDuration $max_running_time_duration -numberOfPreCreatedDocuments $number_of_precreated_documents -preferredRegionsList $ctl_preferred_regions $additional_benchmark_options 2>&1 | tee -a "$log_filename"
else
java -Xmx8g -Xms8g $jvm_opt -Dcosmos.directModeProtocol=$protocol -Dazure.cosmos.directModeProtocol=$protocol -DCOSMOS.ENVIRONMENT_NAME=$ctl_env -DCOSMOS.CLIENT_TELEMETRY_ENDPOINT=$ctl_client_telemetry_endpoint -jar "$jar_file" -serviceEndpoint "$service_endpoint" -masterKey "$master_key" -databaseId "$db_name" -collectionId "$col_name" -readWriteQueryPct "$read_write_query_pct" -diagnosticsThresholdDuration "$diagnostics_threshold_duration" -numberOfCollectionForCtl "$number_Of_collection" -throughput $throughput -consistencyLevel $consistency_level -concurrency $concurrency -numberOfOperations $number_of_operations -operation $operation -connectionMode $connection_mode -maxRunningTimeDuration $max_running_time_duration -graphiteEndpoint $ctl_graphite_endpoint -numberOfPreCreatedDocuments $number_of_precreated_documents $ctl_accountNameInGraphiteReporter $additional_benchmark_options 2>&1 | tee -a "$log_filename"
java -Xmx8g -Xms8g $jvm_opt -Dcosmos.directModeProtocol=$protocol -Dazure.cosmos.directModeProtocol=$protocol -DCOSMOS.ENVIRONMENT_NAME=$ctl_env -DCOSMOS.CLIENT_TELEMETRY_ENDPOINT=$ctl_client_telemetry_endpoint -jar "$jar_file" -serviceEndpoint "$service_endpoint" -masterKey "$master_key" -databaseId "$db_name" -collectionId "$col_name" -readWriteQueryPct "$read_write_query_pct" -diagnosticsThresholdDuration "$diagnostics_threshold_duration" -numberOfCollectionForCtl "$number_Of_collection" -throughput $throughput -consistencyLevel $consistency_level -concurrency $concurrency -numberOfOperations $number_of_operations -operation $operation -connectionMode $connection_mode -maxRunningTimeDuration $max_running_time_duration -graphiteEndpoint $ctl_graphite_endpoint -numberOfPreCreatedDocuments $number_of_precreated_documents -preferredRegionsList $ctl_preferred_regions $ctl_accountNameInGraphiteReporter $additional_benchmark_options 2>&1 | tee -a "$log_filename"
fi

end=$(date +%s)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ private void createClients() {
CosmosClientBuilder cosmosClientBuilder = new CosmosClientBuilder()
.endpoint(endpoint)
.key(key)
.preferredRegions(this.configuration.getPreferredRegionsList())
.consistencyLevel(configuration.getConsistencyLevel())
.connectionSharingAcrossClientsEnabled(true)
.contentResponseOnWriteEnabled(Boolean.parseBoolean(configuration.isContentResponseOnWriteEnabled()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ abstract class AsyncBenchmark<T> {
CosmosClientBuilder cosmosClientBuilder = new CosmosClientBuilder()
.endpoint(cfg.getServiceEndpoint())
.key(cfg.getMasterKey())
.preferredRegions(cfg.getPreferredRegionsList())
.consistencyLevel(cfg.getConsistencyLevel())
.contentResponseOnWriteEnabled(Boolean.parseBoolean(cfg.isContentResponseOnWriteEnabled()));
if (cfg.getConnectionMode().equals(ConnectionMode.DIRECT)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.time.Duration;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class Configuration {

Expand Down Expand Up @@ -91,6 +93,10 @@ public class Configuration {
@Parameter(names = "-manageDatabase", description = "Control switch for creating/deleting underlying database resource")
private boolean manageDatabase = false;

@Parameter(names = "-preferredRegionsList", listConverter = PreferredRegionsConverter.class, description = "Comma" +
" separated preferred regions list")
private List<String> preferredRegionsList;

@Parameter(names = "-operation", description = "Type of Workload:\n"
+ "\tReadThroughput- run a READ workload that prints only throughput *\n"
+ "\tReadThroughputWithMultipleClients - run a READ workload that prints throughput and latency for multiple client read.*\n"
Expand Down Expand Up @@ -445,6 +451,10 @@ public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
}

public List<String> getPreferredRegionsList() {
return preferredRegionsList;
}

public void tryGetValuesFromSystem() {
serviceEndpoint = StringUtils.defaultString(Strings.emptyToNull(System.getenv().get("SERVICE_END_POINT")),
serviceEndpoint);
Expand Down Expand Up @@ -483,6 +493,11 @@ public void tryGetValuesFromSystem() {
String throughputValue = StringUtils.defaultString(
Strings.emptyToNull(System.getenv().get("THROUGHPUT")), Integer.toString(throughput));
throughput = Integer.parseInt(throughputValue);

if (StringUtils.isNotEmpty(System.getenv().get("PREFERRED_REGIONS_LIST"))) {
PreferredRegionsConverter preferredRegionsConverter = new PreferredRegionsConverter();
preferredRegionsList = preferredRegionsConverter.convert(System.getenv().get("PREFERRED_REGIONS_LIST"));
}
}

private synchronized MeterRegistry azureMonitorMeterRegistry(String instrumentationKey) {
Expand Down Expand Up @@ -592,4 +607,18 @@ public String[] tagsAsPrefix() {

return this.graphiteMeterRegistry;
}

private class PreferredRegionsConverter implements IStringConverter<List<String>> {
@Override
public List<String> convert(String preferredRegionsList) {
List<String> preferredRegions = null;
if (StringUtils.isNotEmpty(preferredRegionsList)) {
String[] preferredArray = preferredRegionsList.split(",");
if (preferredArray != null && preferredArray.length > 0) {
preferredRegions = new ArrayList<>(Arrays.asList(preferredArray));
}
}
return preferredRegions;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ public T apply(T o, Throwable throwable) {

CosmosClientBuilder cosmosClientBuilder = new CosmosClientBuilder()
.endpoint(cfg.getServiceEndpoint())
.preferredRegions(cfg.getPreferredRegionsList())
.key(cfg.getMasterKey())
.consistencyLevel(cfg.getConsistencyLevel())
.contentResponseOnWriteEnabled(Boolean.parseBoolean(cfg.isContentResponseOnWriteEnabled()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,18 @@
import com.codahale.metrics.jvm.GarbageCollectorMetricSet;
import com.codahale.metrics.jvm.MemoryUsageGaugeSet;
import io.micrometer.core.instrument.MeterRegistry;
import org.apache.commons.lang3.RandomStringUtils;
import org.apache.commons.lang3.StringUtils;
import org.mpierce.metrics.reservoir.hdrhistogram.HdrHistogramResetOnSnapshotReservoir;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import reactor.core.publisher.BaseSubscriber;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import reactor.core.scheduler.Schedulers;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand All @@ -40,14 +51,6 @@
import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong;
import org.apache.commons.lang3.RandomStringUtils;
import org.mpierce.metrics.reservoir.hdrhistogram.HdrHistogramResetOnSnapshotReservoir;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import reactor.core.publisher.BaseSubscriber;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import reactor.core.scheduler.Schedulers;


public class AsyncCtlWorkload {
Expand Down Expand Up @@ -87,6 +90,7 @@ public AsyncCtlWorkload(Configuration cfg) {
CosmosClientBuilder cosmosClientBuilder = new CosmosClientBuilder()
.endpoint(cfg.getServiceEndpoint())
.key(cfg.getMasterKey())
.preferredRegions(cfg.getPreferredRegionsList())
.consistencyLevel(cfg.getConsistencyLevel())
.clientTelemetryEnabled(true)
.contentResponseOnWriteEnabled(Boolean.parseBoolean(cfg.isContentResponseOnWriteEnabled()));
Expand Down