List of usage examples for io.netty.buffer UnpooledByteBufAllocator DEFAULT
UnpooledByteBufAllocator DEFAULT
To view the source code for io.netty.buffer UnpooledByteBufAllocator DEFAULT.
Click Source Link
From source file:ratpack.server.internal.FileBackedReloadInformant.java
License:Apache License
private void load() { lock.lock();// w w w.j a v a 2 s. c o m try { FileTime lastModifiedTime = Files.getLastModifiedTime(file); ByteBuf bytes = IoUtils.read(UnpooledByteBufAllocator.DEFAULT, file); this.lastModifiedHolder.set(lastModifiedTime); this.contentHolder.set(bytes); } catch (Exception e) { throw uncheck(e); } finally { lock.unlock(); } }
From source file:ratpack.stream.tck.ByteBufferComposingPublisherVerification.java
License:Apache License
@Override public Publisher<CompositeByteBuf> createPublisher(long elements) { TransformablePublisher<ByteBuf> periodically = Streams.periodically(harness.getController().getExecutor(), Duration.ofNanos(100), i -> i < elements * 3 ? i : null).map(Unpooled::copyInt); return ByteBufStreams.buffer(periodically, Long.MAX_VALUE, 3, UnpooledByteBufAllocator.DEFAULT); }
From source file:tk.jomp16.rcon.internal.RconServer.java
License:Open Source License
/** * Creates a new instance of RconServer/*from w ww . ja v a2 s .co m*/ * * @param host the IP that the server will bind on * @param port the port that the server will bind on * @param rconPassword the password to authenticate the users * @param epoll if Netty server will run on epoll */ public RconServer(final String host, final int port, final String rconPassword, final boolean epoll) { this.host = host; this.port = port; this.rconPassword = rconPassword; if (this.rconPassword == null || this.rconPassword.isEmpty()) { log.error("Source RCON password not set!"); return; } this.rconEvents = new LinkedList<>(); this.bossGroup = epoll ? new EpollEventLoopGroup() : new NioEventLoopGroup(); this.workerGroup = epoll ? new EpollEventLoopGroup() : new NioEventLoopGroup(); this.serverBootstrap = new ServerBootstrap(); this.serverBootstrap.group(this.bossGroup, this.workerGroup) .channel(epoll ? EpollServerSocketChannel.class : NioServerSocketChannel.class) .childHandler(new ChannelInitializer<SocketChannel>() { @Override protected void initChannel(final SocketChannel ch) throws Exception { ch.pipeline().addLast(new RconNettyDecoder(), new RconNettyEncoder(), new RconNettyHandler(RconServer.this)); } }).option(ChannelOption.SO_BACKLOG, 128).childOption(ChannelOption.SO_KEEPALIVE, true) .childOption(ChannelOption.ALLOCATOR, UnpooledByteBufAllocator.DEFAULT); this.canStartServer = true; }