Skip to content
Prev Previous commit
Next Next commit
Remove unnecessary public API from CosmosBatchResponse.
  • Loading branch information
jeet1995 committed Jan 7, 2025
commit ec620ab2f9566584b0aa3f6f89999b83c7ba640b
Original file line number Diff line number Diff line change
Expand Up @@ -1331,6 +1331,14 @@ public static void setCosmosBatchResponseAccessor(final CosmosBatchResponseAcces

public interface CosmosBatchResponseAccessor {
List<CosmosBatchOperationResult> getResults(CosmosBatchResponse cosmosBatchResponse);

void setOpCountPerEvaluation(CosmosBatchResponse cosmosBatchResponse, long opCountPerEvaluation);

void setGlobalOpCount(CosmosBatchResponse cosmosBatchResponse, long globalOpCount);

void setRetriedOpCountPerEvaluation(CosmosBatchResponse cosmosBatchResponse, long retriedOpCountPerEvaluation);

void setTargetMaxMicroBatchSize(CosmosBatchResponse cosmosBatchResponse, int targetMaxMicroBatchSize);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ public final class BulkExecutor<TContext> implements Disposable {
private final static AtomicLong instanceCount = new AtomicLong(0);
private static final ImplementationBridgeHelpers.CosmosAsyncClientHelper.CosmosAsyncClientAccessor clientAccessor =
ImplementationBridgeHelpers.CosmosAsyncClientHelper.getCosmosAsyncClientAccessor();
private static final ImplementationBridgeHelpers.CosmosBatchResponseHelper.CosmosBatchResponseAccessor cosmosBatchResponseAccessor =
ImplementationBridgeHelpers.CosmosBatchResponseHelper.getCosmosBatchResponseAccessor();

private final CosmosAsyncContainer container;
private final int maxMicroBatchPayloadSizeInBytes;
Expand Down Expand Up @@ -893,14 +895,18 @@ private Mono<CosmosBatchResponse> executeBatchRequest(
BridgeInternal.getLink(this.container), serverRequest, options, false)
.flatMap(cosmosBatchResponse -> {

cosmosBatchResponse.setGlobalOpCount(partitionScopeThresholds.getTotalOperationCountSnapshot());
cosmosBatchResponseAccessor.setGlobalOpCount(
cosmosBatchResponse, partitionScopeThresholds.getTotalOperationCountSnapshot());

PartitionScopeThresholds.CurrentIntervalThresholds currentIntervalThresholdsSnapshot
= partitionScopeThresholds.getCurrentThresholds();

cosmosBatchResponse.setOpCountPerEvaluation(currentIntervalThresholdsSnapshot.currentOperationCount.get());
cosmosBatchResponse.setRetriedOpCountPerEvaluation(currentIntervalThresholdsSnapshot.currentRetriedOperationCount.get());
cosmosBatchResponse.setTargetMaxMicroBatchSize(partitionScopeThresholds.getTargetMicroBatchSizeSnapshot());
cosmosBatchResponseAccessor.setOpCountPerEvaluation(
cosmosBatchResponse, currentIntervalThresholdsSnapshot.currentOperationCount.get());
cosmosBatchResponseAccessor.setRetriedOpCountPerEvaluation(
cosmosBatchResponse, currentIntervalThresholdsSnapshot.currentRetriedOperationCount.get());
cosmosBatchResponseAccessor.setTargetMaxMicroBatchSize(
cosmosBatchResponse, partitionScopeThresholds.getTargetMicroBatchSizeSnapshot());

return Mono.just(cosmosBatchResponse);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,67 +193,35 @@ public Duration getDuration() {
return this.cosmosDiagnostics.getDuration();
}

/**
* Get operation count per evaluation
* @return Operation count per evaluation
* */
public long getOpCountPerEvaluation() {
return opCountPerEvaluation;
}

/**
* Set operation count per evaluation
* @param opCountPerEvaluation Operation count per evaluation
* */
public void setOpCountPerEvaluation(long opCountPerEvaluation) {
void setOpCountPerEvaluation(long opCountPerEvaluation) {
this.opCountPerEvaluation = opCountPerEvaluation;
}

/**
* Get global operation count
* @return Global operation count
* */
public long getGlobalOpCount() {
return this.globalOpCount;
}

/**
* Set global operation count
* @param globalOpCount Global operation count
* */
public void setGlobalOpCount(long globalOpCount) {
void setGlobalOpCount(long globalOpCount) {
this.globalOpCount = globalOpCount;
}

/**
* Get retried operation count per evaluation
* @return retried operation count per evaluation
* */
public long getRetriedOpCountPerEvaluation() {
return retriedOpCountPerEvaluation;
}

/**
* Set retried operation count per evaluation
* @param retriedOpCountPerEvaluation retried operation count per evaluation
* */
public void setRetriedOpCountPerEvaluation(long retriedOpCountPerEvaluation) {
void setRetriedOpCountPerEvaluation(long retriedOpCountPerEvaluation) {
this.retriedOpCountPerEvaluation = retriedOpCountPerEvaluation;
}

/**
* Get target max micro batch size
* @return target max micro batch size
* */
public int getTargetMaxMicroBatchSize() {
return this.targetMaxMicroBatchSize;
}

/**
* Set target max micro batch size
* @param targetMaxMicroBatchSize target max micro batch size
* */
public void setTargetMaxMicroBatchSize(int targetMaxMicroBatchSize) {
void setTargetMaxMicroBatchSize(int targetMaxMicroBatchSize) {
this.targetMaxMicroBatchSize = targetMaxMicroBatchSize;
}

Expand All @@ -266,8 +234,32 @@ void addAll(List<? extends CosmosBatchOperationResult> collection) {
// the following helper/accessor only helps to access this class outside of this package.//
///////////////////////////////////////////////////////////////////////////////////////////
static void initialize() {
ImplementationBridgeHelpers.CosmosBatchResponseHelper.setCosmosBatchResponseAccessor(
cosmosBatchResponse -> cosmosBatchResponse.results);
ImplementationBridgeHelpers.CosmosBatchResponseHelper.setCosmosBatchResponseAccessor(new ImplementationBridgeHelpers.CosmosBatchResponseHelper.CosmosBatchResponseAccessor() {
@Override
public List<CosmosBatchOperationResult> getResults(CosmosBatchResponse cosmosBatchResponse) {
return cosmosBatchResponse.results;
}

@Override
public void setOpCountPerEvaluation(CosmosBatchResponse cosmosBatchResponse, long opCountPerEvaluation) {
cosmosBatchResponse.setOpCountPerEvaluation(opCountPerEvaluation);
}

@Override
public void setGlobalOpCount(CosmosBatchResponse cosmosBatchResponse, long globalOpCount) {
cosmosBatchResponse.setGlobalOpCount(globalOpCount);
}

@Override
public void setRetriedOpCountPerEvaluation(CosmosBatchResponse cosmosBatchResponse, long retriedOpCountPerEvaluation) {
cosmosBatchResponse.setRetriedOpCountPerEvaluation(retriedOpCountPerEvaluation);
}

@Override
public void setTargetMaxMicroBatchSize(CosmosBatchResponse cosmosBatchResponse, int targetMaxMicroBatchSize) {
cosmosBatchResponse.setTargetMaxMicroBatchSize(targetMaxMicroBatchSize);
}
});
}

static { initialize(); }
Expand Down
Loading