Class Netty4Utils
java.lang.Object
org.elasticsearch.transport.netty4.Netty4Utils
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddListener(io.netty.channel.ChannelFuture channelFuture, io.netty.channel.ChannelFutureListener listener) static voidaddListener(io.netty.util.concurrent.Future<Void> future, ActionListener<Void> listener) Subscribes the givenActionListenerto the givenFuture.static Recycler<org.apache.lucene.util.BytesRef> createRecycler(Settings settings) static HttpBody.FullfullHttpBodyFrom(io.netty.buffer.ByteBuf buf) static voidsafeWriteAndFlush(io.netty.channel.Channel channel, Object message, ActionListener<Void> listener) CallsChannelOutboundInvoker.writeAndFlush(java.lang.Object, io.netty.channel.ChannelPromise)to write the given message to the given channel, but ensures that the listener is completed even if the event loop is concurrently shutting down since Netty does not offer this guarantee.static voidsetAvailableProcessors(int availableProcessors) Set the number of available processors that Netty uses for sizing various resources (e.g., thread pools).static io.netty.buffer.ByteBuftoByteBuf(BytesReference reference) Turns the given BytesReference into a ByteBuf.static BytesReferencetoBytesReference(io.netty.buffer.ByteBuf buffer) Wraps the given ChannelBuffer with a BytesReferencestatic ReleasableBytesReferencetoReleasableBytesReference(io.netty.buffer.ByteBuf buffer) Wrap Netty'sByteBufintoReleasableBytesReferenceand delegating reference count to ByteBuf.
-
Constructor Details
-
Netty4Utils
public Netty4Utils()
-
-
Method Details
-
setAvailableProcessors
public static void setAvailableProcessors(int availableProcessors) Set the number of available processors that Netty uses for sizing various resources (e.g., thread pools).- Parameters:
availableProcessors- the number of available processors- Throws:
IllegalStateException- if available processors was set previously and the specified value does not match the already-set value
-
toByteBuf
Turns the given BytesReference into a ByteBuf. Note: the returned ByteBuf will reference the internal pages of the BytesReference. Don't free the bytes of reference before the ByteBuf goes out of scope. -
toBytesReference
Wraps the given ChannelBuffer with a BytesReference -
toReleasableBytesReference
Wrap Netty'sByteBufintoReleasableBytesReferenceand delegating reference count to ByteBuf. -
fullHttpBodyFrom
-
createRecycler
-
safeWriteAndFlush
public static void safeWriteAndFlush(io.netty.channel.Channel channel, Object message, ActionListener<Void> listener) CallsChannelOutboundInvoker.writeAndFlush(java.lang.Object, io.netty.channel.ChannelPromise)to write the given message to the given channel, but ensures that the listener is completed even if the event loop is concurrently shutting down since Netty does not offer this guarantee. -
addListener
public static void addListener(io.netty.util.concurrent.Future<Void> future, ActionListener<Void> listener) Subscribes the givenActionListenerto the givenFuture. -
addListener
public static void addListener(io.netty.channel.ChannelFuture channelFuture, io.netty.channel.ChannelFutureListener listener)
-