Package io.netty.buffer

Examples of io.netty.buffer.PooledByteBufAllocator


      ServerBootstrap b = new ServerBootstrap();
      b.option(ChannelOption.SO_BACKLOG, 1024);
      b.option(ChannelOption.SO_REUSEADDR, true);
      b.group(loupGroup).channel(serverChannelClass).childHandler(new HelloServerInitializer(loupGroup.next()));
      b.option(ChannelOption.MAX_MESSAGES_PER_READ, Integer.MAX_VALUE);
      b.childOption(ChannelOption.ALLOCATOR, new PooledByteBufAllocator(true));
      b.childOption(ChannelOption.SO_REUSEADDR, true);
      b.childOption(ChannelOption.MAX_MESSAGES_PER_READ, Integer.MAX_VALUE);

      Channel ch = b.bind(port).sync().channel();
      ch.closeFuture().sync();
View Full Code Here


   * @return ByteBufAllocator
   */
  public ByteBufAllocator getNettyAllocator() {
    if (nettyBufferAllocator == null) {
      if (NETTY_USE_POOLED_ALLOCATOR.get(this)) { // Use pooled allocator
        nettyBufferAllocator = new PooledByteBufAllocator(
          NETTY_USE_DIRECT_MEMORY.get(this));
      } else { // Use un-pooled allocator
        // Note: Current default settings create un-pooled heap allocator
        nettyBufferAllocator = new UnpooledByteBufAllocator(
            NETTY_USE_DIRECT_MEMORY.get(this));
View Full Code Here

    int chunkSize = 16 * 1 << 20; // 16 MB

    // shift pageSize maxOrder times to get to chunkSize
    int maxOrder = (int) (Math.log(chunkSize/pageSize) / Math.log(2));

    PooledByteBufAllocator pooledByteBufAllocator =
        new PooledByteBufAllocator(true, numHeapArenas, numDirectArenas, pageSize, maxOrder);

    String msg = String.format("Instantiated PooledByteBufAllocator with direct arenas: %d, heap arenas: %d, " +
        "page size (bytes): %d, chunk size (bytes): %d.",
        numDirectArenas, numHeapArenas, pageSize, (pageSize << maxOrder));
    LOG.info(msg);
View Full Code Here

    IOMode ioMode = IOMode.valueOf(conf.ioMode());
    EventLoopGroup bossGroup =
      NettyUtils.createEventLoop(ioMode, conf.serverThreads(), "shuffle-server");
    EventLoopGroup workerGroup = bossGroup;

    PooledByteBufAllocator allocator = new PooledByteBufAllocator(
      conf.preferDirectBufs() && PlatformDependent.directBufferPreferred());

    bootstrap = new ServerBootstrap()
      .group(bossGroup, workerGroup)
      .channel(NettyUtils.getServerChannelClass(ioMode))
View Full Code Here

   * are disabled because the ByteBufs are allocated by the event loop thread, but released by the
   * executor thread rather than the event loop thread. Those thread-local caches actually delay
   * the recycling of buffers, leading to larger memory usage.
   */
  private PooledByteBufAllocator createPooledByteBufAllocator() {
    return new PooledByteBufAllocator(
        conf.preferDirectBufs() && PlatformDependent.directBufferPreferred(),
        getPrivateStaticField("DEFAULT_NUM_HEAP_ARENA"),
        getPrivateStaticField("DEFAULT_NUM_DIRECT_ARENA"),
        getPrivateStaticField("DEFAULT_PAGE_SIZE"),
        getPrivateStaticField("DEFAULT_MAX_ORDER"),
View Full Code Here

    bootstrap.childOption(ChannelOption.SO_SNDBUF, tcpSendBufferSize);
    bootstrap.childOption(ChannelOption.SO_RCVBUF, tcpReceiveBufferSize);
    bootstrap.option(ChannelOption.SO_LINGER, soLinger);
    bootstrap.childOption(ChannelOption.IP_TOS, trafficClass);
    if (usePooledBuffers) {
      bootstrap.childOption(ChannelOption.ALLOCATOR, new PooledByteBufAllocator());
    } else {
      bootstrap.childOption(ChannelOption.ALLOCATOR, UnpooledByteBufAllocator.DEFAULT);
    }
    bootstrap.childOption(ChannelOption.SO_KEEPALIVE, tcpKeepAlive);
    bootstrap.option(ChannelOption.SO_REUSEADDR, reuseAddress);
View Full Code Here

    bootstrap.option(ChannelOption.SO_SNDBUF, tcpSendBufferSize);
    bootstrap.option(ChannelOption.SO_RCVBUF, tcpReceiveBufferSize);
    bootstrap.option(ChannelOption.SO_LINGER, soLinger);
    bootstrap.option(ChannelOption.IP_TOS, trafficClass);
    bootstrap.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, connectTimeout);
    bootstrap.option(ChannelOption.ALLOCATOR, new PooledByteBufAllocator());
    bootstrap.option(ChannelOption.ALLOCATOR, UnpooledByteBufAllocator.DEFAULT);
  }
View Full Code Here

TOP

Related Classes of io.netty.buffer.PooledByteBufAllocator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.