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
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ abstract class AsyncBenchmark<T> implements Benchmark {
});

CosmosBulkExecutionOptions bulkExecutionOptions = new CosmosBulkExecutionOptions();
bulkExecutionOptions.setExcludedRegions(cfg.getExcludedRegionsList());
List<CosmosBulkOperationResponse<Object>> failedResponses = Collections.synchronizedList(new ArrayList<>());
cosmosAsyncContainer
.executeBulkOperations(bulkOperationFlux, bulkExecutionOptions)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ protected Mono<FeedResponse<PojoizedJson>> performWorkload(long i) {
Flux<FeedResponse<PojoizedJson>> obs;
Random r = new Random();
CosmosQueryRequestOptions options = new CosmosQueryRequestOptions();
options.setExcludedRegions(workloadConfig.getExcludedRegionsList());

if (workloadConfig.getOperationType() == Operation.QueryCross) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class AsyncQuerySinglePartitionMultiple extends AsyncBenchmark<FeedResponse<Pojo
super(cfg);
options = new CosmosQueryRequestOptions();
options.setPartitionKey(new PartitionKey("pk"));
options.setExcludedRegions(cfg.getExcludedRegionsList());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

package com.azure.cosmos.benchmark;

import com.azure.cosmos.models.CosmosItemRequestOptions;
import com.azure.cosmos.models.CosmosItemResponse;
import com.azure.cosmos.models.PartitionKey;

Expand All @@ -18,8 +19,10 @@ class AsyncReadBenchmark extends AsyncBenchmark<PojoizedJson> {
protected Mono<PojoizedJson> performWorkload(long i) {
int index = (int) (i % docsToRead.size());
PojoizedJson doc = docsToRead.get(index);
CosmosItemRequestOptions options = new CosmosItemRequestOptions();
options.setExcludedRegions(workloadConfig.getExcludedRegionsList());
return cosmosAsyncContainer.readItem(doc.getId(),
new PartitionKey(doc.getId()), PojoizedJson.class)
new PartitionKey(doc.getId()), options, PojoizedJson.class)
.map(CosmosItemResponse::getItem);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package com.azure.cosmos.benchmark;

import com.azure.cosmos.models.CosmosItemIdentity;
import com.azure.cosmos.models.CosmosReadManyRequestOptions;
import com.azure.cosmos.models.FeedResponse;
import com.azure.cosmos.models.PartitionKey;

Expand Down Expand Up @@ -37,6 +38,8 @@ protected Mono<FeedResponse<PojoizedJson>> performWorkload(long i) {
cosmosItemIdentities.add(new CosmosItemIdentity(partitionKey, doc.getId()));
}

return cosmosAsyncContainer.readMany(cosmosItemIdentities, PojoizedJson.class);
CosmosReadManyRequestOptions options = new CosmosReadManyRequestOptions();
options.setExcludedRegions(workloadConfig.getExcludedRegionsList());
return cosmosAsyncContainer.readMany(cosmosItemIdentities, options, PojoizedJson.class);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

package com.azure.cosmos.benchmark;

import com.azure.cosmos.models.CosmosItemRequestOptions;
import com.azure.cosmos.models.CosmosItemResponse;
import com.azure.cosmos.models.PartitionKey;

Expand All @@ -28,18 +29,21 @@ class AsyncWriteBenchmark extends AsyncBenchmark<CosmosItemResponse> {
protected Mono<CosmosItemResponse> performWorkload(long i) {
String id = uuid + i;
Mono<? extends CosmosItemResponse<?>> result;
CosmosItemRequestOptions options = new CosmosItemRequestOptions();
options.setExcludedRegions(workloadConfig.getExcludedRegionsList());
if (workloadConfig.isDisablePassingPartitionKeyAsOptionOnWrite()) {
result = cosmosAsyncContainer.createItem(BenchmarkHelper.generateDocument(id,
dataFieldValue,
partitionKey,
workloadConfig.getDocumentDataFieldCount()));
workloadConfig.getDocumentDataFieldCount()),
options);
} else {
result = cosmosAsyncContainer.createItem(BenchmarkHelper.generateDocument(id,
dataFieldValue,
partitionKey,
workloadConfig.getDocumentDataFieldCount()),
new PartitionKey(id),
null);
options);
}
// Raw type cast is required because CosmosItemResponse uses wildcard generics
// that cannot be expressed in the class type parameter without propagating
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ private static ImplementationBridgeHelpers.CosmosClientHelper.CosmosClientAccess
});

CosmosBulkExecutionOptions bulkExecutionOptions = new CosmosBulkExecutionOptions();
bulkExecutionOptions.setExcludedRegions(workloadCfg.getExcludedRegionsList());
List<CosmosBulkOperationResponse<Object>> failedResponses = Collections.synchronizedList(new ArrayList<>());
asyncContainer
.executeBulkOperations(bulkOperationFlux, bulkExecutionOptions)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ protected CosmosItemResponse performWorkload(long i) throws Exception {
PojoizedJson doc = docsToRead.get(index);

String partitionKeyValue = doc.getId();
CosmosItemRequestOptions options = new CosmosItemRequestOptions();
options.setExcludedRegions(workloadConfig.getExcludedRegionsList());
return cosmosContainer.readItem(doc.getId(), new PartitionKey(partitionKeyValue),
new CosmosItemRequestOptions(), InternalObjectNode.class);
options, InternalObjectNode.class);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

package com.azure.cosmos.benchmark;

import com.azure.cosmos.models.CosmosItemRequestOptions;
import com.azure.cosmos.models.CosmosItemResponse;
import com.azure.cosmos.models.PartitionKey;
import org.apache.commons.lang3.RandomStringUtils;
Expand All @@ -26,13 +27,15 @@ class SyncWriteBenchmark extends SyncBenchmark<CosmosItemResponse> {
@Override
protected CosmosItemResponse performWorkload(long i) throws Exception {
String id = uuid + i;
CosmosItemResponse<PojoizedJson> response;
CosmosItemRequestOptions options = new CosmosItemRequestOptions();
options.setExcludedRegions(workloadConfig.getExcludedRegionsList());
if (workloadConfig.isDisablePassingPartitionKeyAsOptionOnWrite()) {
// require parsing partition key from the doc
return cosmosContainer.createItem(BenchmarkHelper.generateDocument(id,
dataFieldValue,
partitionKey,
workloadConfig.getDocumentDataFieldCount()));
workloadConfig.getDocumentDataFieldCount()),
options);
}

// more optimized for write as partition key is already passed as config
Expand All @@ -41,6 +44,6 @@ protected CosmosItemResponse performWorkload(long i) throws Exception {
partitionKey,
workloadConfig.getDocumentDataFieldCount()),
new PartitionKey(id),
null);
options);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,9 @@ class TenantDefaultConfig {
@JsonProperty("preferredRegionsList")
protected String preferredRegionsList;

@JsonProperty("excludedRegionsList")
protected String excludedRegionsList;

@JsonProperty("manageDatabase")
protected Boolean manageDatabase;

Expand Down Expand Up @@ -233,6 +236,13 @@ public List<String> getPreferredRegionsList() {
return regions;
}

public List<String> getExcludedRegionsList() {
if (excludedRegionsList == null || excludedRegionsList.isEmpty()) return null;
List<String> regions = new ArrayList<>();
for (String r : excludedRegionsList.split(",")) { regions.add(r.trim()); }
return regions;
}

public boolean shouldManageDatabase() { return manageDatabase != null ? manageDatabase : false; }
public String getApplicationName() { return applicationName != null ? applicationName : ""; }
public boolean isManagedIdentityRequired() { return isManagedIdentityRequired != null && isManagedIdentityRequired; }
Expand Down Expand Up @@ -278,6 +288,7 @@ void applyTo(TenantWorkloadConfig tenant) {
if (http2Enabled != null && tenant.http2Enabled == null) tenant.http2Enabled = http2Enabled;
if (http2MaxConcurrentStreams != null && tenant.http2MaxConcurrentStreams == null) tenant.http2MaxConcurrentStreams = http2MaxConcurrentStreams;
if (preferredRegionsList != null && tenant.preferredRegionsList == null) tenant.preferredRegionsList = preferredRegionsList;
if (excludedRegionsList != null && tenant.excludedRegionsList == null) tenant.excludedRegionsList = excludedRegionsList;
if (manageDatabase != null && tenant.manageDatabase == null) tenant.manageDatabase = manageDatabase;
if (isManagedIdentityRequired != null && tenant.isManagedIdentityRequired == null) tenant.isManagedIdentityRequired = isManagedIdentityRequired;
if (applicationName != null && tenant.applicationName == null) tenant.applicationName = applicationName;
Expand Down
Loading