Examples of TransportClientAdapter


Examples of com.linkedin.r2.transport.common.bridge.client.TransportClientAdapter

    {
      TransportClient client = _balancer.getClient(request, requestContext);

      if (client != null)
      {
        new TransportClientAdapter(client).restRequest(request, requestContext, transportCallback);
      }
      else
      {
        throw new ServiceUnavailableException("unknown: " + request.getURI(),
                                              "got null client from load balancer");
View Full Code Here

Examples of com.linkedin.r2.transport.common.bridge.client.TransportClientAdapter

    {
      TransportClient client = _balancer.getClient(request, requestContext);

      if (client != null)
      {
        new TransportClientAdapter(client).rpcRequest(request, requestContext, callback);
      }
      else
      {
        throw new ServiceUnavailableException("unknown: " + request.getURI(),
                                              "got null client from load balancer");
View Full Code Here

Examples of com.linkedin.r2.transport.common.bridge.client.TransportClientAdapter

  @Test(dataProvider = com.linkedin.restli.internal.common.TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "requestBuilderDataProvider")
  //test cookbook example from quickstart wiki
  public void testCookbook(RootBuilderWrapper<Long, Greeting> builders) throws Exception
  {
    Client r2Client = new TransportClientAdapter(new HttpClientFactory().getClient(Collections.<String, String>emptyMap()));
    RestClient restClient = new RestClient(r2Client, "http://localhost:1338/");

    // GET
    Request<Greeting> request = builders.get().id(1L).build();
    ResponseFuture<Greeting> future = restClient.sendRequest(request);
    Response<Greeting> greetingResponse = future.getResponse();

    Assert.assertNotNull(greetingResponse.getEntity().getMessage());

    // POST
    Greeting greeting = new Greeting(greetingResponse.getEntity().data().copy());
    final String NEW_MESSAGE = "This is a new message!";
    greeting.setMessage(NEW_MESSAGE);

    Request<EmptyRecord> writeRequest = builders.update().id(1L).input(greeting).build();
    restClient.sendRequest(writeRequest).getResponse();

    // GET again, to verify that our POST worked.
    Request<Greeting> request2 = builders.get().id(1L).build();
    ResponseFuture<Greeting> future2 = restClient.sendRequest(request2);
    greetingResponse = future2.get();

    Assert.assertEquals(greetingResponse.getEntity().getMessage(), NEW_MESSAGE);

    // shut down client
    FutureCallback<None> futureCallback = new FutureCallback<None>();
    r2Client.shutdown(futureCallback);
    futureCallback.get();
  }
View Full Code Here

Examples of com.linkedin.r2.transport.common.bridge.client.TransportClientAdapter

    HttpClientFactory factory = new HttpClientFactory(FilterChains.empty(), channelFactory, true, scheduler, true);

    List<Client> clients = new ArrayList<Client>();
    for (int i = 0; i < 100; i++)
    {
      clients.add(new TransportClientAdapter(factory.getClient(Collections.<String, String>emptyMap())));
    }

    for (Client c : clients)
    {
      RestRequest r = new RestRequestBuilder(_testServer.getRequestURI()).build();
View Full Code Here

Examples of com.linkedin.r2.transport.common.bridge.client.TransportClientAdapter

    HttpClientFactory factory = new HttpClientFactory(FilterChains.empty(), channelFactory, true, scheduler, true);

    List<Client> clients = new ArrayList<Client>();
    for (int i = 0; i < 100; i++)
    {
      clients.add(new TransportClientAdapter(factory.getClient(Collections.<String, String>emptyMap())));
    }

    for (Client c : clients)
    {
      RestRequest r = new RestRequestBuilder(_testServer.getRequestURI()).build();
View Full Code Here

Examples of com.linkedin.r2.transport.common.bridge.client.TransportClientAdapter

    HttpClientFactory factory = new HttpClientFactory(FilterChains.empty(), channelFactory, true, scheduler, true);

    List<Client> clients = new ArrayList<Client>();
    for (int i = 0; i < 100; i++)
    {
      clients.add(new TransportClientAdapter(factory.getClient(Collections.<String, String>emptyMap())));
    }

    for (Client c : clients)
    {
      RestRequest r = new RestRequestBuilder(_testServer.getRequestURI()).build();
View Full Code Here

Examples of com.linkedin.r2.transport.common.bridge.client.TransportClientAdapter

    HttpClientFactory factory = new HttpClientFactory(FilterChains.empty(), channelFactory, true, scheduler, true);

    List<Client> clients = new ArrayList<Client>();
    for (int i = 0; i < 100; i++)
    {
      clients.add(new TransportClientAdapter(factory.getClient(Collections.<String, String>emptyMap())));
    }

    for (Client c : clients)
    {
      RestRequest r = new RestRequestBuilder(_testServer.getRequestURI()).build();
View Full Code Here

Examples of com.linkedin.r2.transport.common.bridge.client.TransportClientAdapter

    ExecutorService worker = Executors.newCachedThreadPool();
    ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor();
    ClientSocketChannelFactory channelFactory = new NioClientSocketChannelFactory(boss, worker);
    HttpClientFactory factory = new HttpClientFactory(FilterChains.empty(), channelFactory, true, scheduler, true);

    Client client = new TransportClientAdapter(factory.getClient(
            Collections.<String, Object>emptyMap()));

    Future<RestResponse> responseFuture = client.restRequest(new RestRequestBuilder(_testServer.resetResponseLatch(1)).build());


    FutureCallback<None> factoryShutdown = new FutureCallback<None>();
    factory.shutdown(factoryShutdown);

    FutureCallback<None> clientShutdown = new FutureCallback<None>();
    client.shutdown(clientShutdown);

    // Client and factory shutdowns are now pending.  When we release the latch, the response will
    // be returned, which causes the shutdowns to complete on the Netty IO thread that received the
    // response.
    _testServer.releaseResponseLatch();
View Full Code Here

Examples of com.linkedin.r2.transport.common.bridge.client.TransportClientAdapter

    // Create an HttpClient and wrap it in an abstraction layer
    final HttpClientFactory http = new HttpClientFactory(FilterChains.create(
      new ClientCompressionFilter(EncodingType.IDENTITY, new EncodingType[]{ EncodingType.SNAPPY}, Collections.singletonList("*"))
    ));

    final Client r2Client = new TransportClientAdapter(
                                      http.getClient(Collections.<String, String>emptyMap()));

    // Create a RestClient to talk to localhost:8080
    RestClient restClient = new RestClient(r2Client, "http://localhost:8080/");

View Full Code Here

Examples of com.linkedin.r2.transport.common.bridge.client.TransportClientAdapter

  {
    // create HTTP Netty client with default properties
    final HttpClientFactory http = new HttpClientFactory();
    final TransportClient transportClient = http.getClient(Collections.<String, String>emptyMap());
    // create an abstraction layer over the actual client, which supports both REST and RPC
    final Client r2Client = new TransportClientAdapter(transportClient);
    // REST client wrapper that simplifies the interface
    final StringBuilder serverUrlBuilder = new StringBuilder("http://").append(SERVER_HOSTNAME).append(":").append(SERVER_PORT).append("/");
    final RestClient restClient = new RestClient(r2Client, serverUrlBuilder.toString());
    final RestLiExampleBasicClient photoClient = new RestLiExampleBasicClient(restClient);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.