Search in sources :

Example 1 with RouteParsingStrategy

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

the class ModClusterService method install.

static void install(String name, CapabilityServiceTarget serviceTarget, ModelNode model, OperationContext operationContext) throws OperationFailedException {
    String securityKey = null;
    ModelNode securityKeyNode = ModClusterDefinition.SECURITY_KEY.resolveModelAttribute(operationContext, model);
    if (securityKeyNode.isDefined()) {
        securityKey = securityKeyNode.asString();
    }
    String managementAccessPredicateString = null;
    ModelNode managementAccessPredicateNode = ModClusterDefinition.MANAGEMENT_ACCESS_PREDICATE.resolveModelAttribute(operationContext, model);
    if (managementAccessPredicateNode.isDefined()) {
        managementAccessPredicateString = managementAccessPredicateNode.asString();
    }
    Predicate managementAccessPredicate = null;
    if (managementAccessPredicateString != null) {
        managementAccessPredicate = PredicateParser.parse(managementAccessPredicateString, ModClusterService.class.getClassLoader());
    }
    final ModelNode sslContext = ModClusterDefinition.SSL_CONTEXT.resolveModelAttribute(operationContext, model);
    final ModelNode securityRealm = ModClusterDefinition.SECURITY_REALM.resolveModelAttribute(operationContext, model);
    final ModelNode packetSizeNode = ModClusterDefinition.MAX_AJP_PACKET_SIZE.resolveModelAttribute(operationContext, model);
    OptionMap.Builder builder = OptionMap.builder();
    if (packetSizeNode.isDefined()) {
        builder.set(UndertowOptions.MAX_AJP_PACKET_SIZE, packetSizeNode.asInt());
    }
    builder.set(UndertowOptions.ENABLE_HTTP2, ModClusterDefinition.ENABLE_HTTP2.resolveModelAttribute(operationContext, model).asBoolean());
    ModClusterDefinition.HTTP2_ENABLE_PUSH.resolveOption(operationContext, model, builder);
    ModClusterDefinition.HTTP2_HEADER_TABLE_SIZE.resolveOption(operationContext, model, builder);
    ModClusterDefinition.HTTP2_INITIAL_WINDOW_SIZE.resolveOption(operationContext, model, builder);
    ModClusterDefinition.HTTP2_MAX_CONCURRENT_STREAMS.resolveOption(operationContext, model, builder);
    ModClusterDefinition.HTTP2_MAX_FRAME_SIZE.resolveOption(operationContext, model, builder);
    ModClusterDefinition.HTTP2_MAX_HEADER_LIST_SIZE.resolveOption(operationContext, model, builder);
    // Resolve affinity
    ModelNode affinityNode = model.get(Constants.AFFINITY);
    RouteParsingStrategy routeParsingStrategy = RouteParsingStrategy.SINGLE;
    String routeDelimiter = null;
    if (affinityNode.hasDefined(Constants.NONE)) {
        routeParsingStrategy = RouteParsingStrategy.NONE;
    } else if (affinityNode.hasDefined(Constants.RANKED)) {
        ModelNode rankedModelNode = affinityNode.get(Constants.RANKED);
        routeParsingStrategy = RouteParsingStrategy.RANKED;
        routeDelimiter = RankedAffinityResourceDefinition.Attribute.DELIMITER.resolveModelAttribute(operationContext, rankedModelNode).asString();
    }
    final String mgmtSocketBindingRef = ModClusterDefinition.MANAGEMENT_SOCKET_BINDING.resolveModelAttribute(operationContext, model).asString();
    final ModelNode advertiseSocketBindingRef = ModClusterDefinition.ADVERTISE_SOCKET_BINDING.resolveModelAttribute(operationContext, model);
    final String workerRef = ModClusterDefinition.WORKER.resolveModelAttribute(operationContext, model).asString();
    final RuntimeCapability<?> capabilityName = ModClusterDefinition.Capability.MOD_CLUSTER_FILTER_CAPABILITY.getDefinition();
    final CapabilityServiceBuilder<?> sb = serviceTarget.addCapability(capabilityName);
    final Consumer<FilterService> serviceConsumer = sb.provides(capabilityName, UndertowService.FILTER.append(name));
    final Supplier<XnioWorker> xwSupplier = sb.requiresCapability(IOServices.IO_WORKER_CAPABILITY_NAME, XnioWorker.class, workerRef);
    final Supplier<SocketBinding> msbSupplier = sb.requiresCapability(Capabilities.REF_SOCKET_BINDING, SocketBinding.class, mgmtSocketBindingRef);
    final Supplier<SocketBinding> asbSupplier = advertiseSocketBindingRef.isDefined() ? sb.requiresCapability(Capabilities.REF_SOCKET_BINDING, SocketBinding.class, advertiseSocketBindingRef.asString()) : null;
    final Supplier<SSLContext> scSupplier = sslContext.isDefined() ? sb.requiresCapability(REF_SSL_CONTEXT, SSLContext.class, sslContext.asString()) : null;
    ModClusterService service = new ModClusterService(serviceConsumer, xwSupplier, msbSupplier, asbSupplier, scSupplier, model, ModClusterDefinition.HEALTH_CHECK_INTERVAL.resolveModelAttribute(operationContext, model).asInt(), ModClusterDefinition.MAX_REQUEST_TIME.resolveModelAttribute(operationContext, model).asInt(), ModClusterDefinition.BROKEN_NODE_TIMEOUT.resolveModelAttribute(operationContext, model).asInt(), ModClusterDefinition.ADVERTISE_FREQUENCY.resolveModelAttribute(operationContext, model).asInt(), ModClusterDefinition.ADVERTISE_PATH.resolveModelAttribute(operationContext, model).asString(), ModClusterDefinition.ADVERTISE_PROTOCOL.resolveModelAttribute(operationContext, model).asString(), securityKey, managementAccessPredicate, ModClusterDefinition.CONNECTIONS_PER_THREAD.resolveModelAttribute(operationContext, model).asInt(), ModClusterDefinition.CACHED_CONNECTIONS_PER_THREAD.resolveModelAttribute(operationContext, model).asInt(), ModClusterDefinition.CONNECTION_IDLE_TIMEOUT.resolveModelAttribute(operationContext, model).asInt(), ModClusterDefinition.REQUEST_QUEUE_SIZE.resolveModelAttribute(operationContext, model).asInt(), ModClusterDefinition.USE_ALIAS.resolveModelAttribute(operationContext, model).asBoolean(), ModClusterDefinition.MAX_RETRIES.resolveModelAttribute(operationContext, model).asInt(), Enum.valueOf(FailoverStrategy.class, ModClusterDefinition.FAILOVER_STRATEGY.resolveModelAttribute(operationContext, model).asString()), routeParsingStrategy, routeDelimiter, builder.getMap());
    sb.setInstance(service);
    sb.install();
}
Also used : SocketBinding(org.jboss.as.network.SocketBinding) XnioWorker(org.xnio.XnioWorker) SSLContext(javax.net.ssl.SSLContext) RouteParsingStrategy(io.undertow.server.handlers.proxy.RouteParsingStrategy) Predicate(io.undertow.predicate.Predicate) OptionMap(org.xnio.OptionMap) ModelNode(org.jboss.dmr.ModelNode)

Aggregations

Predicate (io.undertow.predicate.Predicate)1 RouteParsingStrategy (io.undertow.server.handlers.proxy.RouteParsingStrategy)1 SSLContext (javax.net.ssl.SSLContext)1 SocketBinding (org.jboss.as.network.SocketBinding)1 ModelNode (org.jboss.dmr.ModelNode)1 OptionMap (org.xnio.OptionMap)1 XnioWorker (org.xnio.XnioWorker)1