Top Description Fields Constructors Methods
org.glassfish.grizzly.nio

public abstract Class AbstractNIOAsyncQueueWriter

extends AbstractWriter<SocketAddress>
implements AsyncQueueWriter<SocketAddress>
Class Inheritance
All Implemented Interfaces
org.glassfish.grizzly.asyncqueue.AsyncQueueWriter, org.glassfish.grizzly.asyncqueue.AsyncQueue, org.glassfish.grizzly.Writer
Known Direct Subclasses
org.glassfish.grizzly.nio.transport.TCPNIOAsyncQueueWriter, org.glassfish.grizzly.nio.transport.UDPNIOAsyncQueueWriter
Annotations
@SuppressWarnings:unchecked, deprecation
Imports
java.io.IOException, java.net.SocketAddress, java.util.logging.Level, .Logger, org.glassfish.grizzly.AbstractWriter, .CompletionHandler, .Connection, .Context, .Grizzly, .IOEvent, .WriteHandler, .WriteResult, org.glassfish.grizzly.asyncqueue.AsyncQueueWriter, .AsyncWriteQueueRecord, .MessageCloner, .PushBackHandler, .RecordWriteResult, .TaskQueue, .WritableMessage

The AsyncQueueWriter implementation, based on the Java NIO
Authors
Alexey Stashok, Ryan Lubke, Gustav Trede

Field Summary

Modifier and TypeField and Description
private volatile boolean
private static final Logger
protected volatile int
protected volatile int
protected final NIOTransport

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected AsyncWriteQueueRecord
aggregate(final TaskQueue<AsyncWriteQueueRecord> connectionQueue)

Aggregates records in a queue to be written as one chunk.

public boolean
canWrite(final Connection<SocketAddress> connection, final int size)

Implements org.glassfish.grizzly.asyncqueue.AsyncQueueWriter.canWrite.

Deprecated

public boolean
canWrite(final Connection<SocketAddress> connection)

Implements org.glassfish.grizzly.Writer.canWrite.

Return true if the connection has not exceeded it's maximum size in bytes of pending writes, otherwise false.

private static WritableMessage
cloneRecordIfNeeded(final Connection<L> connection, final MessageCloner<WritableMessage> cloner, final WritableMessage message)

public final void
close()

Implements org.glassfish.grizzly.asyncqueue.AsyncQueue.close.

Close AsyncQueueProcessor and release associated resources

protected AsyncWriteQueueRecord
createRecord(final Connection<L> connection, final WritableMessage message, final CompletionHandler<WriteResult<WritableMessage, SocketAddress>> completionHandler, final SocketAddress dstAddress, final PushBackHandler pushBackHandler, final boolean isUncountable)
References Deprecated PushBackHandler is deprecated or references (maybe indirectly) at least one deprecated element.

private static void
doFineLog(final String msg, final Object... params)

private static void
finishQueueRecord(final NIOConnection nioConnection, final AsyncWriteQueueRecord queueRecord)

public int
public boolean
isAllowDirectWrite()

Implements org.glassfish.grizzly.asyncqueue.AsyncQueueWriter.isAllowDirectWrite.

Returns true, if async write queue is allowed to write buffer directly during write(...) method call, w/o adding buffer to the queue, or false otherwise.

public final boolean
isReady(final Connection<L> connection)

Implements org.glassfish.grizzly.asyncqueue.AsyncQueue.isReady.

Checks whether there is ready data in AsyncQueue, associated with the Connection.

public void
notifyWritePossible(final Connection<SocketAddress> connection, final WriteHandler writeHandler, final int size)

Implements org.glassfish.grizzly.asyncqueue.AsyncQueueWriter.notifyWritePossible.

Deprecated

Registers WriteHandler, which will be notified ones the Connection is able to accept more bytes to be written.

public void
notifyWritePossible(final Connection<SocketAddress> connection, final WriteHandler writeHandler)

Implements org.glassfish.grizzly.Writer.notifyWritePossible.

Registers WriteHandler, which will be notified ones at least one byte can be written.

public void
onClose(final Connection<L> connection)

Implements org.glassfish.grizzly.asyncqueue.AsyncQueue.onClose.

Callback method, which is called, when Connection has been closed, to let processor release a connection associated resources.

protected abstract void
protected static void
onWriteFailure(final Connection<L> connection, final AsyncWriteQueueRecord failedRecord, final Throwable e)

public AsyncQueue.AsyncResult
processAsync(final Context context)

Implements org.glassfish.grizzly.asyncqueue.AsyncQueue.processAsync.

Callback method, which is called async.

public void
setAllowDirectWrite(final boolean isAllowDirectWrite)

Implements org.glassfish.grizzly.asyncqueue.AsyncQueueWriter.setAllowDirectWrite.

Set true, if async write queue is allowed to write buffer directly during write(...) method call, w/o adding buffer to the queue, or false otherwise.

public void
setMaxPendingBytesPerConnection(final int maxPendingBytes)

Implements org.glassfish.grizzly.asyncqueue.AsyncQueueWriter.setMaxPendingBytesPerConnection.

Configures the maximum number of bytes pending to be written for a particular Connection.

public void
write(final Connection<SocketAddress> connection, final SocketAddress dstAddress, final WritableMessage message, final CompletionHandler<WriteResult<WritableMessage, SocketAddress>> completionHandler, final MessageCloner<WritableMessage> cloner)

Implements org.glassfish.grizzly.Writer.write.

Method writes the WritableMessage to the specific address.

public void
write(final Connection<SocketAddress> connection, SocketAddress dstAddress, final WritableMessage message, final CompletionHandler<WriteResult<WritableMessage, SocketAddress>> completionHandler, final PushBackHandler pushBackHandler)

Implements org.glassfish.grizzly.Writer.write.

Deprecated

Method writes the WritableMessage to the specific address.

public void
write(final Connection<SocketAddress> connection, final SocketAddress dstAddress, final WritableMessage message, final CompletionHandler<WriteResult<WritableMessage, SocketAddress>> completionHandler, final PushBackHandler pushBackHandler, final MessageCloner<WritableMessage> cloner)

Implements org.glassfish.grizzly.asyncqueue.AsyncQueueWriter.write.

Deprecated

Method writes the Buffer to the specific address.

protected abstract RecordWriteResult<K, L>
write0(NIOConnection connection, AsyncWriteQueueRecord queueRecord)

Inherited from org.glassfish.grizzly.AbstractWriter:
writewritewritewrite

Field Detail

isAllowDirectWriteback to summary
private volatile boolean isAllowDirectWrite
LOGGERback to summary
private static final Logger LOGGER
maxPendingBytesback to summary
protected volatile int maxPendingBytes
maxWriteReentrantsback to summary
protected volatile int maxWriteReentrants
transportback to summary
protected final NIOTransport transport

Constructor Detail

AbstractNIOAsyncQueueWriterback to summary
public AbstractNIOAsyncQueueWriter(NIOTransport transport)

Method Detail

aggregateback to summary
protected AsyncWriteQueueRecord aggregate(final TaskQueue<AsyncWriteQueueRecord> connectionQueue)

Aggregates records in a queue to be written as one chunk.

canWriteback to summary
public boolean canWrite(final Connection<SocketAddress> connection, final int size)

Implements org.glassfish.grizzly.asyncqueue.AsyncQueueWriter.canWrite.

Deprecated

Annotations
@Deprecated
@Override
canWriteback to summary
public boolean canWrite(final Connection<SocketAddress> connection)

Implements org.glassfish.grizzly.Writer.canWrite.

Doc from org.glassfish.grizzly.Writer.canWrite.

Return true if the connection has not exceeded it's maximum size in bytes of pending writes, otherwise false.

Annotations
@Override
cloneRecordIfNeededback to summary
private static WritableMessage cloneRecordIfNeeded(final Connection<L> connection, final MessageCloner<WritableMessage> cloner, final WritableMessage message)
closeback to summary
public final void close()

Implements org.glassfish.grizzly.asyncqueue.AsyncQueue.close.

Doc from org.glassfish.grizzly.asyncqueue.AsyncQueue.close.

Close AsyncQueueProcessor and release associated resources

Annotations
@Override
createRecordback to summary
protected AsyncWriteQueueRecord createRecord(final Connection<L> connection, final WritableMessage message, final CompletionHandler<WriteResult<WritableMessage, SocketAddress>> completionHandler, final SocketAddress dstAddress, final PushBackHandler pushBackHandler, final boolean isUncountable)

References Deprecated

PushBackHandler is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

doFineLogback to summary
private static void doFineLog(final String msg, final Object... params)
finishQueueRecordback to summary
private static void finishQueueRecord(final NIOConnection nioConnection, final AsyncWriteQueueRecord queueRecord)
getMaxPendingBytesPerConnectionback to summary
public int getMaxPendingBytesPerConnection()

Implements org.glassfish.grizzly.asyncqueue.AsyncQueueWriter.getMaxPendingBytesPerConnection.

Annotations
@Override
isAllowDirectWriteback to summary
public boolean isAllowDirectWrite()

Implements org.glassfish.grizzly.asyncqueue.AsyncQueueWriter.isAllowDirectWrite.

Doc from org.glassfish.grizzly.asyncqueue.AsyncQueueWriter.isAllowDirectWrite.

Returns true, if async write queue is allowed to write buffer directly during write(...) method call, w/o adding buffer to the queue, or false otherwise.

Annotations
@Override
isReadyback to summary
public final boolean isReady(final Connection<L> connection)

Implements org.glassfish.grizzly.asyncqueue.AsyncQueue.isReady.

Doc from org.glassfish.grizzly.asyncqueue.AsyncQueue.isReady.

Checks whether there is ready data in AsyncQueue, associated with the Connection.

Annotations
@Override
notifyWritePossibleback to summary
public void notifyWritePossible(final Connection<SocketAddress> connection, final WriteHandler writeHandler, final int size)

Implements org.glassfish.grizzly.asyncqueue.AsyncQueueWriter.notifyWritePossible.

Doc from org.glassfish.grizzly.asyncqueue.AsyncQueueWriter.notifyWritePossible.

Deprecated

Registers WriteHandler, which will be notified ones the Connection is able to accept more bytes to be written.

Note

using this method from different threads simultaneously may lead to quick situation changes, so at time WriteHandler is called - the queue may become busy again.

Annotations
@Deprecated
@Override
notifyWritePossibleback to summary
public void notifyWritePossible(final Connection<SocketAddress> connection, final WriteHandler writeHandler)

Implements org.glassfish.grizzly.Writer.notifyWritePossible.

Doc from org.glassfish.grizzly.Writer.notifyWritePossible.

Registers WriteHandler, which will be notified ones at least one byte can be written. This method call is equivalent to call notifyWritePossible(connection, writeHandler, 1); Note: using this method from different threads simultaneously may lead to quick situation changes, so at time WriteHandler is called - the queue may become busy again.

Annotations
@Override
onCloseback to summary
public void onClose(final Connection<L> connection)

Implements org.glassfish.grizzly.asyncqueue.AsyncQueue.onClose.

Doc from org.glassfish.grizzly.asyncqueue.AsyncQueue.onClose.

Callback method, which is called, when Connection has been closed, to let processor release a connection associated resources.

Annotations
@Override
onReadyToWriteback to summary
protected abstract void onReadyToWrite(NIOConnection connection) throws IOException
onWriteFailureback to summary
protected static void onWriteFailure(final Connection<L> connection, final AsyncWriteQueueRecord failedRecord, final Throwable e)
processAsyncback to summary
public AsyncQueue.AsyncResult processAsync(final Context context)

Implements org.glassfish.grizzly.asyncqueue.AsyncQueue.processAsync.

Doc from org.glassfish.grizzly.asyncqueue.AsyncQueue.processAsync.

Callback method, which is called async. to process ready AsyncQueue, which are associated with the given Connection

Annotations
@Override
setAllowDirectWriteback to summary
public void setAllowDirectWrite(final boolean isAllowDirectWrite)

Implements org.glassfish.grizzly.asyncqueue.AsyncQueueWriter.setAllowDirectWrite.

Doc from org.glassfish.grizzly.asyncqueue.AsyncQueueWriter.setAllowDirectWrite.

Set true, if async write queue is allowed to write buffer directly during write(...) method call, w/o adding buffer to the queue, or false otherwise.

Annotations
@Override
setMaxPendingBytesPerConnectionback to summary
public void setMaxPendingBytesPerConnection(final int maxPendingBytes)

Implements org.glassfish.grizzly.asyncqueue.AsyncQueueWriter.setMaxPendingBytesPerConnection.

Doc from org.glassfish.grizzly.asyncqueue.AsyncQueueWriter.setMaxPendingBytesPerConnection.

Configures the maximum number of bytes pending to be written for a particular Connection.

Annotations
@Override
writeback to summary
public void write(final Connection<SocketAddress> connection, final SocketAddress dstAddress, final WritableMessage message, final CompletionHandler<WriteResult<WritableMessage, SocketAddress>> completionHandler, final MessageCloner<WritableMessage> cloner)

Implements org.glassfish.grizzly.Writer.write.

Doc from org.glassfish.grizzly.Writer.write.

Method writes the WritableMessage to the specific address.

Annotations
@Override
writeback to summary
public void write(final Connection<SocketAddress> connection, SocketAddress dstAddress, final WritableMessage message, final CompletionHandler<WriteResult<WritableMessage, SocketAddress>> completionHandler, final PushBackHandler pushBackHandler)

Implements org.glassfish.grizzly.Writer.write.

Doc from org.glassfish.grizzly.Writer.write.

Deprecated

Method writes the WritableMessage to the specific address.

Annotations
@Override
@Deprecated
writeback to summary
public void write(final Connection<SocketAddress> connection, final SocketAddress dstAddress, final WritableMessage message, final CompletionHandler<WriteResult<WritableMessage, SocketAddress>> completionHandler, final PushBackHandler pushBackHandler, final MessageCloner<WritableMessage> cloner)

Implements org.glassfish.grizzly.asyncqueue.AsyncQueueWriter.write.

Doc from org.glassfish.grizzly.asyncqueue.AsyncQueueWriter.write.

Deprecated

Method writes the Buffer to the specific address.

Annotations
@Override
@Deprecated
write0back to summary
protected abstract RecordWriteResult<K, L> write0(NIOConnection connection, AsyncWriteQueueRecord queueRecord) throws IOException