NIO endpoint.
| 69 | * NIO endpoint. |
| 70 | */ |
| 71 | public class NioEndpoint extends AbstractNetworkChannelEndpoint<NioChannel,SocketChannel> { |
| 72 | |
| 73 | /** |
| 74 | * Default constructor. |
| 75 | */ |
| 76 | public NioEndpoint() { |
| 77 | } |
| 78 | |
| 79 | |
| 80 | // -------------------------------------------------------------- Constants |
| 81 | |
| 82 | |
| 83 | private static final Log log = LogFactory.getLog(NioEndpoint.class); |
| 84 | private static final Log logCertificate = LogFactory.getLog(NioEndpoint.class.getName() + ".certificate"); |
| 85 | private static final Log logHandshake = LogFactory.getLog(NioEndpoint.class.getName() + ".handshake"); |
| 86 | |
| 87 | |
| 88 | /** |
| 89 | * Custom operation for registering interest in a socket. |
| 90 | */ |
| 91 | public static final int OP_REGISTER = 0x100; // register interest op |
| 92 | |
| 93 | // ----------------------------------------------------------------- Fields |
| 94 | |
| 95 | /** |
| 96 | * Server socket "pointer". |
| 97 | */ |
| 98 | private volatile ServerSocketChannel serverSock = null; |
| 99 | |
| 100 | /** |
| 101 | * Stop latch used to wait for poller stop |
| 102 | */ |
| 103 | private volatile CountDownLatch stopLatch = null; |
| 104 | |
| 105 | /** |
| 106 | * Cache for poller events |
| 107 | */ |
| 108 | private SynchronizedStack<PollerEvent> eventCache; |
| 109 | |
| 110 | /** |
| 111 | * Bytebuffer cache, each channel holds a set of buffers (two, except for SSL holds four) |
| 112 | */ |
| 113 | private SynchronizedStack<NioChannel> nioChannels; |
| 114 | |
| 115 | /** |
| 116 | * Address of the previously accepted socket for duplicate detection. |
| 117 | */ |
| 118 | private SocketAddress previousAcceptedSocketRemoteAddress = null; |
| 119 | |
| 120 | /** |
| 121 | * Nano time when the previous socket was accepted for duplicate detection. |
| 122 | */ |
| 123 | private long previousAcceptedSocketNanoTime = 0; |
| 124 | |
| 125 | |
| 126 | // ------------------------------------------------------------- Properties |
| 127 | |
| 128 | /** |