Class NodeIdentity
A list of former identities is retained to aid in migrating from the former identity to the new identity.
Currently the storageIdentity is a randomly generated UUID, that is also used for backwards compatibility with JMRI 4.14. If we find a reliable cross-platform mechanism to tie that to the machine's unique identity (from the CPU or motherboard), not from a NIC, this may change. If a JMRI 4.14 generated UUID is available, it is retained and used as the storageIdentity.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final StringA string of 64 URL compatible characters. -
Method Summary
Modifier and TypeMethodDescriptionIf network hardware on a node was replaced, the identity will change.static StringReturn the node's current network identity.static StringReturn the node's current storage identity for the active profile.static StringstorageIdentity(Profile profile) Return the node's current storage identity.protected static UUIDuuidFromCompactString(String compact) Decodes the original UUID from a 22 character string generated byuuidToCompactString.protected static StringuuidToCompactString(UUID uuid) Encodes a UUID into a 22 character URL compatible string.
-
Field Details
-
URL_SAFE_CHARACTERS
A string of 64 URL compatible characters.Used by
uuidToCompactStringanduuidFromCompactString.- See Also:
-
-
Method Details
-
networkIdentity
Return the node's current network identity. For historical purposes, the network identity is also referred to as the node or node identity.- Returns:
- A network identity. If this identity is not in the form
jmri-MACADDRESS-profileId, or ifMACADDRESSis a multicast MAC address, this identity should be considered unreliable and subject to change across JMRI restarts. Note that if the identity is in the formjmri-MACADDRESSthe JMRI instance has not loaded a configuration profile, and the network identity will change once that a configuration profile is loaded.
-
storageIdentity
Return the node's current storage identity for the active profile. This is a convenience method that callsstorageIdentity(Profile)with the result ofProfileManager.getActiveProfile().- Returns:
- A storage identity.
- See Also:
-
storageIdentity
Return the node's current storage identity. This can be used in networked file systems to ensure per-computer storage is available.Note this only ensure uniqueness if the preferences path is not shared between multiple computers as documented in
FileUtil.getPreferencesPath()(the most common cause of this would be sharing a user's home directory in its entirety between two computers with similar operating systems as noted in getPreferencesPath()).- Parameters:
profile- The profile to get the identity for. This is only needed to check that the identity should not be in an older format.- Returns:
- A storage identity. If this identity is not in the form of a UUID
or
jmri-UUID-profileId, this identity should be considered unreliable and subject to change across JMRI restarts. When generating a new storage ID, the form is always a UUID and other forms are used only to ensure continuity where other forms may have been used in the past.
-
formerIdentities
If network hardware on a node was replaced, the identity will change.- Returns:
- A list of other identities this node may have had in the past.
-
uuidToCompactString
Encodes a UUID into a 22 character URL compatible string. This is used to store the UUID in a manner compatible with JMRI 4.14.From an example by Tom Lobato.
- Parameters:
uuid- the UUID to encode- Returns:
- the 22 character string
-
uuidFromCompactString
Decodes the original UUID from a 22 character string generated byuuidToCompactString. This is used to store the UUID in a manner compatible with JMRI 4.14.- Parameters:
compact- the 22 character string- Returns:
- the original UUID
-
getFormerIdentities
- Returns:
- the former identities; this is a combination of former network and storage identities
-