public R2Store(String storeName, String restBootstrapURL, String routingCodeStr, final TransportClient transportClient, Client d2Client, RESTClientConfig config, int zoneId) { super(storeName); if(transportClient == null) { this.client = d2Client; } else { this.client = new TransportClientAdapter(transportClient); } this.config = config; this.restBootstrapURL = restBootstrapURL; this.mapper = new ObjectMapper(); this.routingTypeCode = routingCodeStr; this.zoneId = zoneId; this.isActive = new AtomicBoolean(true); }
@Override public void shutdown(Callback<None> callback) { try { super.shutdown(callback); } finally { factory.shutdown(new FutureCallback<>()); } } }
this.transportClient.shutdown(clientShutdownCallback); try { clientShutdownCallback.get();
@Override public void restRequest(RestRequest request, RequestContext requestContext, Map<String, String> wireAttrs, TransportCallback<RestResponse> callback) { _client.restRequest(request, requestContext, wireAttrs, callback); }
@Override public void streamRequest(StreamRequest request, RequestContext requestContext, Map<String, String> wireAttrs, TransportCallback<StreamResponse> callback) { _streamClient.streamRequest(request, requestContext, wireAttrs, callback); }
@Override public void streamRequest(StreamRequest request, RequestContext requestContext, Callback<StreamResponse> callback) { final Map<String, String> wireAttrs = new HashMap<String, String>(); //make a copy of the caller's RequestContext to ensure that we have a unique instance per-request _client.streamRequest(request, new RequestContext(requestContext), wireAttrs, new TransportCallbackAdapter<StreamResponse>(callback)); }
public CoordinatorAdminClient(RESTClientConfig config) { this.config = config; this.httpClientFactory = new HttpClientFactory(); Map<String, String> properties = Maps.newHashMap(); properties.put(HttpClientFactory.HTTP_POOL_SIZE, Integer.toString(this.config.getMaxR2ConnectionPoolSize())); this.client = new TransportClientAdapter(httpClientFactory.getClient(properties)); }
@Override public void shutdown(Callback<None> callback) { _client.shutdown(callback); } }
@Override public void restRequest(RestRequest request, RequestContext requestContext, Map<String, String> wireAttrs, TransportCallback<RestResponse> callback) { _legacyClient.restRequest(request, requestContext, wireAttrs, callback); }
@Override public void streamRequest(StreamRequest request, RequestContext requestContext, Map<String, String> wireAttrs, TransportCallback<StreamResponse> callback) { _client.streamRequest(request, requestContext, wireAttrs, callback); }
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 shutdown(Callback<None> callback) { _wrappedClient.shutdown(callback); }
private Client newTransportClient(Map<String, ? extends Object> properties) { Client client = new TransportClientAdapter(_clientFactory.getClient(properties)); _transportClients.add(client); return client; }
/** * Starts asynchronous shutdown of the client. This method should block minimally, if at all. * * @param callback a callback that will be invoked once the shutdown is complete */ @Override public void shutdown(Callback<None> callback) { _transportClient.shutdown(callback); }
/** * 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(); }
@Override public void shutdown(Callback<None> callback) { _client.shutdown(callback); } }
/** * 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(); }
/** * 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 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")); } }
final Client r2Client = new TransportClientAdapter(http.getClient(Collections.<String, String>emptyMap()));