|
@@ -41,11 +41,6 @@ class BulkPrimaryExecutionContext {
|
|
|
* submitted
|
|
|
*/
|
|
|
WAIT_FOR_MAPPING_UPDATE,
|
|
|
- /**
|
|
|
- * The request should be executed again, but there is no need to wait for an external event.
|
|
|
- * This is needed to support retry on conflicts during updates.
|
|
|
- */
|
|
|
- IMMEDIATE_RETRY,
|
|
|
/** The request has been executed on the primary shard (successfully or not) */
|
|
|
EXECUTED,
|
|
|
/**
|
|
@@ -115,29 +110,11 @@ class BulkPrimaryExecutionContext {
|
|
|
return retryCounter;
|
|
|
}
|
|
|
|
|
|
- /** returns true if the current request has been executed on the primary */
|
|
|
- public boolean isOperationExecuted() {
|
|
|
- return currentItemState == ItemProcessingState.EXECUTED;
|
|
|
- }
|
|
|
-
|
|
|
/** returns true if the request needs to wait for a mapping update to arrive from the master */
|
|
|
public boolean requiresWaitingForMappingUpdate() {
|
|
|
return currentItemState == ItemProcessingState.WAIT_FOR_MAPPING_UPDATE;
|
|
|
}
|
|
|
|
|
|
- /** returns true if the current request should be retried without waiting for an external event */
|
|
|
- public boolean requiresImmediateRetry() {
|
|
|
- return currentItemState == ItemProcessingState.IMMEDIATE_RETRY;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * returns true if the current request has been completed and it's result translated to a user
|
|
|
- * facing response
|
|
|
- */
|
|
|
- public boolean isCompleted() {
|
|
|
- return currentItemState == ItemProcessingState.COMPLETED;
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* returns true if the current request is in INITIAL state
|
|
|
*/
|
|
@@ -203,19 +180,19 @@ class BulkPrimaryExecutionContext {
|
|
|
|
|
|
/** resets the current item state, prepare for a new execution */
|
|
|
public void resetForExecutionForRetry() {
|
|
|
- assertInvariants(ItemProcessingState.WAIT_FOR_MAPPING_UPDATE, ItemProcessingState.EXECUTED);
|
|
|
+ assert assertInvariants(ItemProcessingState.WAIT_FOR_MAPPING_UPDATE, ItemProcessingState.EXECUTED);
|
|
|
currentItemState = ItemProcessingState.INITIAL;
|
|
|
requestToExecute = null;
|
|
|
executionResult = null;
|
|
|
- assertInvariants(ItemProcessingState.INITIAL);
|
|
|
+ assert assertInvariants(ItemProcessingState.INITIAL);
|
|
|
}
|
|
|
|
|
|
/** completes the operation without doing anything on the primary */
|
|
|
public void markOperationAsNoOp(DocWriteResponse response) {
|
|
|
- assertInvariants(ItemProcessingState.INITIAL);
|
|
|
+ assert assertInvariants(ItemProcessingState.INITIAL);
|
|
|
executionResult = BulkItemResponse.success(getCurrentItem().id(), getCurrentItem().request().opType(), response);
|
|
|
currentItemState = ItemProcessingState.EXECUTED;
|
|
|
- assertInvariants(ItemProcessingState.EXECUTED);
|
|
|
+ assert assertInvariants(ItemProcessingState.EXECUTED);
|
|
|
}
|
|
|
|
|
|
/** indicates that the operation needs to be failed as the required mapping didn't arrive in time */
|
|
@@ -235,7 +212,7 @@ class BulkPrimaryExecutionContext {
|
|
|
|
|
|
/** the current operation has been executed on the primary with the specified result */
|
|
|
public void markOperationAsExecuted(Engine.Result result) {
|
|
|
- assertInvariants(ItemProcessingState.TRANSLATED);
|
|
|
+ assert assertInvariants(ItemProcessingState.TRANSLATED);
|
|
|
final BulkItemRequest current = getCurrentItem();
|
|
|
DocWriteRequest<?> docWriteRequest = getRequestToExecute();
|
|
|
switch (result.getResultType()) {
|
|
@@ -290,7 +267,7 @@ class BulkPrimaryExecutionContext {
|
|
|
|
|
|
/** finishes the execution of the current request, with the response that should be returned to the user */
|
|
|
public void markAsCompleted(BulkItemResponse translatedResponse) {
|
|
|
- assertInvariants(ItemProcessingState.EXECUTED);
|
|
|
+ assert assertInvariants(ItemProcessingState.EXECUTED);
|
|
|
assert executionResult != null && translatedResponse.getItemId() == executionResult.getItemId();
|
|
|
assert translatedResponse.getItemId() == getCurrentItem().id();
|
|
|
|
|
@@ -329,10 +306,6 @@ class BulkPrimaryExecutionContext {
|
|
|
assert requestToExecute == null;
|
|
|
assert executionResult == null : executionResult;
|
|
|
break;
|
|
|
- case IMMEDIATE_RETRY:
|
|
|
- assert requestToExecute != null;
|
|
|
- assert executionResult == null : executionResult;
|
|
|
- break;
|
|
|
case EXECUTED:
|
|
|
// requestToExecute can be null if the update ended up as NOOP
|
|
|
assert executionResult != null;
|