Package com.linkedin.r2.transport.http.client

Examples of com.linkedin.r2.transport.http.client.PoolStats$LifecycleStats


        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

    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, new RootBuilderWrapper<Long, Greeting>(new GreetingsBuilders()) };
      result[index--] = new Object[]{ client, operation, new RootBuilderWrapper<Long, Greeting>(new GreetingsBuilders(TestConstants.FORCE_USE_NEXT_OPTIONS)) };
      result[index--] = new Object[]{ client, operation, new RootBuilderWrapper<Long, Greeting>(new GreetingsRequestBuilders()) };
      result[index--] = new Object[]{ client, operation, new RootBuilderWrapper<Long, Greeting>(new GreetingsRequestBuilders(TestConstants.FORCE_USE_NEXT_OPTIONS)) };
View Full Code Here

   */
  @DataProvider(name = com.linkedin.restli.internal.common.TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "clientsCookbookDataProvider")
  public Object[][] clientsCookbookDataProvider()
  {
    // need separate TransportClientAdapter for shutdown test
    TransportClientAdapter clientAdapter1 = new TransportClientAdapter(new HttpClientFactory(FilterChains.empty()).
      getClient(Collections.<String, String>emptyMap()));
    TransportClientAdapter clientAdapter2 = new TransportClientAdapter(new HttpClientFactory(FilterChains.empty()).
      getClient(Collections.<String, String>emptyMap()));
    return new Object[][]
      {
        { new RestClient(clientAdapter1, URI_PREFIX), RestliRequestOptions.DEFAULT_OPTIONS },
        { new RestClient(clientAdapter2, URI_PREFIX), TestConstants.FORCE_USE_NEXT_OPTIONS },
View Full Code Here

   */
  @DataProvider(name = com.linkedin.restli.internal.common.TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "clientsNoCompressedResponsesDataProvider")
  public Object[][] clientsNoCompressedResponsesDataProvider()
  {
    // need separate TransportClientAdapter for shutdown test
    TransportClientAdapter clientAdapter1 = new TransportClientAdapter(new HttpClientFactory(FilterChains.empty()).
        getClient(Collections.<String, String>emptyMap()));
    TransportClientAdapter clientAdapter2 = new TransportClientAdapter(new HttpClientFactory(FilterChains.empty()).
      getClient(Collections.<String, String>emptyMap()));
    TransportClientAdapter clientAdapter3 = new TransportClientAdapter(new HttpClientFactory(FilterChains.empty()).
      getClient(Collections.<String, String>emptyMap()));
    TransportClientAdapter clientAdapter4 = new TransportClientAdapter(new HttpClientFactory(FilterChains.empty()).
      getClient(Collections.<String, String>emptyMap()));
    return new Object[][]
      {
        { new RestClient(clientAdapter1, URI_PREFIX), new RootBuilderWrapper<Long, Greeting>(new GreetingsBuilders()) },
        { new RestClient(clientAdapter2, URI_PREFIX), new RootBuilderWrapper<Long, Greeting>(new GreetingsBuilders(TestConstants.FORCE_USE_NEXT_OPTIONS)) },
View Full Code Here

  }

  private Map<String, TransportClientFactory> createDefaultTransportClientFactories()
  {
    final Map<String, TransportClientFactory> clientFactories = new HashMap<String, TransportClientFactory>();
    clientFactories.put("http", new HttpClientFactory());
    return clientFactories;
  }
View Full Code Here

            .createServer(port, createDispatcher());
  }

  public static Client createHttpClient(FilterChain filters)
  {
    final TransportClient client = new HttpClientFactory(filters)
            .getClient(Collections.<String, String>emptyMap());
    return new TransportClientAdapter(client);
  }
View Full Code Here

    final UnreliableLifecycle lifecycle = new UnreliableLifecycle();
    final AsyncPool<AtomicBoolean> pool = new AsyncPoolImpl<AtomicBoolean>(
        "object pool", lifecycle, POOL_SIZE, TIMEOUT, _executor
    );
    PoolStats stats;
    final List<AtomicBoolean> objects = new ArrayList<AtomicBoolean>();

    pool.start();

    // do a few gets
    for(int i = 0; i < GET; i++)
    {
      FutureCallback<AtomicBoolean> cb = new FutureCallback<AtomicBoolean>();
      pool.get(cb);
      AtomicBoolean obj = cb.get();
      objects.add(obj);
    }

    // put and destroy some, with errors
    lifecycle.setFail(true);
    for(int i = 0; i < PUT_BAD; i++)
    {
      AtomicBoolean obj = objects.remove(objects.size() - 1);
      obj.set(false);
      pool.put(obj);
    }
    for(int i = 0; i < DISPOSE; i++)
    {
      AtomicBoolean obj = objects.remove(objects.size() - 1);
      pool.dispose(obj);
    }
    stats = pool.getStats();
    Assert.assertEquals(stats.getTotalDestroyed(), 0);
    Assert.assertEquals(stats.getTotalCreateErrors(), 0);
    Assert.assertEquals(stats.getTotalDestroyErrors(), PUT_BAD + DISPOSE);
    Assert.assertEquals(stats.getTotalBadDestroyed(), PUT_BAD + DISPOSE);

    // create some with errors
    for(int i = 0; i < CREATE_BAD; i++)
    {
      FutureCallback<AtomicBoolean> cb = new FutureCallback<AtomicBoolean>();
      try
      {
        pool.get(cb);
      }
      catch (Exception e)
      {
        // this error is expected
      }
    }
    stats = pool.getStats();
    Assert.assertEquals(stats.getCheckedOut(), GET - PUT_BAD - DISPOSE);
    // When the each create fails, it will retry and cancel the waiter,
    // resulting in a second create error.
    Assert.assertEquals(stats.getTotalCreateErrors(), 2*CREATE_BAD);
  }
View Full Code Here

        100,
        _executor
    );
    pool.start();

    PoolStats stats;
    List<Object> objects = new ArrayList<Object>(CHECKOUT);
    for (int i = 0; i < CHECKOUT; i++)
    {
      FutureCallback<Object> cb = new FutureCallback<Object>();
      pool.get(cb);
      Object o = cb.get();
      objects.add(o);
    }

    stats = pool.getStats();
    Assert.assertEquals(stats.getWaitTimeAvg(), DELAY, DELTA * DELAY);
  }
View Full Code Here

TOP

Related Classes of com.linkedin.r2.transport.http.client.PoolStats$LifecycleStats

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.