All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.airlift.http.client.jetty.ConnectionPoolDistribution Maven / Gradle / Ivy

The newest version!
package io.airlift.http.client.jetty;

import io.airlift.stats.Distribution;
import org.eclipse.jetty.client.DuplexConnectionPool;
import org.eclipse.jetty.client.HttpClient;
import org.eclipse.jetty.client.transport.HttpDestination;

import java.util.Objects;

class ConnectionPoolDistribution
        extends CachedDistribution
{
    interface Processor
    {
        void process(Distribution distribution, DuplexConnectionPool pool);
    }

    public ConnectionPoolDistribution(HttpClient httpClient, Processor processor)
    {
        super(() -> {
            Distribution distribution = new Distribution();
            httpClient.getDestinations().stream()
                    .filter(HttpDestination.class::isInstance)
                    .map(HttpDestination.class::cast)
                    .map(HttpDestination::getConnectionPool)
                    .filter(Objects::nonNull)
                    .map(DuplexConnectionPool.class::cast)
                    .forEach(pool -> processor.process(distribution, pool));
            return distribution;
        });
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy