• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java BufferAllocator类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.xnio.BufferAllocator的典型用法代码示例。如果您正苦于以下问题:Java BufferAllocator类的具体用法?Java BufferAllocator怎么用?Java BufferAllocator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



BufferAllocator类属于org.xnio包,在下文中一共展示了BufferAllocator类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: create

import org.xnio.BufferAllocator; //导入依赖的package包/类
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);
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:24,代码来源:ManagementHttpServer.java


示例2: DirectBufferCache

import org.xnio.BufferAllocator; //导入依赖的package包/类
public DirectBufferCache(int sliceSize, int slicesPerPage, int maxMemory, final BufferAllocator<ByteBuffer> bufferAllocator, int maxAge) {
    this.sliceSize = sliceSize;
    this.pool = new LimitedBufferSlicePool(bufferAllocator, sliceSize, sliceSize * slicesPerPage, maxMemory / (sliceSize * slicesPerPage));
    this.cache = new ConcurrentHashMap<>(16);
    this.accessQueue = ConcurrentDirectDeque.newInstance();
    this.maxAge = maxAge;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:8,代码来源:DirectBufferCache.java


示例3: LimitedBufferSlicePool

import org.xnio.BufferAllocator; //导入依赖的package包/类
/**
 * Construct a new instance.
 *
 * @param allocator the buffer allocator to use
 * @param bufferSize the size of each buffer
 * @param maxRegionSize the maximum region size for each backing buffer
 * @param maxRegions the maximum regions to create, zero for unlimited
 */
public LimitedBufferSlicePool(final BufferAllocator<ByteBuffer> allocator, final int bufferSize, final int maxRegionSize, final int maxRegions) {
    if (bufferSize <= 0) {
        throw new IllegalArgumentException("Buffer size must be greater than zero");
    }
    if (maxRegionSize < bufferSize) {
        throw new IllegalArgumentException("Maximum region size must be greater than or equal to the buffer size");
    }
    buffersPerRegion = maxRegionSize / bufferSize;
    this.bufferSize = bufferSize;
    this.allocator = allocator;
    this.maxRegions = maxRegions;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:21,代码来源:LimitedBufferSlicePool.java


示例4: createByteBufferPool

import org.xnio.BufferAllocator; //导入依赖的package包/类
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);
}
 
开发者ID:hawkular,项目名称:hawkular-metrics,代码行数:32,代码来源:TokenAuthenticator.java


示例5: getResourceManager

import org.xnio.BufferAllocator; //导入依赖的package包/类
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);
}
 
开发者ID:cfmlprojects,项目名称:runwar,代码行数:9,代码来源:Server.java


示例6: upgradeConnection

import org.xnio.BufferAllocator; //导入依赖的package包/类
private void upgradeConnection(ClientExchange result) throws IOException {
    if (result.getResponse().getResponseCode() == 101) {
        // flush response
        new StringReadChannelListener(bufferPool) {
            @Override
            protected void stringDone(String string) {
            }

            @Override
            protected void error(IOException e) {
            }
        }.setup(result.getResponseChannel());

        // Create the upgraded SPDY connection
        ByteBufferPool heapBufferPool =
            new XnioByteBufferPool(new ByteBufferSlicePool(BufferAllocator.BYTE_BUFFER_ALLOCATOR, 8196, 8196));
        SpdyChannel spdyChannel =
            new SpdyChannelWithoutFlowControl(connection.performUpgrade(), bufferPool, null, heapBufferPool, true,
                OptionMap.EMPTY);
        Integer idleTimeout = DEFAULT_OPTIONS.get(UndertowOptions.IDLE_TIMEOUT);
        if (idleTimeout != null && idleTimeout > 0) {
            spdyChannel.setIdleTimeout(idleTimeout);
        }
        connection = new SpdyClientConnection(spdyChannel, null);
    } else {
        throw new IOException("Failed to upgrade connection");
    }
}
 
开发者ID:arquillian,项目名称:arquillian-cube,代码行数:29,代码来源:PortForwarder.java


示例7: dispatchMockRequest

import org.xnio.BufferAllocator; //导入依赖的package包/类
@Override
public void dispatchMockRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException {

    final ByteBufferSlicePool bufferPool = new ByteBufferSlicePool(BufferAllocator.BYTE_BUFFER_ALLOCATOR, 1024, 1024);
    MockServerConnection connection = new MockServerConnection(bufferPool);
    HttpServerExchange exchange = new HttpServerExchange(connection);
    exchange.setRequestScheme(request.getScheme());
    exchange.setRequestMethod(new HttpString(request.getMethod()));
    exchange.setProtocol(Protocols.HTTP_1_0);
    exchange.setResolvedPath(request.getContextPath());
    String relative;
    if (request.getPathInfo() == null) {
        relative = request.getServletPath();
    } else {
        relative = request.getServletPath() + request.getPathInfo();
    }
    exchange.setRelativePath(relative);
    final ServletPathMatch info = paths.getServletHandlerByPath(request.getServletPath());
    final HttpServletResponseImpl oResponse = new HttpServletResponseImpl(exchange, servletContext);
    final HttpServletRequestImpl oRequest = new HttpServletRequestImpl(exchange, servletContext);
    final ServletRequestContext servletRequestContext = new ServletRequestContext(servletContext.getDeployment(), oRequest, oResponse, info);
    servletRequestContext.setServletRequest(request);
    servletRequestContext.setServletResponse(response);
    //set the max request size if applicable
    if (info.getServletChain().getManagedServlet().getMaxRequestSize() > 0) {
        exchange.setMaxEntitySize(info.getServletChain().getManagedServlet().getMaxRequestSize());
    }
    exchange.putAttachment(ServletRequestContext.ATTACHMENT_KEY, servletRequestContext);

    exchange.startBlocking(new ServletBlockingHttpExchange(exchange));
    servletRequestContext.setServletPathMatch(info);

    try {
        dispatchRequest(exchange, servletRequestContext, info.getServletChain(), DispatcherType.REQUEST);
    } catch (Exception e) {
        if (e instanceof RuntimeException) {
            throw (RuntimeException) e;
        }
        throw new ServletException(e);
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:42,代码来源:ServletInitialHandler.java


示例8: createSpdyChannel

import org.xnio.BufferAllocator; //导入依赖的package包/类
private static SpdyClientConnection createSpdyChannel(StreamConnection connection, Pool<ByteBuffer> bufferPool) {
    SpdyChannel spdyChannel = new SpdyChannel(connection, bufferPool, null, new ByteBufferSlicePool(BufferAllocator.BYTE_BUFFER_ALLOCATOR, 8192, 8192), true);
    return new SpdyClientConnection(spdyChannel);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:5,代码来源:SpdyClientProvider.java


示例9: start

import org.xnio.BufferAllocator; //导入依赖的package包/类
@Override
public void start(StartContext context) throws StartException {
    bufferPool = new ByteBufferSlicePool(directBuffers ? BufferAllocator.DIRECT_BYTE_BUFFER_ALLOCATOR : BufferAllocator.BYTE_BUFFER_ALLOCATOR, bufferSize, buffersPerSlice * bufferSize);
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:5,代码来源:BufferPoolService.java


示例10: setUp

import org.xnio.BufferAllocator; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
	this.app = new App();
	this.buffer = new ByteBufferSlicePool(
			BufferAllocator.BYTE_BUFFER_ALLOCATOR, 256, 256);
}
 
开发者ID:taichi,项目名称:siden,代码行数:7,代码来源:WebSocketTest.java



注:本文中的org.xnio.BufferAllocator类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java PersistenceBroker类代码示例发布时间:2022-05-22
下一篇:
Java ComponentIdentifier类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap