io.reactivex.netty.client.RxClient Java Examples
The following examples show how to use
io.reactivex.netty.client.RxClient.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LoadBalancingTcpClient.java From ribbon with Apache License 2.0 | 6 votes |
@Override protected RxClient<I, O> createRxClient(Server server) { ClientBuilder<I, O> builder = RxNetty.newTcpClientBuilder(server.getHost(), server.getPort()); if (pipelineConfigurator != null) { builder.pipelineConfigurator(pipelineConfigurator); } Integer connectTimeout = getProperty(IClientConfigKey.Keys.ConnectTimeout, null, DefaultClientConfigImpl.DEFAULT_CONNECT_TIMEOUT); builder.channelOption(ChannelOption.CONNECT_TIMEOUT_MILLIS, connectTimeout); if (isPoolEnabled()) { builder.withConnectionPoolLimitStrategy(poolStrategy) .withIdleConnectionsTimeoutMillis(idleConnectionEvictionMills) .withPoolIdleCleanupScheduler(poolCleanerScheduler); } else { builder.withNoConnectionPooling(); } RxClient<I, O> client = builder.build(); return client; }
Example #2
Source File: MyUDPClient.java From ribbon with Apache License 2.0 | 6 votes |
public Observable<DatagramPacket> submit(final String content) { return LoadBalancerCommand.<DatagramPacket>builder() .withLoadBalancerContext(lbContext) .build() .submit(new ServerOperation<DatagramPacket>() { @Override public Observable<DatagramPacket> call(Server server) { RxClient<DatagramPacket, DatagramPacket> rxClient = getOrCreateRxClient(server); return rxClient.connect().flatMap(new Func1<ObservableConnection<DatagramPacket, DatagramPacket>, Observable<? extends DatagramPacket>>() { @Override public Observable<? extends DatagramPacket> call(ObservableConnection<DatagramPacket, DatagramPacket> connection) { connection.writeStringAndFlush(content); return connection.getInput().timeout(10, TimeUnit.MILLISECONDS).take(1); } }); } }); }
Example #3
Source File: RedisTextWebSocketHandler.java From sc-generator with Apache License 2.0 | 6 votes |
public void close(WebSocketSession webSocketSession) { Replicator replicator = replicatorMap.remove(webSocketSession.getId()); if (replicator != null) { try { replicator.close(); webSocketSession.close(); } catch (IOException e) { logger.warn(e.getMessage()); } } RxClient rxClient = rxClientMap.get(webSocketSession.getId()); if (rxClient != null) { rxClient.shutdown(); } observableMap.remove(webSocketSession.getId()); authMap.remove(webSocketSession.getId()); }
Example #4
Source File: SpyClientUnderTestFactory.java From azure-cosmosdb-java with MIT License | 6 votes |
void initRequestCapture(CompositeHttpClient<ByteBuf, ByteBuf> spyClient) { doAnswer(new Answer() { @Override public Object answer(InvocationOnMock invocationOnMock) throws Throwable { RxClient.ServerInfo serverInfo = invocationOnMock.getArgumentAt(0, RxClient.ServerInfo.class); HttpClientRequest<ByteBuf> httpReq = invocationOnMock.getArgumentAt(1, HttpClientRequest.class); CompletableFuture<HttpResponseHeaders> f = new CompletableFuture<>(); requestsResponsePairs.add(Pair.of(httpReq, f)); return origHttpClient.submit(serverInfo, httpReq) .doOnNext( res -> f.complete(res.getHeaders()) ).doOnError( e -> f.completeExceptionally(e) ); } }).when(spyClient).submit(Mockito.any(RxClient.ServerInfo.class), Mockito.any(HttpClientRequest.class)); }
Example #5
Source File: SpyClientUnderTestFactory.java From azure-cosmosdb-java with MIT License | 6 votes |
void initRequestCapture(CompositeHttpClient<ByteBuf, ByteBuf> spyClient) { doAnswer(new Answer() { @Override public Object answer(InvocationOnMock invocationOnMock) throws Throwable { RxClient.ServerInfo serverInfo = invocationOnMock.getArgumentAt(0, RxClient.ServerInfo.class); HttpClientRequest<ByteBuf> httpReq = invocationOnMock.getArgumentAt(1, HttpClientRequest.class); CompletableFuture<HttpResponseHeaders> f = new CompletableFuture<>(); requestsResponsePairs.add(Pair.of(httpReq, f)); return origHttpClient.submit(serverInfo, httpReq) .doOnNext( res -> f.complete(res.getHeaders()) ).doOnError( e -> f.completeExceptionally(e) ); } }).when(spyClient).submit(Mockito.any(RxClient.ServerInfo.class), Mockito.any(HttpClientRequest.class)); }
Example #6
Source File: GatewayServiceConfigurationReaderTest.java From azure-cosmosdb-java with MIT License | 5 votes |
@Test(groups = "simple") public void mockInitializeReaderAsyncWithResourceToken() throws Exception { mockGatewayServiceConfigurationReader = new GatewayServiceConfigurationReader(new URI(TestConfigurations.HOST), true, "SampleResourceToken", connectionPolicy, baseAuthorizationTokenProvider, mockHttpClient); HttpClientResponse<ByteBuf> mockedResponse = getMockResponse(databaseAccountJson); Mockito.when(mockHttpClient.submit(Matchers.any(RxClient.ServerInfo.class), Matchers.any())) .thenReturn(Observable.just(mockedResponse)); Single<DatabaseAccount> databaseAccount = mockGatewayServiceConfigurationReader.initializeReaderAsync(); validateSuccess(databaseAccount, expectedDatabaseAccount); }
Example #7
Source File: RxGatewayStoreModel.java From azure-cosmosdb-java with MIT License | 5 votes |
/** * Given the request it creates an observable which upon subscription issues HTTP call and emits one RxDocumentServiceResponse. * * @param request * @param method * @return Observable<RxDocumentServiceResponse> */ public Observable<RxDocumentServiceResponse> performRequest(RxDocumentServiceRequest request, HttpMethod method) { try { URI uri = getUri(request); HttpClientRequest<ByteBuf> httpRequest = HttpClientRequest.create(method, uri.toString()); this.fillHttpRequestBaseWithHeaders(request.getHeaders(), httpRequest); if (request.getContentObservable() != null) { // TODO validate this // convert byte[] to ByteBuf // why not use Observable<byte[]> directly? Observable<ByteBuf> byteBufObservable = request.getContentObservable() .map(bytes -> Unpooled.wrappedBuffer(bytes)); httpRequest.withContentSource(byteBufObservable); } else if (request.getContent() != null){ httpRequest.withContent(request.getContent()); } RxClient.ServerInfo serverInfo = new RxClient.ServerInfo(uri.getHost(), uri.getPort()); Observable<HttpClientResponse<ByteBuf>> clientResponseObservable = this.httpClient.submit(serverInfo, httpRequest); return toDocumentServiceResponse(clientResponseObservable, request).observeOn(Schedulers.computation()); } catch (Exception e) { return Observable.error(e); } }
Example #8
Source File: UdpClientTest.java From ribbon with Apache License 2.0 | 5 votes |
@Test public void testUdpClientWithoutTimeout() throws Exception { int port = choosePort(); UdpServer<DatagramPacket, DatagramPacket> server = new HelloUdpServer(port, 0).createServer(); server.start(); BaseLoadBalancer lb = new BaseLoadBalancer(); lb.setServersList(Lists.newArrayList(new Server("localhost", port))); RxClient<DatagramPacket, DatagramPacket> client = RibbonTransport.newUdpClient(lb, DefaultClientConfigImpl.getClientConfigWithDefaultValues()); try { String response = client.connect().flatMap(new Func1<ObservableConnection<DatagramPacket, DatagramPacket>, Observable<DatagramPacket>>() { @Override public Observable<DatagramPacket> call(ObservableConnection<DatagramPacket, DatagramPacket> connection) { connection.writeStringAndFlush("Is there anybody out there?"); return connection.getInput(); } }).take(1) .map(new Func1<DatagramPacket, String>() { @Override public String call(DatagramPacket datagramPacket) { return datagramPacket.content().toString(Charset.defaultCharset()); } }) .toBlocking() .first(); assertEquals(HelloUdpServer.WELCOME_MSG, response); } finally { server.shutdown(); } }
Example #9
Source File: LoadBalancingHttpClient.java From ribbon with Apache License 2.0 | 5 votes |
/** * Construct an RxClient.ClientConfig from an IClientConfig * * @param requestConfig * @return */ private RxClient.ClientConfig getRxClientConfig(IClientConfig requestConfig) { if (requestConfig == null) { return DEFAULT_RX_CONFIG; } int requestReadTimeout = getProperty(IClientConfigKey.Keys.ReadTimeout, requestConfig, DefaultClientConfigImpl.DEFAULT_READ_TIMEOUT); Boolean followRedirect = getProperty(IClientConfigKey.Keys.FollowRedirects, requestConfig, null); HttpClientConfig.Builder builder = new HttpClientConfig.Builder().readTimeout(requestReadTimeout, TimeUnit.MILLISECONDS); if (followRedirect != null) { builder.setFollowRedirect(followRedirect); } return builder.build(); }
Example #10
Source File: SSEClient.java From ribbon with Apache License 2.0 | 5 votes |
@Override protected HttpClient<I, ServerSentEvent> getOrCreateRxClient(Server server) { HttpClientBuilder<I, ServerSentEvent> clientBuilder = new HttpClientBuilder<I, ServerSentEvent>(server.getHost(), server.getPort()).pipelineConfigurator(pipelineConfigurator); int requestConnectTimeout = getProperty(IClientConfigKey.Keys.ConnectTimeout, null, DefaultClientConfigImpl.DEFAULT_CONNECT_TIMEOUT); RxClient.ClientConfig rxClientConfig = new HttpClientConfig.Builder().build(); HttpClient<I, ServerSentEvent> client = clientBuilder.channelOption( ChannelOption.CONNECT_TIMEOUT_MILLIS, requestConnectTimeout).config(rxClientConfig).build(); return client; }
Example #11
Source File: HttpClientUnderTestWrapper.java From azure-cosmosdb-java with MIT License | 5 votes |
void initRequestCapture(CompositeHttpClient<ByteBuf, ByteBuf> spyClient) { doAnswer(new Answer() { @Override public Object answer(InvocationOnMock invocationOnMock) throws Throwable { RxClient.ServerInfo serverInfo = invocationOnMock.getArgumentAt(0, RxClient.ServerInfo.class); HttpClientRequest<ByteBuf> httpReq = invocationOnMock.getArgumentAt(1, HttpClientRequest.class); capturedRequest.add(httpReq); return origHttpClient.submit(serverInfo, httpReq); } }).when(spyClient).submit(Mockito.any(RxClient.ServerInfo.class), Mockito.any(HttpClientRequest.class)); }
Example #12
Source File: LoadBalancingUdpClient.java From ribbon with Apache License 2.0 | 5 votes |
@Override protected RxClient<I, O> createRxClient(Server server) { UdpClientBuilder<I, O> builder = RxNetty.newUdpClientBuilder(server.getHost(), server.getPort()); if (pipelineConfigurator != null) { builder.pipelineConfigurator(pipelineConfigurator); } return builder.build(); }
Example #13
Source File: RxGatewayStoreModelTest.java From azure-cosmosdb-java with MIT License | 5 votes |
@Test(groups = "unit") public void readTimeout() throws Exception { ISessionContainer sessionContainer = Mockito.mock(ISessionContainer.class); QueryCompatibilityMode queryCompatibilityMode = QueryCompatibilityMode.Default; UserAgentContainer userAgentContainer = new UserAgentContainer(); GlobalEndpointManager globalEndpointManager = Mockito.mock(GlobalEndpointManager.class); Mockito.doReturn(new URL("https://localhost")) .when(globalEndpointManager).resolveServiceEndpoint(Mockito.any()); CompositeHttpClient<ByteBuf, ByteBuf> httpClient = Mockito.mock(CompositeHttpClient.class); Mockito.doReturn(Observable.error(ReadTimeoutException.INSTANCE)) .when(httpClient).submit(Mockito.any(RxClient.ServerInfo.class), Mockito.any(HttpClientRequest.class)); RxGatewayStoreModel storeModel = new RxGatewayStoreModel( sessionContainer, ConsistencyLevel.Session, queryCompatibilityMode, userAgentContainer, globalEndpointManager, httpClient); RxDocumentServiceRequest dsr = RxDocumentServiceRequest.createFromName( OperationType.Read, "/dbs/db/colls/col/docs/docId", ResourceType.Document); dsr.getHeaders().put("key", "value"); dsr.requestContext = Mockito.mock(DocumentServiceRequestContext.class); Observable<RxDocumentServiceResponse> resp = storeModel.processMessage(dsr); validateFailure(resp, FailureValidator.builder() .instanceOf(DocumentClientException.class) .causeInstanceOf(ReadTimeoutException.class) .documentClientExceptionHeaderRequestContainsEntry("key", "value") .statusCode(0).build()); }
Example #14
Source File: HttpTransportClientTest.java From azure-cosmosdb-java with MIT License | 5 votes |
@Test(groups = "unit") public void validateDefaultHeaders() { HttpClientResponse<ByteBuf> mockedResponse = new HttpClientMockWrapper.HttpClientBehaviourBuilder() .withContent("").withStatus(200) .withHeaders(EmptyHttpHeaders.INSTANCE) .asHttpClientResponse(); HttpClientMockWrapper httpClientMockWrapper = new HttpClientMockWrapper(mockedResponse); UserAgentContainer userAgentContainer = new UserAgentContainer(); userAgentContainer.setSuffix("i am suffix"); HttpTransportClient transportClient = getHttpTransportClientUnderTest(100, userAgentContainer, httpClientMockWrapper.getClient()); RxDocumentServiceRequest request = RxDocumentServiceRequest.createFromName( OperationType.Create, "dbs/db/colls/col", ResourceType.Document); request.setContentBytes(new byte[0]); transportClient.invokeStoreAsync(Uri.create(physicalAddress), new ResourceOperation(OperationType.Create, ResourceType.Document), request).toBlocking().value(); assertThat(httpClientMockWrapper.getCapturedInvocation()).asList().hasSize(1); ImmutablePair<HttpClientRequest<ByteBuf>, RxClient.ServerInfo> httpClientInvocation = httpClientMockWrapper.getCapturedInvocation().get(0); assertThat(httpClientInvocation.left.getHeaders().get(HttpConstants.HttpHeaders.USER_AGENT)).endsWith("i am suffix"); assertThat(httpClientInvocation.left.getHeaders().get(HttpConstants.HttpHeaders.CACHE_CONTROL)).isEqualTo("no-cache"); assertThat(httpClientInvocation.left.getHeaders().get(HttpConstants.HttpHeaders.ACCEPT)).isEqualTo("application/json"); assertThat(httpClientInvocation.left.getHeaders().get(HttpConstants.HttpHeaders.VERSION)).isEqualTo(HttpConstants.Versions.CURRENT_VERSION); }
Example #15
Source File: RxDocumentClientUnderTest.java From azure-cosmosdb-java with MIT License | 5 votes |
RxGatewayStoreModel createRxGatewayProxy( ISessionContainer sessionContainer, ConsistencyLevel consistencyLevel, QueryCompatibilityMode queryCompatibilityMode, UserAgentContainer userAgentContainer, GlobalEndpointManager globalEndpointManager, CompositeHttpClient<ByteBuf, ByteBuf> rxOrigClient) { origHttpClient = rxOrigClient; spyHttpClient = Mockito.spy(rxOrigClient); doAnswer((Answer<Observable<HttpClientResponse<ByteBuf>>>) invocationOnMock -> { RxClient.ServerInfo serverInfo = invocationOnMock.getArgumentAt(0, RxClient.ServerInfo.class); HttpClientRequest<ByteBuf> request = invocationOnMock.getArgumentAt(1, HttpClientRequest.class); httpRequests.add(request); Observable<HttpClientResponse<ByteBuf>> httpRespObs = origHttpClient.submit(serverInfo, request); return httpRespObs; }).when(spyHttpClient).submit( anyObject(), (HttpClientRequest) anyObject()); return super.createRxGatewayProxy(sessionContainer, consistencyLevel, queryCompatibilityMode, userAgentContainer, globalEndpointManager, spyHttpClient); }
Example #16
Source File: GatewayServiceConfigurationReaderTest.java From azure-cosmosdb-java with MIT License | 5 votes |
@Test(groups = "simple") public void mockInitializeReaderAsync() throws Exception { HttpClientResponse<ByteBuf> mockedResponse = getMockResponse(databaseAccountJson); Mockito.when(mockHttpClient.submit(Matchers.any(RxClient.ServerInfo.class), Matchers.any())) .thenReturn(Observable.just(mockedResponse)); Single<DatabaseAccount> databaseAccount = mockGatewayServiceConfigurationReader.initializeReaderAsync(); validateSuccess(databaseAccount, expectedDatabaseAccount); }
Example #17
Source File: GatewayServiceConfigurationReader.java From azure-cosmosdb-java with MIT License | 5 votes |
private Single<DatabaseAccount> getDatabaseAccountAsync(URI serviceEndpoint) { HttpClientRequest<ByteBuf> httpRequest = HttpClientRequest.create(HttpMethod.GET, this.serviceEndpoint.toString()); httpRequest.withHeader(HttpConstants.HttpHeaders.VERSION, HttpConstants.Versions.CURRENT_VERSION); UserAgentContainer userAgentContainer = new UserAgentContainer(); String userAgentSuffix = this.connectionPolicy.getUserAgentSuffix(); if (userAgentSuffix != null && userAgentSuffix.length() > 0) { userAgentContainer.setSuffix(userAgentSuffix); } httpRequest.withHeader(HttpConstants.HttpHeaders.USER_AGENT, userAgentContainer.getUserAgent()); httpRequest.withHeader(HttpConstants.HttpHeaders.API_TYPE, Constants.Properties.SQL_API_TYPE); String authorizationToken = StringUtils.EMPTY; if (this.hasAuthKeyResourceToken || baseAuthorizationTokenProvider == null) { authorizationToken = HttpUtils.urlEncode(this.authKeyResourceToken); } else { // Retrieve the document service properties. String xDate = Utils.nowAsRFC1123(); httpRequest.withHeader(HttpConstants.HttpHeaders.X_DATE, xDate); Map<String, String> header = new HashMap<>(); header.put(HttpConstants.HttpHeaders.X_DATE, xDate); authorizationToken = baseAuthorizationTokenProvider .generateKeyAuthorizationSignature(HttpConstants.HttpMethods.GET, serviceEndpoint, header); } httpRequest.withHeader(HttpConstants.HttpHeaders.AUTHORIZATION, authorizationToken); RxClient.ServerInfo serverInfo = new RxClient.ServerInfo(serviceEndpoint.getHost(), serviceEndpoint.getPort()); Observable<HttpClientResponse<ByteBuf>> clientResponseObservable = this.httpClient.submit(serverInfo, httpRequest); return toDatabaseAccountObservable(clientResponseObservable.toSingle()); }
Example #18
Source File: GatewayAddressCache.java From azure-cosmosdb-java with MIT License | 4 votes |
Single<List<Address>> getServerAddressesViaGatewayAsync( RxDocumentServiceRequest request, String collectionRid, List<String> partitionKeyRangeIds, boolean forceRefresh) { if (logger.isDebugEnabled()) { logger.debug("getServerAddressesViaGatewayAsync collectionRid {}, partitionKeyRangeIds {}", collectionRid, JavaStreamUtils.toString(partitionKeyRangeIds, ",")); } String entryUrl = PathsHelper.generatePath(ResourceType.Document, collectionRid, true); HashMap<String, String> addressQuery = new HashMap<>(); addressQuery.put(HttpConstants.QueryStrings.URL, HttpUtils.urlEncode(entryUrl)); HashMap<String, String> headers = new HashMap<>(defaultRequestHeaders); if (forceRefresh) { headers.put(HttpConstants.HttpHeaders.FORCE_REFRESH, Boolean.TRUE.toString()); } if (request.forceCollectionRoutingMapRefresh) { headers.put(HttpConstants.HttpHeaders.FORCE_COLLECTION_ROUTING_MAP_REFRESH, Boolean.TRUE.toString()); } addressQuery.put(HttpConstants.QueryStrings.FILTER, HttpUtils.urlEncode(this.protocolFilter)); addressQuery.put(HttpConstants.QueryStrings.PARTITION_KEY_RANGE_IDS, String.join(",", partitionKeyRangeIds)); headers.put(HttpConstants.HttpHeaders.X_DATE, Utils.nowAsRFC1123()); String token = null; token = this.tokenProvider.getUserAuthorizationToken( collectionRid, ResourceType.Document, HttpConstants.HttpMethods.GET, headers, AuthorizationTokenType.PrimaryMasterKey, request.properties); if (token == null && request.getIsNameBased()) { // User doesn't have rid based resource token. Maybe user has name based. String collectionAltLink = PathsHelper.getCollectionPath(request.getResourceAddress()); token = this.tokenProvider.getUserAuthorizationToken( collectionAltLink, ResourceType.Document, HttpConstants.HttpMethods.GET, headers, AuthorizationTokenType.PrimaryMasterKey, request.properties); } token = HttpUtils.urlEncode(token); headers.put(HttpConstants.HttpHeaders.AUTHORIZATION, token); URL targetEndpoint = Utils.setQuery(this.addressEndpoint.toString(), Utils.createQuery(addressQuery)); String identifier = logAddressResolutionStart(request, targetEndpoint); HttpClientRequest<ByteBuf> httpGet = HttpClientRequest.createGet(targetEndpoint.toString()); for (Map.Entry<String, String> entry : headers.entrySet()) { httpGet.withHeader(entry.getKey(), entry.getValue()); } RxClient.ServerInfo serverInfo = new RxClient.ServerInfo(targetEndpoint.getHost(), targetEndpoint.getPort()); Observable<HttpClientResponse<ByteBuf>> responseObs = this.httpClient.submit(serverInfo, httpGet); Single<RxDocumentServiceResponse> dsrObs = responseObs.toSingle().flatMap(rsp -> HttpClientUtils.parseResponseAsync(rsp)); return dsrObs.map( dsr -> { if (logger.isDebugEnabled()) { logger.debug("getServerAddressesViaGatewayAsync deserializes result"); } logAddressResolutionEnd(request, identifier); List<Address> addresses = dsr.getQueryResponse(Address.class); return addresses; }); }
Example #19
Source File: GatewayAddressCache.java From azure-cosmosdb-java with MIT License | 4 votes |
Single<List<Address>> getMasterAddressesViaGatewayAsync( RxDocumentServiceRequest request, ResourceType resourceType, String resourceAddress, String entryUrl, boolean forceRefresh, boolean useMasterCollectionResolver, Map<String, Object> properties) { logger.debug("getMasterAddressesViaGatewayAsync " + "resourceType {}, " + "resourceAddress {}, " + "entryUrl {}, " + "forceRefresh {}, " + "useMasterCollectionResolver {}", resourceType, resourceAddress, entryUrl, forceRefresh, useMasterCollectionResolver ); HashMap<String, String> queryParameters = new HashMap<>(); queryParameters.put(HttpConstants.QueryStrings.URL, HttpUtils.urlEncode(entryUrl)); HashMap<String, String> headers = new HashMap<>(defaultRequestHeaders); if (forceRefresh) { headers.put(HttpConstants.HttpHeaders.FORCE_REFRESH, Boolean.TRUE.toString()); } if (useMasterCollectionResolver) { headers.put(HttpConstants.HttpHeaders.USE_MASTER_COLLECTION_RESOLVER, Boolean.TRUE.toString()); } if (request.forceCollectionRoutingMapRefresh) { headers.put(HttpConstants.HttpHeaders.FORCE_COLLECTION_ROUTING_MAP_REFRESH, Boolean.TRUE.toString()); } queryParameters.put(HttpConstants.QueryStrings.FILTER, HttpUtils.urlEncode(this.protocolFilter)); headers.put(HttpConstants.HttpHeaders.X_DATE, Utils.nowAsRFC1123()); String token = this.tokenProvider.getUserAuthorizationToken( resourceAddress, resourceType, HttpConstants.HttpMethods.GET, headers, AuthorizationTokenType.PrimaryMasterKey, properties); headers.put(HttpConstants.HttpHeaders.AUTHORIZATION, HttpUtils.urlEncode(token)); URL targetEndpoint = Utils.setQuery(this.addressEndpoint.toString(), Utils.createQuery(queryParameters)); String identifier = logAddressResolutionStart(request, targetEndpoint); HttpClientRequest<ByteBuf> httpGet = HttpClientRequest.createGet(targetEndpoint.toString()); for (Map.Entry<String, String> entry : headers.entrySet()) { httpGet.withHeader(entry.getKey(), entry.getValue()); } RxClient.ServerInfo serverInfo = new RxClient.ServerInfo(targetEndpoint.getHost(), targetEndpoint.getPort()); Observable<HttpClientResponse<ByteBuf>> responseObs = this.httpClient.submit(serverInfo, httpGet); Single<RxDocumentServiceResponse> dsrObs = responseObs.toSingle().flatMap(rsp -> HttpClientUtils.parseResponseAsync(rsp)); return dsrObs.map( dsr -> { logAddressResolutionEnd(request, identifier); List<Address> addresses = dsr.getQueryResponse(Address.class); return addresses; }); }
Example #20
Source File: RibbonTransport.java From ribbon with Apache License 2.0 | 4 votes |
public static RxClient<ByteBuf, ByteBuf> newTcpClient(ILoadBalancer loadBalancer, IClientConfig config) { return new LoadBalancingTcpClient<ByteBuf, ByteBuf>(loadBalancer, config, getDefaultRetryHandlerWithConfig(config), null, poolCleanerScheduler); }
Example #21
Source File: RibbonTransport.java From ribbon with Apache License 2.0 | 4 votes |
public static <I, O> RxClient<I, O> newTcpClient(ILoadBalancer loadBalancer, PipelineConfigurator<O, I> pipelineConfigurator, IClientConfig config, RetryHandler retryHandler) { return new LoadBalancingTcpClient<I, O>(loadBalancer, config, retryHandler, pipelineConfigurator, poolCleanerScheduler); }
Example #22
Source File: RibbonTransport.java From ribbon with Apache License 2.0 | 4 votes |
public static <I, O> RxClient<I, O> newTcpClient(PipelineConfigurator<O, I> pipelineConfigurator, IClientConfig config) { return new LoadBalancingTcpClient<I, O>(config, getDefaultRetryHandlerWithConfig(config), pipelineConfigurator, poolCleanerScheduler); }
Example #23
Source File: RibbonTransport.java From ribbon with Apache License 2.0 | 4 votes |
public static RxClient<ByteBuf, ByteBuf> newTcpClient(IClientConfig config) { return new LoadBalancingTcpClient<ByteBuf, ByteBuf>(config, getDefaultRetryHandlerWithConfig(config), null, poolCleanerScheduler); }
Example #24
Source File: RibbonTransport.java From ribbon with Apache License 2.0 | 4 votes |
public static RxClient<DatagramPacket, DatagramPacket> newUdpClient(ILoadBalancer loadBalancer, IClientConfig config) { return new LoadBalancingUdpClient<DatagramPacket, DatagramPacket>(loadBalancer, config, getDefaultRetryHandlerWithConfig(config), null); }
Example #25
Source File: RibbonTransport.java From ribbon with Apache License 2.0 | 4 votes |
public static RxClient<DatagramPacket, DatagramPacket> newUdpClient(IClientConfig config) { return new LoadBalancingUdpClient<DatagramPacket, DatagramPacket>(config, getDefaultRetryHandlerWithConfig(config), null); }
Example #26
Source File: RibbonTransport.java From ribbon with Apache License 2.0 | 4 votes |
public static <I, O> RxClient<I, O> newUdpClient(ILoadBalancer loadBalancer, PipelineConfigurator<O, I> pipelineConfigurator, IClientConfig config, RetryHandler retryHandler) { return new LoadBalancingUdpClient<I, O>(loadBalancer, config, retryHandler, pipelineConfigurator); }
Example #27
Source File: RibbonTransport.java From ribbon with Apache License 2.0 | 4 votes |
public static <I, O> RxClient<I, O> newUdpClient(PipelineConfigurator<O, I> pipelineConfigurator, IClientConfig config) { return new LoadBalancingUdpClient<I, O>(config, getDefaultRetryHandlerWithConfig(config), pipelineConfigurator); }
Example #28
Source File: RibbonTransportFactory.java From ribbon with Apache License 2.0 | 4 votes |
public RxClient<ByteBuf, ByteBuf> newTcpClient(IClientConfig config) { return RibbonTransport.newTcpClient(config); }
Example #29
Source File: RibbonTransportFactory.java From ribbon with Apache License 2.0 | 4 votes |
public RxClient<DatagramPacket, DatagramPacket> newUdpClient(IClientConfig config) { return RibbonTransport.newUdpClient(config); }
Example #30
Source File: RibbonTransportFactory.java From ribbon with Apache License 2.0 | 4 votes |
public final RxClient<ByteBuf, ByteBuf> newTcpClient(String name) { IClientConfig config = clientConfigFactory.newConfig(); config.loadProperties(name); return newTcpClient(config); }