CosmosBulkExecutionOptions Class

  • java.lang.Object
    • com.azure.cosmos.models.CosmosBulkExecutionOptions

public final class CosmosBulkExecutionOptions

Encapsulates options that can be specified for operations used in Bulk execution. It can be passed while processing bulk operations.

Constructor Summary

Constructor Description
CosmosBulkExecutionOptions()

Constructor

CosmosBulkExecutionOptions(CosmosBulkExecutionThresholdsState thresholdsState)

Constructor

Method Summary

Modifier and Type Method and Description
CosmosItemSerializer getCustomItemSerializer()

Gets the custom item serializer defined for this instance of request options

List<String> getExcludedRegions()

Gets the list of regions to be excluded for the request/retries.

int getInitialMicroBatchSize()

Gets the initial size of micro batches that will be sent to the backend.

int getMaxMicroBatchConcurrency()

The maximum concurrency for executing requests for a partition key range.

int getMaxMicroBatchSize()

The maximum batch size for bulk operations.

CosmosBulkExecutionThresholdsState getThresholdsState()

Returns threshold state that can be passed to other CosmosBulkExecutionOptions in the future

String getThroughputControlGroupName()

Gets the throughput control group name.

CosmosBulkExecutionOptions setCustomItemSerializer(CosmosItemSerializer customItemSerializer)

Allows specifying a custom item serializer to be used for this operation.

CosmosBulkExecutionOptions setExcludedRegions(List<String> excludeRegions)

List of regions to exclude for the request/retries.

CosmosBulkExecutionOptions setInitialMicroBatchSize(int initialMicroBatchSize)

Sets the initial size of micro batches that will be sent to the backend.

CosmosBulkExecutionOptions setMaxMicroBatchConcurrency(int maxMicroBatchConcurrency)

Set the maximum concurrency for executing requests for a partition key range.

CosmosBulkExecutionOptions setMaxMicroBatchSize(int maxMicroBatchSize)

The maximum batch size for bulk operations.

CosmosBulkExecutionOptions setThroughputControlGroupName(String throughputControlGroupName)

Sets the throughput control group name.

Methods inherited from java.lang.Object

Constructor Details

CosmosBulkExecutionOptions

public CosmosBulkExecutionOptions()

Constructor

CosmosBulkExecutionOptions

public CosmosBulkExecutionOptions(CosmosBulkExecutionThresholdsState thresholdsState)

Constructor

Parameters:

thresholdsState - thresholds

Method Details

getCustomItemSerializer

public CosmosItemSerializer getCustomItemSerializer()

Gets the custom item serializer defined for this instance of request options

Returns:

the custom item serializer

getExcludedRegions

public List getExcludedRegions()

Gets the list of regions to be excluded for the request/retries. These regions are excluded from the preferred region list.

Returns:

a list of excluded regions

getInitialMicroBatchSize

public int getInitialMicroBatchSize()

Gets the initial size of micro batches that will be sent to the backend. The size of micro batches will be dynamically adjusted based on the throttling rate. The default value is 100 - so, it starts with relatively large micro batches and when the throttling rate is too high, it will reduce the batch size. When the short spikes of throttling before dynamically reducing the initial batch size results in side effects for other workloads the initial micro batch size can be reduced - for example set to 1 - at which point it would start with small micro batches and then increase the batch size over time.

Returns:

the initial micro batch size

getMaxMicroBatchConcurrency

public int getMaxMicroBatchConcurrency()

The maximum concurrency for executing requests for a partition key range. By default, the maxMicroBatchConcurrency is 1.

Returns:

max micro batch concurrency

getMaxMicroBatchSize

public int getMaxMicroBatchSize()

The maximum batch size for bulk operations. Once queued docs exceed this value, the micro batch will be flushed to the wire.

Returns:

the max micro batch size.

getThresholdsState

public CosmosBulkExecutionThresholdsState getThresholdsState()

Returns threshold state that can be passed to other CosmosBulkExecutionOptions in the future

Returns:

thresholds

getThroughputControlGroupName

public String getThroughputControlGroupName()

Gets the throughput control group name.

Returns:

the throughput control group name.

setCustomItemSerializer

public CosmosBulkExecutionOptions setCustomItemSerializer(CosmosItemSerializer customItemSerializer)

Allows specifying a custom item serializer to be used for this operation. If the serializer on the request options is null, the serializer on CosmosClientBuilder is used. If both serializers are null (the default), an internal Jackson ObjectMapper is ued for serialization/deserialization.

Parameters:

customItemSerializer - the custom item serializer for this operation

Returns:

the CosmosItemRequestOptions.

setExcludedRegions

public CosmosBulkExecutionOptions setExcludedRegions(List excludeRegions)

List of regions to exclude for the request/retries. Example "East US" or "East US, West US" These regions will be excluded from the preferred regions list

Parameters:

excludeRegions - list of regions

Returns:

setInitialMicroBatchSize

public CosmosBulkExecutionOptions setInitialMicroBatchSize(int initialMicroBatchSize)

Sets the initial size of micro batches that will be sent to the backend. The size of micro batches will be dynamically adjusted based on the throttling rate. The default value is 100 - so, it starts with relatively large micro batches and when the throttling rate is too high, it will reduce the batch size. When the short spikes of throttling before dynamically reducing the initial batch size results in side effects for other workloads the initial micro batch size can be reduced - for example set to 1 - at which point it would start with small micro batches and then increase the batch size over time.

Parameters:

initialMicroBatchSize - the initial micro batch size to be used. Must be a positive integer.

Returns:

the bulk execution options.

setMaxMicroBatchConcurrency

public CosmosBulkExecutionOptions setMaxMicroBatchConcurrency(int maxMicroBatchConcurrency)

Set the maximum concurrency for executing requests for a partition key range. By default, the maxMicroBatchConcurrency is 1. It only allows values ?1 and ?5. Attention! Please adjust this value with caution. By increasing this value, more concurrent requests will be allowed to be sent to the server, in which case may cause 429 or request timed out due to saturate local resources, which could degrade the performance.

Parameters:

maxMicroBatchConcurrency - the micro batch concurrency.

Returns:

the bulk processing options.

setMaxMicroBatchSize

public CosmosBulkExecutionOptions setMaxMicroBatchSize(int maxMicroBatchSize)

The maximum batch size for bulk operations. Once queued docs exceed this value, the micro batch will be flushed to the wire.

Parameters:

maxMicroBatchSize - maximum batching size.

Returns:

the bulk processing options.

setThroughputControlGroupName

public CosmosBulkExecutionOptions setThroughputControlGroupName(String throughputControlGroupName)

Sets the throughput control group name.

Parameters:

throughputControlGroupName - the throughput control group name.

Returns:

the CosmosBulkExecutionOptions.

Applies to