org.xnio.Options Java Examples
The following examples show how to use
org.xnio.Options.
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 Project: galeb Author: galeb File: UndertowConfiguration.java License: Apache License 2.0 | 6 votes |
@Bean public Undertow undertow() { return Undertow.builder().addHttpListener(port, "0.0.0.0", rootHandler) .setIoThreads(Integer.parseInt(SystemEnv.IO_THREADS.getValue())) .setWorkerThreads(Integer.parseInt(SystemEnv.WORKER_THREADS.getValue())) .setBufferSize(Integer.parseInt(SystemEnv.BUFFER_SIZE.getValue())) .setDirectBuffers(Boolean.parseBoolean(SystemEnv.DIRECT_BUFFER.getValue())) .setSocketOption(Options.BACKLOG, Integer.parseInt(SystemEnv.BACKLOG.getValue())) .setSocketOption(Options.KEEP_ALIVE, true) .setSocketOption(Options.REUSE_ADDRESSES, true) .setSocketOption(Options.TCP_NODELAY, true) .setServerOption(UndertowOptions.RECORD_REQUEST_START_TIME, true) .setServerOption(UndertowOptions.ENABLE_STATISTICS, true) .setServerOption(UndertowOptions.ALLOW_UNESCAPED_CHARACTERS_IN_URL, true) .build(); }
Example #2
Source Project: galeb Author: galeb File: UndertowOptionMapConfiguration.java License: Apache License 2.0 | 6 votes |
public OptionMap buildUndertowOptionMapFromEnvironment(String prefix, Map<String, String> environmentVariables) { if (!prefix.endsWith("_")) { prefix = prefix + "_"; } String prefixWithoutUnderscoreAtEnd = prefix.substring(0, prefix.length() - 1); Properties properties = new Properties(); for (Entry<String, String> entry : environmentVariables.entrySet()) { String key = entry.getKey(); if (key.startsWith(prefix)) { String keyWithoutPrefix = key.substring(prefix.length()); String fieldValue = entry.getValue(); String className = Options.class.getName(); String propertyKey = prefixWithoutUnderscoreAtEnd + "." + className + "." + keyWithoutPrefix; properties.put(propertyKey, fieldValue); } } OptionMap optionMap = OptionMap.builder().parseAll(properties, prefixWithoutUnderscoreAtEnd).getMap(); return optionMap; }
Example #3
Source Project: lams Author: lamsfoundation File: UndertowAcceptingSslChannel.java License: GNU General Public License v2.0 | 6 votes |
UndertowAcceptingSslChannel(final UndertowXnioSsl ssl, final AcceptingChannel<? extends StreamConnection> tcpServer, final OptionMap optionMap, final ByteBufferPool applicationBufferPool, final boolean startTls) { this.tcpServer = tcpServer; this.ssl = ssl; this.applicationBufferPool = applicationBufferPool; this.startTls = startTls; clientAuthMode = optionMap.get(Options.SSL_CLIENT_AUTH_MODE); useClientMode = optionMap.get(Options.SSL_USE_CLIENT_MODE, false) ? 1 : 0; enableSessionCreation = optionMap.get(Options.SSL_ENABLE_SESSION_CREATION, true) ? 1 : 0; final Sequence<String> enabledCipherSuites = optionMap.get(Options.SSL_ENABLED_CIPHER_SUITES); cipherSuites = enabledCipherSuites != null ? enabledCipherSuites.toArray(new String[enabledCipherSuites.size()]) : null; final Sequence<String> enabledProtocols = optionMap.get(Options.SSL_ENABLED_PROTOCOLS); protocols = enabledProtocols != null ? enabledProtocols.toArray(new String[enabledProtocols.size()]) : null; //noinspection ThisEscapedInObjectConstruction closeSetter = ChannelListeners.<AcceptingChannel<SslConnection>>getDelegatingSetter(tcpServer.getCloseSetter(), this); //noinspection ThisEscapedInObjectConstruction acceptSetter = ChannelListeners.<AcceptingChannel<SslConnection>>getDelegatingSetter(tcpServer.getAcceptSetter(), this); useCipherSuitesOrder = optionMap.get(UndertowOptions.SSL_USER_CIPHER_SUITES_ORDER, false); }
Example #4
Source Project: lams Author: lamsfoundation File: UndertowAcceptingSslChannel.java License: GNU General Public License v2.0 | 6 votes |
public <T> T getOption(final Option<T> option) throws IOException { if (option == Options.SSL_CLIENT_AUTH_MODE) { return option.cast(clientAuthMode); } else if (option == Options.SSL_USE_CLIENT_MODE) { return option.cast(Boolean.valueOf(useClientMode != 0)); } else if (option == Options.SSL_ENABLE_SESSION_CREATION) { return option.cast(Boolean.valueOf(enableSessionCreation != 0)); } else if (option == Options.SSL_ENABLED_CIPHER_SUITES) { final String[] cipherSuites = this.cipherSuites; return cipherSuites == null ? null : option.cast(Sequence.of(cipherSuites)); } else if (option == Options.SSL_ENABLED_PROTOCOLS) { final String[] protocols = this.protocols; return protocols == null ? null : option.cast(Sequence.of(protocols)); } else { return tcpServer.getOption(option); } }
Example #5
Source Project: lams Author: lamsfoundation File: UndertowSslConnection.java License: GNU General Public License v2.0 | 6 votes |
/** {@inheritDoc} */ @Override public <T> T setOption(final Option<T> option, final T value) throws IllegalArgumentException, IOException { if (option == Options.SSL_CLIENT_AUTH_MODE) { try { return option.cast(engine.getNeedClientAuth() ? SslClientAuthMode.REQUIRED : engine.getWantClientAuth() ? SslClientAuthMode.REQUESTED : SslClientAuthMode.NOT_REQUESTED); } finally { engine.setNeedClientAuth(value == SslClientAuthMode.REQUIRED); engine.setWantClientAuth(value == SslClientAuthMode.REQUESTED); } } else if (option == Options.SECURE) { throw new IllegalArgumentException(); } else { return delegate.setOption(option, value); } }
Example #6
Source Project: lams Author: lamsfoundation File: HttpClientProvider.java License: GNU General Public License v2.0 | 6 votes |
@Override public void connect(ClientCallback<ClientConnection> listener, InetSocketAddress bindAddress, URI uri, XnioWorker worker, XnioSsl ssl, ByteBufferPool bufferPool, OptionMap options) { if (uri.getScheme().equals("https")) { if (ssl == null) { listener.failed(UndertowMessages.MESSAGES.sslWasNull()); return; } OptionMap tlsOptions = OptionMap.builder().addAll(options).set(Options.SSL_STARTTLS, true).getMap(); if (bindAddress == null) { ssl.openSslConnection(worker, new InetSocketAddress(uri.getHost(), uri.getPort() == -1 ? 443 : uri.getPort()), createOpenListener(listener, bufferPool, tlsOptions, uri), tlsOptions).addNotifier(createNotifier(listener), null); } else { ssl.openSslConnection(worker, bindAddress, new InetSocketAddress(uri.getHost(), uri.getPort() == -1 ? 443 : uri.getPort()), createOpenListener(listener, bufferPool, tlsOptions, uri), tlsOptions).addNotifier(createNotifier(listener), null); } } else { if (bindAddress == null) { worker.openStreamConnection(new InetSocketAddress(uri.getHost(), uri.getPort() == -1 ? 80 : uri.getPort()), createOpenListener(listener, bufferPool, options, uri), options).addNotifier(createNotifier(listener), null); } else { worker.openStreamConnection(bindAddress, new InetSocketAddress(uri.getHost(), uri.getPort() == -1 ? 80 : uri.getPort()), createOpenListener(listener, bufferPool, options, uri), null, options).addNotifier(createNotifier(listener), null); } } }
Example #7
Source Project: lams Author: lamsfoundation File: HttpClientProvider.java License: GNU General Public License v2.0 | 6 votes |
@Override public void connect(ClientCallback<ClientConnection> listener, InetSocketAddress bindAddress, URI uri, XnioIoThread ioThread, XnioSsl ssl, ByteBufferPool bufferPool, OptionMap options) { if (uri.getScheme().equals("https")) { if (ssl == null) { listener.failed(UndertowMessages.MESSAGES.sslWasNull()); return; } OptionMap tlsOptions = OptionMap.builder().addAll(options).set(Options.SSL_STARTTLS, true).getMap(); if (bindAddress == null) { ssl.openSslConnection(ioThread, new InetSocketAddress(uri.getHost(), uri.getPort() == -1 ? 443 : uri.getPort()), createOpenListener(listener, bufferPool, tlsOptions, uri), tlsOptions).addNotifier(createNotifier(listener), null); } else { ssl.openSslConnection(ioThread, bindAddress, new InetSocketAddress(uri.getHost(), uri.getPort() == -1 ? 443 : uri.getPort()), createOpenListener(listener, bufferPool, tlsOptions, uri), tlsOptions).addNotifier(createNotifier(listener), null); } } else { if (bindAddress == null) { ioThread.openStreamConnection(new InetSocketAddress(uri.getHost(), uri.getPort() == -1 ? 80 : uri.getPort()), createOpenListener(listener, bufferPool, options, uri), options).addNotifier(createNotifier(listener), null); } else { ioThread.openStreamConnection(bindAddress, new InetSocketAddress(uri.getHost(), uri.getPort() == -1 ? 80 : uri.getPort()), createOpenListener(listener, bufferPool, options, uri), null, options).addNotifier(createNotifier(listener), null); } } }
Example #8
Source Project: lams Author: lamsfoundation File: Http2SslSessionInfo.java License: GNU General Public License v2.0 | 6 votes |
@Override public Certificate[] getPeerCertificates() throws SSLPeerUnverifiedException, RenegotiationRequiredException { try { return channel.getSslSession().getPeerCertificates(); } catch (SSLPeerUnverifiedException e) { try { SslClientAuthMode sslClientAuthMode = channel.getOption(Options.SSL_CLIENT_AUTH_MODE); if (sslClientAuthMode == SslClientAuthMode.NOT_REQUESTED) { throw new RenegotiationRequiredException(); } } catch (IOException e1) { //ignore, will not actually happen } throw e; } }
Example #9
Source Project: lams Author: lamsfoundation File: Http2SslSessionInfo.java License: GNU General Public License v2.0 | 6 votes |
@Override public X509Certificate[] getPeerCertificateChain() throws SSLPeerUnverifiedException, RenegotiationRequiredException { try { return channel.getSslSession().getPeerCertificateChain(); } catch (SSLPeerUnverifiedException e) { try { SslClientAuthMode sslClientAuthMode = channel.getOption(Options.SSL_CLIENT_AUTH_MODE); if (sslClientAuthMode == SslClientAuthMode.NOT_REQUESTED) { throw new RenegotiationRequiredException(); } } catch (IOException e1) { //ignore, will not actually happen } throw e; } }
Example #10
Source Project: lams Author: lamsfoundation File: ConnectionSSLSessionInfo.java License: GNU General Public License v2.0 | 6 votes |
@Override public Certificate[] getPeerCertificates() throws SSLPeerUnverifiedException, RenegotiationRequiredException { if(unverified != null) { throw unverified; } if(renegotiationRequiredException != null) { throw renegotiationRequiredException; } try { return channel.getSslSession().getPeerCertificates(); } catch (SSLPeerUnverifiedException e) { try { SslClientAuthMode sslClientAuthMode = channel.getOption(Options.SSL_CLIENT_AUTH_MODE); if (sslClientAuthMode == SslClientAuthMode.NOT_REQUESTED) { renegotiationRequiredException = RENEGOTIATION_REQUIRED_EXCEPTION; throw renegotiationRequiredException; } } catch (IOException e1) { //ignore, will not actually happen } unverified = PEER_UNVERIFIED_EXCEPTION; throw unverified; } }
Example #11
Source Project: lams Author: lamsfoundation File: ConnectionSSLSessionInfo.java License: GNU General Public License v2.0 | 6 votes |
@Override public X509Certificate[] getPeerCertificateChain() throws SSLPeerUnverifiedException, RenegotiationRequiredException { if(unverified != null) { throw unverified; } if(renegotiationRequiredException != null) { throw renegotiationRequiredException; } try { return channel.getSslSession().getPeerCertificateChain(); } catch (SSLPeerUnverifiedException e) { try { SslClientAuthMode sslClientAuthMode = channel.getOption(Options.SSL_CLIENT_AUTH_MODE); if (sslClientAuthMode == SslClientAuthMode.NOT_REQUESTED) { renegotiationRequiredException = RENEGOTIATION_REQUIRED_EXCEPTION; throw renegotiationRequiredException; } } catch (IOException e1) { //ignore, will not actually happen } unverified = PEER_UNVERIFIED_EXCEPTION; throw unverified; } }
Example #12
Source Project: lams Author: lamsfoundation File: MCMPHandler.java License: GNU General Public License v2.0 | 6 votes |
/** * Check whether a host is up. * * @param scheme the scheme * @param host the host * @param port the port * @param exchange the http server exchange * @param callback the ping callback */ protected void checkHostUp(final String scheme, final String host, final int port, final HttpServerExchange exchange, final NodePingUtil.PingCallback callback) { final XnioSsl xnioSsl = null; // TODO final OptionMap options = OptionMap.builder() .set(Options.TCP_NODELAY, true) .getMap(); try { // http, ajp and maybe more in future if ("ajp".equalsIgnoreCase(scheme) || "http".equalsIgnoreCase(scheme)) { final URI uri = new URI(scheme, null, host, port, "/", null, null); NodePingUtil.pingHttpClient(uri, callback, exchange, container.getClient(), xnioSsl, options); } else { final InetSocketAddress address = new InetSocketAddress(host, port); NodePingUtil.pingHost(address, exchange, callback, options); } } catch (URISyntaxException e) { callback.failed(); } }
Example #13
Source Project: lams Author: lamsfoundation File: WriteTimeoutStreamSinkConduit.java License: GNU General Public License v2.0 | 6 votes |
private Integer getTimeout() { Integer timeout = 0; try { timeout = connection.getSourceChannel().getOption(Options.WRITE_TIMEOUT); } catch (IOException ignore) { // should never happen, ignoring } Integer idleTimeout = openListener.getUndertowOptions().get(UndertowOptions.IDLE_TIMEOUT); if ((timeout == null || timeout <= 0) && idleTimeout != null) { timeout = idleTimeout; } else if (timeout != null && idleTimeout != null && idleTimeout > 0) { timeout = Math.min(timeout, idleTimeout); } return timeout; }
Example #14
Source Project: light-4j Author: networknt File: Light4jHttpClientProvider.java License: Apache License 2.0 | 6 votes |
@Override public void connect(ClientCallback<ClientConnection> listener, InetSocketAddress bindAddress, URI uri, XnioWorker worker, XnioSsl ssl, ByteBufferPool bufferPool, OptionMap options) { if (uri.getScheme().equals(HTTPS)) { if (ssl == null) { listener.failed(UndertowMessages.MESSAGES.sslWasNull()); return; } OptionMap tlsOptions = OptionMap.builder().addAll(options).set(Options.SSL_STARTTLS, true).getMap(); if (bindAddress == null) { ssl.openSslConnection(worker, new InetSocketAddress(uri.getHost(), uri.getPort() == -1 ? 443 : uri.getPort()), createOpenListener(listener, bufferPool, tlsOptions, uri), tlsOptions).addNotifier(createNotifier(listener), null); } else { ssl.openSslConnection(worker, bindAddress, new InetSocketAddress(uri.getHost(), uri.getPort() == -1 ? 443 : uri.getPort()), createOpenListener(listener, bufferPool, tlsOptions, uri), tlsOptions).addNotifier(createNotifier(listener), null); } } else { if (bindAddress == null) { worker.openStreamConnection(new InetSocketAddress(uri.getHost(), uri.getPort() == -1 ? 80 : uri.getPort()), createOpenListener(listener, bufferPool, options, uri), options).addNotifier(createNotifier(listener), null); } else { worker.openStreamConnection(bindAddress, new InetSocketAddress(uri.getHost(), uri.getPort() == -1 ? 80 : uri.getPort()), createOpenListener(listener, bufferPool, options, uri), null, options).addNotifier(createNotifier(listener), null); } } }
Example #15
Source Project: light-4j Author: networknt File: Light4jHttpClientProvider.java License: Apache License 2.0 | 6 votes |
@Override public void connect(ClientCallback<ClientConnection> listener, InetSocketAddress bindAddress, URI uri, XnioIoThread ioThread, XnioSsl ssl, ByteBufferPool bufferPool, OptionMap options) { if (uri.getScheme().equals(HTTPS)) { if (ssl == null) { listener.failed(UndertowMessages.MESSAGES.sslWasNull()); return; } OptionMap tlsOptions = OptionMap.builder().addAll(options).set(Options.SSL_STARTTLS, true).getMap(); if (bindAddress == null) { ssl.openSslConnection(ioThread, new InetSocketAddress(uri.getHost(), uri.getPort() == -1 ? 443 : uri.getPort()), createOpenListener(listener, bufferPool, tlsOptions, uri), tlsOptions).addNotifier(createNotifier(listener), null); } else { ssl.openSslConnection(ioThread, bindAddress, new InetSocketAddress(uri.getHost(), uri.getPort() == -1 ? 443 : uri.getPort()), createOpenListener(listener, bufferPool, tlsOptions, uri), tlsOptions).addNotifier(createNotifier(listener), null); } } else { if (bindAddress == null) { ioThread.openStreamConnection(new InetSocketAddress(uri.getHost(), uri.getPort() == -1 ? 80 : uri.getPort()), createOpenListener(listener, bufferPool, options, uri), options).addNotifier(createNotifier(listener), null); } else { ioThread.openStreamConnection(bindAddress, new InetSocketAddress(uri.getHost(), uri.getPort() == -1 ? 80 : uri.getPort()), createOpenListener(listener, bufferPool, options, uri), null, options).addNotifier(createNotifier(listener), null); } } }
Example #16
Source Project: wildfly-core Author: wildfly File: ProtocolConnectionUtils.java License: GNU Lesser General Public License v2.1 | 6 votes |
private static AuthenticationConfiguration configureSaslMechanisms(Map<String, String> saslOptions, boolean isLocal, AuthenticationConfiguration authenticationConfiguration) { String[] mechanisms = null; String listed; if (saslOptions != null && (listed = saslOptions.get(Options.SASL_DISALLOWED_MECHANISMS.getName())) != null) { // Disallowed mechanisms were passed via the saslOptions map; need to convert to an XNIO option String[] split = listed.split(" "); if (isLocal) { mechanisms = new String[split.length + 1]; mechanisms[0] = JBOSS_LOCAL_USER; System.arraycopy(split, 0, mechanisms, 1, split.length); } else { mechanisms = split; } } else if (!isLocal) { mechanisms = new String[]{ JBOSS_LOCAL_USER }; } return (mechanisms != null && mechanisms.length > 0) ? authenticationConfiguration.setSaslMechanismSelector(SaslMechanismSelector.DEFAULT.forbidMechanisms(mechanisms)) : authenticationConfiguration; }
Example #17
Source Project: wildfly-core Author: wildfly File: RemoteChannelPairSetup.java License: GNU Lesser General Public License v2.1 | 6 votes |
public void startChannels() throws IOException, URISyntaxException { ProtocolConnectionConfiguration configuration = ProtocolConnectionConfiguration.create(channelServer.getEndpoint(), new URI("" + URI_SCHEME + "://127.0.0.1:" + PORT + ""), OptionMap.create(Options.SASL_POLICY_NOANONYMOUS, Boolean.FALSE, Options.SSL_ENABLED, Boolean.FALSE)); configuration.setClientBindAddress("127.0.0.1"); // we set this to exercise this code path in ProtocolConnectionUtils.connectSync // The path with no client bind address gets used all the time connection = ProtocolConnectionUtils.connectSync(configuration); clientChannel = connection.openChannel(TEST_CHANNEL, OptionMap.EMPTY).get(); try { clientConnectedLatch.await(); } catch (InterruptedException e) { throw new RuntimeException(e); } }
Example #18
Source Project: wildfly-core Author: wildfly File: ConnectorUtils.java License: GNU Lesser General Public License v2.1 | 6 votes |
protected static OptionMap getFullOptions(OperationContext context, ModelNode fullModel) throws OperationFailedException { OptionMap.Builder builder = OptionMap.builder(); builder.set(Options.TCP_NODELAY, true); builder.set(Options.REUSE_ADDRESSES, true); builder.set(RemotingOptions.SASL_PROTOCOL, ConnectorCommon.SASL_PROTOCOL.resolveModelAttribute(context, fullModel).asString()); ModelNode serverName = ConnectorCommon.SERVER_NAME.resolveModelAttribute(context, fullModel); if (serverName.isDefined()) { builder.set(RemotingOptions.SERVER_NAME, serverName.asString()); } ModelNode properties = fullModel.get(PROPERTY); if (properties.isDefined() && properties.asInt() > 0) { addOptions(context, properties, builder); } if (fullModel.hasDefined(SECURITY)) { ModelNode security = fullModel.require(SECURITY); if (security.hasDefined(SASL)) { ModelNode sasl = security.require(SASL); addSasl(context, sasl, builder); } } return builder.getMap(); }
Example #19
Source Project: wildfly-core Author: wildfly File: ManagementHttpServer.java License: GNU Lesser General Public License v2.1 | 6 votes |
public void start() { try { OptionMap.Builder serverOptionsBuilder = OptionMap.builder() .set(Options.TCP_NODELAY, true) .set(Options.REUSE_ADDRESSES, true); ChannelListener acceptListener = ChannelListeners.openListenerAdapter(openListener); if (httpAddress != null) { normalServer = worker.createStreamConnectionServer(httpAddress, acceptListener, serverOptionsBuilder.getMap()); normalServer.resumeAccepts(); } if (secureAddress != null) { if (sslClientAuthMode != null) { serverOptionsBuilder.set(SSL_CLIENT_AUTH_MODE, sslClientAuthMode); } OptionMap secureOptions = serverOptionsBuilder.getMap(); XnioSsl xnioSsl = new UndertowXnioSsl(worker.getXnio(), secureOptions, sslContext); secureServer = xnioSsl.createSslConnectionServer(worker, secureAddress, acceptListener, secureOptions); secureServer.resumeAccepts(); } } catch (IOException e) { throw new RuntimeException(e); } }
Example #20
Source Project: wildfly-core Author: wildfly File: ManagementWorkerService.java License: GNU Lesser General Public License v2.1 | 6 votes |
public static void installService(ServiceTarget serviceTarget){ //todo make configurable ManagementWorkerService service = new ManagementWorkerService(OptionMap.builder() .set(Options.WORKER_IO_THREADS, 2) .set(Options.WORKER_TASK_CORE_THREADS, 5) .set(Options.WORKER_TASK_MAX_THREADS, 10) .set(Options.TCP_NODELAY, true) .set(Options.CORK, true) .set(Options.WORKER_NAME, "management") .getMap()); serviceTarget.addService(SERVICE_NAME, service) .setInitialMode(ServiceController.Mode.ON_DEMAND) //have it on demand as it might not be needed in certain scenarios .install(); }
Example #21
Source Project: wildfly-core Author: wildfly File: IOSubsystem20TestCase.java License: GNU Lesser General Public License v2.1 | 6 votes |
@Test public void testRuntime() throws Exception { KernelServicesBuilder builder = createKernelServicesBuilder(createAdditionalInitialization()) .setSubsystemXml(getSubsystemXml()); KernelServices mainServices = builder.build(); if (!mainServices.isSuccessfulBoot()) { Assert.fail(String.valueOf(mainServices.getBootError())); } ServiceController<XnioWorker> workerServiceController = (ServiceController<XnioWorker>) mainServices.getContainer().getService(IOServices.WORKER.append("default")); workerServiceController.setMode(ServiceController.Mode.ACTIVE); workerServiceController.awaitValue(); XnioWorker worker = workerServiceController.getService().getValue(); Assert.assertEquals(ProcessorInfo.availableProcessors() * 2, worker.getIoThreadCount()); Assert.assertEquals(ProcessorInfo.availableProcessors() * 16, worker.getOption(Options.WORKER_TASK_MAX_THREADS).intValue()); PathAddress addr = PathAddress.parseCLIStyleAddress("/subsystem=io/worker=default"); ModelNode op = Util.createOperation("read-resource", addr); op.get("include-runtime").set(true); mainServices.executeOperation(op); }
Example #22
Source Project: wildfly-core Author: wildfly File: IOSubsystem11TestCase.java License: GNU Lesser General Public License v2.1 | 6 votes |
@Test public void testRuntime() throws Exception { KernelServicesBuilder builder = createKernelServicesBuilder(createAdditionalInitialization()) .setSubsystemXml(getSubsystemXml()); KernelServices mainServices = builder.build(); if (!mainServices.isSuccessfulBoot()) { Assert.fail(mainServices.getBootError().toString()); } ServiceController<XnioWorker> workerServiceController = (ServiceController<XnioWorker>) mainServices.getContainer().getService(IOServices.WORKER.append("default")); workerServiceController.setMode(ServiceController.Mode.ACTIVE); workerServiceController.awaitValue(); XnioWorker worker = workerServiceController.getService().getValue(); Assert.assertEquals(ProcessorInfo.availableProcessors() * 2, worker.getIoThreadCount()); Assert.assertEquals(ProcessorInfo.availableProcessors() * 16, worker.getOption(Options.WORKER_TASK_MAX_THREADS).intValue()); PathAddress addr = PathAddress.parseCLIStyleAddress("/subsystem=io/worker=default"); ModelNode op = Util.createOperation("read-resource", addr); op.get("include-runtime").set(true); mainServices.executeOperation(op); }
Example #23
Source Project: seed Author: seedstack File: UndertowLauncher.java License: Mozilla Public License 2.0 | 6 votes |
private void createWorker(Coffig config) throws Exception { UndertowConfig undertowConfig = config.get(UndertowConfig.class); try { xnioWorker = Xnio.getInstance().createWorker(OptionMap.builder() .set(Options.WORKER_IO_THREADS, undertowConfig.getIoThreads()) .set(Options.WORKER_TASK_CORE_THREADS, undertowConfig.getWorkerThreads()) .set(Options.WORKER_TASK_MAX_THREADS, undertowConfig.getWorkerThreads()) .set(Options.TCP_NODELAY, undertowConfig.isTcpNoDelay()) .set(Options.READ_TIMEOUT, undertowConfig.getReadTimeout()) .set(Options.WRITE_TIMEOUT, undertowConfig.getWriteTimeout()) .getMap()); } catch (RuntimeException e) { throw unwrapUndertowException(e); } }
Example #24
Source Project: cxf Author: apache File: UndertowHTTPServerEngine.java License: Apache License 2.0 | 6 votes |
private Builder configureThreads(Builder builder) { if (this.threadingParameters != null) { if (this.threadingParameters.isWorkerIOThreadsSet()) { builder = builder.setWorkerOption(Options.WORKER_IO_THREADS, this.threadingParameters.getWorkerIOThreads()); } if (this.threadingParameters.isMinThreadsSet()) { builder = builder.setWorkerOption(Options.WORKER_TASK_CORE_THREADS, this.threadingParameters.getMinThreads()); } if (this.threadingParameters.isMaxThreadsSet()) { builder = builder.setWorkerOption(Options.WORKER_TASK_MAX_THREADS, this.threadingParameters.getMaxThreads()); } if (this.threadingParameters.isWorkerIONameSet()) { builder = builder.setWorkerOption(Options.WORKER_NAME, this.threadingParameters.getWorkerIOName()); } } return builder; }
Example #25
Source Project: galeb Author: galeb File: SimpleWebServerService.java License: Apache License 2.0 | 5 votes |
@PostConstruct public void init() { Undertow.builder().addHttpListener(port, "0.0.0.0", pingHandler()) .setSocketOption(Options.KEEP_ALIVE, true) .setSocketOption(Options.REUSE_ADDRESSES, true) .setSocketOption(Options.TCP_NODELAY, true) .build().start(); }
Example #26
Source Project: galeb Author: galeb File: UndertowOptionMapConfigurationTest.java License: Apache License 2.0 | 5 votes |
@Test public void testBuildUndertowOptionMapFromEnvironmentWithOptionKeepAlive() throws Exception { HashMap<String, String> env = new HashMap<String, String>(); env.put("UNDERTOW_OPTIONS_KEEP_ALIVE", "true"); UndertowOptionMapConfiguration undertowOptionMapConfiguration = new UndertowOptionMapConfiguration(); OptionMap optionMap = undertowOptionMapConfiguration.buildUndertowOptionMapFromEnvironment("UNDERTOW_OPTIONS_", env); Assert.assertEquals(optionMap.get(Options.KEEP_ALIVE, false), true); }
Example #27
Source Project: galeb Author: galeb File: UndertowOptionMapConfigurationTest.java License: Apache License 2.0 | 5 votes |
@Test public void testGetUndertowOptionMapWithTwoBooleanOptions() throws Exception { HashMap<String, String> env = new HashMap<String, String>(); env.put("UNDERTOW_OPTIONS_KEEP_ALIVE", "true"); env.put("UNDERTOW_OPTIONS_ALLOW_BLOCKING", "true"); UndertowOptionMapConfiguration undertowOptionMapConfiguration = new UndertowOptionMapConfiguration(); OptionMap optionMap = undertowOptionMapConfiguration.buildUndertowOptionMapFromEnvironment("UNDERTOW_OPTIONS_", env); Assert.assertEquals(optionMap.get(Options.KEEP_ALIVE, false), true); Assert.assertEquals(optionMap.get(Options.ALLOW_BLOCKING, false), true); }
Example #28
Source Project: galeb Author: galeb File: UndertowOptionMapConfigurationTest.java License: Apache License 2.0 | 5 votes |
@Test public void testGetUndertowOptionMapWithBooleanOptionAndIntegerOption() throws Exception { HashMap<String, String> env = new HashMap<String, String>(); env.put("UNDERTOW_OPTIONS_KEEP_ALIVE", "true"); env.put("UNDERTOW_OPTIONS_BALANCING_CONNECTIONS", "100"); UndertowOptionMapConfiguration undertowOptionMapConfiguration = new UndertowOptionMapConfiguration(); OptionMap optionMap = undertowOptionMapConfiguration.buildUndertowOptionMapFromEnvironment("UNDERTOW_OPTIONS_", env); Assert.assertEquals(optionMap.get(Options.KEEP_ALIVE, false), true); Assert.assertEquals(optionMap.get(Options.BALANCING_CONNECTIONS, 0), 100); }
Example #29
Source Project: lams Author: lamsfoundation File: UndertowSslConnection.java License: GNU General Public License v2.0 | 5 votes |
/** {@inheritDoc} */ @Override public <T> T getOption(final Option<T> option) throws IOException { if (option == Options.SSL_CLIENT_AUTH_MODE) { return option.cast(engine.getNeedClientAuth() ? SslClientAuthMode.REQUIRED : engine.getWantClientAuth() ? SslClientAuthMode.REQUESTED : SslClientAuthMode.NOT_REQUESTED); } else { return option == Options.SECURE ? (T)Boolean.TRUE : delegate.getOption(option); } }
Example #30
Source Project: lams Author: lamsfoundation File: Http2ClientProvider.java License: GNU General Public License v2.0 | 5 votes |
@Override public void connect(final ClientCallback<ClientConnection> listener, InetSocketAddress bindAddress, final URI uri, final XnioWorker worker, final XnioSsl ssl, final ByteBufferPool bufferPool, final OptionMap options) { if (ssl == null) { listener.failed(UndertowMessages.MESSAGES.sslWasNull()); return; } OptionMap tlsOptions = OptionMap.builder().addAll(options).set(Options.SSL_STARTTLS, true).getMap(); if(bindAddress == null) { ssl.openSslConnection(worker, new InetSocketAddress(uri.getHost(), uri.getPort() == -1 ? 443 : uri.getPort()), createOpenListener(listener, uri, ssl, bufferPool, tlsOptions), tlsOptions).addNotifier(createNotifier(listener), null); } else { ssl.openSslConnection(worker, bindAddress, new InetSocketAddress(uri.getHost(), uri.getPort() == -1 ? 443 : uri.getPort()), createOpenListener(listener, uri, ssl, bufferPool, tlsOptions), tlsOptions).addNotifier(createNotifier(listener), null); } }