/** * 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); } }
@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)); }