当前位置: 首页>>代码示例>>Java>>正文


Java ByteBufferSlicePool类代码示例

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


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

示例1: mountServerEndpoints

import org.xnio.ByteBufferSlicePool; //导入依赖的package包/类
protected PathHandler mountServerEndpoints(final PathHandler pathHandler , List<Class<?>> serverEndpoints) throws ServletException{
  if(!serverEndpoints.isEmpty()){
    DeploymentInfo builder = new DeploymentInfo()
      .setClassLoader(this.getClass().getClassLoader())
      .setContextPath("/");
    WebSocketDeploymentInfo wsDeployInfo = new WebSocketDeploymentInfo();
    wsDeployInfo.setBuffers(new ByteBufferSlicePool(100, 1000));
    for(Class<?> serverEndpoint : serverEndpoints ){
      wsDeployInfo.addEndpoint( serverEndpoint );
    }
    builder.addServletContextAttribute(WebSocketDeploymentInfo.ATTRIBUTE_NAME, wsDeployInfo );
    builder.setDeploymentName("websocketDeploy.war");
    
    final ServletContainer container = ServletContainer.Factory.newInstance();
    DeploymentManager manager = container.addDeployment(builder);
    manager.deploy();
    pathHandler.addPrefixPath("/", manager.start() );
  }      
  return pathHandler;
}
 
开发者ID:EsmerilProgramming,项目名称:overtown,代码行数:21,代码来源:PathHandlerMounter.java

示例2: create

import org.xnio.ByteBufferSlicePool; //导入依赖的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

示例3: main

import org.xnio.ByteBufferSlicePool; //导入依赖的package包/类
public static void main(final String... args) throws Exception {
    final DeploymentManager deployment = Servlets.defaultContainer()
        .addDeployment(
            Servlets.deployment()
                .setClassLoader(UndertowContainer.class.getClassLoader())
                .setContextPath("/")
                .setDeploymentName(UndertowContainer.class.getName())
                .addServletContextAttribute(
                    WebSocketDeploymentInfo.ATTRIBUTE_NAME,
                    new WebSocketDeploymentInfo()
                        .addEndpoint(ApplicationConfig.ENDPOINT_CONFIG)
                        .setWorker(Xnio.getInstance().createWorker(OptionMap.builder().getMap()))
                        .setBuffers(new XnioByteBufferPool(new ByteBufferSlicePool(1024, 10240)))
                )
        );
    deployment.deploy();
    final HttpHandler servletHandler = deployment.start();
    Undertow.builder()
        .addHttpListener(Client.PORT, Client.HOST)
        .setHandler(servletHandler)
        .build()
        .start();
}
 
开发者ID:softappeal,项目名称:yass,代码行数:24,代码来源:UndertowContainer.java

示例4: createRootHandler

import org.xnio.ByteBufferSlicePool; //导入依赖的package包/类
public HttpHandler createRootHandler(Configuration configuration , ScannerResult scannerResult) {
  PathHandler pathHandler = Handlers.path();

  String appContext = "/" + configuration.getAppContext();
  pathHandler.addPrefixPath( appContext , createAppHandlers(scannerResult));
  if(!scannerResult.getServerEndpoints().isEmpty()){
    DeploymentInfo builder = new DeploymentInfo().setClassLoader(this.getClass().getClassLoader()).setContextPath("/");
    WebSocketDeploymentInfo wsDeployInfo = new WebSocketDeploymentInfo();
    wsDeployInfo.setBuffers(new ByteBufferSlicePool(100, 1000));
    for(Class<?> serverEndpoint : scannerResult.getServerEndpoints() ){
      wsDeployInfo.addEndpoint( serverEndpoint );
    }
    builder.addServletContextAttribute(WebSocketDeploymentInfo.ATTRIBUTE_NAME, wsDeployInfo);
    builder.setDeploymentName("websocketDeploy.war");

    final ServletContainer container = ServletContainer.Factory.newInstance();
    DeploymentManager manager = container.addDeployment(builder);
    manager.deploy();
    try {
      OvertownSessionManager sessionManager = OvertownSessionManager.getInstance();
      String wsContextPath = "ws";
      if( !appContext.endsWith("/") ){
        wsContextPath += appContext + "/" + wsContextPath;
      }
      pathHandler.addPrefixPath( wsContextPath ,
              new SessionAttachmentHandler(  manager.start() , sessionManager.getSessionManager(),
                sessionManager.getSessionConfig()) );
    } catch (ServletException e) {
      e.printStackTrace();
    }
  }
  String staticContextPath = configuration.getStaticRootPath();
  if( !appContext.endsWith("/") ){
    staticContextPath = appContext + "/" + staticContextPath;
  }
  pathHandler.addPrefixPath( staticContextPath , new ResourceHandlerMounter().mount());
  return pathHandler;
}
 
开发者ID:EsmerilProgramming,项目名称:overtown,代码行数:39,代码来源:StartupHandlerImpl.java

示例5: createByteBufferPool

import org.xnio.ByteBufferSlicePool; //导入依赖的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

示例6: upgradeConnection

import org.xnio.ByteBufferSlicePool; //导入依赖的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: main

import org.xnio.ByteBufferSlicePool; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
    final OptionMap options = OptionMap.builder()
            .set(WORKER_IO_THREADS, 8)
            .set(TCP_NODELAY, true)
            .set(KEEP_ALIVE, true)
            .set(WORKER_NAME, "Client")
            .getMap();
    final Xnio xnio = Xnio.getInstance();
    final XnioWorker worker = xnio.createWorker(null, options);
    final UndertowClient client = UndertowClient.getInstance();

    final URI serverAddress = new URI(SERVER_URL);
    final ClientConnection connection = client.connect(serverAddress, worker, new ByteBufferSlicePool(1024, 1024), EMPTY).get();

    final CountDownLatch latch = new CountDownLatch(1);

    try {
        connection.getIoThread().execute(new Runnable() {
            @Override
            public void run() {
                final ClientRequest request = new ClientRequest().setMethod(GET).setPath("/");
                request.getRequestHeaders().add(UPGRADE, HORNETQ_REMOTING);
                String secretKey = HandshakeUtil.createSecretKey();
                request.getRequestHeaders().add(HttpString.tryFromString(HandshakeUtil.SEC_HORNETQ_REMOTING_KEY), secretKey);
                connection.sendRequest(request, createClientCallback(latch, secretKey));
            }
        });
        latch.await(10, TimeUnit.MINUTES);
        if (connection.isUpgraded()) {
            StreamConnection streamConnection = connection.performUpgrade();
            switchToHornetQProtocol(streamConnection);
        }
    } finally {
        IoUtils.safeClose(connection);
        worker.shutdown();
    }
}
 
开发者ID:jmesnil,项目名称:hornetq-undertow-client,代码行数:38,代码来源:Client.java

示例8: allocateDirect

import org.xnio.ByteBufferSlicePool; //导入依赖的package包/类
static Pooled<ByteBuffer> allocateDirect(ByteBufferSlicePool pool, int initialCapacity) {
    Pooled<ByteBuffer> pooled;
    if (initialCapacity <= pool.getBufferSize()) {
        pooled = pool.allocate();
    } else {
        pooled = new PooledByteBuf(ByteBuffer.allocateDirect(initialCapacity));
    }
    return pooled;
}
 
开发者ID:xnio,项目名称:netty-xnio-transport,代码行数:10,代码来源:XnioByteBufUtil.java

示例9: main

import org.xnio.ByteBufferSlicePool; //导入依赖的package包/类
public static void main(final String... args) throws Exception {
    final DeploymentManager deployment = Servlets.defaultContainer()
        .addDeployment(
            Servlets.deployment()
                .setClassLoader(AsyncWsConnectionTest.class.getClassLoader())
                .setContextPath("/")
                .setDeploymentName(AsyncWsConnectionTest.class.getName())
                .addServletContextAttribute(
                    WebSocketDeploymentInfo.ATTRIBUTE_NAME,
                    new WebSocketDeploymentInfo()
                        .addEndpoint(serverEndpointConfig())
                        .setWorker(Xnio.getInstance().createWorker(OptionMap.builder().getMap()))
                        .setBuffers(new XnioByteBufferPool(new ByteBufferSlicePool(1024, 10240)))
                )
        );
    deployment.deploy();
    Undertow.builder()
        .addHttpListener(PORT, HOST)
        .setHandler(deployment.start())
        .build()
        .start();
    TimeUnit.SECONDS.sleep(1);
    if (true) {
        client(new ServerWebSocketContainer(
            DefaultClassIntrospector.INSTANCE,
            Xnio.getInstance().createWorker(OptionMap.create(Options.THREAD_DAEMON, true)),
            new XnioByteBufferPool(new ByteBufferSlicePool(1024, 10240)),
            List.of(new ContextClassLoaderSetupAction(ClassLoader.getSystemClassLoader())),
            true,
            true
        ));
    } else {
        final ClientContainer container = new ClientContainer(); // $note: setSendTimeout not yet implemented in Jetty
        container.start();
        client(container);
    }
}
 
开发者ID:softappeal,项目名称:yass,代码行数:38,代码来源:AsyncWsConnectionTest.java

示例10: run

import org.xnio.ByteBufferSlicePool; //导入依赖的package包/类
protected static void run(final CountDownLatch latch) throws Exception {
    final Xnio xnio = Xnio.getInstance();
    final DeploymentManager deployment = Servlets.defaultContainer()
        .addDeployment(
            Servlets.deployment()
                .setClassLoader(UndertowTest.class.getClassLoader())
                .setContextPath("/")
                .setDeploymentName(UndertowTest.class.getName())
                .addServletContextAttribute(
                    WebSocketDeploymentInfo.ATTRIBUTE_NAME,
                    new WebSocketDeploymentInfo()
                        .addEndpoint(serverEndpointConfig())
                        .setWorker(xnio.createWorker(OptionMap.builder().getMap()))
                        .setBuffers(new XnioByteBufferPool(new ByteBufferSlicePool(1024, 10240)))
                )
        );
    deployment.deploy();
    final Undertow server = Undertow.builder()
        .addHttpListener(PORT, "localhost")
        .setHandler(deployment.start())
        .build();
    server.start();
    connect(
        new ServerWebSocketContainer(
            DefaultClassIntrospector.INSTANCE,
            xnio.createWorker(OptionMap.create(Options.THREAD_DAEMON, true)),
            new XnioByteBufferPool(new ByteBufferSlicePool(1024, 10240)),
            List.of(new ContextClassLoaderSetupAction(ClassLoader.getSystemClassLoader())),
            true,
            true
        ),
        latch
    );
    server.stop();
}
 
开发者ID:softappeal,项目名称:yass,代码行数:36,代码来源:UndertowTest.java

示例11: main

import org.xnio.ByteBufferSlicePool; //导入依赖的package包/类
public static void main(final String... args) throws Exception {
    final DeploymentManager deployment = Servlets.defaultContainer()
        .addDeployment(
            Servlets.deployment()
                .setClassLoader(UndertowAcceptor.class.getClassLoader())
                .setContextPath("/")
                .setDeploymentName(UndertowAcceptor.class.getName())
                .addServlet(
                    Servlets.servlet("Xhr", XhrServlet.class)
                        .addMapping(XHR_PATH)
                )
                .addServletContextAttribute(
                    WebSocketDeploymentInfo.ATTRIBUTE_NAME,
                    new WebSocketDeploymentInfo()
                        .addEndpoint(ENDPOINT_CONFIG)
                        .setWorker(Xnio.getInstance().createWorker(OptionMap.builder().getMap()))
                        .setBuffers(new XnioByteBufferPool(new ByteBufferSlicePool(1024, 10240)))
                )
        );
    deployment.deploy();
    final HttpHandler servletHandler = deployment.start();
    final HttpHandler fileHandler = Handlers.resource(new FileResourceManager(new File(WEB_PATH), 100));
    Undertow.builder()
        .addHttpListener(PORT, HOST)
        .addHttpsListener(PORT + 1, HOST, SslConfig.SERVER.context) // $note: we don't know how to force client authentication
        .setHandler(exchange -> {
            final String path = exchange.getRequestPath();
            if (WS_PATH.equals(path) || XHR_PATH.equals(path)) {
                servletHandler.handleRequest(exchange);
            } else {
                fileHandler.handleRequest(exchange);
            }
        })
        .build()
        .start();
    System.out.println("started");
}
 
开发者ID:softappeal,项目名称:yass,代码行数:38,代码来源:UndertowAcceptor.java

示例12: main

import org.xnio.ByteBufferSlicePool; //导入依赖的package包/类
public static void main(final String... args) throws Exception {
    run(new ServerWebSocketContainer(
        DefaultClassIntrospector.INSTANCE,
        Xnio.getInstance().createWorker(OptionMap.create(Options.THREAD_DAEMON, true)),
        new XnioByteBufferPool(new ByteBufferSlicePool(1024, 10240)),
        List.of(new ContextClassLoaderSetupAction(ClassLoader.getSystemClassLoader())),
        true,
        true
    ));
}
 
开发者ID:softappeal,项目名称:yass,代码行数:11,代码来源:UndertowInitiator.java

示例13: dispatchMockRequest

import org.xnio.ByteBufferSlicePool; //导入依赖的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

示例14: createSpdyChannel

import org.xnio.ByteBufferSlicePool; //导入依赖的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

示例15: start

import org.xnio.ByteBufferSlicePool; //导入依赖的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


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