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