org.xnio.Xnio Java Examples

The following examples show how to use org.xnio.Xnio. 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: ProgrammaticWebSocketServer.java    From wildfly-samples with MIT License 9 votes vote down vote up
public ProgrammaticWebSocketServer() throws IOException {
    final Xnio xnio = Xnio.getInstance("nio", Undertow.class.getClassLoader());
    final XnioWorker xnioWorker = xnio.createWorker(OptionMap.builder().getMap());

    WebSocketDeploymentInfo websocket = new WebSocketDeploymentInfo()
            .addEndpoint(MyAnnotatedEndpoint.class)
            .setWorker(xnioWorker);

    DeploymentInfo deploymentInfo = deployment()
            .setClassLoader(MyAnnotatedEndpoint.class.getClassLoader())
            .setContextPath("/myapp")
            .setDeploymentName("websockets")
            .addServletContextAttribute(WebSocketDeploymentInfo.ATTRIBUTE_NAME, websocket);

    manager = defaultContainer().addDeployment(deploymentInfo);
    manager.deploy();
}
 
Example #2
Source File: AnnotatedWebSocketServer.java    From wildfly-samples with MIT License 7 votes vote down vote up
public AnnotatedWebSocketServer() throws IOException {
    final Xnio xnio = Xnio.getInstance("nio", Undertow.class.getClassLoader());
    final XnioWorker xnioWorker = xnio.createWorker(OptionMap.builder().getMap());

    WebSocketDeploymentInfo websocket = new WebSocketDeploymentInfo()
            .addEndpoint(MyAnnotatedEndpoint.class)
            .setWorker(xnioWorker);

    DeploymentInfo deploymentInfo = deployment()
            .setClassLoader(MyAnnotatedEndpoint.class.getClassLoader())
            .setContextPath("/myapp")
            .setDeploymentName("websockets")
            .addServletContextAttribute(WebSocketDeploymentInfo.ATTRIBUTE_NAME, websocket);

    manager = defaultContainer().addDeployment(deploymentInfo);
    manager.deploy();
}
 
Example #3
Source File: AbstractWebSocketIntegrationTests.java    From spring-analysis-note with MIT License 6 votes vote down vote up
@Parameters(name = "client[{0}] - server [{1}]")
public static Object[][] arguments() throws IOException {

	WebSocketClient[] clients = new WebSocketClient[] {
			new TomcatWebSocketClient(),
			new JettyWebSocketClient(),
			new ReactorNettyWebSocketClient(),
			new UndertowWebSocketClient(Xnio.getInstance().createWorker(OptionMap.EMPTY))
	};

	Map<HttpServer, Class<?>> servers = new LinkedHashMap<>();
	servers.put(new TomcatHttpServer(TMP_DIR.getAbsolutePath(), WsContextListener.class), TomcatConfig.class);
	servers.put(new JettyHttpServer(), JettyConfig.class);
	servers.put(new ReactorHttpServer(), ReactorNettyConfig.class);
	servers.put(new UndertowHttpServer(), UndertowConfig.class);

	Flux<WebSocketClient> f1 = Flux.fromArray(clients).concatMap(c -> Flux.just(c).repeat(servers.size()));
	Flux<HttpServer> f2 = Flux.fromIterable(servers.keySet()).repeat(clients.length);
	Flux<Class<?>> f3 = Flux.fromIterable(servers.values()).repeat(clients.length);

	return Flux.zip(f1, f2, f3).map(Tuple3::toArray).collectList().block()
			.toArray(new Object[clients.length * servers.size()][2]);
}
 
Example #4
Source File: AbstractWebSocketIntegrationTests.java    From java-technology-stack with MIT License 6 votes vote down vote up
@Parameters(name = "client[{0}] - server [{1}]")
public static Object[][] arguments() throws IOException {

	WebSocketClient[] clients = new WebSocketClient[] {
			new TomcatWebSocketClient(),
			new JettyWebSocketClient(),
			new ReactorNettyWebSocketClient(),
			new UndertowWebSocketClient(Xnio.getInstance().createWorker(OptionMap.EMPTY))
	};

	Map<HttpServer, Class<?>> servers = new LinkedHashMap<>();
	servers.put(new TomcatHttpServer(TMP_DIR.getAbsolutePath(), WsContextListener.class), TomcatConfig.class);
	servers.put(new JettyHttpServer(), JettyConfig.class);
	servers.put(new ReactorHttpServer(), ReactorNettyConfig.class);
	servers.put(new UndertowHttpServer(), UndertowConfig.class);

	Flux<WebSocketClient> f1 = Flux.fromArray(clients).concatMap(c -> Flux.just(c).repeat(servers.size()));
	Flux<HttpServer> f2 = Flux.fromIterable(servers.keySet()).repeat(clients.length);
	Flux<Class<?>> f3 = Flux.fromIterable(servers.values()).repeat(clients.length);

	return Flux.zip(f1, f2, f3).map(Tuple3::toArray).collectList().block()
			.toArray(new Object[clients.length * servers.size()][2]);
}
 
Example #5
Source File: UndertowLauncher.java    From seed with Mozilla Public License 2.0 6 votes vote down vote up
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 #6
Source File: UndertowAcceptingSslChannel.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
private static String getHostNameNoResolve(InetSocketAddress socketAddress) {
    if (Xnio.NIO2) {
        return socketAddress.getHostString();
    } else {
        String hostName;
        if (socketAddress.isUnresolved()) {
            hostName = socketAddress.getHostName();
        } else {
            final InetAddress address = socketAddress.getAddress();
            final String string = address.toString();
            final int slash = string.indexOf('/');
            if (slash == -1 || slash == 0) {
                // unresolved both ways
                hostName = string.substring(slash + 1);
            } else {
                // has a cached host name
                hostName = string.substring(0, slash);
            }
        }
        return hostName;
    }
}
 
Example #7
Source File: UndertowXhrTransport.java    From spring-analysis-note with MIT License 5 votes vote down vote up
public UndertowXhrTransport(OptionMap optionMap) throws IOException {
	Assert.notNull(optionMap, "OptionMap is required");
	this.optionMap = optionMap;
	this.httpClient = UndertowClient.getInstance();
	this.worker = Xnio.getInstance().createWorker(optionMap);
	this.bufferPool = new DefaultByteBufferPool(false, 1024, -1, 2);
}
 
Example #8
Source File: ManagementWorkerService.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void start(StartContext startContext) throws StartException {
    final Xnio xnio = Xnio.getInstance();
    try {
        worker = xnio.createWorker(null,  options, this::stopDone);
    } catch (IOException e) {
        throw new StartException(e);
    }

}
 
Example #9
Source File: RemotingLegacySubsystemTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private AdditionalInitialization createRuntimeAdditionalInitialization(final boolean legacyParser) {
    return new AdditionalInitialization() {
        @Override
        protected void setupController(ControllerInitializer controllerInitializer) {
            controllerInitializer.addSocketBinding("test", 27258);
            controllerInitializer.addRemoteOutboundSocketBinding("dummy-outbound-socket", "localhost", 6799);
            controllerInitializer.addRemoteOutboundSocketBinding("other-outbound-socket", "localhost", 1234);
        }

        @Override
        protected void addExtraServices(ServiceTarget target) {
            //Needed for initialization of the RealmAuthenticationProviderService
            AbsolutePathService.addService(ServerEnvironment.CONTROLLER_TEMP_DIR, new File("target/temp" + System.currentTimeMillis()).getAbsolutePath(), target);
            if (!legacyParser) {
                ServiceBuilder<?> builder = target.addService(IOServices.WORKER.append("default"));
                Consumer<XnioWorker> workerConsumer = builder.provides(IOServices.WORKER.append("default"));
                builder.setInstance(new WorkerService(workerConsumer, () -> Executors.newFixedThreadPool(1), Xnio.getInstance().createWorkerBuilder().setWorkerIoThreads(2)));
                builder.install();                }
        }

        @Override
        protected void initializeExtraSubystemsAndModel(ExtensionRegistry extensionRegistry, Resource rootResource, ManagementResourceRegistration rootRegistration, RuntimeCapabilityRegistry capabilityRegistry) {
            super.initializeExtraSubystemsAndModel(extensionRegistry, rootResource, rootRegistration, capabilityRegistry);

            Map<String, Class> capabilities = new HashMap<>();
            capabilities.put(buildDynamicCapabilityName(IO_WORKER_CAPABILITY_NAME,
                    "default-remoting"), XnioWorker.class);

            if (legacyParser) {
                // Deal with the fact that legacy parsers will add the io extension/subsystem
                RemotingSubsystemTestUtil.registerIOExtension(extensionRegistry, rootRegistration);
            } else {
                capabilities.put(buildDynamicCapabilityName(IO_WORKER_CAPABILITY_NAME,
                        RemotingSubsystemRootResource.WORKER.getDefaultValue().asString()), XnioWorker.class);
            }

            AdditionalInitialization.registerServiceCapabilities(capabilityRegistry, capabilities);
        }
    };
}
 
Example #10
Source File: RemotingSubsystemTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private AdditionalInitialization createRuntimeAdditionalInitialization() {
    return new AdditionalInitialization() {
        @Override
        protected void setupController(ControllerInitializer controllerInitializer) {
            controllerInitializer.addSocketBinding("remoting", 27258);
            controllerInitializer.addRemoteOutboundSocketBinding("dummy-outbound-socket", "localhost", 6799);
            controllerInitializer.addRemoteOutboundSocketBinding("other-outbound-socket", "localhost", 1234);
        }

        @Override
        protected void addExtraServices(ServiceTarget target) {
            //Needed for initialization of the RealmAuthenticationProviderService
            AbsolutePathService.addService(ServerEnvironment.CONTROLLER_TEMP_DIR, new File("target/temp" + System.currentTimeMillis()).getAbsolutePath(), target);
            ServiceBuilder<?> builder = target.addService(IOServices.WORKER.append("default"));
            Consumer<XnioWorker> workerConsumer = builder.provides(IOServices.WORKER.append("default"));
            builder.setInstance(new WorkerService(workerConsumer, () -> Executors.newFixedThreadPool(1), Xnio.getInstance().createWorkerBuilder().setWorkerIoThreads(2)));
            builder.setInitialMode(ServiceController.Mode.ON_DEMAND);
            builder.install();

            builder = target.addService(IOServices.WORKER.append("default-remoting"));
            workerConsumer = builder.provides(IOServices.WORKER.append("default-remoting"));
            builder.setInstance(new WorkerService(workerConsumer, () -> Executors.newFixedThreadPool(1), Xnio.getInstance().createWorkerBuilder().setWorkerIoThreads(2)));
            builder.setInitialMode(ServiceController.Mode.ON_DEMAND);
            builder.install();            }

        @Override
        protected void initializeExtraSubystemsAndModel(ExtensionRegistry extensionRegistry, Resource rootResource, ManagementResourceRegistration rootRegistration, RuntimeCapabilityRegistry capabilityRegistry) {
            super.initializeExtraSubystemsAndModel(extensionRegistry, rootResource, rootRegistration, capabilityRegistry);
            Map<String, Class> capabilities = new HashMap<>();
            capabilities.put(buildDynamicCapabilityName(IO_WORKER_CAPABILITY_NAME,
                    RemotingSubsystemRootResource.WORKER.getDefaultValue().asString()), XnioWorker.class);
            capabilities.put(buildDynamicCapabilityName(IO_WORKER_CAPABILITY_NAME,
                    "default-remoting"), XnioWorker.class);
            AdditionalInitialization.registerServiceCapabilities(capabilityRegistry, capabilities);
        }
    };
}
 
Example #11
Source File: SNICombinedWithALPNTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private XnioSsl createClientSSL(File hostNameKeystore) throws NoSuchAlgorithmException, KeyStoreException, IOException, CertificateException, UnrecoverableKeyException, KeyManagementException {
    SSLContext clientContext = SSLContext.getInstance("TLS");
    KeyStore store = KeyStore.getInstance("jks");
    try (FileInputStream in = new FileInputStream(hostNameKeystore)) {
        store.load(in, PASSWORD.toCharArray());
    }

    KeyManagerFactory km = KeyManagerFactory.getInstance(keyAlgorithm());
    km.init(store, PASSWORD.toCharArray());
    TrustManagerFactory tm = TrustManagerFactory.getInstance(keyAlgorithm());
    tm.init(store);
    clientContext.init(km.getKeyManagers(), tm.getTrustManagers(), new SecureRandom());
    return new UndertowXnioSsl(Xnio.getInstance(), OptionMap.EMPTY, clientContext);
}
 
Example #12
Source File: ClassProviderStarter.java    From websocket-classloader with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) throws IOException, ServletException {
    final Xnio xnio = Xnio.getInstance("nio", Undertow.class.getClassLoader());
    final XnioWorker xnioWorker = xnio.createWorker(OptionMap.builder().getMap());
    final WebSocketDeploymentInfo webSockets = new WebSocketDeploymentInfo()
            .addEndpoint(ClassProvider.class)
            .setWorker(xnioWorker);
    final DeploymentManager deploymentManager = Servlets.defaultContainer()
            .addDeployment(Servlets.deployment()
                    .setClassLoader(ClassProviderStarter.class.getClassLoader())
                    .setContextPath("/")
                    .setDeploymentName("class-provider")
                    .addServletContextAttribute(WebSocketDeploymentInfo.ATTRIBUTE_NAME, webSockets));

    deploymentManager.deploy();
    //noinspection deprecation
    Undertow.builder()
            .addListener(5000, "localhost")
            .setHandler(deploymentManager.start())
            .build()
            .start();
}
 
Example #13
Source File: TokenAuthenticator.java    From hawkular-metrics with Apache License 2.0 5 votes vote down vote up
private ConnectionFactory(URI kubernetesMasterUri) {
    this.kubernetesMasterUri = kubernetesMasterUri;
    undertowClient = UndertowClient.getInstance();
    Xnio xnio = Xnio.getInstance(Undertow.class.getClassLoader());
    try {
        ssl = new UndertowXnioSsl(xnio, OptionMap.EMPTY);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    byteBufferPool = createByteBufferPool();
}
 
Example #14
Source File: JBoss.java    From ysoserial with MIT License 5 votes vote down vote up
public ConnectionProviderContextImpl ( OptionMap opts, String endpointName ) throws IllegalArgumentException, IOException {
    this.instance = Xnio.getInstance();

    this.worker = this.instance.createWorker(opts);
    this.endpoint = Remoting.createEndpoint(endpointName, this.worker, opts);
    this.executor = Executors.newCachedThreadPool(new ThreadFactory() {

        public Thread newThread ( Runnable r ) {
            Thread t = new Thread(r, "Worker");
            t.setDaemon(true);
            return t;
        }
    });
}
 
Example #15
Source File: UndertowXhrTransport.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
public UndertowXhrTransport(OptionMap optionMap) throws IOException {
	Assert.notNull(optionMap, "OptionMap is required");
	this.optionMap = optionMap;
	this.httpClient = UndertowClient.getInstance();
	this.worker = Xnio.getInstance().createWorker(optionMap);
	this.undertowBufferSupport =
			(undertow13Present ? new Undertow13BufferSupport() : new UndertowXnioBufferSupport());
}
 
Example #16
Source File: JBoss.java    From ysoserial-modified with MIT License 5 votes vote down vote up
public ConnectionProviderContextImpl ( OptionMap opts, String endpointName ) throws IllegalArgumentException, IOException {
    this.instance = Xnio.getInstance();

    this.worker = this.instance.createWorker(opts);
    this.endpoint = Remoting.createEndpoint(endpointName, this.worker, opts);
    this.executor = Executors.newCachedThreadPool(new ThreadFactory() {

        public Thread newThread ( Runnable r ) {
            Thread t = new Thread(r, "Worker");
            t.setDaemon(true);
            return t;
        }
    });
}
 
Example #17
Source File: UndertowXhrTransport.java    From java-technology-stack with MIT License 5 votes vote down vote up
public UndertowXhrTransport(OptionMap optionMap) throws IOException {
	Assert.notNull(optionMap, "OptionMap is required");
	this.optionMap = optionMap;
	this.httpClient = UndertowClient.getInstance();
	this.worker = Xnio.getInstance().createWorker(optionMap);
	this.bufferPool = new DefaultByteBufferPool(false, 1024, -1, 2);
}
 
Example #18
Source File: Http2Server.java    From quarkus-http with Apache License 2.0 5 votes vote down vote up
public static void main(final String[] args) throws Exception {
    String version = System.getProperty("java.version");
    System.out.println("Java version " + version);
    if(version.charAt(0) == '1' && Integer.parseInt(version.charAt(2) + "") < 8 ) {
        System.out.println("This example requires Java 1.8 or later");
        System.out.println("The HTTP2 spec requires certain cyphers that are not present in older JVM's");
        System.out.println("See section 9.2.2 of the HTTP2 specification for details");
        System.exit(1);
    }
    String bindAddress = System.getProperty("bind.address", "localhost");
    SSLContext sslContext = createSSLContext(loadKeyStore("server.keystore"), loadKeyStore("server.truststore"));
    Undertow server = Undertow.builder()
            .setServerOption(UndertowOptions.ENABLE_HTTP2, true)
            .addHttpListener(8080, bindAddress)
            .addHttpsListener(8443, bindAddress, sslContext)
            .setHandler(new SessionAttachmentHandler(new LearningPushHandler(100, -1, Handlers.header(predicate(secure(), resource(new PathResourceManager(Paths.get(System.getProperty("example.directory", System.getProperty("user.home"))), 100))
                    .setDirectoryListingEnabled(true), new HttpHandler() {
                @Override
                public void handleRequest(HttpServerExchange exchange) throws Exception {
                    exchange.getResponseHeaders().add(Headers.LOCATION, "https://" + exchange.getHostName() + ":" + (exchange.getHostPort() + 363) + exchange.getRelativePath());
                    exchange.setStatusCode(StatusCodes.TEMPORARY_REDIRECT);
                }
            }), "x-undertow-transport", ExchangeAttributes.transportProtocol())), new InMemorySessionManager("test"), new SessionCookieConfig())).build();

    server.start();

    SSLContext clientSslContext = createSSLContext(loadKeyStore("client.keystore"), loadKeyStore("client.truststore"));
    LoadBalancingProxyClient proxy = new LoadBalancingProxyClient()
            .addHost(new URI("https://localhost:8443"), null, new UndertowXnioSsl(Xnio.getInstance(), OptionMap.EMPTY, clientSslContext), UndertowOptionMap.create(UndertowOptions.ENABLE_HTTP2, true))
            .setConnectionsPerThread(20);

    Undertow reverseProxy = Undertow.builder()
            .setServerOption(UndertowOptions.ENABLE_HTTP2, true)
            .addHttpListener(8081, bindAddress)
            .addHttpsListener(8444, bindAddress, sslContext)
            .setHandler(ProxyHandler.builder().setProxyClient(proxy).setMaxRequestTime( 30000).build())
            .build();
    reverseProxy.start();

}
 
Example #19
Source File: ModClusterProxyServer.java    From quarkus-http with Apache License 2.0 5 votes vote down vote up
public static void main(final String[] args) throws IOException {
    final XnioWorker worker = Xnio.getInstance().createWorker(OptionMap.EMPTY);
    final Undertow server;

    final ModCluster modCluster = ModCluster.builder(worker).build();
    try {
        if (chost == null) {
            // We are going to guess it.
            chost = java.net.InetAddress.getLocalHost().getHostName();
            System.out.println("Using: " + chost + ":" + cport);
        }

        modCluster.start();

        // Create the proxy and mgmt handler
        final HttpHandler proxy = modCluster.createProxyHandler();
        final MCMPConfig config = MCMPConfig.webBuilder()
                .setManagementHost(chost)
                .setManagementPort(cport)
                .enableAdvertise()
                .getParent()
                .build();

        final HttpHandler mcmp = config.create(modCluster, proxy);

        server = Undertow.builder()
                .addHttpListener(cport, chost)
                .addHttpListener(pport, phost)
                .setHandler(mcmp)
                .build();
        server.start();

        // Start advertising the mcmp handler
        modCluster.advertise(config);

    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example #20
Source File: JBoss.java    From ysoserial-modified with MIT License 4 votes vote down vote up
public Xnio getXnio () {
    return this.instance;
}
 
Example #21
Source File: JBoss.java    From ysoserial with MIT License 4 votes vote down vote up
public Xnio getXnio () {
    return this.instance;
}
 
Example #22
Source File: Undertow.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
public Xnio getXnio() {
    return xnio;
}
 
Example #23
Source File: WorkerAdd.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException {
    final PathAddress address = PathAddress.pathAddress(operation.get(OP_ADDR));
    Resource resource = context.readResourceFromRoot(address.subAddress(0, address.size() - 1));
    ModelNode workers = Resource.Tools.readModel(resource).get(IOExtension.WORKER_PATH.getKey());
    int allWorkerCount = workers.asList().size();
    final String name = context.getCurrentAddressValue();
    final XnioWorker.Builder builder = Xnio.getInstance().createWorkerBuilder();

    final OptionMap.Builder optionMapBuilder = OptionMap.builder();

    for (OptionAttributeDefinition attr : WorkerResourceDefinition.ATTRIBUTES) {
        Option option = attr.getOption();
        ModelNode value = attr.resolveModelAttribute(context, model);
        if (!value.isDefined()) {
            continue;
        }
        if (attr.getType() == ModelType.INT) {
            optionMapBuilder.set((Option<Integer>) option, value.asInt());
        } else if (attr.getType() == ModelType.LONG) {
            optionMapBuilder.set(option, value.asLong());
        } else if (attr.getType() == ModelType.BOOLEAN) {
            optionMapBuilder.set(option, value.asBoolean());
        }
    }
    builder.populateFromOptions(optionMapBuilder.getMap());
    builder.setWorkerName(name);

    ModelNode ioThreadsModel = WORKER_IO_THREADS.resolveModelAttribute(context, model);
    ModelNode coreTaskThreadsModel = WORKER_TASK_CORE_THREADS.resolveModelAttribute(context, model);
    ModelNode maxTaskThreadsModel = WORKER_TASK_MAX_THREADS.resolveModelAttribute(context, model);
    int cpuCount = getCpuCount();
    int ioThreadsCalculated = getSuggestedIoThreadCount();
    int workerThreads = builder.getMaxWorkerPoolSize();
    int coreWorkerThreads = coreTaskThreadsModel.asInt();
    if (!ioThreadsModel.isDefined() && !maxTaskThreadsModel.isDefined()) {
        workerThreads = getWorkerThreads(name, allWorkerCount);
        builder.setWorkerIoThreads(ioThreadsCalculated);
        builder.setCoreWorkerPoolSize(coreWorkerThreads);
        builder.setMaxWorkerPoolSize(workerThreads);
        IOLogger.ROOT_LOGGER.printDefaults(name, ioThreadsCalculated, workerThreads, cpuCount);
    } else {
        if (!ioThreadsModel.isDefined()) {
            builder.setWorkerIoThreads(ioThreadsCalculated);
            IOLogger.ROOT_LOGGER.printDefaultsIoThreads(name, ioThreadsCalculated, cpuCount);
        }
        if (!maxTaskThreadsModel.isDefined()) {
            workerThreads = getWorkerThreads(name, allWorkerCount);
            builder.setCoreWorkerPoolSize(coreWorkerThreads);
            builder.setMaxWorkerPoolSize(workerThreads);
            IOLogger.ROOT_LOGGER.printDefaultsWorkerThreads(name, workerThreads, cpuCount);
        }
    }

    registerMax(context, name, workerThreads);

    final CapabilityServiceBuilder<?> capBuilder = context.getCapabilityServiceTarget().addCapability(IO_WORKER_RUNTIME_CAPABILITY);
    final Consumer<XnioWorker> workerConsumer = capBuilder.provides(IO_WORKER_RUNTIME_CAPABILITY);
    final Supplier<ExecutorService> executorSupplier = capBuilder.requiresCapability("org.wildfly.management.executor", ExecutorService.class);
    capBuilder.setInstance(new WorkerService(workerConsumer, executorSupplier, builder));
    capBuilder.setInitialMode(ServiceController.Mode.ON_DEMAND);
    capBuilder.install();
}
 
Example #24
Source File: UndertowXnioSsl.java    From lams with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Construct a new instance.
 *  @param xnio the XNIO instance to associate with
 * @param optionMap the options for this provider
 * @param bufferPool
 * @param sslContext the SSL context to use for this instance
 */
public UndertowXnioSsl(final Xnio xnio, final OptionMap optionMap, ByteBufferPool bufferPool, final SSLContext sslContext) {
    super(xnio, sslContext, optionMap);
    this.bufferPool = bufferPool;
    this.sslContext = sslContext;
}
 
Example #25
Source File: UndertowXnioSsl.java    From lams with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Construct a new instance.
 *
 * @param xnio the XNIO instance to associate with
 * @param optionMap the options for this provider
 * @param bufferPool
 * @throws java.security.NoSuchProviderException if the given SSL provider is not found
 * @throws java.security.NoSuchAlgorithmException if the given SSL algorithm is not supported
 * @throws java.security.KeyManagementException if the SSL context could not be initialized
 */
public UndertowXnioSsl(final Xnio xnio, final OptionMap optionMap, ByteBufferPool bufferPool) throws NoSuchProviderException, NoSuchAlgorithmException, KeyManagementException {
    this(xnio, optionMap, bufferPool, JsseSslUtils.createSSLContext(optionMap));
}
 
Example #26
Source File: UndertowXnioSsl.java    From lams with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Construct a new instance.
 *  @param xnio the XNIO instance to associate with
 * @param optionMap the options for this provider
 * @param sslContext the SSL context to use for this instance
 */
public UndertowXnioSsl(final Xnio xnio, final OptionMap optionMap, final SSLContext sslContext) {
    this(xnio, optionMap, DEFAULT_BUFFER_POOL, sslContext);
}
 
Example #27
Source File: UndertowXnioSsl.java    From lams with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Construct a new instance.
 *
 * @param xnio the XNIO instance to associate with
 * @param optionMap the options for this provider
 * @throws java.security.NoSuchProviderException if the given SSL provider is not found
 * @throws java.security.NoSuchAlgorithmException if the given SSL algorithm is not supported
 * @throws java.security.KeyManagementException if the SSL context could not be initialized
 */
public UndertowXnioSsl(final Xnio xnio, final OptionMap optionMap) throws NoSuchProviderException, NoSuchAlgorithmException, KeyManagementException {
    this(xnio, optionMap, DEFAULT_BUFFER_POOL, JsseSslUtils.createSSLContext(optionMap));
}
 
Example #28
Source File: XnioEventLoopGroup.java    From netty-xnio-transport with Apache License 2.0 2 votes vote down vote up
/**
 * Create a new {@link XnioEventLoopGroup} which creates a new {@link XnioWorker} by itself and use it for all
 * operations. Using the given number of Threads to handle the IO.
 *
 * @throws IOException
 */
public XnioEventLoopGroup(int numThreads) throws IOException {
    this(Xnio.getInstance().createWorker(OptionMap.create(Options.WORKER_IO_THREADS, numThreads)));
}