OpenDDS
Snapshot(2023/04/28-20:55)
|
Create RepoId values for use within DDS. More...
#include <RepoIdGenerator.h>
Public Member Functions | |
RepoIdGenerator (long federation, long participant=0, EntityKind kind=KIND_PARTICIPANT) | |
construct with at least a FederationId value. More... | |
virtual | ~RepoIdGenerator () |
GUID_t | next (bool builtin=false) |
Obtain the next GUID_t value. More... | |
void | last (long key) |
Static Public Attributes | |
static const unsigned int | KeyBits = 24 |
static const unsigned int | KeyMask = (1 << KeyBits) - 1 |
Private Attributes | |
EntityKind | kind_ |
Type of Entity to generate GUID values for. More... | |
long | federation_ |
Unique identifier for the repository. More... | |
long | participant_ |
Unique identifier for the DomainParticipant. More... | |
long | lastKey_ |
Unique value for the EntityKey. More... | |
Create RepoId values for use within DDS.
Internal to the OpenDDS repository, the Repository Identifiers that uniquely identify all DDS Entities within the service managed by this (and other federated) repositories consist of GUID values.
These GUID (Global Unique IDentifiers) values are based on the RTPS specification (formal/08-04-09) GUID_t values. They use the same structure. The VendorId value is applied in the first 2 bytes of the prefix. The remainder of the Participant Id value is composed of the OpenDDS specific Federation Id value (the identifier of the repository where the Entity was created) and a DomainParticipant identifier within that repository. In addition to the standard EntityKind values, the EntityKind byte has an added value of ENTITYKIND_OPENDDS_TOPIC allowed to permit the use of GUID values for Topic entities as well. This is an OpenDDS specific extension.
The EntityKey field is used to distinguish Topics, Publications and Subscriptions within a single Participant. Each of these is within its own number (address) space. The EntityKind byte will ensure that identical EntityKey values of these different types will not conflict in the final GUID value.
Values are generated using the specified FederationId and DomainParticipant identifiers. The EntityKey for a type is incremented each time a value is generated.
The ability to reset the last used value is provided to allow the reloading of Entities from persistent storage without inducing conflicts with newly created Entities. This is a simplistic mechanism and requires that all information from the persistent storage be processed prior to any new Entities being created within the repository. After this processing is complete, the last used value should be reset to ensure that any new values will not conflict with the restored values.
NOTE: This mechanism does not work well for values that have wrapped around the 24 bit EntityKey space. It is possible to extend the current mapping to overflow into the two '0' bytes (2 and 3) with the Key value number (address) space to increase the possible unique identifiers if this becomes an issue. Doing that would alleviate the need to manage an arena of Key values.
Even though each Domain could have a separate GUID (address) space, since we do not currently include the domain value within the GUID mapping, all domains within a repository will use the same generator instance to ensure no conflicting GUID values. This will restrict the total number of DomainParticipants within all domains of a repository to be within the 32 bit (2**32) DomainParticipant address space. It is likely that other limits will be exceeded before this one is approached.
The current mapping of meanings to the GUID component values is:
Content: | VendorId| 0 | 0 | FederationId | DomainParticpant | EntityKey |Kind| GUID_t bytes: | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | GuidPrefix_t GUID_t.guidPrefix bytes: | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | EntityId_t GUID_t.entityId bytes: | 0 | 1 | 2 | 3 | EntityKey_t GUID_t.entityId.entityKey bytes: | 0 | 1 | 2 |
Where the VendorId value used for OpenDDS is defined in GuidUtils.h
Definition at line 92 of file RepoIdGenerator.h.
OpenDDS::DCPS::RepoIdGenerator::RepoIdGenerator | ( | long | federation, |
long | participant = 0 , |
||
EntityKind | kind = KIND_PARTICIPANT |
||
) |
construct with at least a FederationId value.
federation | identifier for the repository. |
participant | identifier for the participant. |
kind | type of Entities to generate Id values for. |
If the kind
is KIND_PARTICIPANT then the generator will generate Participant RepoId values. Otherwise it will generate the specified type of Entity values within the specified Participant.
Definition at line 22 of file RepoIdGenerator.cpp.
|
virtual |
Definition at line 30 of file RepoIdGenerator.cpp.
void OpenDDS::DCPS::RepoIdGenerator::last | ( | long | key | ) |
Set the minimum of the last key (or participant) value used.
key | the smallest value that the last generated key can be |
If the supplied key
value is larger than the actual last generated key value, the new key value replaces the old one.
Definition at line 82 of file RepoIdGenerator.cpp.
References lastKey_, and OPENDDS_END_VERSIONED_NAMESPACE_DECL.
Referenced by DCPS_IR_Domain::last_participant_key(), DCPS_IR_Participant::last_publication_key(), DCPS_IR_Participant::last_subscription_key(), DCPS_IR_Participant::last_topic_key(), and TAO_DDS_DCPSInfo_i::receive_image().
GUID_t OpenDDS::DCPS::RepoIdGenerator::next | ( | bool | builtin = false | ) |
Obtain the next GUID_t value.
Definition at line 35 of file RepoIdGenerator.cpp.
References ACE_ERROR, ACE_TEXT(), OpenDDS::DCPS::GuidBuilder::entityId(), OpenDDS::DCPS::ENTITYID_PARTICIPANT, OpenDDS::DCPS::GuidBuilder::entityKey(), OpenDDS::DCPS::GuidBuilder::entityKind(), federation_, OpenDDS::DCPS::RepoIdBuilder::federationId(), KeyMask, kind_, OpenDDS::DCPS::KIND_PARTICIPANT, lastKey_, LM_ERROR, participant_, and OpenDDS::DCPS::RepoIdBuilder::participantId().
Referenced by DCPS_IR_Domain::get_next_participant_id(), DCPS_IR_Participant::get_next_publication_id(), DCPS_IR_Participant::get_next_subscription_id(), and DCPS_IR_Participant::get_next_topic_id().
|
private |
Unique identifier for the repository.
Definition at line 135 of file RepoIdGenerator.h.
Referenced by next().
|
static |
Definition at line 94 of file RepoIdGenerator.h.
|
static |
Definition at line 96 of file RepoIdGenerator.h.
Referenced by next().
|
private |
Type of Entity to generate GUID values for.
Definition at line 132 of file RepoIdGenerator.h.
Referenced by next().
|
private |
Unique value for the EntityKey.
Definition at line 141 of file RepoIdGenerator.h.
|
private |
Unique identifier for the DomainParticipant.
Definition at line 138 of file RepoIdGenerator.h.
Referenced by next().