NioSelectorPool (Apache Tomcat 6.0.51 API Documentation)
Keywords: org.apache.tomcat.util.net.NioSelectorPool class

Overview | Package | Class | Tree | Deprecated | Index | Help
| Apache Tomcat 6.0.51
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.tomcat.util.net
Class NioSelectorPool

    java.lang.Object
      org.apache.tomcat.util.net.NioSelectorPool

    public class NioSelectorPool

extends java.lang.Object

Thread safe non blocking selector pool

Since:
  6.0
Version:
  1.0
Author:
  Filip Hanik

Field Summary
`protected java.util.concurrent.atomic.AtomicInteger` | `active`
`protected NioBlockingSelector` | `blockingSelector`
`protected boolean` | `enabled`
`protected static Log` | `log`
`protected int` | `maxSelectors`
`protected int` | `maxSpareSelectors`
`protected java.util.concurrent.ConcurrentLinkedQueue<java.nio.channels.Selector>` | `selectors`
`protected static boolean` | `SHARED`
`protected java.nio.channels.Selector` | `SHARED_SELECTOR`
`protected long` | `sharedSelectorTimeout`
`protected java.util.concurrent.atomic.AtomicInteger` | `spare`
`protected static int` | `threadCount`

Constructor Summary
`NioSelectorPool()`

Method Summary
`void` | `close()`
`java.nio.channels.Selector` | `get()`
`int` | `getMaxSelectors()`
`int` | `getMaxSpareSelectors()`
`java.util.concurrent.ConcurrentLinkedQueue` | `getSelectors()`
`protected java.nio.channels.Selector` | `getSharedSelector()`
`long` | `getSharedSelectorTimeout()`
`java.util.concurrent.atomic.AtomicInteger` | `getSpare()`
`boolean` | `isEnabled()`
`void` | `open()`
`void` | `put(java.nio.channels.Selector s)`
`int` | `read(java.nio.ByteBuffer buf, NioChannel socket, java.nio.channels.Selector selector, long readTimeout)` Performs a blocking read using the bytebuffer for data to be read and a selector to block.
`int` | `read(java.nio.ByteBuffer buf, NioChannel socket, java.nio.channels.Selector selector, long readTimeout, boolean block)` Performs a read using the bytebuffer for data to be read and a selector to register for events should you have the block=true.
`void` | `setEnabled(boolean enabled)`
`void` | `setMaxSelectors(int maxSelectors)`
`void` | `setMaxSpareSelectors(int maxSpareSelectors)`
`void` | `setSharedSelectorTimeout(long sharedSelectorTimeout)`
`int` | `write(java.nio.ByteBuffer buf, NioChannel socket, java.nio.channels.Selector selector, long writeTimeout)` Performs a blocking write using the bytebuffer for data to be written and a selector to block.
`int` | `write(java.nio.ByteBuffer buf, NioChannel socket, java.nio.channels.Selector selector, long writeTimeout, boolean block, MutableInteger lastWrite)`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### threadCount

    protected static int threadCount

### log

    protected static Log log

### SHARED

    protected static final boolean SHARED

### blockingSelector

    protected NioBlockingSelector blockingSelector

### SHARED_SELECTOR

    protected java.nio.channels.Selector SHARED_SELECTOR

### maxSelectors

    protected int maxSelectors

### sharedSelectorTimeout

    protected long sharedSelectorTimeout

### maxSpareSelectors

    protected int maxSpareSelectors

### enabled

    protected boolean enabled

### active

    protected java.util.concurrent.atomic.AtomicInteger active

### spare

    protected java.util.concurrent.atomic.AtomicInteger spare

### selectors

    protected java.util.concurrent.ConcurrentLinkedQueue<java.nio.channels.Selector> selectors

Constructor Detail

### NioSelectorPool

    public NioSelectorPool()

Method Detail

### getSharedSelector

    protected java.nio.channels.Selector getSharedSelector()
                                                    throws java.io.IOException

  Throws:
    `java.io.IOException`

### get

    public java.nio.channels.Selector get()
                                   throws java.io.IOException

  Throws:
    `java.io.IOException`

### put

    public void put(java.nio.channels.Selector s)
             throws java.io.IOException

  Throws:
    `java.io.IOException`

### close

    public void close()
               throws java.io.IOException

  Throws:
    `java.io.IOException`

### open

    public void open()
              throws java.io.IOException

  Throws:
    `java.io.IOException`

### write

    public int write(java.nio.ByteBuffer buf,
                     NioChannel socket,
                     java.nio.channels.Selector selector,
                     long writeTimeout)
              throws java.io.IOException

  Performs a blocking write using the bytebuffer for data to be written and a selector to block. If the `selector` parameter is null, then it will perform a busy write that could take up a lot of CPU cycles.

  Parameters:
    `buf` - ByteBuffer - the buffer containing the data, we will write as long as `(buf.hasRemaining()==true)`
    `socket` - SocketChannel - the socket to write data to
    `selector` - Selector - the selector to use for blocking, if null then a busy write will be initiated
    `writeTimeout` - long - the timeout for this write operation in milliseconds, -1 means no timeout
  Returns:
    int - returns the number of bytes written
  Throws:
    `java.io.EOFException` - if write returns -1
    `java.net.SocketTimeoutException` - if the write times out
    `java.io.IOException` - if an IO Exception occurs in the underlying socket logic

### write

    public int write(java.nio.ByteBuffer buf,
                     NioChannel socket,
                     java.nio.channels.Selector selector,
                     long writeTimeout,
                     boolean block,
                     MutableInteger lastWrite)
              throws java.io.IOException

  Throws:
    `java.io.IOException`

### read

    public int read(java.nio.ByteBuffer buf,
                    NioChannel socket,
                    java.nio.channels.Selector selector,
                    long readTimeout)
             throws java.io.IOException

  Performs a blocking read using the bytebuffer for data to be read and a selector to block. If the `selector` parameter is null, then it will perform a busy read that could take up a lot of CPU cycles.

  Parameters:
    `buf` - ByteBuffer - the buffer containing the data, we will read as until we have read at least one byte or we timed out
    `socket` - SocketChannel - the socket to write data to
    `selector` - Selector - the selector to use for blocking, if null then a busy read will be initiated
    `readTimeout` - long - the timeout for this read operation in milliseconds, -1 means no timeout
  Returns:
    int - returns the number of bytes read
  Throws:
    `java.io.EOFException` - if read returns -1
    `java.net.SocketTimeoutException` - if the read times out
    `java.io.IOException` - if an IO Exception occurs in the underlying socket logic

### read

    public int read(java.nio.ByteBuffer buf,
                    NioChannel socket,
                    java.nio.channels.Selector selector,
                    long readTimeout,
                    boolean block)
             throws java.io.IOException

  Performs a read using the bytebuffer for data to be read and a selector to register for events should you have the block=true. If the `selector` parameter is null, then it will perform a busy read that could take up a lot of CPU cycles.

  Parameters:
    `buf` - ByteBuffer - the buffer containing the data, we will read as until we have read at least one byte or we timed out
    `socket` - SocketChannel - the socket to write data to
    `selector` - Selector - the selector to use for blocking, if null then a busy read will be initiated
    `readTimeout` - long - the timeout for this read operation in milliseconds, -1 means no timeout
    `block` - - true if you want to block until data becomes available or timeout time has been reached
  Returns:
    int - returns the number of bytes read
  Throws:
    `java.io.EOFException` - if read returns -1
    `java.net.SocketTimeoutException` - if the read times out
    `java.io.IOException` - if an IO Exception occurs in the underlying socket logic

### setMaxSelectors

    public void setMaxSelectors(int maxSelectors)

### setMaxSpareSelectors

    public void setMaxSpareSelectors(int maxSpareSelectors)

### setEnabled

    public void setEnabled(boolean enabled)

### setSharedSelectorTimeout

    public void setSharedSelectorTimeout(long sharedSelectorTimeout)

### getMaxSelectors

    public int getMaxSelectors()

### getMaxSpareSelectors

    public int getMaxSpareSelectors()

### isEnabled

    public boolean isEnabled()

### getSharedSelectorTimeout

    public long getSharedSelectorTimeout()

### getSelectors

    public java.util.concurrent.ConcurrentLinkedQueue getSelectors()

### getSpare

    public java.util.concurrent.atomic.AtomicInteger getSpare()

Overview | Package | Class | Tree | Deprecated | Index | Help
| Apache Tomcat 6.0.51
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2000-2017 Apache Software Foundation. All Rights Reserved.