barchart-udt-core
2.3.0-SNAPSHOT / 2013-05-13T01:37:38.485-0500

com.barchart.udt.nio
Class SelectionKeyUDT

java.lang.Object
  extended by java.nio.channels.SelectionKey
      extended by com.barchart.udt.nio.SelectionKeyUDT
All Implemented Interfaces:
Comparable<SelectionKeyUDT>

public class SelectionKeyUDT
extends SelectionKey
implements Comparable<SelectionKeyUDT>

UDT selection key implementation.


Field Summary
protected static int HAS_READ
          JDK interest to Epoll READ mapping.
protected static int HAS_WRITE
          JDK interest to Epoll WRITE mapping.
protected static org.slf4j.Logger log
           
 
Fields inherited from class java.nio.channels.SelectionKey
OP_ACCEPT, OP_CONNECT, OP_READ, OP_WRITE
 
Constructor Summary
protected SelectionKeyUDT(SelectorUDT selectorUDT, ChannelUDT channelUDT, Object attachment)
           
 
Method Summary
protected  void assertValidKey()
          Ensure key is NOT canceled.
protected  void assertValidOps(int interestOps)
          Ensure only permitted interest mask bits are present.
 void cancel()
           
 SelectableChannel channel()
           
protected  ChannelUDT channelUDT()
          Underlying UDT channel.
 int compareTo(SelectionKeyUDT that)
           
protected  boolean doRead(int resultIndex)
          Apply READ readiness according to KindUDT channel role.
protected  boolean doWrite(int resultIndex)
          Apply WRITE readiness according to KindUDT channel role.
protected  EpollUDT.Opt epollOpt()
          Requested interest in epoll format.
protected  EpollUDT epollUDT()
          Epoll bound to this key.
 boolean equals(Object otherKey)
          Key equality based on socket-id.
protected static EpollUDT.Opt from(int interestOps)
          Convert select options : from jdk into epoll.
 int hashCode()
          Key hach code based on socket-id.
 int interestOps()
           
 SelectionKey interestOps(int interestOps)
           
protected  boolean isSocketBroken()
          Check socket termination status.
 boolean isValid()
           
protected  KindUDT kindUDT()
          Channel role.
protected  void logError(String comment)
          Key processing logic error logger.
protected  void makeValid(boolean isValid)
          Change socket registration with epoll, and change key validity status.
 int readyOps()
           
protected  void readyOps(int ops)
           
 SelectorUDT selector()
           
protected  int socketId()
          Id of a socket bound to this key.
protected  SocketUDT socketUDT()
          Socket bound to this key.
 String toString()
           
static String toStringOps(int selectOps)
          Render select options.
 
Methods inherited from class java.nio.channels.SelectionKey
attach, attachment, isAcceptable, isConnectable, isReadable, isWritable
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

HAS_READ

protected static final int HAS_READ
JDK interest to Epoll READ mapping.

See Also:
Constant Field Values

HAS_WRITE

protected static final int HAS_WRITE
JDK interest to Epoll WRITE mapping.

See Also:
Constant Field Values

log

protected static final org.slf4j.Logger log
Constructor Detail

SelectionKeyUDT

protected SelectionKeyUDT(SelectorUDT selectorUDT,
                          ChannelUDT channelUDT,
                          Object attachment)
Method Detail

from

protected static EpollUDT.Opt from(int interestOps)
Convert select options : from jdk into epoll.


toStringOps

public static final String toStringOps(int selectOps)
Render select options.


assertValidKey

protected void assertValidKey()
                       throws CancelledKeyException
Ensure key is NOT canceled.

Throws:
CancelledKeyException

assertValidOps

protected void assertValidOps(int interestOps)
Ensure only permitted interest mask bits are present.


cancel

public void cancel()
Specified by:
cancel in class SelectionKey

channel

public SelectableChannel channel()
Specified by:
channel in class SelectionKey

channelUDT

protected ChannelUDT channelUDT()
Underlying UDT channel.


compareTo

public int compareTo(SelectionKeyUDT that)
Specified by:
compareTo in interface Comparable<SelectionKeyUDT>

doRead

protected boolean doRead(int resultIndex)
Apply READ readiness according to KindUDT channel role.

Note: doRead(int) is invoked before doWrite(int)

Sockets with exceptions are returned to both read and write sets.

Returns:
Should report ready-state change?

doWrite

protected boolean doWrite(int resultIndex)
Apply WRITE readiness according to KindUDT channel role.

Note: doRead(int) is invoked before doWrite(int)

Sockets with exceptions are returned to both read and write sets.

Returns:
Should report ready-state change?

epollOpt

protected EpollUDT.Opt epollOpt()
Requested interest in epoll format.


epollUDT

protected EpollUDT epollUDT()
Epoll bound to this key.


equals

public boolean equals(Object otherKey)
Key equality based on socket-id.

Overrides:
equals in class Object

hashCode

public int hashCode()
Key hach code based on socket-id.

Overrides:
hashCode in class Object

interestOps

public int interestOps()
Specified by:
interestOps in class SelectionKey

interestOps

public SelectionKey interestOps(int interestOps)
Specified by:
interestOps in class SelectionKey

isSocketBroken

protected boolean isSocketBroken()
Check socket termination status.

Returns:
true if status is StatusUDT.BROKEN or worse

isValid

public boolean isValid()
Specified by:
isValid in class SelectionKey

kindUDT

protected KindUDT kindUDT()
Channel role.


logError

protected void logError(String comment)
Key processing logic error logger.


makeValid

protected void makeValid(boolean isValid)
Change socket registration with epoll, and change key validity status.


readyOps

public int readyOps()
Specified by:
readyOps in class SelectionKey

readyOps

protected void readyOps(int ops)

selector

public SelectorUDT selector()
Specified by:
selector in class SelectionKey

socketId

protected int socketId()
Id of a socket bound to this key.


socketUDT

protected SocketUDT socketUDT()
Socket bound to this key.


toString

public String toString()
Overrides:
toString in class Object

barchart-udt-core
2.3.0-SNAPSHOT / 2013-05-13T01:37:38.485-0500

Copyright © 2009-2013 Barchart, Inc.. All Rights Reserved.