List of usage examples for io.netty.buffer PooledByteBufAllocator DEFAULT
PooledByteBufAllocator DEFAULT
To view the source code for io.netty.buffer PooledByteBufAllocator DEFAULT.
Click Source Link
From source file:herddb.log.LogEntry.java
License:Apache License
public ByteBuf serializeAsByteBuf() { ByteBuf buffer = PooledByteBufAllocator.DEFAULT.directBuffer(DEFAULT_BUFFER_SIZE); try (ExtendedDataOutputStream doo = new ExtendedDataOutputStream(new ByteBufOutputStream(buffer))) { serialize(doo);/*from w w w . ja va 2 s.com*/ return buffer; } catch (IOException err) { throw new RuntimeException(err); } }
From source file:info.zhoumin.dat.analyzer.ByteArrayAnalyzer.java
License:Apache License
@Override public ByteBuf rest() { int len = value.length - (index + 1); ByteBuf bb = PooledByteBufAllocator.DEFAULT.directBuffer(len).order(ByteOrder.nativeOrder()); for (int i = len; i > 0; i--) { bb.writeByte(value[value.length - i]); }//from www . j a v a 2 s .c o m return bb; }
From source file:info.zhoumin.dat.analyzer.IntegerAnalyzer.java
License:Apache License
@Override public ByteBuf rest() { int len = STEPS - (index + 1); ByteBuf bb = PooledByteBufAllocator.DEFAULT.directBuffer(len).order(ByteOrder.nativeOrder()); for (int i = len; i > 0; i--) { byte b = (byte) ((value >> (STEPS - i)) & 0xff); bb.writeByte(b);/*from w ww. ja va2 s. c o m*/ } return bb; }
From source file:info.zhoumin.dat.analyzer.StringAnalyzer.java
License:Apache License
@Override public ByteBuf rest() { int len = (value.length() << 1) - (index + 1); ByteBuf bb = PooledByteBufAllocator.DEFAULT.directBuffer(len).order(ByteOrder.nativeOrder()); for (int i = len; i > 0; i--) { int idx = (value.length() << 1) - i; char ch = value.charAt(idx >> 1); byte b = (byte) ((idx & 1) == 0 ? (ch & 0xff) : (ch >> Byte.SIZE & 0xff)); bb.writeByte(b);/*from w w w. j a va2 s. co m*/ } return bb; }
From source file:info.zhoumin.dat.util.ResizableIntArray.java
License:Apache License
public ResizableIntArray() { buffer = PooledByteBufAllocator.DEFAULT.directBuffer().order(ByteOrder.nativeOrder()); }
From source file:info.zhoumin.dat.util.ResizableIntArray.java
License:Apache License
public ResizableIntArray(int initialCapacity) { buffer = PooledByteBufAllocator.DEFAULT.directBuffer(initialCapacity << INT_SIZE_BITS) .order(ByteOrder.nativeOrder()); }
From source file:io.airlift.drift.transport.netty.server.DriftNettyServerModule.java
License:Apache License
public DriftNettyServerModule() { this(PooledByteBufAllocator.DEFAULT); }
From source file:io.atomix.cluster.messaging.impl.NettyMessagingService.java
License:Apache License
private Bootstrap bootstrapClient(Address address) { Bootstrap bootstrap = new Bootstrap(); bootstrap.option(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT); bootstrap.option(ChannelOption.WRITE_BUFFER_WATER_MARK, new WriteBufferWaterMark(10 * 32 * 1024, 10 * 64 * 1024)); bootstrap.option(ChannelOption.SO_RCVBUF, 1024 * 1024); bootstrap.option(ChannelOption.SO_SNDBUF, 1024 * 1024); bootstrap.option(ChannelOption.SO_KEEPALIVE, true); bootstrap.option(ChannelOption.TCP_NODELAY, true); bootstrap.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 1000); bootstrap.group(clientGroup);/* w w w . j a v a 2s. c o m*/ // TODO: Make this faster: // http://normanmaurer.me/presentations/2014-facebook-eng-netty/slides.html#37.0 bootstrap.channel(clientChannelClass); bootstrap.remoteAddress(address.address(true), address.port()); if (enableNettyTls) { bootstrap.handler(new SslClientCommunicationChannelInitializer()); } else { bootstrap.handler(new BasicChannelInitializer()); } return bootstrap; }
From source file:io.atomix.cluster.messaging.impl.NettyMessagingService.java
License:Apache License
private CompletableFuture<Void> startAcceptingConnections() { CompletableFuture<Void> future = new CompletableFuture<>(); ServerBootstrap b = new ServerBootstrap(); b.option(ChannelOption.SO_REUSEADDR, true); b.option(ChannelOption.SO_BACKLOG, 128); b.childOption(ChannelOption.WRITE_BUFFER_WATER_MARK, new WriteBufferWaterMark(8 * 1024, 32 * 1024)); b.childOption(ChannelOption.SO_RCVBUF, 1024 * 1024); b.childOption(ChannelOption.SO_SNDBUF, 1024 * 1024); b.childOption(ChannelOption.SO_KEEPALIVE, true); b.childOption(ChannelOption.TCP_NODELAY, true); b.childOption(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT); b.group(serverGroup, clientGroup);//from www .j a v a 2 s . com b.channel(serverChannelClass); if (enableNettyTls) { b.childHandler(new SslServerCommunicationChannelInitializer()); } else { b.childHandler(new BasicChannelInitializer()); } // Bind and start to accept incoming connections. b.bind(localAddress.port()).addListener((ChannelFutureListener) f -> { if (f.isSuccess()) { log.info("{} accepting incoming connections on port {}", localAddress.address(true), localAddress.port()); serverChannel = f.channel(); future.complete(null); } else { log.warn("{} failed to bind to port {} due to {}", localAddress.address(true), localAddress.port(), f.cause()); future.completeExceptionally(f.cause()); } }); return future; }
From source file:io.blobkeeper.server.BlobKeeperServer.java
License:Apache License
@Override protected void doStart() { fileWriterService.start();/* w w w . ja va 2s. com*/ clusterMembershipService.start(serverConfiguration.getServerName()); bossGroup = new EpollEventLoopGroup(); // FIXME: add to config workerGroup = new EpollEventLoopGroup(512); bootstrap = new ServerBootstrap(); bootstrap.option(ALLOCATOR, PooledByteBufAllocator.DEFAULT); bootstrap.group(bossGroup, workerGroup).channel(EpollServerSocketChannel.class) .childHandler(serverInitializer); bootstrap.childOption(SO_LINGER, -1); bootstrap.childOption(TCP_NODELAY, true); bootstrap.childOption(SO_REUSEADDR, true); bootstrap.childOption(ALLOCATOR, PooledByteBufAllocator.DEFAULT); bootstrap.childOption(EpollChannelOption.SO_REUSEPORT, true); bootstrap.childOption(EpollChannelOption.TCP_CORK, true); try { serverChannel = bootstrap.bind(serverConfiguration.getServerPort()).sync(); notifyStarted(); } catch (InterruptedException e) { notifyFailed(e); throw new RuntimeException(e); } }