本文整理汇总了Java中org.xnio.BufferAllocator.DIRECT_BYTE_BUFFER_ALLOCATOR属性的典型用法代码示例。如果您正苦于以下问题:Java BufferAllocator.DIRECT_BYTE_BUFFER_ALLOCATOR属性的具体用法?Java BufferAllocator.DIRECT_BYTE_BUFFER_ALLOCATOR怎么用?Java BufferAllocator.DIRECT_BYTE_BUFFER_ALLOCATOR使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.xnio.BufferAllocator
的用法示例。
在下文中一共展示了BufferAllocator.DIRECT_BYTE_BUFFER_ALLOCATOR属性的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: create
private static ManagementHttpServer create(Builder builder) {
SSLContext sslContext = null;
SslClientAuthMode sslClientAuthMode = builder.sslClientAuthMode;
if (builder.secureBindAddress != null) {
sslContext = getSSLContext(builder);
if (sslContext == null) {
throw ROOT_LOGGER.sslRequestedNoSslContext();
}
}
HttpOpenListener openListener = new HttpOpenListener(new ByteBufferSlicePool(BufferAllocator.DIRECT_BYTE_BUFFER_ALLOCATOR, 4096, 10 * 4096));
int secureRedirectPort = builder.secureBindAddress != null ? builder.secureBindAddress.getPort() : -1;
// WFLY-2870 -- redirect not supported if bindAddress and secureBindAddress are using different InetAddress
boolean redirectSupported = (builder.bindAddress == null || builder.secureBindAddress == null || builder.bindAddress.getAddress().equals(builder.secureBindAddress.getAddress()));
if (!redirectSupported && secureRedirectPort > 0) {
HttpServerLogger.ROOT_LOGGER.httpsRedirectNotSupported(builder.bindAddress.getAddress(), builder.secureBindAddress.getAddress());
secureRedirectPort = -1;
}
final ExtensionHandlers extensionHandlers = setupOpenListener(openListener, secureRedirectPort, builder);
return new ManagementHttpServer(openListener, builder.bindAddress, builder.secureBindAddress, sslContext, sslClientAuthMode, builder.worker, extensionHandlers);
}
示例2: createByteBufferPool
private ByteBufferPool createByteBufferPool() {
long maxMemory = Runtime.getRuntime().maxMemory();
boolean useDirectBuffers;
int bufferSize, buffersPerRegion;
if (maxMemory < 64 * 1024 * 1024) {
//smaller than 64mb of ram we use 512b buffers
useDirectBuffers = false;
bufferSize = 512;
buffersPerRegion = 10;
} else if (maxMemory < 128 * 1024 * 1024) {
//use 1k buffers
useDirectBuffers = true;
bufferSize = 1024;
buffersPerRegion = 10;
} else {
//use 16k buffers for best performance
//as 16k is generally the max amount of data that can be sent in a single write() call
useDirectBuffers = true;
bufferSize = 1024 * 16;
buffersPerRegion = 20;
}
BufferAllocator<ByteBuffer> allocator;
if (useDirectBuffers) {
allocator = BufferAllocator.DIRECT_BYTE_BUFFER_ALLOCATOR;
} else {
allocator = BufferAllocator.BYTE_BUFFER_ALLOCATOR;
}
int maxRegionSize = buffersPerRegion * bufferSize;
ByteBufferSlicePool pool = new ByteBufferSlicePool(allocator, bufferSize, maxRegionSize);
return new XnioByteBufferPool(pool);
}
示例3: getResourceManager
private ResourceManager getResourceManager(File warFile, Long transferMinSize, String cfmlDirs, File internalCFMLServerRoot) {
MappedResourceManager mappedResourceManager = new MappedResourceManager(warFile, transferMinSize, cfmlDirs, internalCFMLServerRoot);
if(serverOptions.isDirectoryListingRefreshEnabled()) return mappedResourceManager;
final DirectBufferCache dataCache = new DirectBufferCache(1000, 10, 1000 * 10 * 1000, BufferAllocator.DIRECT_BYTE_BUFFER_ALLOCATOR, METADATA_MAX_AGE);
final int metadataCacheSize = 100;
final long maxFileSize = 10000;
return new CachingResourceManager(metadataCacheSize,maxFileSize, dataCache, mappedResourceManager, METADATA_MAX_AGE);
}
示例4: DirectBufferCache
public DirectBufferCache(int sliceSize, int slicesPerPage, int maxMemory) {
this(sliceSize, slicesPerPage, maxMemory, BufferAllocator.DIRECT_BYTE_BUFFER_ALLOCATOR);
}
示例5: start
@Override
public void start(StartContext context) throws StartException {
bufferPool = new ByteBufferSlicePool(directBuffers ? BufferAllocator.DIRECT_BYTE_BUFFER_ALLOCATOR : BufferAllocator.BYTE_BUFFER_ALLOCATOR, bufferSize, buffersPerSlice * bufferSize);
}
示例6: LimitedBufferSlicePool
/**
* Construct a new instance, using a direct buffer allocator.
*
* @param bufferSize the size of each buffer
* @param maxRegionSize the maximum region size for each backing buffer
*/
public LimitedBufferSlicePool(final int bufferSize, final int maxRegionSize) {
this(BufferAllocator.DIRECT_BYTE_BUFFER_ALLOCATOR, bufferSize, maxRegionSize);
}