org.xnio.Pool Java Examples

The following examples show how to use org.xnio.Pool. 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: BufferPoolResourceDefinition.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException {
    final PathAddress address = PathAddress.pathAddress(operation.get(OP_ADDR));
    final ModelNode bufferSizeModel = BUFFER_SIZE.resolveModelAttribute(context, model);
    final ModelNode bufferPerSliceModel = BUFFER_PER_SLICE.resolveModelAttribute(context, model);
    final ModelNode directModel = DIRECT_BUFFERS.resolveModelAttribute(context, model);

    final int bufferSize = bufferSizeModel.isDefined() ? bufferSizeModel.asInt() : defaultBufferSize;
    final int bufferPerSlice = bufferPerSliceModel.isDefined() ? bufferPerSliceModel.asInt() : defaultBuffersPerRegion;
    final boolean direct = directModel.isDefined() ? directModel.asBoolean() : defaultDirectBuffers;

    CapabilityServiceBuilder<?> builder = context.getCapabilityServiceTarget().addCapability(IO_POOL_RUNTIME_CAPABILITY);
    final Consumer<Pool<ByteBuffer>> byteBufferConsumer = builder.provides(IO_POOL_RUNTIME_CAPABILITY);
    builder.setInstance(new BufferPoolService(byteBufferConsumer, bufferSize, bufferPerSlice, direct));
    builder.setInitialMode(ServiceController.Mode.ON_DEMAND);
    builder.install();

    builder = context.getCapabilityServiceTarget().addCapability(IO_BYTE_BUFFER_POOL_RUNTIME_CAPABILITY);
    final Consumer<ByteBufferPool> poolConsumer = builder.provides(IO_BYTE_BUFFER_POOL_RUNTIME_CAPABILITY);
    final Supplier<Pool> poolSupplier = builder.requiresCapability(IO_POOL_RUNTIME_CAPABILITY.getDynamicName(address), Pool.class);
    builder.setInstance(new ByteBufferPoolService(poolConsumer, poolSupplier));
    builder.setInitialMode(ServiceController.Mode.ON_DEMAND);
    builder.install();
}
 
Example #2
Source File: AbstractServerConnection.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Pool<ByteBuffer> getBufferPool() {
    if(poolAdaptor == null) {
        poolAdaptor = new XnioBufferPoolAdaptor(getByteBufferPool());
    }
    return poolAdaptor;
}
 
Example #3
Source File: Http2ServerConnection.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Pool<ByteBuffer> getBufferPool() {
    if(poolAdaptor == null) {
        poolAdaptor = new XnioBufferPoolAdaptor(getByteBufferPool());
    }
    return poolAdaptor;
}
 
Example #4
Source File: InVMConnection.java    From thorntail with Apache License 2.0 5 votes vote down vote up
@Override
@SuppressWarnings("deprecation")
public Pool<ByteBuffer> getBufferPool() {
    if (poolAdaptor == null) {
        poolAdaptor = new XnioBufferPoolAdaptor(getByteBufferPool());
    }
    return poolAdaptor;
}
 
Example #5
Source File: InVMConnection.java    From thorntail with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("deprecation")
@Override
public Pool<ByteBuffer> getBufferPool() {
    if (poolAdaptor == null) {
        poolAdaptor = new XnioBufferPoolAdaptor(getByteBufferPool());
    }
    return poolAdaptor;
}
 
Example #6
Source File: UndertowXhrTransport.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
public UndertowXnioBufferSupport() {
	this.xnioBufferPool = new org.xnio.ByteBufferSlicePool(1048, 1048);
	this.httpClientConnectCallbackMethod = ReflectionUtils.findMethod(UndertowClient.class, "connect",
			ClientCallback.class, URI.class, XnioWorker.class, Pool.class, OptionMap.class);
	this.httpClientConnectMethod = ReflectionUtils.findMethod(UndertowClient.class, "connect",
			URI.class, XnioWorker.class, Pool.class, OptionMap.class);
}
 
Example #7
Source File: ServletInitialHandler.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Pool<ByteBuffer> getBufferPool() {
    if(poolAdaptor == null) {
        poolAdaptor = new XnioBufferPoolAdaptor(getByteBufferPool());
    }
    return poolAdaptor;
}
 
Example #8
Source File: XnioByteBufferPool.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public XnioByteBufferPool(Pool<ByteBuffer> pool) {
    this.pool = pool;
    Pooled<ByteBuffer> buf = pool.allocate();
    bufferSize = buf.getResource().remaining();
    direct = !buf.getResource().hasArray();
    buf.free();
    if(direct) {
        arrayBackedPool = new DefaultByteBufferPool(false, bufferSize);
    } else {
        arrayBackedPool = this;
    }
}
 
Example #9
Source File: AlpnOpenListener.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
public AlpnOpenListener(Pool<ByteBuffer> bufferPool, OptionMap undertowOptions, DelegateOpenListener httpListener) {
    this(bufferPool, undertowOptions, "http/1.1", httpListener);
}
 
Example #10
Source File: BufferPoolService.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public Pool<ByteBuffer> getValue() throws IllegalStateException, IllegalArgumentException {
    return bufferPool;
}
 
Example #11
Source File: BufferPoolService.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public BufferPoolService(final Consumer<Pool<ByteBuffer>> byteBufferConsumer, final int bufferSize, final int buffersPerSlice, final boolean directBuffers) {
    this.byteBufferConsumer = byteBufferConsumer;
    this.bufferSize = bufferSize;
    this.buffersPerSlice = buffersPerSlice;
    this.directBuffers = directBuffers;
}
 
Example #12
Source File: BufferPoolResourceDefinition.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
private ByteBufferPoolService(final Consumer<ByteBufferPool> poolConsumer, final Supplier<Pool> poolSupplier) {
    this.poolConsumer = poolConsumer;
    this.poolSupplier = poolSupplier;
}
 
Example #13
Source File: StringReadChannelListener.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Deprecated
public StringReadChannelListener(final Pool<ByteBuffer> bufferPool) {
    this.bufferPool = new XnioByteBufferPool(bufferPool);
}
 
Example #14
Source File: AlpnOpenListener.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
public AlpnOpenListener(Pool<ByteBuffer> bufferPool, OptionMap undertowOptions, String fallbackProtocol, DelegateOpenListener fallbackListener) {
    this(new XnioByteBufferPool(bufferPool), undertowOptions, fallbackProtocol, fallbackListener);
}
 
Example #15
Source File: AlpnOpenListener.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
public AlpnOpenListener(Pool<ByteBuffer> bufferPool, OptionMap undertowOptions) {
    this(bufferPool, undertowOptions, null, null);
}
 
Example #16
Source File: HttpOpenListener.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Deprecated
public HttpOpenListener(final Pool<ByteBuffer> pool, final OptionMap undertowOptions) {
    this(new XnioByteBufferPool(pool), undertowOptions);
}
 
Example #17
Source File: HttpOpenListener.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Deprecated
public HttpOpenListener(final Pool<ByteBuffer> pool) {
    this(pool, OptionMap.EMPTY);
}
 
Example #18
Source File: Http2OpenListener.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Deprecated
public Http2OpenListener(final Pool<ByteBuffer> pool, final OptionMap undertowOptions, String protocol) {
    this(new XnioByteBufferPool(pool), undertowOptions, protocol);
}
 
Example #19
Source File: Http2OpenListener.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Deprecated
public Http2OpenListener(final Pool<ByteBuffer> pool, final OptionMap undertowOptions) {
    this(pool, undertowOptions, HTTP2);
}
 
Example #20
Source File: Http2OpenListener.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Deprecated
public Http2OpenListener(final Pool<ByteBuffer> pool) {
    this(pool, OptionMap.EMPTY);
}
 
Example #21
Source File: AjpOpenListener.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
public AjpOpenListener(final Pool<ByteBuffer> pool, final OptionMap undertowOptions) {
    this(new XnioByteBufferPool(pool), undertowOptions);
}
 
Example #22
Source File: AjpOpenListener.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
public AjpOpenListener(final Pool<ByteBuffer> pool) {
    this(pool, OptionMap.EMPTY);
}
 
Example #23
Source File: ServerConnection.java    From lams with GNU General Public License v2.0 2 votes vote down vote up
/**
 *
 * @return The connections buffer pool
 */
@Deprecated
public abstract Pool<ByteBuffer> getBufferPool();