Search in sources :

Example 1 with ExclusivityChecker

use of io.undertow.server.handlers.proxy.ExclusivityChecker in project wildfly by wildfly.

the class ReverseProxyHandler method createHandler.

@Override
public HttpHandler createHandler(final OperationContext context, ModelNode model) throws OperationFailedException {
    String sessionCookieNames = SESSION_COOKIE_NAMES.resolveModelAttribute(context, model).asString();
    int connectionsPerThread = CONNECTIONS_PER_THREAD.resolveModelAttribute(context, model).asInt();
    int problemServerRetry = PROBLEM_SERVER_RETRY.resolveModelAttribute(context, model).asInt();
    int maxTime = MAX_REQUEST_TIME.resolveModelAttribute(context, model).asInt();
    int requestQueueSize = REQUEST_QUEUE_SIZE.resolveModelAttribute(context, model).asInt();
    int cachedConnectionsPerThread = CACHED_CONNECTIONS_PER_THREAD.resolveModelAttribute(context, model).asInt();
    int connectionIdleTimeout = CONNECTION_IDLE_TIMEOUT.resolveModelAttribute(context, model).asInt();
    int maxRetries = MAX_RETRIES.resolveModelAttribute(context, model).asInt();
    final LoadBalancingProxyClient lb = new LoadBalancingProxyClient(new ExclusivityChecker() {

        @Override
        public boolean isExclusivityRequired(HttpServerExchange exchange) {
            //we always create a new connection for upgrade requests
            return exchange.getRequestHeaders().contains(Headers.UPGRADE);
        }
    }).setConnectionsPerThread(connectionsPerThread).setMaxQueueSize(requestQueueSize).setSoftMaxConnectionsPerThread(cachedConnectionsPerThread).setTtl(connectionIdleTimeout).setProblemServerRetry(problemServerRetry);
    String[] sessionIds = sessionCookieNames.split(",");
    for (String id : sessionIds) {
        lb.addSessionCookieName(id);
    }
    ProxyHandler handler = new ProxyHandler(lb, maxTime, ResponseCodeHandler.HANDLE_404, false, false, maxRetries);
    return handler;
}
Also used : HttpServerExchange(io.undertow.server.HttpServerExchange) ProxyHandler(io.undertow.server.handlers.proxy.ProxyHandler) ExclusivityChecker(io.undertow.server.handlers.proxy.ExclusivityChecker) LoadBalancingProxyClient(io.undertow.server.handlers.proxy.LoadBalancingProxyClient)

Aggregations

HttpServerExchange (io.undertow.server.HttpServerExchange)1 ExclusivityChecker (io.undertow.server.handlers.proxy.ExclusivityChecker)1 LoadBalancingProxyClient (io.undertow.server.handlers.proxy.LoadBalancingProxyClient)1 ProxyHandler (io.undertow.server.handlers.proxy.ProxyHandler)1