IDs

The ID

IDs in D1 are usually of type IId.

We decided to use flexible IDs for D1. Therefore, the ID can consist of one of the following types:

  • an integer (in the stream: 4 bytes)
  • a string (in the stream: variable, UTF-8)
  • an UUID (in the stream: 16+1 bytes)

The distinction is made by a 1-byte header. Empty or invalid IDs simply have no data.

This makes us flexible, while keeping overhead low.

  • If highest performance is required, numerical IDs are used.
  • If readability comes first, take the string.
  • The UUID is suitable for unmistakability and unique APIs.

The ID may be extended later by other types. This is easily done by registering another IIdFactory at the CIdFactory:

CIdFactory.registerFactory(aFactory);

The CIdFactory is also used to generate the IDs. “Random” IDs are created like this:

// wird einfach inkrementiert
IId id1 = CIdFactory.create(EIdType.INT);

// ist eine UUID als String
IId id2 = CIdFactory.create(EIdType.STRING);

// ist eine UUID
IId id3 = CIdFactory.create(EIdType.UUID);

// leere ID
IId id4 = CIdFactory.create(EIdType.EMPTY);

For the creation of an ID with a specific type, another method is used:

IId id1 = CIdFactory.create(EIdType.INT, 15);
IId id2 = CIdFactory.create(EIdType.STRING, "SYSTEM");
IId id3 = CIdFactory.create(EIdType.UUID, "e87092d7-2f74-4d7b-9eef-8bdd7789b049");

If only the object is available and the type is not of interest, proceed as follows:

IId id1 = CIdFactory.create(object);

The system first checks whether the object is zero (–>EMPTY). If this is not the case, an attempt is made to create an ID using the registered ID factories. If nothing works at all, the conversion results in a string ID using object.toString().

The CIdFactory is also good for a number of I/O methods. Thus IId objects from streams and strings are read and written in again.

There are also a number of methods for IId` arrays:

  • Reading from and writing to streams
  • Reading from and writing to strings
  • Reading from and writing to string arrays
  • Reading from and writing to string lists
  • Creating random arrays
  • Comparison Methods

The Target ID (TID)

The target ID is unique for a target within a namespace. The same TID can exist again in other namespaces.

When registering targets, a “random” ID is generated if no ID is given. A numerical ID is generated for this purpose. This is usually okay, because target IDs do not have to “speak”. For log files, there are other ways of connecting TIDs to name strings. (TODO: Link NameDb)

For frequently used TIDs there is the class CWellKnownTID, which defines a set of string IDs for known targets.

Target objects can easily be found via the ITargetRegistry of each namespace.

The Namespace ID (NID)

The namespace ID is unique for a namespace within a D1 NODE. String IDs are usually used here for better readability of target addresses.

The NODE ID (INodeID)

The NODE ID is not as variable as the other IDs and consists of only one UUID.

It is the ID of a D1 NODE and therefore unique.

(TODO: URL, Link) D1

The Target-Address

The target address is the address at which a message can reach a target. The position of the target is completely described with this address in a D1 network.

The address consists of three components:

In JAVA, the address is represented by its interface ITargetAddress, as well as the class CTargetAddress. The latter is not public; for instantiation there is the factory CTargetAddressFactory.