io.reactivex.netty.pipeline.PipelineConfigurator Java Examples

The following examples show how to use io.reactivex.netty.pipeline.PipelineConfigurator. 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: LoadBalancingRxClientWithPoolOptions.java    From ribbon with Apache License 2.0 6 votes vote down vote up
public LoadBalancingRxClientWithPoolOptions(ILoadBalancer lb, IClientConfig config,
        RetryHandler retryHandler,
        PipelineConfigurator<O, I> pipelineConfigurator, ScheduledExecutorService poolCleanerScheduler) {
    super(lb, config, retryHandler, pipelineConfigurator);
    poolEnabled = config.get(CommonClientConfigKey.EnableConnectionPool, 
            DefaultClientConfigImpl.DEFAULT_ENABLE_CONNECTION_POOL);
    if (poolEnabled) {
        this.poolCleanerScheduler = poolCleanerScheduler;
        int maxTotalConnections = config.get(IClientConfigKey.Keys.MaxTotalConnections,
                DefaultClientConfigImpl.DEFAULT_MAX_TOTAL_CONNECTIONS);
        int maxConnections = config.get(Keys.MaxConnectionsPerHost, DefaultClientConfigImpl.DEFAULT_MAX_CONNECTIONS_PER_HOST);
        MaxConnectionsBasedStrategy perHostStrategy = new DynamicPropertyBasedPoolStrategy(maxConnections,
                config.getClientName() + "." + config.getNameSpace() + "." + CommonClientConfigKey.MaxConnectionsPerHost);
        globalStrategy = new DynamicPropertyBasedPoolStrategy(maxTotalConnections, 
                config.getClientName() + "." + config.getNameSpace() + "." + CommonClientConfigKey.MaxTotalConnections);
        poolStrategy = new CompositePoolLimitDeterminationStrategy(perHostStrategy, globalStrategy);
        idleConnectionEvictionMills = config.get(Keys.ConnIdleEvictTimeMilliSeconds, DefaultClientConfigImpl.DEFAULT_CONNECTIONIDLE_TIME_IN_MSECS);
    }
}
 
Example #2
Source File: RibbonTransport.java    From ribbon with Apache License 2.0 5 votes vote down vote up
public static <I, O> LoadBalancingHttpClient<I, O> newHttpClient(PipelineConfigurator<HttpClientResponse<O>, HttpClientRequest<I>> pipelineConfigurator,
                                                         ILoadBalancer loadBalancer, IClientConfig config, RetryHandler retryHandler,
                                                              List<ExecutionListener<HttpClientRequest<I>, HttpClientResponse<O>>> listeners) {
    return LoadBalancingHttpClient.<I, O>builder()
            .withLoadBalancer(loadBalancer)
            .withClientConfig(config)
            .withRetryHandler(retryHandler)
            .withPipelineConfigurator(pipelineConfigurator)
            .withPoolCleanerScheduler(poolCleanerScheduler)
            .withExecutorListeners(listeners)
            .build();
}
 
Example #3
Source File: RibbonTransport.java    From ribbon with Apache License 2.0 5 votes vote down vote up
public static <I, O> LoadBalancingHttpClient<I, O> newHttpClient(PipelineConfigurator<HttpClientResponse<O>, HttpClientRequest<I>> pipelineConfigurator,
        IClientConfig config, RetryHandler retryHandler) {
    return LoadBalancingHttpClient.<I, O>builder()
            .withClientConfig(config)
            .withRetryHandler(retryHandler)
            .withPipelineConfigurator(pipelineConfigurator)
            .withPoolCleanerScheduler(poolCleanerScheduler)
            .build();
}
 
Example #4
Source File: RibbonTransport.java    From ribbon with Apache License 2.0 5 votes vote down vote up
public static <I, O> LoadBalancingHttpClient<I, O> newHttpClient(PipelineConfigurator<HttpClientResponse<O>, HttpClientRequest<I>> pipelineConfigurator,
        IClientConfig config) {
    return LoadBalancingHttpClient.<I, O>builder()
            .withClientConfig(config)
            .withRetryHandler(getDefaultHttpRetryHandlerWithConfig(config))
            .withPipelineConfigurator(pipelineConfigurator)
            .withPoolCleanerScheduler(poolCleanerScheduler)
            .build();
}
 
Example #5
Source File: RibbonTransport.java    From ribbon with Apache License 2.0 5 votes vote down vote up
public static <I, O> LoadBalancingHttpClient<I, O> newHttpClient(PipelineConfigurator<HttpClientResponse<O>, HttpClientRequest<I>> pipelineConfigurator,
        ILoadBalancer loadBalancer, IClientConfig config) {
    return LoadBalancingHttpClient.<I, O>builder()
            .withLoadBalancer(loadBalancer)
            .withClientConfig(config)
            .withRetryHandler(getDefaultHttpRetryHandlerWithConfig(config))
            .withPipelineConfigurator(pipelineConfigurator)
            .withPoolCleanerScheduler(poolCleanerScheduler)
            .build();
}
 
Example #6
Source File: HttpClientFactory.java    From azure-cosmosdb-java with MIT License 5 votes vote down vote up
private static PipelineConfigurator createClientPipelineConfigurator(Configs config) {
    PipelineConfigurator clientPipelineConfigurator = new PipelineConfiguratorComposite(
            new HttpClientPipelineConfigurator<ByteBuf, ByteBuf>(
                    config.getMaxHttpInitialLineLength(),
                    config.getMaxHttpHeaderSize(),
                    config.getMaxHttpChunkSize(),
                    true),
            new HttpObjectAggregationConfigurator(config.getMaxHttpBodyLength()));
    return clientPipelineConfigurator;
}
 
Example #7
Source File: RibbonTransport.java    From ribbon with Apache License 2.0 5 votes vote down vote up
public static <I> LoadBalancingHttpClient<I, ServerSentEvent> newSSEClient(PipelineConfigurator<HttpClientResponse<ServerSentEvent>, HttpClientRequest<I>> pipelineConfigurator,
        ILoadBalancer loadBalancer, IClientConfig config) {
    return SSEClient.<I>sseClientBuilder()
            .withLoadBalancer(loadBalancer)
            .withClientConfig(config)
            .withRetryHandler(getDefaultHttpRetryHandlerWithConfig(config))
            .withPipelineConfigurator(pipelineConfigurator)
            .build();
}
 
Example #8
Source File: RibbonTransport.java    From ribbon with Apache License 2.0 5 votes vote down vote up
public static <I> LoadBalancingHttpClient<I, ServerSentEvent> newSSEClient(PipelineConfigurator<HttpClientResponse<ServerSentEvent>, HttpClientRequest<I>> pipelineConfigurator,
        IClientConfig config) {
    return SSEClient.<I>sseClientBuilder()
            .withClientConfig(config)
            .withRetryHandler(getDefaultHttpRetryHandlerWithConfig(config))
            .withPipelineConfigurator(pipelineConfigurator)
            .build();
}
 
Example #9
Source File: LoadBalancingRxClientWithPoolOptions.java    From ribbon with Apache License 2.0 5 votes vote down vote up
public LoadBalancingRxClientWithPoolOptions(IClientConfig config,
        RetryHandler retryHandler,
        PipelineConfigurator<O, I> pipelineConfigurator, ScheduledExecutorService poolCleanerScheduler) {
    this(LoadBalancerBuilder.newBuilder().withClientConfig(config).buildDynamicServerListLoadBalancer(),
            config,
            retryHandler,
            pipelineConfigurator,
            poolCleanerScheduler);
}
 
Example #10
Source File: LoadBalancingRxClient.java    From ribbon with Apache License 2.0 5 votes vote down vote up
public LoadBalancingRxClient(ILoadBalancer lb, IClientConfig config, RetryHandler defaultRetryHandler, PipelineConfigurator<O, I> pipelineConfigurator) {
    this.rxClientCache = new ConcurrentHashMap<Server, T>();
    this.lbContext = new LoadBalancerContext(lb, config, defaultRetryHandler);
    this.defaultRetryHandler = defaultRetryHandler;
    this.pipelineConfigurator = pipelineConfigurator;
    this.clientConfig = config;
    this.listener = createListener(config.getClientName());
    
    eventSubject = new MetricEventsSubject<ClientMetricsEvent<?>>();
    boolean isSecure = getProperty(IClientConfigKey.Keys.IsSecure, null, false); 
    if (isSecure) {
        final URL trustStoreUrl = getResourceForOptionalProperty(CommonClientConfigKey.TrustStore);
        final URL keyStoreUrl = getResourceForOptionalProperty(CommonClientConfigKey.KeyStore);
        boolean isClientAuthRequired = clientConfig.get(IClientConfigKey.Keys.IsClientAuthRequired, false);
        if (    // if client auth is required, need both a truststore and a keystore to warrant configuring
                // if client is not is not required, we only need a keystore OR a truststore to warrant configuring
                (isClientAuthRequired && (trustStoreUrl != null && keyStoreUrl != null))
                ||
                (!isClientAuthRequired && (trustStoreUrl != null || keyStoreUrl != null))
                ) {

            try {
                sslContextFactory = new URLSslContextFactory(trustStoreUrl,
                        clientConfig.get(CommonClientConfigKey.TrustStorePassword),
                        keyStoreUrl,
                        clientConfig.get(CommonClientConfigKey.KeyStorePassword));

            } catch (ClientSslSocketFactoryException e) {
                throw new IllegalArgumentException("Unable to configure custom secure socket factory", e);
            }
        } else {
            sslContextFactory = null;
        }
    } else {
        sslContextFactory = null;
    }

    addLoadBalancerListener();
}
 
Example #11
Source File: LoadBalancingRxClient.java    From ribbon with Apache License 2.0 5 votes vote down vote up
public LoadBalancingRxClient(IClientConfig config, RetryHandler defaultRetryHandler, PipelineConfigurator<O, I> pipelineConfigurator) {
    this(LoadBalancerBuilder.newBuilder().withClientConfig(config).buildLoadBalancerFromConfigWithReflection(),
            config,
            defaultRetryHandler,
            pipelineConfigurator
            );
}
 
Example #12
Source File: TcpRxServerProvider.java    From karyon with Apache License 2.0 5 votes vote down vote up
public TcpRxServerProvider(String name, Class<I> iType, Class<O> oType) {
    nameAnnotation = Names.named(name);

    connectionHandlerKey = keyFor(ConnectionHandler.class, iType, oType, nameAnnotation);
    pipelineConfiguratorKey = Key.get(PipelineConfigurator.class, nameAnnotation);
    metricEventsListenerFactoryKey = Key.get(MetricEventsListenerFactory.class, nameAnnotation);
    serverConfigKey = Key.get(ServerConfig.class, nameAnnotation);
}
 
Example #13
Source File: HttpRxServerProvider.java    From karyon with Apache License 2.0 5 votes vote down vote up
public HttpRxServerProvider(String name, Class<I> iType, Class<O> oType) {
    nameAnnotation = Names.named(name);

    routerKey = keyFor(RequestHandler.class, iType, oType, nameAnnotation);
    interceptorSupportKey = keyFor(GovernatorHttpInterceptorSupport.class, iType, oType, nameAnnotation);
    pipelineConfiguratorKey = Key.get(PipelineConfigurator.class, nameAnnotation);
    metricEventsListenerFactoryKey = Key.get(MetricEventsListenerFactory.class, nameAnnotation);
    serverConfigKey = Key.get(ServerConfig.class, nameAnnotation);
}
 
Example #14
Source File: WebSocketsRxServerProvider.java    From karyon with Apache License 2.0 5 votes vote down vote up
public WebSocketsRxServerProvider(String name, Class<I> iType, Class<O> oType) {
    nameAnnotation = Names.named(name);

    connectionHandlerKey = keyFor(ConnectionHandler.class, iType, oType, nameAnnotation);
    pipelineConfiguratorKey = Key.get(PipelineConfigurator.class, nameAnnotation);
    metricEventsListenerFactoryKey = Key.get(MetricEventsListenerFactory.class, nameAnnotation);
    serverConfigKey = Key.get(AbstractServerModule.ServerConfig.class, nameAnnotation);
}
 
Example #15
Source File: AbstractServerModule.java    From karyon with Apache License 2.0 5 votes vote down vote up
protected AbstractServerModule(String moduleName, Class<I> iType, Class<O> oType) {
    nameAnnotation = Names.named(moduleName);
    this.iType = iType;
    this.oType = oType;

    pipelineConfiguratorKey = Key.get(PipelineConfigurator.class, nameAnnotation);
    serverConfigKey = Key.get(ServerConfig.class, nameAnnotation);

    serverConfigBuilder = newServerConfigBuilder();
}
 
Example #16
Source File: MyUDPClient.java    From ribbon with Apache License 2.0 4 votes vote down vote up
public MyUDPClient(IClientConfig config, PipelineConfigurator<DatagramPacket, DatagramPacket> pipelineConfigurator) {
    super(config, new MyRetryHandler(config), pipelineConfigurator);
}
 
Example #17
Source File: AbstractServerModule.java    From karyon with Apache License 2.0 4 votes vote down vote up
protected LinkedBindingBuilder<PipelineConfigurator> bindPipelineConfigurator() {
    return bind(pipelineConfiguratorKey);
}
 
Example #18
Source File: RibbonTransport.java    From ribbon with Apache License 2.0 4 votes vote down vote up
public static <I, O> RxClient<I, O> newUdpClient(PipelineConfigurator<O, I> pipelineConfigurator, IClientConfig config) {
    return new LoadBalancingUdpClient<I, O>(config, getDefaultRetryHandlerWithConfig(config), pipelineConfigurator);
}
 
Example #19
Source File: RibbonTransport.java    From ribbon with Apache License 2.0 4 votes vote down vote up
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 #20
Source File: RibbonTransport.java    From ribbon with Apache License 2.0 4 votes vote down vote up
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 #21
Source File: RibbonTransport.java    From ribbon with Apache License 2.0 4 votes vote down vote up
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: LoadBalancingHttpClient.java    From ribbon with Apache License 2.0 4 votes vote down vote up
public Builder<I, O> withPipelineConfigurator(PipelineConfigurator<HttpClientResponse<O>, HttpClientRequest<I>> pipelineConfigurator) {
    this.pipelineConfigurator = pipelineConfigurator;
    return this;
}
 
Example #23
Source File: LoadBalancingTcpClient.java    From ribbon with Apache License 2.0 4 votes vote down vote up
public LoadBalancingTcpClient(IClientConfig config,
        RetryHandler retryHandler,
        PipelineConfigurator<O, I> pipelineConfigurator,
        ScheduledExecutorService poolCleanerScheduler) {
    super(config, retryHandler, pipelineConfigurator, poolCleanerScheduler);
}
 
Example #24
Source File: LoadBalancingTcpClient.java    From ribbon with Apache License 2.0 4 votes vote down vote up
public LoadBalancingTcpClient(ILoadBalancer lb, IClientConfig config,
        RetryHandler retryHandler,
        PipelineConfigurator<O, I> pipelineConfigurator, ScheduledExecutorService poolCleanerScheduler) {
    super(lb, config, retryHandler, pipelineConfigurator, poolCleanerScheduler);
}
 
Example #25
Source File: LoadBalancingUdpClient.java    From ribbon with Apache License 2.0 4 votes vote down vote up
public LoadBalancingUdpClient(ILoadBalancer lb, IClientConfig config,
        RetryHandler retryHandler,
        PipelineConfigurator<O, I> pipelineConfigurator) {
    super(lb, config, retryHandler, pipelineConfigurator);
}
 
Example #26
Source File: LoadBalancingUdpClient.java    From ribbon with Apache License 2.0 4 votes vote down vote up
public LoadBalancingUdpClient(IClientConfig config,
        RetryHandler retryHandler,
        PipelineConfigurator<O, I> pipelineConfigurator) {
    super(config, retryHandler, pipelineConfigurator);
}