Class NioChannel

java.lang.Object
org.elasticsearch.nio.NioChannel
Direct Known Subclasses:
NioServerSocketChannel, NioSocketChannel

public abstract class NioChannel
extends java.lang.Object
This is a basic channel abstraction used by the NioSelector.

A channel is open once it is constructed. The channel remains open and isOpen() will return true until the channel is explicitly closed.

  • Constructor Summary

    Constructors 
    Constructor Description
    NioChannel()  
  • Method Summary

    Modifier and Type Method Description
    void addCloseListener​(java.util.function.BiConsumer<java.lang.Void,​java.lang.Exception> listener)
    Adds a close listener to the channel.
    void close()
    Schedules channel for close.
    abstract ChannelContext<?> getContext()  
    abstract java.net.InetSocketAddress getLocalAddress()  
    abstract java.nio.channels.NetworkChannel getRawChannel()  
    boolean isOpen()  

    Methods inherited from class java.lang.Object

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

  • Method Details

    • isOpen

      public boolean isOpen()
    • addCloseListener

      public void addCloseListener​(java.util.function.BiConsumer<java.lang.Void,​java.lang.Exception> listener)
      Adds a close listener to the channel. Multiple close listeners can be added. There is no guarantee about the order in which close listeners will be executed. If the channel is already closed, the listener is executed immediately.
      Parameters:
      listener - to be called at close
    • close

      public void close()
      Schedules channel for close. This process is asynchronous.
    • getLocalAddress

      public abstract java.net.InetSocketAddress getLocalAddress()
    • getRawChannel

      public abstract java.nio.channels.NetworkChannel getRawChannel()
    • getContext

      public abstract ChannelContext<?> getContext()