Top Description Inners Fields Constructors Methods
org.mortbay.io.nio

public Class SelectChannelEndPoint

extends ChannelEndPoint
implements Runnable
Class Inheritance
All Implemented Interfaces
java.lang.Runnable
Known Direct Subclasses
org.mortbay.jetty.nio.SelectChannelConnector.ConnectorEndPoint
Imports
java.io.IOException, java.nio.channels.ClosedChannelException, .SelectableChannel, .SelectionKey, .SocketChannel, org.mortbay.io.Buffer, .Connection, org.mortbay.io.nio.SelectorManager.SelectSet, org.mortbay.jetty.EofException, .HttpException, org.mortbay.log.Log, org.mortbay.thread.Timeout

An Endpoint that can be scheduled by SelectorManager.
Author
gregw

Nested and Inner Type Summary

Modifier and TypeClass and Description
public class

Field Summary

Modifier and TypeField and Description
protected Connection
protected boolean
protected int
protected SelectionKey
protected SelectorManager
protected boolean
protected SelectorManager.SelectSet
private Timeout.Task
protected boolean
protected boolean
Inherited from org.mortbay.io.nio.ChannelEndPoint:
_channel_gather2_local_remote_socket

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public boolean
public boolean
public void
public void
close()

Overrides org.mortbay.io.nio.ChannelEndPoint.close.

Implements org.mortbay.io.EndPoint.close.

Close any backing stream associated with the buffer
pack-priv void
public boolean

Returns:

True if the endpoint should be dispatched to a thread pool.
dispatch
(boolean
If true, the interested ops are not modified.
assumeShortDispatch
)

Put the endpoint into the dispatched state.

pack-priv void
doUpdateKey()

Synchronize the interestOps with the actual key.

public int
flush(Buffer
A buffer to write before flushing this buffer. This buffers getIndex is updated.
header
,
Buffer
The buffer to flush. This buffers getIndex is updated.
buffer
,
Buffer
A buffer to write after flushing this buffer. This buffers getIndex is updated.
trailer
)

Overrides org.mortbay.io.nio.ChannelEndPoint.flush.

Implements org.mortbay.io.EndPoint.flush.

Flush the buffer from the current getIndex to it's putIndex using whatever byte sink is backing the buffer.
public int
flush(Buffer
The buffer to flush. This buffers getIndex is updated.
buffer
)

Overrides org.mortbay.io.nio.ChannelEndPoint.flush.

Implements org.mortbay.io.EndPoint.flush.

Flush the buffer from the current getIndex to it's putIndex using whatever byte sink is backing the buffer.
public Connection
public SelectorManager.SelectSet
public Timeout.Task
protected void
public void
run()

Implements java.lang.Runnable.run.

Runs this operation.
public void
public void
public void
setWritable(boolean writable)

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
public void
undispatch()

Called when a dispatched thread is no longer handling the endpoint.

private void
updateKey()

Updates selection key.

Inherited from org.mortbay.io.nio.ChannelEndPoint:
fillflushgetChannelgetLocalAddrgetLocalHostgetLocalPortgetRemoteAddrgetRemoteHostgetRemotePortgetTransportisBlockingisBufferingInputisBufferingOutputisBufferredisOpenshutdownOutput

Field Detail

_connectionback to summary
protected Connection _connection
_dispatchedback to summary
protected boolean _dispatched
_interestOpsback to summary
protected int _interestOps
_keyback to summary
protected SelectionKey _key
_managerback to summary
protected SelectorManager _manager
_readBlockedback to summary
protected boolean _readBlocked
_selectSetback to summary
protected SelectorManager.SelectSet _selectSet
_timeoutTaskback to summary
private Timeout.Task _timeoutTask
_writableback to summary
protected boolean _writable
_writeBlockedback to summary
protected boolean _writeBlocked

Constructor Detail

SelectChannelEndPointback to summary
public SelectChannelEndPoint(SocketChannel channel, SelectorManager.SelectSet selectSet, SelectionKey key)

Method Detail

blockReadableback to summary
public boolean blockReadable(long timeoutMs) throws IOException

Overrides org.mortbay.io.nio.ChannelEndPoint.blockReadable.

Implements org.mortbay.io.EndPoint.blockReadable.

blockWritableback to summary
public boolean blockWritable(long timeoutMs) throws IOException

Overrides org.mortbay.io.nio.ChannelEndPoint.blockWritable.

Implements org.mortbay.io.EndPoint.blockWritable.

cancelIdleback to summary
public void cancelIdle()
closeback to summary
public void close() throws IOException

Overrides org.mortbay.io.nio.ChannelEndPoint.close.

Implements org.mortbay.io.EndPoint.close.

Doc from org.mortbay.io.EndPoint.close.

Close any backing stream associated with the buffer

dispatchback to summary
pack-priv void dispatch() throws IOException
dispatchback to summary
public boolean dispatch(boolean assumeShortDispatch) throws IOException

Put the endpoint into the dispatched state. A blocked thread may be woken up by this call, or the endpoint placed in a state ready for a dispatch to a threadpool.

Parameters
assumeShortDispatch:boolean

If true, the interested ops are not modified.

Returns:boolean

True if the endpoint should be dispatched to a thread pool.

doUpdateKeyback to summary
pack-priv void doUpdateKey()

Synchronize the interestOps with the actual key. Call is scheduled by a call to updateKey

flushback to summary
public int flush(Buffer header, Buffer buffer, Buffer trailer) throws IOException

Overrides org.mortbay.io.nio.ChannelEndPoint.flush.

Implements org.mortbay.io.EndPoint.flush.

Doc from org.mortbay.io.EndPoint.flush.

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.

Parameters
header:Buffer

A buffer to write before flushing this buffer. This buffers getIndex is updated.

buffer:Buffer

The buffer to flush. This buffers getIndex is updated.

trailer:Buffer

A buffer to write after flushing this buffer. This buffers getIndex is updated.

Returns:int

the total number of bytes written.

flushback to summary
public int flush(Buffer buffer) throws IOException

Overrides org.mortbay.io.nio.ChannelEndPoint.flush.

Implements org.mortbay.io.EndPoint.flush.

Doc from org.mortbay.io.EndPoint.flush.

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.

Parameters
buffer:Buffer

The buffer to flush. This buffers getIndex is updated.

Returns:int

the number of bytes written

getConnectionback to summary
public Connection getConnection()
getSelectSetback to summary
public SelectorManager.SelectSet getSelectSet()
getTimeoutTaskback to summary
public Timeout.Task getTimeoutTask()
idleExpiredback to summary
protected void idleExpired()
runback to summary
public void run()

Implements java.lang.Runnable.run.

Doc from java.lang.Runnable.run.

Runs this operation.

scheduleIdleback to summary
public void scheduleIdle()
scheduleWriteback to summary
public void scheduleWrite()
setWritableback to summary
public void setWritable(boolean writable)
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

undispatchback to summary
public void undispatch()

Called when a dispatched thread is no longer handling the endpoint. The selection key operations are updated.

updateKeyback to summary
private void updateKey()

Updates selection key. Adds operations types to the selection key as needed. No operations are removed as this is only done during dispatch. This method records the new key and schedules a call to doUpdateKey to do the keyChange

org.mortbay.io.nio back to summary

public Class SelectChannelEndPoint.IdleTask

extends Task
Class Inheritance

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from org.mortbay.thread.Timeout.Task:
cancelexpiregetAgegetTimestampisExpiredisScheduledreschedulescheduleschedule

Constructor Detail

IdleTaskback to summary
public IdleTask()

Method Detail

expiredback to summary
public void expired()

Overrides org.mortbay.thread.Timeout.Task.expired.

Doc from org.mortbay.thread.Timeout.Task.expired.

Expire task. This method is called when the timeout expires. It is called outside of any synchronization scope and may be delayed.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.