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

public Class UDPNIOConnection

extends NIOConnection
Class Inheritance
Known Direct Subclasses
org.glassfish.grizzly.nio.transport.UDPNIOServerConnection
Annotations
@SuppressWarnings:unchecked
Imports
java.io.IOException, java.net.InetAddress, .NetworkInterface, .SocketAddress, java.nio.channels.DatagramChannel, .MembershipKey, .SelectionKey, java.util.HashMap, .HashSet, .Iterator, .Map, .Set, java.util.function.Supplier, java.util.logging.Level, .Logger, org.glassfish.grizzly.Buffer, .ConnectionProbe, .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 UDPNIOTransport
Author
Alexey Stashok

Field Summary

Modifier and TypeField and Description
pack-priv Holder<SocketAddress>
private static final Logger
private Map<InetAddress, Set<MembershipKey>>
private final Object
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 void
block(final InetAddress
The multicast address to join
group
,
final NetworkInterface
The network interface on which to join the group
networkInterface
,
final InetAddress
The source address to block
source
)

Blocks multicast datagrams from the given source address.

public boolean
public boolean
canWrite(int length)

Implements org.glassfish.grizzly.OutputSink.canWrite.

Deprecated

public void
drop(final InetAddress
The multicast address to join
group
,
final NetworkInterface
The network interface on which to join the group
networkInterface
)

Drops non-source specific membership in a multicast group.

public void
drop(final InetAddress
The multicast address to join
group
,
final NetworkInterface
The network interface on which to join the group
networkInterface
,
final InetAddress
The source address
source
)

Drops membership in a multicast group.

public void
dropAll(final InetAddress
The multicast address to join
group
,
final NetworkInterface
The network interface on which to join the group
networkInterface
)

Drops all active membership in a multicast group.

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 boolean
public void
join(final InetAddress
The multicast address to join
group
,
final NetworkInterface
The network interface on which to join the group
networkInterface
)

Joins a multicast group to begin receiving all datagrams sent to the group.

public void
join(final InetAddress
The multicast address to join
group
,
final NetworkInterface
The network interface on which to join the group
networkInterface
,
final InetAddress
The source address
source
)

Joins a multicast group to begin receiving datagrams sent to the group from a given source address.

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, int size)

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

protected final void
pack-priv void
setMonitoringProbes(final ConnectionProbe[] monitoringProbes)

Hides org.glassfish.grizzly.nio.NIOConnection.setMonitoringProbes.

Set the monitoringProbes array directly.

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.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

public void
unblock(final InetAddress
The multicast address to join
group
,
final NetworkInterface
The network interface on which to join the group
networkInterface
,
final InetAddress
The source address to block
source
)

Unblocks multicast datagrams from the given source address.

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

Field Detail

localSocketAddressHolderback to summary
pack-priv Holder<SocketAddress> localSocketAddressHolder
LOGGERback to summary
private static final Logger LOGGER

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

membershipKeysMapback to summary
private Map<InetAddress, Set<MembershipKey>> membershipKeysMap
multicastSyncback to summary
private final Object multicastSync
peerSocketAddressHolderback to summary
pack-priv Holder<SocketAddress> peerSocketAddressHolder
readBufferSizeback to summary
private int readBufferSize
writeBufferSizeback to summary
private int writeBufferSize

Constructor Detail

UDPNIOConnectionback to summary
public UDPNIOConnection(UDPNIOTransport transport, DatagramChannel channel)

Method Detail

blockback to summary
public void block(final InetAddress group, final NetworkInterface networkInterface, final InetAddress source) throws IOException

Blocks multicast datagrams from the given source address. If this connection has non-source specific membership in the group on the given interface then this method blocks multicast datagrams from the given source address. If the given source address is already blocked then this method has no effect.

Parameters
group:InetAddress

The multicast address to join

networkInterface:NetworkInterface

The network interface on which to join the group

source:InetAddress

The source address to block

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
dropback to summary
public void drop(final InetAddress group, final NetworkInterface networkInterface) throws IOException

Drops non-source specific membership in a multicast group. If this connection doesn't have non-source specific membership in the group on the given interface to receive datagrams then this method call has no effect. Otherwise this connection drops the group membership.

Parameters
group:InetAddress

The multicast address to join

networkInterface:NetworkInterface

The network interface on which to join the group

dropback to summary
public void drop(final InetAddress group, final NetworkInterface networkInterface, final InetAddress source) throws IOException

Drops membership in a multicast group. If the source parameter is null - this method call is equivalent to drop(java.net.InetAddress, java.net.NetworkInterface). If the source parameter is not null and this connection doesn't have source specific membership in the group on the given interface to receive datagrams then this method call has no effect. Otherwise this connection drops the source specific group membership.

Parameters
group:InetAddress

The multicast address to join

networkInterface:NetworkInterface

The network interface on which to join the group

source:InetAddress

The source address

dropAllback to summary
public void dropAll(final InetAddress group, final NetworkInterface networkInterface) throws IOException

Drops all active membership in a multicast group. If this connection doesn't have any type of membership in the group on the given interface to receive datagrams then this method call has no effect. Otherwise this connection drops all types of the group membership.

Parameters
group:InetAddress

The multicast address to join

networkInterface:NetworkInterface

The network interface on which to join the group

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
isConnectedback to summary
public boolean isConnected()
joinback to summary
public void join(final InetAddress group, final NetworkInterface networkInterface) throws IOException

Joins a multicast group to begin receiving all datagrams sent to the group. If this connection is currently a member of the group on the given interface to receive all datagrams then this method call has no effect. Otherwise this connection joins the requested group and channel's membership in not source-specific. A multicast connection may join several multicast groups, including the same group on more than one interface. An implementation may impose a limit on the number of groups that may be joined at the same time.

Parameters
group:InetAddress

The multicast address to join

networkInterface:NetworkInterface

The network interface on which to join the group

joinback to summary
public void join(final InetAddress group, final NetworkInterface networkInterface, final InetAddress source) throws IOException

Joins a multicast group to begin receiving datagrams sent to the group from a given source address. If this connection is currently a member of the group on the given interface to receive datagrams from the given source address then this method call has no effect. Otherwise this connection joins the group and depending on the source parameter value (whether it's not null or null value) the connection's membership is or is not source-specific. Membership is cumulative and this method may be invoked again with the same group and interface to allow receiving datagrams sent by other source addresses to the group.

Parameters
group:InetAddress

The multicast address to join

networkInterface:NetworkInterface

The network interface on which to join the group

source:InetAddress

The source address

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, int size)

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

resetPropertiesback to summary
protected final void resetProperties()
setMonitoringProbesback to summary
pack-priv void setMonitoringProbes(final ConnectionProbe[] monitoringProbes)

Hides org.glassfish.grizzly.nio.NIOConnection.setMonitoringProbes.

Set the monitoringProbes array directly.

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
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
unblockback to summary
public void unblock(final InetAddress group, final NetworkInterface networkInterface, final InetAddress source) throws IOException

Unblocks multicast datagrams from the given source address. If this connection has non-source specific membership in the group on the given interface and specified source address was previously blocked using block(java.net.InetAddress, java.net.NetworkInterface, java.net.InetAddress) method then this method unblocks multicast datagrams from the given source address. If the given source address wasn't blocked then this method has no effect.

Parameters
group:InetAddress

The multicast address to join

networkInterface:NetworkInterface

The network interface on which to join the group

source:InetAddress

The source address to block