void handleMutationCancellation(Mutation canceledMutation ) { Log.v(TAG, "Thread:[" + Thread.currentThread().getId() +"]: Handling cancellation for mutation [" + canceledMutation +"]"); //Check if the mutation being cancelled is the one currently being executed. if (currentMutation != null && currentMutation.request != null && canceledMutation.equals(currentMutation.request.operation)) { Log.v(TAG, "Thread:[" + Thread.currentThread().getId() +"]: Mutation being canceled is the one currently in progress. Handling it "); setInProgressMutationAsCompleted(currentMutation.recordIdentifier); queueHandler.sendEmptyMessage(MessageNumberUtil.FAIL_EXEC); return; } //Otherwise, it is further down in the queue. Add it to the cancelled Mutations tests so that it can be handled when it reaches the front //of the queue. Log.v(TAG, "Thread:[" + Thread.currentThread().getId() +"]: Lodging mutation in cancelled mutations list "); inMemoryOfflineMutationManager.addCancelledMutation(canceledMutation); //Remove it from the persistent queue InMemoryOfflineMutationObject inMemoryOfflineMutationObject = inMemoryOfflineMutationManager.getMutationObject(canceledMutation); if ( inMemoryOfflineMutationObject != null ) { persistentOfflineMutationManager.removePersistentMutationObject(inMemoryOfflineMutationObject.recordIdentifier); } }
private void setMutationExecutionAsCompletedAndRemoveFromQueue (PersistentOfflineMutationObject p) { //This mutation is completed. So remove it from the queue. persistentOfflineMutationManager.removePersistentMutationObject(p.recordIdentifier); if (persistentOfflineMutationManager.getTimedoutMutations().contains(p)) { //Mutation has been tagged as timed out. Remove this from the timedOutList. //The queueHandler will manage getting the queue unblocked for this case. persistentOfflineMutationManager.removeTimedoutMutation(p); } else { //Mutation not tagged as timed out. Signal queueHandler that this mutation is done. queueHandler.setMutationInProgressStatusToFalse(); } }
void setInProgressPersistentMutationAsCompleted(String recordIdentifier) { persistentOfflineMutationManager.removePersistentMutationObject(recordIdentifier); queueHandler.setMutationInProgressStatusToFalse(); queueHandler.clearInMemoryOfflineMutationObjectBeingExecuted(); queueHandler.clearPersistentOfflineMutationObjectBeingExecuted(); }
void setInProgressMutationAsCompleted(String recordIdentifier) { persistentOfflineMutationManager.removePersistentMutationObject(recordIdentifier); inMemoryOfflineMutationManager.removeFromQueue(recordIdentifier); queueHandler.setMutationInProgressStatusToFalse(); queueHandler.clearInMemoryOfflineMutationObjectBeingExecuted(); queueHandler.clearPersistentOfflineMutationObjectBeingExecuted(); }
appSyncOfflineMutationManager.persistentOfflineMutationManager.removePersistentMutationObject(persistentOfflineMutationObjectBeingExecuted.recordIdentifier);