Class Netty4Utils


  • public class Netty4Utils
    extends java.lang.Object
    • Constructor Summary

      Constructors 
      Constructor Description
      Netty4Utils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void closeChannels​(java.util.Collection<io.netty.channel.Channel> channels)  
      static void maybeDie​(java.lang.Throwable cause)
      If the specified cause is an unrecoverable error, this method will rethrow the cause on a separate thread so that it can not be caught and bubbles up to the uncaught exception handler.
      static void setAvailableProcessors​(int availableProcessors)
      Set the number of available processors that Netty uses for sizing various resources (e.g., thread pools).
      static void setup()  
      static io.netty.buffer.ByteBuf toByteBuf​(org.elasticsearch.common.bytes.BytesReference reference)
      Turns the given BytesReference into a ByteBuf.
      static org.elasticsearch.common.bytes.BytesReference toBytesReference​(io.netty.buffer.ByteBuf buffer)
      Wraps the given ChannelBuffer with a BytesReference
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Netty4Utils

        public Netty4Utils()
    • Method Detail

      • setup

        public static void setup()
      • 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:
        java.lang.IllegalStateException - if available processors was set previously and the specified value does not match the already-set value
      • toByteBuf

        public static io.netty.buffer.ByteBuf toByteBuf​(org.elasticsearch.common.bytes.BytesReference reference)
        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

        public static org.elasticsearch.common.bytes.BytesReference toBytesReference​(io.netty.buffer.ByteBuf buffer)
        Wraps the given ChannelBuffer with a BytesReference
      • closeChannels

        public static void closeChannels​(java.util.Collection<io.netty.channel.Channel> channels)
                                  throws java.io.IOException
        Throws:
        java.io.IOException
      • maybeDie

        public static void maybeDie​(java.lang.Throwable cause)
        If the specified cause is an unrecoverable error, this method will rethrow the cause on a separate thread so that it can not be caught and bubbles up to the uncaught exception handler.
        Parameters:
        cause - the throwable to test