Package com.linkedin.r2.transport.common.bridge.client

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


  }

  @Test
  public void testNoProtocolVersionHeaderSuccess() throws InterruptedException, ExecutionException
  {
    final TransportClientAdapter client = new TransportClientAdapter(CLIENT_FACTORY.getClient(Collections.<String, String>emptyMap()));
    final RestRequestBuilder requestBuilder = new RestRequestBuilder(URI.create(URI_PREFIX + "greetings/1"));
    final RestRequest request = requestBuilder.build();
    Assert.assertTrue(request.getHeaders().isEmpty());

    final RestResponse response = client.restRequest(request).get();
    Assert.assertEquals(response.getStatus(), HttpStatus.S_200_OK.getCode());
    Assert.assertEquals(response.getHeader(RestConstants.HEADER_RESTLI_PROTOCOL_VERSION),
                        AllProtocolVersions.RESTLI_PROTOCOL_1_0_0.getProtocolVersion().toString());
  }
View Full Code Here


  }

  @Test
  public void testNoProtocolVersionHeaderFail() throws InterruptedException
  {
    final TransportClientAdapter client = new TransportClientAdapter(CLIENT_FACTORY.getClient(Collections.<String, String>emptyMap()));
    final RestRequestBuilder requestBuilder = new RestRequestBuilder(URI.create(URI_PREFIX));
    final RestRequest request = requestBuilder.build();
    Assert.assertTrue(request.getHeaders().isEmpty());

    try
    {
      client.restRequest(request).get();
    }
    catch (ExecutionException e)
    {
      final RestException exception = (RestException) e.getCause();
      final RestResponse response = exception.getResponse();
View Full Code Here

      __metadata = new HashMap<String, Object>();
      if (restliProtocolVersion != null)
      {
        __metadata.put(RestConstants.RESTLI_PROTOCOL_VERSION_PROPERTY, restliProtocolVersion);
      }
      __client = new TransportClientAdapter(CLIENT_FACTORY.getClient(Collections.<String, String>emptyMap()));
    }
View Full Code Here

    AsyncCallableTask.register(engineBuilder, executor);

    final Engine engine = engineBuilder.build();
    ResourceFactory resourceFactory = createResourceFactory(beans);

    TransportDispatcher dispatcher = new DelegatingTransportDispatcher(new RestLiServer(config,
                                                                                        resourceFactory,
                                                                                        engine));

    final FilterChain fc = FilterChains.empty().addLast(new SimpleLoggingFilter());
    final HttpServer server = new HttpServerFactory(fc).createServer(port,
View Full Code Here

    beanProvider.add("albumEntryDb", new AlbumEntryDatabaseImpl(photoDb, 3));

    // using InjectMockResourceFactory to keep examples spring-free
    final ResourceFactory factory = new InjectMockResourceFactory(beanProvider);

    final TransportDispatcher dispatcher = new DelegatingTransportDispatcher(new RestLiServer(config, factory));
    return new HttpServerFactory(FilterChains.empty()).createServer(SERVER_PORT, dispatcher);
  }
View Full Code Here

        RESTClientConfig restClientConfig = new RESTClientConfig();
        restClientConfig.setHttpBootstrapURL("http://localhost:"
                                             + cluster.getNodeById(0).getRestPort())
                        .setTimeoutMs(10000, TimeUnit.MILLISECONDS)
                        .setMaxR2ConnectionPoolSize(100);
        clientFactory = new HttpClientFactory();
        Map<String, String> properties = new HashMap<String, String>();
        properties.put(HttpClientFactory.HTTP_POOL_SIZE,
                       Integer.toString(restClientConfig.getMaxR2ConnectionPoolSize()));
        TransportClient transportClient = clientFactory.getClient(properties);
        R2Store r2Store = new R2Store(STORE_NAME,
View Full Code Here

        restClientConfig = new RESTClientConfig();
        restClientConfig.setHttpBootstrapURL("http://localhost:8085")
                        .setTimeoutMs(1500, TimeUnit.MILLISECONDS)
                        .setMaxR2ConnectionPoolSize(100);
        clientFactory = new HttpClientFactory();
        Map<String, String> properties = new HashMap<String, String>();
        properties.put(HttpClientFactory.HTTP_POOL_SIZE,
                       Integer.toString(restClientConfig.getMaxR2ConnectionPoolSize()));
        transportClient = clientFactory.getClient(properties);
        r2store = new R2Store("test",
View Full Code Here

        this.config = new RESTClientConfig(restClientFactoryConfig.getClientConfig());
        this.stats = new StoreStats("aggregate.rest-client-factory");
        this.rawStoreList = new ArrayList<R2Store>();
        // Create the R2 (Netty) Factory object
        // TODO: Add monitoring for R2 factory
        this._clientFactory = new HttpClientFactory();
        this.RESTClientFactoryStats = new StoreClientFactoryStats();
        keySerializerMap = new HashMap<String, SerializerDefinition>();
        valueSerializerMap = new HashMap<String, SerializerDefinition>();
    }
View Full Code Here

        this(new RESTClientConfig());
    }

    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));
    }
View Full Code Here

    int index = entries * 4 - 1;
    for (String operation: compressionOperations)
    {
      Map<String, String> clientProperties = new HashMap<String, String>();
      clientProperties.put(HttpClientFactory.HTTP_RESPONSE_COMPRESSION_OPERATIONS, operation);
      TransportClientAdapter clientAdapter = new TransportClientAdapter(new HttpClientFactory(FilterChains.empty()).getClient(clientProperties));
      RestClient client = new RestClient(clientAdapter, URI_PREFIX);
      result[index--] = new Object[]{ client, operation, RestliRequestOptions.DEFAULT_OPTIONS, Arrays.asList(1000L, 2000L), 0 };
      result[index--] = new Object[]{ client, operation, TestConstants.FORCE_USE_NEXT_OPTIONS, Arrays.asList(1000L, 2000L), 0 };
      result[index--] = new Object[]{ client, operation, RestliRequestOptions.DEFAULT_OPTIONS, Arrays.asList(1L, 2L, 3L, 4L), 4 };
      result[index--] = new Object[]{ client, operation, TestConstants.FORCE_USE_NEXT_OPTIONS, Arrays.asList(1L, 2L, 3L, 4L), 4 };
View Full Code Here

TOP

Related Classes of com.linkedin.r2.transport.common.bridge.client.TransportClientAdapter

Copyright © 2018 www.massapicom. 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.