@Override public void onFailure(@Nonnull ApolloException e) { Log.v(TAG, "Thread:[" + Thread.currentThread().getId() +"]: onFailure() " + e.getLocalizedMessage()); if (e instanceof ApolloNetworkException ) { //Happened due to a network error. Log.v(TAG, "Thread:[" + Thread.currentThread().getId() +"]: Network Exception " + e.getLocalizedMessage()); Log.v(TAG, "Thread:[" + Thread.currentThread().getId() +"]: Will retry mutation when back on network"); queueHandler.setMutationInProgressStatusToFalse(); return; } shouldRetry = false; //Call the customer's callback customerCallBack.onFailure(e); //Set the mutation as completed. appSyncOfflineMutationManager.setInProgressMutationAsCompleted(recordIdentifier); //Send a message to the QueueHandler to process the next mutation in queue Message message = new Message(); message.obj = new MutationInterceptorMessage(originalMutation, currentMutation); message.what = MessageNumberUtil.FAIL_EXEC; queueHandler.sendMessage(message); return; }
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(); } }
queueHandler.setMutationInProgressStatusToFalse(); return;
void setInProgressMutationAsCompleted(String recordIdentifier) { persistentOfflineMutationManager.removePersistentMutationObject(recordIdentifier); inMemoryOfflineMutationManager.removeFromQueue(recordIdentifier); queueHandler.setMutationInProgressStatusToFalse(); queueHandler.clearInMemoryOfflineMutationObjectBeingExecuted(); queueHandler.clearPersistentOfflineMutationObjectBeingExecuted(); }
void setInProgressPersistentMutationAsCompleted(String recordIdentifier) { persistentOfflineMutationManager.removePersistentMutationObject(recordIdentifier); queueHandler.setMutationInProgressStatusToFalse(); queueHandler.clearInMemoryOfflineMutationObjectBeingExecuted(); queueHandler.clearPersistentOfflineMutationObjectBeingExecuted(); }