public class MultiNodeConnectionIdGenerator extends Object implements NodeConnectionIdGenerator
| Constructor and Description |
|---|
MultiNodeConnectionIdGenerator(int nodeId,
int connectionIdLength)
Create new connection id generator for multiple nodes.
|
| Modifier and Type | Method and Description |
|---|---|
ConnectionId |
createConnectionId()
Creates a connection id.
|
int |
getNodeId()
Get node ID of generator.
|
int |
getNodeId(ConnectionId cid)
Get node ID encoded in cid.
|
ConnectionId |
read(org.eclipse.californium.elements.util.DatagramReader reader)
Read connection id from record header bytes.
|
boolean |
useConnectionId()
Indicates, if connection ids are used or just supported.
|
public MultiNodeConnectionIdGenerator(int nodeId,
int connectionIdLength)
nodeId - node id of this node. The lowest byte must be unique in the
cluster, to ensure, that other nodes of the cluster don't
generate the same connection id.connectionIdLength - length of connection idIllegalArgumentException - if length is less than 2 bytespublic boolean useConnectionId()
ConnectionIdGeneratoruseConnectionId in interface ConnectionIdGeneratortrue, if a connection is used, false, if only a
connection id from the other peer is supported.public ConnectionId createConnectionId()
nodeId into the first byte of the connection id.createConnectionId in interface ConnectionIdGeneratornull, if this generator only
supports connection ids from the other peer.public ConnectionId read(org.eclipse.californium.elements.util.DatagramReader reader)
null, if nodeId doesn't match the first byte of
the connection id.read in interface ConnectionIdGeneratorreader - reader with header bytes at the position of the connection
id.null, if this generator only
supports connection ids from the other peer.public int getNodeId()
NodeConnectionIdGeneratorgetNodeId in interface NodeConnectionIdGeneratorpublic int getNodeId(ConnectionId cid)
NodeConnectionIdGeneratorgetNodeId in interface NodeConnectionIdGeneratorcid - cidCopyright © 2023 Eclipse Foundation. All rights reserved.