org.eclipse.jetty.io.nio
Class SelectChannelEndPoint

java.lang.Object
  extended by org.eclipse.jetty.io.nio.ChannelEndPoint
      extended by org.eclipse.jetty.io.nio.SelectChannelEndPoint
All Implemented Interfaces:
AsyncEndPoint, ConnectedEndPoint, EndPoint
Direct Known Subclasses:
NetworkTrafficSelectChannelEndPoint, SslSelectChannelEndPoint

public class SelectChannelEndPoint
extends ChannelEndPoint
implements AsyncEndPoint, ConnectedEndPoint

An Endpoint that can be scheduled by SelectorManager.


Field Summary
 
Fields inherited from class org.eclipse.jetty.io.nio.ChannelEndPoint
_channel, _gather2, _local, _maxIdleTime, _remote, _socket
 
Constructor Summary
SelectChannelEndPoint(SocketChannel channel, SelectorManager.SelectSet selectSet, SelectionKey key)
           
SelectChannelEndPoint(SocketChannel channel, SelectorManager.SelectSet selectSet, SelectionKey key, int maxIdleTime)
           
 
Method Summary
 boolean blockReadable(long timeoutMs)
           
 boolean blockWritable(long timeoutMs)
           
 void cancelIdle()
          Cancel a call to the idle timeout
 void checkIdleTimestamp(long now)
           
 void close()
          Close any backing stream associated with the endpoint
 void dispatch()
          Dispatch the endpoint to a thread to attend to it.
 int flush(Buffer buffer)
          Flush the buffer from the current getIndex to it's putIndex using whatever byte sink is backing the buffer.
 int flush(Buffer header, Buffer buffer, Buffer trailer)
          Flush the buffer from the current getIndex to it's putIndex using whatever byte sink is backing the buffer.
 Connection getConnection()
           
 SelectionKey getSelectionKey()
           
 SelectorManager getSelectManager()
           
 SelectorManager.SelectSet getSelectSet()
           
protected  void handle()
           
protected  void idleExpired()
           
 boolean isReadyForDispatch()
           
 void schedule()
          Called by selectSet to schedule handling
 void scheduleIdle()
          Schedule a call to the idle timeout
 void scheduleWrite()
          Schedule a write dispatch.
 void setConnection(Connection connection)
           
 void setMaxIdleTime(int timeMs)
          Don't set the SoTimeout
 String toString()
           
protected  boolean undispatch()
          Called when a dispatched thread is no longer handling the endpoint.
 
Methods inherited from class org.eclipse.jetty.io.nio.ChannelEndPoint
fill, flush, gatheringFlush, getChannel, getLocalAddr, getLocalHost, getLocalPort, getMaxIdleTime, getRemoteAddr, getRemoteHost, getRemotePort, getTransport, isBlocking, isBufferingInput, isBufferingOutput, isBufferred, isInputShutdown, isOpen, isOutputShutdown, shutdownInput, shutdownOutput
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.eclipse.jetty.io.EndPoint
fill, flush, getLocalAddr, getLocalHost, getLocalPort, getMaxIdleTime, getRemoteAddr, getRemoteHost, getRemotePort, getTransport, isBlocking, isBufferingInput, isBufferingOutput, isBufferred, isInputShutdown, isOpen, isOutputShutdown, shutdownInput, shutdownOutput
 

Constructor Detail

SelectChannelEndPoint

public SelectChannelEndPoint(SocketChannel channel,
                             SelectorManager.SelectSet selectSet,
                             SelectionKey key,
                             int maxIdleTime)
                      throws IOException
Throws:
IOException

SelectChannelEndPoint

public SelectChannelEndPoint(SocketChannel channel,
                             SelectorManager.SelectSet selectSet,
                             SelectionKey key)
                      throws IOException
Throws:
IOException
Method Detail

getSelectionKey

public SelectionKey getSelectionKey()

getSelectManager

public SelectorManager getSelectManager()

getConnection

public Connection getConnection()
Specified by:
getConnection in interface ConnectedEndPoint

setConnection

public void setConnection(Connection connection)
Specified by:
setConnection in interface ConnectedEndPoint

schedule

public void schedule()
Called by selectSet to schedule handling


dispatch

public void dispatch()
Description copied from interface: AsyncEndPoint
Dispatch the endpoint to a thread to attend to it.

Specified by:
dispatch in interface AsyncEndPoint

undispatch

protected boolean undispatch()
Called when a dispatched thread is no longer handling the endpoint. The selection key operations are updated.

Returns:
If false is returned, the endpoint has been redispatched and thread must keep handling the endpoint.

scheduleIdle

public void scheduleIdle()
Description copied from interface: AsyncEndPoint
Schedule a call to the idle timeout

Specified by:
scheduleIdle in interface AsyncEndPoint

cancelIdle

public void cancelIdle()
Description copied from interface: AsyncEndPoint
Cancel a call to the idle timeout

Specified by:
cancelIdle in interface AsyncEndPoint

checkIdleTimestamp

public void checkIdleTimestamp(long now)

idleExpired

protected void idleExpired()

flush

public int flush(Buffer header,
                 Buffer buffer,
                 Buffer trailer)
          throws IOException
Description copied from interface: EndPoint
Flush the buffer from the current getIndex to it's putIndex using whatever byte sink is backing the buffer. The getIndex is updated with the number of bytes flushed. Any mark set is cleared. If the entire contents of the buffer are flushed, then an implicit empty() is done. The passed header/trailer buffers are written before/after the contents of this buffer. This may be done either as gather writes, as a poke into this buffer or as several writes. The implementation is free to select the optimal mechanism.

Specified by:
flush in interface EndPoint
Overrides:
flush in class ChannelEndPoint
Parameters:
header - A buffer to write before flushing this buffer. This buffers getIndex is updated.
buffer - The buffer to flush. This buffers getIndex is updated.
trailer - A buffer to write after flushing this buffer. This buffers getIndex is updated.
Returns:
the total number of bytes written.
Throws:
IOException

flush

public int flush(Buffer buffer)
          throws IOException
Description copied from interface: EndPoint
Flush the buffer from the current getIndex to it's putIndex using whatever byte sink is backing the buffer. The getIndex is updated with the number of bytes flushed. Any mark set is cleared. If the entire contents of the buffer are flushed, then an implicit empty() is done.

Specified by:
flush in interface EndPoint
Overrides:
flush in class ChannelEndPoint
Parameters:
buffer - The buffer to flush. This buffers getIndex is updated.
Returns:
the number of bytes written
Throws:
IOException

isReadyForDispatch

public boolean isReadyForDispatch()
Specified by:
isReadyForDispatch in interface AsyncEndPoint
Returns:
true if this endpoint can accept a dispatch. False if the endpoint cannot accept a dispatched (eg is suspended or already dispatched)

blockReadable

public boolean blockReadable(long timeoutMs)
                      throws IOException
Specified by:
blockReadable in interface EndPoint
Overrides:
blockReadable in class ChannelEndPoint
Throws:
IOException

blockWritable

public boolean blockWritable(long timeoutMs)
                      throws IOException
Specified by:
blockWritable in interface EndPoint
Overrides:
blockWritable in class ChannelEndPoint
Throws:
IOException

scheduleWrite

public void scheduleWrite()
Description copied from interface: AsyncEndPoint
Schedule a write dispatch. Set the endpoint to not be writable and schedule a dispatch when it becomes writable.

Specified by:
scheduleWrite in interface AsyncEndPoint

handle

protected void handle()

close

public void close()
           throws IOException
Description copied from interface: EndPoint
Close any backing stream associated with the endpoint

Specified by:
close in interface EndPoint
Overrides:
close in class ChannelEndPoint
Throws:
IOException

toString

public String toString()
Overrides:
toString in class Object

getSelectSet

public SelectorManager.SelectSet getSelectSet()

setMaxIdleTime

public void setMaxIdleTime(int timeMs)
                    throws IOException
Don't set the SoTimeout

Specified by:
setMaxIdleTime in interface EndPoint
Overrides:
setMaxIdleTime in class ChannelEndPoint
Parameters:
timeMs - the max idle time in MS.
Throws:
IOException - if the timeout cannot be set.
See Also:
ChannelEndPoint.setMaxIdleTime(int)


Copyright © 1995-2011 Mort Bay Consulting. All Rights Reserved.