|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectecologylab.generic.Debug
ecologylab.services.distributed.impl.NIOCore
ecologylab.services.distributed.impl.NIONetworking
public abstract class NIONetworking
Handles backend, low-level communication between distributed programs, using NIO. This is the basis for servers for handling network communication.
| Field Summary | |
|---|---|
protected ByteBufferPool |
byteBufferPool
|
protected int |
connectionCount
|
protected Scope<?> |
objectRegistry
Provides a context for request processing. |
protected boolean |
shuttingDown
|
protected TranslationSpace |
translationSpace
Space that defines mappings between xml names, and Java class names, for request messages. |
| Fields inherited from class ecologylab.services.distributed.impl.NIOCore |
|---|
portNumber, selector |
| Fields inherited from interface ecologylab.services.distributed.common.NetworkingConstants |
|---|
CHARACTER_ENCODING, CONTENT_LENGTH_STRING, CONTENT_LENGTH_STRING_LENGTH, DECODER, ENCODER, HTTP_HEADER_LINE_DELIMITER, HTTP_HEADER_TERMINATOR, MAX_HTTP_HEADER_LENGTH, MAX_PACKET_SIZE_BYTES, MAX_PACKET_SIZE_CHARACTERS, UNIQUE_IDENTIFIER_STRING |
| Constructor Summary | |
|---|---|
protected |
NIONetworking(java.lang.String networkIdentifier,
int portNumber,
TranslationSpace translationSpace,
Scope<?> objectRegistry)
Creates a Services Server Base. |
| Method Summary | |
|---|---|
protected abstract void |
acceptKey(java.nio.channels.SelectionKey key)
Optional operation. |
java.nio.ByteBuffer |
acquireByteBufferFromPool()
Retrieves a ByteBuffer object from this's pool of ByteBuffers. |
protected void |
connectionTerminated()
Remove the argument passed in from the set of connections we know about. |
void |
enqueueBytesForWriting(java.nio.channels.SelectionKey socketKey,
java.nio.ByteBuffer data)
Queue up bytes to send on a particular socket. |
protected abstract void |
processReadData(java.lang.Object sessionId,
java.nio.channels.SelectionKey sk,
java.nio.ByteBuffer bytes,
int bytesRead)
This method is called whenever bytes have been read from a socket. |
protected void |
readReady(java.nio.channels.SelectionKey key)
|
protected void |
terminationAction()
This defines the actions that server needs to perform when the client ends unexpected way. |
protected void |
writeKey(java.nio.channels.SelectionKey key)
Writes the bytes from pendingWrites that belong to key. |
protected void |
writeReady(java.nio.channels.SelectionKey key)
|
| Methods inherited from class ecologylab.services.distributed.impl.NIOCore |
|---|
acceptFinished, acceptReady, checkAndDropIdleKeys, close, connectFinished, connectReady, getPortNumber, invalidateKey, invalidateKey, queueForAccept, queueForConnect, queueForRead, queueForWrite, readFinished, removeBadConnections, run, setPendingInvalidate, start, stop, writeFinished |
| Methods inherited from class ecologylab.generic.Debug |
|---|
classSimpleName, closeLoggingFile, debug, debug, debug, debug, debugA, debugA, debugA, debugI, debugI, debugI, error, error, getClassName, getClassName, getInteractive, getPackageName, getPackageName, getPackageName, initialize, level, level, level, logToFile, print, print, println, println, println, println, println, println, printlnA, printlnA, printlnA, printlnI, printlnI, printlnI, printlnI, setLoggingFile, show, show, superString, toggleInteractive, toString, toString, warning, warning, weird, weird |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected boolean shuttingDown
protected TranslationSpace translationSpace
protected Scope<?> objectRegistry
protected int connectionCount
protected ByteBufferPool byteBufferPool
| Constructor Detail |
|---|
protected NIONetworking(java.lang.String networkIdentifier,
int portNumber,
TranslationSpace translationSpace,
Scope<?> objectRegistry)
throws java.io.IOException
portNumber - the port number to use for communicating.translationSpace - the TranslationSpace to use for incoming messages; if this is null, uses DefaultServicesTranslations
instead.objectRegistry - Provides a context for request processing; if this is null, creates a new ObjectRegistry.
java.io.IOException - if an I/O error occurs while trying to open a Selector from the system.| Method Detail |
|---|
protected void readReady(java.nio.channels.SelectionKey key)
throws ClientOfflineException,
BadClientException
readReady in class NIOCoreClientOfflineException
BadClientExceptionNIOCore.readReady(java.nio.channels.SelectionKey)
protected void writeReady(java.nio.channels.SelectionKey key)
throws java.io.IOException
writeReady in class NIOCorejava.io.IOExceptionNIOCore.writeReady(java.nio.channels.SelectionKey)
public void enqueueBytesForWriting(java.nio.channels.SelectionKey socketKey,
java.nio.ByteBuffer data)
socketKey - data -
protected void writeKey(java.nio.channels.SelectionKey key)
throws java.io.IOException
key -
java.io.IOExceptionprotected abstract void acceptKey(java.nio.channels.SelectionKey key)
key -
javax.naming.OperationNotSupportedExceptionprotected void connectionTerminated()
protected abstract void processReadData(java.lang.Object sessionId,
java.nio.channels.SelectionKey sk,
java.nio.ByteBuffer bytes,
int bytesRead)
throws BadClientException
sessionId - the id being use for this session.sc - the SocketChannel from which the bytes originated.bytes - the bytes read from the SocketChannel.bytesRead - the number of bytes in the bytes array.
BadClientException - if the client from which the bytes were read has transmitted something inappropriate, such as data too
large for a buffer or a possibly malicious message.protected void terminationAction()
public java.nio.ByteBuffer acquireByteBufferFromPool()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||