Search in sources :

Example 1 with SuccessCallback

use of com.linkedin.common.callback.SuccessCallback in project rest.li by linkedin.

the class DynamicClient method getClientCallback.

private Callback<TransportClient> getClientCallback(Request request, RequestContext requestContext, final boolean restOverStream, Callback<? extends Response> callback, SuccessCallback<Client> clientSuccessCallback) {
    return new Callback<TransportClient>() {

        @Override
        public void onError(Throwable e) {
            TimingContextUtil.markTiming(requestContext, TIMING_KEY);
            callback.onError(e);
            warn(_log, "unable to find service for: ", extractLogInfo(request));
        }

        @Override
        public void onSuccess(TransportClient client) {
            TimingContextUtil.markTiming(requestContext, TIMING_KEY);
            if (client != null) {
                clientSuccessCallback.onSuccess(new TransportClientAdapter(client, restOverStream));
            } else {
                callback.onError(new ServiceUnavailableException("PEGA_1000. Unknown: " + request.getURI(), "got null client from load balancer"));
            }
        }
    };
}
Also used : SuccessCallback(com.linkedin.common.callback.SuccessCallback) Callback(com.linkedin.common.callback.Callback) TransportClient(com.linkedin.r2.transport.common.bridge.client.TransportClient) TransportClientAdapter(com.linkedin.r2.transport.common.bridge.client.TransportClientAdapter) ServiceUnavailableException(com.linkedin.d2.balancer.ServiceUnavailableException)

Aggregations

Callback (com.linkedin.common.callback.Callback)1 SuccessCallback (com.linkedin.common.callback.SuccessCallback)1 ServiceUnavailableException (com.linkedin.d2.balancer.ServiceUnavailableException)1 TransportClient (com.linkedin.r2.transport.common.bridge.client.TransportClient)1 TransportClientAdapter (com.linkedin.r2.transport.common.bridge.client.TransportClientAdapter)1