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

public Class TCPNIOConnection

extends NIOConnection
Class Inheritance
Known Direct Subclasses
org.glassfish.grizzly.nio.transport.TCPNIOServerConnection
Annotations
@SuppressWarnings:unchecked
Imports
java.io.IOException, java.net.SocketAddress, java.nio.channels.SelectableChannel, .SelectionKey, .SocketChannel, java.util.concurrent.atomic.AtomicReference, java.util.function.Supplier, java.util.logging.Level, .Logger, org.glassfish.grizzly.Buffer, .CloseReason, .Closeable, .CompletionHandler, .Connection, .Grizzly, .WriteHandler, org.glassfish.grizzly.asyncqueue.AsyncQueueWriter, org.glassfish.grizzly.localization.LogMessages, org.glassfish.grizzly.nio.NIOConnection, .SelectorRunner, org.glassfish.grizzly.utils.Holder

org.glassfish.grizzly.Connection implementation for the TCPNIOTransport
Author
Alexey Stashok

Nested and Inner Type Summary

Modifier and TypeClass and Description
protected static interface
TCPNIOConnection.ConnectResultHandler

This interface implementations can be used to be notified about the TCPNIOConnection connect state.

Field Summary

Modifier and TypeField and Description
private AtomicReference<TCPNIOConnection.ConnectResultHandler>
pack-priv Holder<SocketAddress>
private static final Logger
pack-priv Holder<SocketAddress>
private int
private int
Inherited from org.glassfish.grizzly.nio.NIOConnection:
attributeschannelconnectCloseSemaphoreUpdaterisBlockingisStandalonemaxAsyncWriteQueueSizemonitoringConfigNOTIFICATION_CLOSED_COMPLETENOTIFICATION_INITIALIZEDprocessorprocessorSelectorreadTimeoutMillisselectionKeyselectorRunnertransportwriteTimeoutMilliszeroByteReadCount

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public boolean
public boolean
canWrite(int length)

Implements org.glassfish.grizzly.OutputSink.canWrite.

Deprecated

protected final void
checkConnectFailed(Throwable failure)

Method will be called in order to check if failure happened before Connection was reported as connected.

protected void
enableInitialOpRead()

Overrides org.glassfish.grizzly.nio.NIOConnection.enableInitialOpRead.

Enables OP_READ if it has never been enabled before.

public SocketAddress

Returns:

the local address of this Connection, or null if it is unconnected.
getLocalAddress
()

Implements org.glassfish.grizzly.Connection.getLocalAddress.

Returns the local address of this Connection, or null if it is unconnected.

public SocketAddress

Returns:

the address of the endpoint this Connection is connected to, or null if it is unconnected.
getPeerAddress
()

Implements org.glassfish.grizzly.Connection.getPeerAddress.

Returns the address of the endpoint this Connection is connected to, or null if it is unconnected.

public int
getReadBufferSize()

Implements org.glassfish.grizzly.Connection.getReadBufferSize.

Get the default size of Buffers, which will be allocated for reading data from Connection.

public int
getWriteBufferSize()

Implements org.glassfish.grizzly.Connection.getWriteBufferSize.

Get the default size of Buffers, which will be allocated for writing data to Connection.

public void
notifyCanWrite(final WriteHandler writeHandler)

Implements org.glassfish.grizzly.OutputSink.notifyCanWrite.

Instructs the OutputSink to invoke the provided WriteHandler when it is possible to write more bytes (or characters).

public void
notifyCanWrite(WriteHandler handler, int length)

Implements org.glassfish.grizzly.OutputSink.notifyCanWrite.

Deprecated

Instructs the OutputSink to invoke the provided WriteHandler when it is possible to write length bytes (or characters).

protected boolean
protected final void
onConnect()

Method will be called, when the connection gets connected.

protected final void
onRead(Buffer data, int size)

Method will be called, when some data was read on the connection

protected final void
onWrite(Buffer data, long size)

Method will be called, when some data was written on the connection

protected void
protected void
protected final void
public void
setReadBufferSize(final int readBufferSize)

Implements org.glassfish.grizzly.Connection.setReadBufferSize.

Set the default size of Buffers, which will be allocated for reading data from Connection.

protected void
protected void
public void
setWriteBufferSize(int writeBufferSize)

Implements org.glassfish.grizzly.Connection.setWriteBufferSize.

Set the default size of Buffers, which will be allocated for writing data to Connection.

protected void
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from org.glassfish.grizzly.nio.NIOConnection:
addCloseListeneraddCloseListenerassertOpenattachToSelectorRunnercheckEmptyReadcloseclosecloseFuturecloseGracefully0closeSilentlycloseWithReasonconfigureBlockingconfigureStandalonedetachSelectorRunnerdisableIOEventdoCloseenableIOEventexecuteInEventThreadgetAsyncReadQueuegetAsyncWriteQueuegetAttributesgetChannelgetCloseReasongetIdgetMaxAsyncWriteQueueSizegetMemoryManagergetMonitoringConfiggetProcessorgetProcessorSelectorgetReadTimeoutgetSelectionKeygetSelectorRunnergetTransportgetWriteTimeoutisBlockingisClosedisOpenisStandalonenotifyConnectionErrornotifyIOEventDisablednotifyIOEventEnablednotifyIOEventReadynotifyProbesAcceptnotifyProbesBindnotifyProbesClosenotifyProbesConnectnotifyProbesErrornotifyProbesReadnotifyProbesWriteobtainProcessorobtainProcessorStatereadreadremoveCloseListenerremoveCloseListenersetChannelsetMaxAsyncWriteQueueSizesetProcessorsetProcessorSelectorsetReadTimeoutsetWriteTimeoutsimulateIOEventterminateterminateSilentlyterminateWithReasonwritewritewritewritewrite

Field Detail

connectHandlerRefback to summary
private AtomicReference<TCPNIOConnection.ConnectResultHandler> connectHandlerRef
localSocketAddressHolderback to summary
pack-priv Holder<SocketAddress> localSocketAddressHolder
LOGGERback to summary
private static final Logger LOGGER

Hides org.glassfish.grizzly.nio.NIOConnection.LOGGER.

peerSocketAddressHolderback to summary
pack-priv Holder<SocketAddress> peerSocketAddressHolder
readBufferSizeback to summary
private int readBufferSize
writeBufferSizeback to summary
private int writeBufferSize

Constructor Detail

TCPNIOConnectionback to summary
public TCPNIOConnection(TCPNIOTransport transport, SelectableChannel channel)

Method Detail

canWriteback to summary
public boolean canWrite()

Implements org.glassfish.grizzly.OutputSink.canWrite.

Annotations
@Override
canWriteback to summary
public boolean canWrite(int length)

Implements org.glassfish.grizzly.OutputSink.canWrite.

Deprecated

Annotations
@Deprecated
@Override
checkConnectFailedback to summary
protected final void checkConnectFailed(Throwable failure)

Method will be called in order to check if failure happened before Connection was reported as connected.

enableInitialOpReadback to summary
protected void enableInitialOpRead() throws IOException

Overrides org.glassfish.grizzly.nio.NIOConnection.enableInitialOpRead.

Doc from org.glassfish.grizzly.nio.NIOConnection.enableInitialOpRead.

Enables OP_READ if it has never been enabled before.

Annotations
@Override
getLocalAddressback to summary
public SocketAddress getLocalAddress()

Implements org.glassfish.grizzly.Connection.getLocalAddress.

Returns the local address of this Connection, or null if it is unconnected.

Returns:SocketAddress

the local address of this Connection, or null if it is unconnected.

Annotations
@Override
getPeerAddressback to summary
public SocketAddress getPeerAddress()

Implements org.glassfish.grizzly.Connection.getPeerAddress.

Returns the address of the endpoint this Connection is connected to, or null if it is unconnected.

Returns:SocketAddress

the address of the endpoint this Connection is connected to, or null if it is unconnected.

Annotations
@Override
getReadBufferSizeback to summary
public int getReadBufferSize()

Implements org.glassfish.grizzly.Connection.getReadBufferSize.

Doc from org.glassfish.grizzly.Connection.getReadBufferSize.

Get the default size of Buffers, which will be allocated for reading data from Connection. The value less or equal to zero will be ignored.

Annotations
@Override
getWriteBufferSizeback to summary
public int getWriteBufferSize()

Implements org.glassfish.grizzly.Connection.getWriteBufferSize.

Doc from org.glassfish.grizzly.Connection.getWriteBufferSize.

Get the default size of Buffers, which will be allocated for writing data to Connection.

Annotations
@Override
notifyCanWriteback to summary
public void notifyCanWrite(final WriteHandler writeHandler)

Implements org.glassfish.grizzly.OutputSink.notifyCanWrite.

Doc from org.glassfish.grizzly.OutputSink.notifyCanWrite.

Instructs the OutputSink to invoke the provided WriteHandler when it is possible to write more bytes (or characters). Note that once the WriteHandler has been notified, it will not be considered for notification again at a later point in time.

Annotations
@Override
notifyCanWriteback to summary
public void notifyCanWrite(WriteHandler handler, int length)

Implements org.glassfish.grizzly.OutputSink.notifyCanWrite.

Doc from org.glassfish.grizzly.OutputSink.notifyCanWrite.

Deprecated

Instructs the OutputSink to invoke the provided WriteHandler when it is possible to write length bytes (or characters). Note that once the WriteHandler has been notified, it will not be considered for notification again at a later point in time.

Annotations
@Deprecated
@Override
notifyReadyback to summary
protected boolean notifyReady()
onConnectback to summary
protected final void onConnect() throws IOException

Method will be called, when the connection gets connected.

onReadback to summary
protected final void onRead(Buffer data, int size)

Method will be called, when some data was read on the connection

onWriteback to summary
protected final void onWrite(Buffer data, long size)

Method will be called, when some data was written on the connection

preCloseback to summary
protected void preClose()

Overrides org.glassfish.grizzly.nio.NIOConnection.preClose.

Annotations
@Override
resetPropertiesback to summary
protected void resetProperties()
setConnectResultHandlerback to summary
protected final void setConnectResultHandler(final TCPNIOConnection.ConnectResultHandler connectHandler)
setReadBufferSizeback to summary
public void setReadBufferSize(final int readBufferSize)

Implements org.glassfish.grizzly.Connection.setReadBufferSize.

Doc from org.glassfish.grizzly.Connection.setReadBufferSize.

Set the default size of Buffers, which will be allocated for reading data from Connection. The value less or equal to zero will be ignored.

Annotations
@Override
setSelectionKeyback to summary
protected void setSelectionKey(SelectionKey selectionKey)

Overrides org.glassfish.grizzly.nio.NIOConnection.setSelectionKey.

Annotations
@Override
setSelectorRunnerback to summary
protected void setSelectorRunner(SelectorRunner selectorRunner)

Overrides org.glassfish.grizzly.nio.NIOConnection.setSelectorRunner.

Annotations
@Override
setWriteBufferSizeback to summary
public void setWriteBufferSize(int writeBufferSize)

Implements org.glassfish.grizzly.Connection.setWriteBufferSize.

Doc from org.glassfish.grizzly.Connection.setWriteBufferSize.

Set the default size of Buffers, which will be allocated for writing data to Connection.

Annotations
@Override
terminate0back to summary
protected void terminate0(final CompletionHandler<Closeable> completionHandler, final CloseReason closeReason)

Overrides org.glassfish.grizzly.nio.NIOConnection.terminate0.

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Annotations
@Override
org.glassfish.grizzly.nio.transport back to summary

protected Interface TCPNIOConnection.ConnectResultHandler


This interface implementations can be used to be notified about the TCPNIOConnection connect state.

Method Summary

Modifier and TypeMethod and Description
public void
public void
failed(final Throwable t)

Method Detail

connectedback to summary
public void connected() throws IOException
failedback to summary
public void failed(final Throwable t)