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;
}
Aggregations