Search in sources :

Example 1 with DefaultByteBufferPool

use of io.undertow.server.DefaultByteBufferPool in project spring-framework by spring-projects.

the class UndertowWebSocketClient method createConnectionBuilder.

/**
	 * Create a {@link ConnectionBuilder} for the given URI.
	 * <p>The default implementation creates a builder with the configured
	 * {@link #getXnioWorker() XnioWorker} and {@link #getPoolBufferSize()} and
	 * then passes it to the {@link #getConnectionBuilderConsumer() consumer}
	 * provided at construction time.
	 */
protected ConnectionBuilder createConnectionBuilder(URI url) {
    ConnectionBuilder builder = io.undertow.websockets.client.WebSocketClient.connectionBuilder(getXnioWorker(), new DefaultByteBufferPool(false, getPoolBufferSize()), url);
    this.builderConsumer.accept(builder);
    return builder;
}
Also used : DefaultByteBufferPool(io.undertow.server.DefaultByteBufferPool) ConnectionBuilder(io.undertow.websockets.client.WebSocketClient.ConnectionBuilder)

Example 2 with DefaultByteBufferPool

use of io.undertow.server.DefaultByteBufferPool in project camel by apache.

the class UndertowProducer method doStart.

@Override
protected void doStart() throws Exception {
    super.doStart();
    pool = new DefaultByteBufferPool(true, 8192);
    worker = Xnio.getInstance().createWorker(options);
    LOG.debug("Created worker: {} with options: {}", worker, options);
}
Also used : DefaultByteBufferPool(io.undertow.server.DefaultByteBufferPool)

Example 3 with DefaultByteBufferPool

use of io.undertow.server.DefaultByteBufferPool in project undertow by undertow-io.

the class AutobahnExtensionCustomReceiverServer method run.

public void run() {
    xnio = Xnio.getInstance();
    try {
        worker = xnio.createWorker(OptionMap.builder().set(Options.WORKER_WRITE_THREADS, 4).set(Options.WORKER_READ_THREADS, 4).set(Options.CONNECTION_HIGH_WATER, 1000000).set(Options.CONNECTION_LOW_WATER, 1000000).set(Options.WORKER_TASK_CORE_THREADS, 10).set(Options.WORKER_TASK_MAX_THREADS, 12).set(Options.TCP_NODELAY, true).set(Options.CORK, true).getMap());
        OptionMap serverOptions = OptionMap.builder().set(Options.WORKER_ACCEPT_THREADS, 4).set(Options.TCP_NODELAY, true).set(Options.REUSE_ADDRESSES, true).getMap();
        openListener = new HttpOpenListener(new DefaultByteBufferPool(false, 8192));
        ChannelListener acceptListener = ChannelListeners.openListenerAdapter(openListener);
        server = worker.createStreamConnectionServer(new InetSocketAddress(port), acceptListener, serverOptions);
        setRootHandler(getRootHandler().addExtension(new PerMessageDeflateHandshake()));
        server.resumeAccepts();
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
Also used : ChannelListener(org.xnio.ChannelListener) DefaultByteBufferPool(io.undertow.server.DefaultByteBufferPool) InetSocketAddress(java.net.InetSocketAddress) OptionMap(org.xnio.OptionMap) HttpOpenListener(io.undertow.server.protocol.http.HttpOpenListener) IOException(java.io.IOException)

Example 4 with DefaultByteBufferPool

use of io.undertow.server.DefaultByteBufferPool in project undertow by undertow-io.

the class AutobahnExtensionsServer method run.

public void run() {
    xnio = Xnio.getInstance();
    try {
        worker = xnio.createWorker(OptionMap.builder().set(Options.CONNECTION_HIGH_WATER, 1000000).set(Options.CONNECTION_LOW_WATER, 1000000).set(Options.WORKER_TASK_CORE_THREADS, 10).set(Options.WORKER_TASK_MAX_THREADS, 12).set(Options.TCP_NODELAY, true).set(Options.CORK, true).getMap());
        OptionMap serverOptions = OptionMap.builder().set(Options.TCP_NODELAY, true).set(Options.REUSE_ADDRESSES, true).getMap();
        openListener = new HttpOpenListener(new DefaultByteBufferPool(false, 8192));
        ChannelListener acceptListener = ChannelListeners.openListenerAdapter(openListener);
        server = worker.createStreamConnectionServer(new InetSocketAddress(port), acceptListener, serverOptions);
        WebSocketProtocolHandshakeHandler handler = webSocketDebugHandler().addExtension(new PerMessageDeflateHandshake());
        DebugExtensionsHeaderHandler debug = new DebugExtensionsHeaderHandler(handler);
        setRootHandler(debug);
        server.resumeAccepts();
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
Also used : ChannelListener(org.xnio.ChannelListener) DefaultByteBufferPool(io.undertow.server.DefaultByteBufferPool) InetSocketAddress(java.net.InetSocketAddress) OptionMap(org.xnio.OptionMap) WebSocketProtocolHandshakeHandler(io.undertow.websockets.WebSocketProtocolHandshakeHandler) HttpOpenListener(io.undertow.server.protocol.http.HttpOpenListener) IOException(java.io.IOException)

Example 5 with DefaultByteBufferPool

use of io.undertow.server.DefaultByteBufferPool in project undertow by undertow-io.

the class UndertowContainerProvider method getDefaultContainer.

static ServerWebSocketContainer getDefaultContainer() {
    if (defaultContainerDisabled) {
        return null;
    }
    if (defaultContainer != null) {
        return defaultContainer;
    }
    synchronized (UndertowContainerProvider.class) {
        if (defaultContainer == null) {
            try {
                //this is not great, as we have no way to control the lifecycle
                //but there is not much we can do
                //todo: what options should we use here?
                XnioWorker worker = Xnio.getInstance().createWorker(OptionMap.create(Options.THREAD_DAEMON, true));
                ByteBufferPool buffers = new DefaultByteBufferPool(directBuffers, 1024, 100, 12);
                defaultContainer = new ServerWebSocketContainer(defaultIntrospector, UndertowContainerProvider.class.getClassLoader(), worker, buffers, Collections.EMPTY_LIST, !invokeInIoThread);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return defaultContainer;
    }
}
Also used : ByteBufferPool(io.undertow.connector.ByteBufferPool) DefaultByteBufferPool(io.undertow.server.DefaultByteBufferPool) DefaultByteBufferPool(io.undertow.server.DefaultByteBufferPool) XnioWorker(org.xnio.XnioWorker) IOException(java.io.IOException)

Aggregations

DefaultByteBufferPool (io.undertow.server.DefaultByteBufferPool)13 HttpOpenListener (io.undertow.server.protocol.http.HttpOpenListener)6 IOException (java.io.IOException)6 InetSocketAddress (java.net.InetSocketAddress)6 ChannelListener (org.xnio.ChannelListener)6 OptionMap (org.xnio.OptionMap)6 DeploymentInfo (io.undertow.servlet.api.DeploymentInfo)4 DeploymentManager (io.undertow.servlet.api.DeploymentManager)4 ServletContainer (io.undertow.servlet.api.ServletContainer)4 WebSocketDeploymentInfo (io.undertow.websockets.jsr.WebSocketDeploymentInfo)4 StreamConnection (org.xnio.StreamConnection)3 XnioWorker (org.xnio.XnioWorker)3 ByteBufferPool (io.undertow.connector.ByteBufferPool)2 FilterInfo (io.undertow.servlet.api.FilterInfo)2 PerMessageDeflateHandshake (io.undertow.websockets.extensions.PerMessageDeflateHandshake)2 ServletException (javax.servlet.ServletException)2 Xnio (org.xnio.Xnio)2 Undertow (io.undertow.Undertow)1 UndertowXnioSsl (io.undertow.protocols.ssl.UndertowXnioSsl)1 HttpHandler (io.undertow.server.HttpHandler)1