/** * Schedules operation to be executed in dispatcher * * @param callback to be notified about operation result */ public void enqueue(@Nullable final Callback<T> callback) { checkIfExecuted(); this.callback.set(callback); dispatcher.execute(new Runnable() { @Override public void run() { T result; try { result = perform(); } catch (Exception e) { notifyFailure(new ApolloException("Failed to perform store operation", e)); return; } notifySuccess(result); } }); }
@Override public void onFailure(@Nonnull ApolloException e) { Log.e(TAG, "Delta Sync: onFailure executed with exception: [" + e.getLocalizedMessage() + "]"); //Propagate if (subscriptionCallback != null) { Log.v(TAG, "Delta Sync: Propagating onFailure"); subscriptionCallback.onFailure(e); } }
public void onFailure(final ApolloException e) { if (e.getCause() instanceof SubscriptionDisconnectedException) { notifyDisconnectionEventToAllListeners(); } else { notifyErrorToAllListeners(e); } }
@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; }
/** * Execute store operation * <p> * <b>NOTE: this is a sync operation, proceed with a caution as it may include SQLite instruction<b/> * </p> * * @throws {@link ApolloException} in case of any errors */ public final T execute() throws ApolloException { checkIfExecuted(); try { return perform(); } catch (Exception e) { throw new ApolloException("Failed to perform store operation", e); } }
@Override public void run() { T result; try { result = perform(); } catch (Exception e) { notifyFailure(new ApolloException("Failed to perform store operation", e)); return; } notifySuccess(result); } });
InterceptorResponse resolveFromCache(InterceptorRequest request) throws ApolloException { ResponseNormalizer<Record> responseNormalizer = apolloStore.cacheResponseNormalizer(); //noinspection unchecked ApolloStoreOperation<Response> apolloStoreOperation = apolloStore.read(request.operation, responseFieldMapper, responseNormalizer, request.cacheHeaders); Response cachedResponse = apolloStoreOperation.execute(); if (cachedResponse.data() != null) { logger.d("Cache HIT for operation %s", request.operation); return new InterceptorResponse(null, cachedResponse, responseNormalizer.records()); } logger.d("Cache MISS for operation %s", request.operation); throw new ApolloException(String.format("Cache miss for operation %s", request.operation)); }
@Override public void run() { T result; try { result = perform(); } catch (Exception e) { notifyFailure(new ApolloException("Failed to perform store operation", e)); return; } notifySuccess(result); } });
@Override public void run() { T result; try { result = perform(); } catch (Exception e) { notifyFailure(new ApolloException("Failed to perform store operation", e)); return; } notifySuccess(result); } });
@Override public void onError(String topic, Exception e) { final Set<SubscriptionObject> subscriptionObjects = getSubscriptionObjectSetFromTopicMap(topic); if (subscriptionObjects == null || subscriptionObjects.size() == 0) { Log.w(TAG, "Subscription Infrastructure: No subscription objects found for topic [" + topic+"]"); } else { for (SubscriptionObject subscriptionObject : subscriptionObjects) { subscriptionObject.onFailure(new ApolloException("Subscription Infrastructure: onError called for Subscription [" + subscriptionObject +"]", e)); } } } };
/** * Schedules operation to be executed in dispatcher * * @param callback to be notified about operation result */ public void enqueue(@Nullable final Callback<T> callback) { checkIfExecuted(); this.callback.set(callback); dispatcher.execute(new Runnable() { @Override public void run() { T result; try { result = perform(); } catch (Exception e) { notifyFailure(new ApolloException("Failed to perform store operation", e)); return; } notifySuccess(result); } }); }
/** * Schedules operation to be executed in dispatcher * * @param callback to be notified about operation result */ public void enqueue(@Nullable final Callback<T> callback) { checkIfExecuted(); this.callback.set(callback); dispatcher.execute(new Runnable() { @Override public void run() { T result; try { result = perform(); } catch (Exception e) { notifyFailure(new ApolloException("Failed to perform store operation", e)); return; } notifySuccess(result); } }); }
/** * Execute store operation * <p> * <b>NOTE: this is a sync operation, proceed with a caution as it may include SQLite instruction<b/> * </p> * * @throws {@link ApolloException} in case of any errors */ public final T execute() throws ApolloException { checkIfExecuted(); try { return perform(); } catch (Exception e) { throw new ApolloException("Failed to perform store operation", e); } }
/** * Execute store operation * <p> * <b>NOTE: this is a sync operation, proceed with a caution as it may include SQLite instruction<b/> * </p> * * @throws {@link ApolloException} in case of any errors */ public final T execute() throws ApolloException { checkIfExecuted(); try { return perform(); } catch (Exception e) { throw new ApolloException("Failed to perform store operation", e); } }
@Override public void onError(Exception e) { Log.v(TAG, "Subscription Infrastructure: onError called " + e); if (subscriptionsAutoReconnect) { if ( e instanceof SubscriptionDisconnectedException ) { Log.v(TAG, "Subscription Infrastructure: Disconnect received. Unexpected - Initiating reconnect sequence."); reportConnectionError(); initiateReconnectSequence(); return; } } //Propagate connection error for (String topic: info.topics) { if ( getSubscriptionObjectSetFromTopicMap(topic) != null ) { for (SubscriptionObject subscriptionObject : getSubscriptionObjectSetFromTopicMap(topic)) { subscriptionObject.onFailure(new ApolloException("Connection Error Reported", e)); } } } allClientsConnectedLatch.countDown(); } });
callBack.onFailure(new ApolloException("S3 Object Manager not setup")); return; return; callBack.onFailure(new ApolloException("S3 upload failed.", e.getCause())); return; callBack.onFailure(new ApolloException("S3 upload failed.", e.getCause())); return;
private InterceptorResponse resolveFromCache(InterceptorRequest request) throws ApolloException { ResponseNormalizer<Record> responseNormalizer = mApolloStore.cacheResponseNormalizer(); //noinspection unchecked GraphQLStoreOperation<Response> graphQLStoreOperation = mApolloStore.read(request.operation, responseFieldMapper, responseNormalizer, request.cacheHeaders); Response cachedResponse = graphQLStoreOperation.execute(); if (cachedResponse.data() != null) { logger.d("Cache HIT for operation %s", request.operation); return new InterceptorResponse(null, cachedResponse, responseNormalizer.records()); } logger.d("Cache MISS for operation %s", request.operation); throw new ApolloException(String.format("Cache miss for operation %s", request.operation)); }
private InterceptorResponse resolveFromCache(InterceptorRequest request) throws ApolloException { ResponseNormalizer<Record> responseNormalizer = mApolloStore.cacheResponseNormalizer(); //noinspection unchecked GraphQLStoreOperation<Response> graphQLStoreOperation = mApolloStore.read(request.operation, responseFieldMapper, responseNormalizer, request.cacheHeaders); Response cachedResponse = graphQLStoreOperation.execute(); if (cachedResponse.data() != null) { logger.d("Cache HIT for operation %s", request.operation); return new InterceptorResponse(null, cachedResponse, responseNormalizer.records()); } logger.d("Cache MISS for operation %s", request.operation); throw new ApolloException(String.format("Cache miss for operation %s", request.operation)); }