|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.glassfish.grizzly.AbstractWriter<SocketAddress>
org.glassfish.grizzly.nio.AbstractNIOAsyncQueueWriter
public abstract class AbstractNIOAsyncQueueWriter
The AsyncQueueWriter implementation, based on the Java NIO
| Field Summary | |
|---|---|
protected int |
maxPendingBytes
|
protected int |
maxWriteReenterants
|
protected NIOTransport |
transport
|
| Constructor Summary | |
|---|---|
AbstractNIOAsyncQueueWriter(NIOTransport transport)
|
|
| Method Summary | |
|---|---|
boolean |
canWrite(Connection connection,
int size)
|
void |
close()
Close AsyncQueueProcessor and release associated resources |
protected AsyncWriteQueueRecord |
createRecord(Connection connection,
Buffer message,
Future<WriteResult<Buffer,SocketAddress>> future,
WriteResult<Buffer,SocketAddress> currentResult,
CompletionHandler<WriteResult<Buffer,SocketAddress>> completionHandler,
Interceptor<WriteResult<Buffer,SocketAddress>> interceptor,
SocketAddress dstAddress,
Buffer outputBuffer,
boolean isCloned,
boolean isEmptyRecord)
|
protected void |
failWriteRecord(AsyncWriteQueueRecord record,
Throwable e)
|
int |
getMaxPendingBytesPerConnection()
|
int |
getMaxWriteReenterants()
Returns the maximum number of write() method reenterants a thread is allowed to made. |
boolean |
isReady(Connection connection)
Checks whether there is ready data in AsyncQueue,
associated with the Connection. |
void |
onClose(Connection connection)
Callback method, which is called, when Connection has been closed,
to let processor release a connection associated resources. |
protected abstract void |
onReadyToWrite(Connection connection)
|
protected void |
onWriteComplete(AsyncWriteQueueRecord record)
|
protected void |
onWriteFailure(Connection connection,
AsyncWriteQueueRecord failedRecord,
IOException e)
|
protected void |
onWriteIncomplete(AsyncWriteQueueRecord record)
|
void |
processAsync(Connection connection)
Callback method, which is called async. |
void |
setMaxPendingBytesPerConnection(int maxPendingBytes)
Configures the maximum number of bytes pending to be written for a particular Connection. |
void |
setMaxWriteReenterants(int maxWriteReenterants)
Sets the maximum number of write() method reenterants a thread is allowed to made. |
GrizzlyFuture<WriteResult<Buffer,SocketAddress>> |
write(Connection connection,
SocketAddress dstAddress,
Buffer buffer,
CompletionHandler<WriteResult<Buffer,SocketAddress>> completionHandler,
Interceptor<WriteResult<Buffer,SocketAddress>> interceptor)
Method writes the buffer to the specific address. |
GrizzlyFuture<WriteResult<Buffer,SocketAddress>> |
write(Connection connection,
SocketAddress dstAddress,
Buffer buffer,
CompletionHandler<WriteResult<Buffer,SocketAddress>> completionHandler,
Interceptor<WriteResult<Buffer,SocketAddress>> interceptor,
MessageCloner<Buffer> cloner)
Method writes the Buffer to the specific address. |
protected abstract int |
write0(NIOConnection connection,
AsyncWriteQueueRecord queueRecord)
|
| Methods inherited from class org.glassfish.grizzly.AbstractWriter |
|---|
write, write, write, write |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface org.glassfish.grizzly.Writer |
|---|
write, write, write, write |
| Field Detail |
|---|
protected final NIOTransport transport
protected volatile int maxPendingBytes
protected volatile int maxWriteReenterants
| Constructor Detail |
|---|
public AbstractNIOAsyncQueueWriter(NIOTransport transport)
| Method Detail |
|---|
public boolean canWrite(Connection connection,
int size)
canWrite in interface AsyncQueueWriter<SocketAddress>connection - the Connection to test whether or not the
specified number of bytes can be written to.size - number of bytes to write.
true if the queue has not exceeded it's maximum
size in bytes of pending writes, otherwise falsepublic void setMaxPendingBytesPerConnection(int maxPendingBytes)
Connection.
setMaxPendingBytesPerConnection in interface AsyncQueueWriter<SocketAddress>maxPendingBytes - maximum number of pending writes that may be
queued for a particular Connectionpublic int getMaxPendingBytesPerConnection()
getMaxPendingBytesPerConnection in interface AsyncQueueWriter<SocketAddress>Connection.public int getMaxWriteReenterants()
getMaxWriteReenterants in interface AsyncQueueWriter<SocketAddress>public void setMaxWriteReenterants(int maxWriteReenterants)
setMaxWriteReenterants in interface AsyncQueueWriter<SocketAddress>maxWriteReenterants - the maximum number of write() method
reenterants a thread is allowed to made.
public GrizzlyFuture<WriteResult<Buffer,SocketAddress>> write(Connection connection,
SocketAddress dstAddress,
Buffer buffer,
CompletionHandler<WriteResult<Buffer,SocketAddress>> completionHandler,
Interceptor<WriteResult<Buffer,SocketAddress>> interceptor)
throws IOException
Writer
write in interface Writer<SocketAddress>connection - the Connection to write todstAddress - the destination address the buffer will be
sent tobuffer - the buffer, from which the data will be writtencompletionHandler - CompletionHandler,
which will get notified, when write will be completedinterceptor - Interceptor, which will be able to intercept
control each time new portion of a data was written from a
buffer.
The interceptor can decide, whether asynchronous write is
completed or not, or provide other processing instructions.
Future, using which it's possible to check the
result
IOException
public GrizzlyFuture<WriteResult<Buffer,SocketAddress>> write(Connection connection,
SocketAddress dstAddress,
Buffer buffer,
CompletionHandler<WriteResult<Buffer,SocketAddress>> completionHandler,
Interceptor<WriteResult<Buffer,SocketAddress>> interceptor,
MessageCloner<Buffer> cloner)
throws IOException
Buffer to the specific address.
write in interface AsyncQueueWriter<SocketAddress>connection - the Connection to write todstAddress - the destination address the message will be
sent tobuffer - the Buffer from which the data will be writtencompletionHandler - CompletionHandler,
which will get notified, when write will be completedinterceptor - Interceptor, which will be able to intercept
control each time new portion of a data was written from a
buffer.
The interceptor can decide, whether asynchronous write is
completed or not, or provide other processing instructions.cloner - MessageCloner, which will be invoked by
AsyncQueueWriter, if message could not be written to a
channel directly and has to be put on a asynchronous queue
Future, using which it's possible to check the
result
IOException
protected AsyncWriteQueueRecord createRecord(Connection connection,
Buffer message,
Future<WriteResult<Buffer,SocketAddress>> future,
WriteResult<Buffer,SocketAddress> currentResult,
CompletionHandler<WriteResult<Buffer,SocketAddress>> completionHandler,
Interceptor<WriteResult<Buffer,SocketAddress>> interceptor,
SocketAddress dstAddress,
Buffer outputBuffer,
boolean isCloned,
boolean isEmptyRecord)
public final boolean isReady(Connection connection)
AsyncQueue,
associated with the Connection.
isReady in interface AsyncQueueconnection - Connection
public void processAsync(Connection connection)
throws IOException
AsyncQueue, which are associated with the given
Connection
processAsync in interface AsyncQueueconnection - Connection
IOExceptionpublic void onClose(Connection connection)
Connection has been closed,
to let processor release a connection associated resources.
onClose in interface AsyncQueueconnection - Connectionpublic final void close()
close in interface AsyncQueue
protected final void onWriteComplete(AsyncWriteQueueRecord record)
throws IOException
IOException
protected final void onWriteIncomplete(AsyncWriteQueueRecord record)
throws IOException
IOException
protected final void onWriteFailure(Connection connection,
AsyncWriteQueueRecord failedRecord,
IOException e)
protected final void failWriteRecord(AsyncWriteQueueRecord record,
Throwable e)
protected abstract int write0(NIOConnection connection,
AsyncWriteQueueRecord queueRecord)
throws IOException
IOException
protected abstract void onReadyToWrite(Connection connection)
throws IOException
IOException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||