|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.glassfish.grizzly.AbstractWriter<java.net.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 |
maxWriteReentrants
|
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,
java.util.concurrent.Future<WriteResult<Buffer,java.net.SocketAddress>> future,
WriteResult<Buffer,java.net.SocketAddress> currentResult,
CompletionHandler<WriteResult<Buffer,java.net.SocketAddress>> completionHandler,
java.net.SocketAddress dstAddress,
boolean isEmptyRecord)
|
protected static void |
failWriteRecord(AsyncWriteQueueRecord record,
java.lang.Throwable e)
|
int |
getMaxPendingBytesPerConnection()
|
int |
getMaxWriteReentrants()
Returns the maximum number of write() method reentrants 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 static void |
onWriteComplete(AsyncWriteQueueRecord record)
|
protected static void |
onWriteFailure(Connection connection,
AsyncWriteQueueRecord failedRecord,
java.io.IOException e)
|
protected void |
onWriteIncomplete(AsyncWriteQueueRecord record)
|
boolean |
processAsync(Context context)
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 |
setMaxWriteReentrants(int maxWriteReentrants)
Sets the maximum number of write() method reentrants a thread is allowed to made. |
GrizzlyFuture<WriteResult<Buffer,java.net.SocketAddress>> |
write(Connection connection,
java.net.SocketAddress dstAddress,
Buffer buffer,
CompletionHandler<WriteResult<Buffer,java.net.SocketAddress>> completionHandler,
Interceptor<WriteResult<Buffer,java.net.SocketAddress>> interceptor)
Method writes the buffer to the specific address. |
GrizzlyFuture<WriteResult<Buffer,java.net.SocketAddress>> |
write(Connection connection,
java.net.SocketAddress dstAddress,
Buffer buffer,
CompletionHandler<WriteResult<Buffer,java.net.SocketAddress>> completionHandler,
Interceptor<WriteResult<Buffer,java.net.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 maxWriteReentrants
| Constructor Detail |
|---|
public AbstractNIOAsyncQueueWriter(NIOTransport transport)
| Method Detail |
|---|
public boolean canWrite(Connection connection,
int size)
canWrite in interface AsyncQueueWriter<java.net.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<java.net.SocketAddress>maxPendingBytes - maximum number of bytes that may be pending to be
written to a particular Connection.public int getMaxPendingBytesPerConnection()
getMaxPendingBytesPerConnection in interface AsyncQueueWriter<java.net.SocketAddress>Connection.public int getMaxWriteReentrants()
getMaxWriteReentrants in interface AsyncQueueWriter<java.net.SocketAddress>public void setMaxWriteReentrants(int maxWriteReentrants)
setMaxWriteReentrants in interface AsyncQueueWriter<java.net.SocketAddress>maxWriteReentrants - the maximum number of write() method calls
a thread is allowed to make.
public GrizzlyFuture<WriteResult<Buffer,java.net.SocketAddress>> write(Connection connection,
java.net.SocketAddress dstAddress,
Buffer buffer,
CompletionHandler<WriteResult<Buffer,java.net.SocketAddress>> completionHandler,
Interceptor<WriteResult<Buffer,java.net.SocketAddress>> interceptor)
throws java.io.IOException
Writer
write in interface Writer<java.net.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
java.io.IOException
public GrizzlyFuture<WriteResult<Buffer,java.net.SocketAddress>> write(Connection connection,
java.net.SocketAddress dstAddress,
Buffer buffer,
CompletionHandler<WriteResult<Buffer,java.net.SocketAddress>> completionHandler,
Interceptor<WriteResult<Buffer,java.net.SocketAddress>> interceptor,
MessageCloner<Buffer> cloner)
throws java.io.IOException
Buffer to the specific address.
write in interface AsyncQueueWriter<java.net.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
java.io.IOException
protected AsyncWriteQueueRecord createRecord(Connection connection,
Buffer message,
java.util.concurrent.Future<WriteResult<Buffer,java.net.SocketAddress>> future,
WriteResult<Buffer,java.net.SocketAddress> currentResult,
CompletionHandler<WriteResult<Buffer,java.net.SocketAddress>> completionHandler,
java.net.SocketAddress dstAddress,
boolean isEmptyRecord)
public final boolean isReady(Connection connection)
AsyncQueue,
associated with the Connection.
isReady in interface AsyncQueueconnection - Connection
public boolean processAsync(Context context)
throws java.io.IOException
AsyncQueue, which are associated with the given
Connection
processAsync in interface AsyncQueuecontext - Context
java.io.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 static void onWriteComplete(AsyncWriteQueueRecord record)
throws java.io.IOException
java.io.IOException
protected final void onWriteIncomplete(AsyncWriteQueueRecord record)
throws java.io.IOException
java.io.IOException
protected static void onWriteFailure(Connection connection,
AsyncWriteQueueRecord failedRecord,
java.io.IOException e)
protected static void failWriteRecord(AsyncWriteQueueRecord record,
java.lang.Throwable e)
protected abstract int write0(NIOConnection connection,
AsyncWriteQueueRecord queueRecord)
throws java.io.IOException
java.io.IOException
protected abstract void onReadyToWrite(Connection connection)
throws java.io.IOException
java.io.IOException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||