public <T> ResponseFuture<T> sendRequest(RequestBuilder<? extends Request<T>> requestBuilder, RequestContext requestContext, ErrorHandlingBehavior errorHandlingBehavior) { return _delegate.sendRequest(requestBuilder, requestContext, errorHandlingBehavior); }
/** * Construct a {@link FlowStatusClient} to communicate with http flow status server at URI serverUri * @param serverUri address and port of the REST server */ public FlowStatusClient(String serverUri) { LOG.debug("FlowConfigClient with serverUri " + serverUri); _httpClientFactory = Optional.of(new HttpClientFactory()); Client r2Client = new TransportClientAdapter(_httpClientFactory.get().getClient(Collections.<String, String>emptyMap())); _restClient = Optional.of(new RestClient(r2Client, serverUri)); _flowstatusesRequestBuilders = new FlowstatusesRequestBuilders(); }
public void shutdown(Callback<None> callback) { _delegate.shutdown(callback); }
private <T> void sendRequestNoScatterGather(final Request<T> request, final RequestContext requestContext, final Callback<Response<T>> callback) { //Here we need to decide if we want to use StreamRequest/StreamResponse or RestRequest/RestResponse. //Eventually we will move completely to StreamRequest/StreamResponse for all traffic. //However for the time being we will only use StreamRequest/StreamResponse for traffic that contains attachments. // //Therefore the decision is made as follows: //1. If the content-type OR accept-type is multipart/related then we use StreamRequest/StreamResponse, //otherwise we use RestRequest/RestResponse. //2. The content-type will be decided based on the presence of attachments in the request. //3. The accept-type will be based on the RestLiRequestOptions. //Note that it is not possible for the list of streaming attachments to be non-null and have 0 elements. If the //list of streaming attachments is non null then it must have at least one attachment. The request builders enforce //this invariant. if (_restLiClientConfig.isUseStreaming() || request.getStreamingAttachments() != null || request.getRequestOptions().getAcceptResponseAttachments()) { //Set content type and accept type correctly and use StreamRequest/StreamResponse sendStreamRequest(request, requestContext, new RestLiStreamCallbackAdapter<T>(request.getResponseDecoder(), callback)); } else { sendRestRequest(request, requestContext, new RestLiCallbackAdapter<T>(request.getResponseDecoder(), callback)); } }
public <T> void sendRestRequest(Request<T> request, RequestContext requestContext, Callback<RestResponse> callback) { _capturedRequestContexts.put(request, requestContext); _delegate.sendRestRequest(request, requestContext, withTransformationRestResponse(callback)); }
public <T> ResponseFuture<T> sendRequest(RequestBuilder<? extends Request<T>> requestBuilder, RequestContext requestContext) { return _delegate.sendRequest(requestBuilder, requestContext); }
/** * Construct a {@link FlowConfigV2Client} to communicate with http flow config server at URI serverUri * @param serverUri address and port of the REST server */ public FlowConfigV2Client(String serverUri) { LOG.debug("FlowConfigClient with serverUri " + serverUri); _httpClientFactory = Optional.of(new HttpClientFactory()); Client r2Client = new TransportClientAdapter(_httpClientFactory.get().getClient(Collections.<String, String>emptyMap())); _restClient = Optional.of(new RestClient(r2Client, serverUri)); _flowconfigsV2RequestBuilders = new FlowconfigsV2RequestBuilders(); }
@Override public void close() throws IOException { if (_restClient.isPresent()) { _restClient.get().shutdown(new FutureCallback<None>()); } if (_httpClientFactory.isPresent()) { _httpClientFactory.get().shutdown(new FutureCallback<None>()); } } }
public <T> ResponseFuture<T> sendRequest(RequestBuilder<? extends Request<T>> requestBuilder, ErrorHandlingBehavior errorHandlingBehavior) { return _delegate.sendRequest(requestBuilder, errorHandlingBehavior); }
/** * Construct a {@link FlowConfigClient} to communicate with http flow config server at URI serverUri * @param serverUri address and port of the REST server */ public FlowConfigClient(String serverUri) { LOG.debug("FlowConfigClient with serverUri " + serverUri); _httpClientFactory = Optional.of(new HttpClientFactory()); Client r2Client = new TransportClientAdapter(_httpClientFactory.get().getClient(Collections.<String, String>emptyMap())); _restClient = Optional.of(new RestClient(r2Client, serverUri)); _flowconfigsRequestBuilders = new FlowconfigsRequestBuilders(); }
@Override public void close() throws IOException { if (_restClient.isPresent()) { _restClient.get().shutdown(new FutureCallback<None>()); } if (_httpClientFactory.isPresent()) { _httpClientFactory.get().shutdown(new FutureCallback<None>()); } } }
public <T> ResponseFuture<T> sendRequest(Request<T> request) { return _delegate.sendRequest(request); }
public JobExecutionInfoClient(String serverUri) { this.httpClientFactory = new HttpClientFactory(); Client r2Client = new TransportClientAdapter(this.httpClientFactory.getClient(Collections.<String, String>emptyMap())); this.restClient = new RestClient(r2Client, serverUri); }
@Override public void close() throws IOException { if (_restClient.isPresent()) { _restClient.get().shutdown(new FutureCallback<None>()); } if (_httpClientFactory.isPresent()) { _httpClientFactory.get().shutdown(new FutureCallback<None>()); } } }
public void sendRequest(MultiplexedRequest multiplexedRequest) { _delegate.sendRequest(multiplexedRequest); }
protected RestClient createRestClient() { Client client = newTransportClient(Collections.<String, String> emptyMap()); return new RestClient(client, URI_PREFIX); }
@Override public void close() throws IOException { this.restClient.shutdown(new FutureCallback<None>()); this.httpClientFactory.shutdown(new FutureCallback<None>()); } }
public <T> ResponseFuture<T> sendRequest(Request<T> request, ErrorHandlingBehavior errorHandlingBehavior) { return _delegate.sendRequest(request, errorHandlingBehavior); }
@Override public SharedResourceFactoryResponse<RestClient> createResource(SharedResourcesBroker<S> broker, ScopedConfigView<S, SharedRestClientKey> config) throws NotConfiguredException { try { SharedRestClientKey key = config.getKey(); if (!(key instanceof UriRestClientKey)) { return new ResourceCoordinate<>(this, new UriRestClientKey(key.serviceName, resolveUriPrefix(config.getConfig(), key)), config.getScope()); } String uriPrefix = ((UriRestClientKey) key).getUri(); HttpClientFactory http = new HttpClientFactory(FilterChains.empty(), new NioEventLoopGroup(0 /* use default settings */, ExecutorsUtils.newDaemonThreadFactory(Optional.<Logger>absent(), Optional.of("R2 Nio Event Loop-%d"))), true, Executors.newSingleThreadScheduledExecutor( ExecutorsUtils.newDaemonThreadFactory(Optional.<Logger>absent(), Optional.of("R2 Netty Scheduler"))), true); Client r2Client = new TransportClientAdapter(http.getClient(Collections.<String, String>emptyMap())); return new ResourceInstance<>(new RestClient(r2Client,uriPrefix)); } catch (URISyntaxException use) { throw new RuntimeException("Could not create a rest client for key " + Optional.fromNullable(config.getKey().toConfigurationKey()).or("null")); } }
@Override public void close() throws IOException { if (_restClient.isPresent()) { _restClient.get().shutdown(new FutureCallback<None>()); } if (_httpClientFactory.isPresent()) { _httpClientFactory.get().shutdown(new FutureCallback<None>()); } } }