Class ResourceId

java.lang.Object
dev.getelements.elements.sdk.cluster.id.ResourceId
All Implemented Interfaces:
HasNodeId, Serializable, Comparable<dev.getelements.elements.sdk.cluster.id.HasCompoundId<dev.getelements.elements.sdk.cluster.id.V1CompoundId>>

public class ResourceId extends Object implements Serializable, HasNodeId
Represents the globally unique ID for a particular resource. This is currently backed by an instance of UUID, but the string representation should be considered opaque by users of this type. Though the ResourceId is may be globally represented by a single UUID, for addressment we represent a ResourceId as a 3-tuple of UUIDs: (InstanceUuid, ApplicationUuid, ResourceUuid), i.e. Resource r is belongs to Application a on Instance i. The first two elements of the tuple are represented in the code by a NodeId owned by a ResourceId object, and the latter element would be held in a direct UUID object by the ResourceId object. For now, a ResourceId should at all times have exactly both the NodeId and ResourceUuid assigned and non-null. By convention, we may represent the ResourceId as a compound Id string, combining the string representation of the NodeId with the string representation of the resource UUID, separated by the ID_SEPARATOR. Such a string will take the form "{instance_uuid}.{app_uuid}+{resource_uuid}". Created by patricktwohig on 4/11/17.
See Also:
  • Method Details

    • asBytes

      public byte[] asBytes()
      Returns the byte[] representation of this ResourceId
      Returns:
      the string representation
    • asString

      public String asString()
      Returns the string representation of this ResourceId
      Returns:
      the string representation
    • toByteBuffer

      public void toByteBuffer(ByteBuffer byteBuffer)
      Writes this ResourceId to the supplied ByteBuffer.
      Parameters:
      byteBuffer - the ByteBuffer to receive the ResourceId
    • toByteBuffer

      public void toByteBuffer(ByteBuffer byteBuffer, int position)
      Writes this ResourceId to a ByteBuffer at the supplied position. As the position is specified, this does not affect the buffer's mark, limit, position.
      Parameters:
      byteBuffer - the byteBuffer to receive the NodeId
      position - the position at which to write the byte buffer
    • getId

      public dev.getelements.elements.sdk.cluster.id.V1CompoundId getId()
    • getNodeId

      public NodeId getNodeId()
      Returns the NodeId assocaited with this ResourceId.
      Specified by:
      getNodeId in interface HasNodeId
      Returns:
      the NodeId
    • getInstanceId

      public InstanceId getInstanceId()
      Returns the InstanceId.
      Returns:
      the InstanceId assocaited with this ResourceId
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • valueOf

      public static ResourceId valueOf(String value)
      The Java standard valueOf method.
      Parameters:
      value - the value
      Returns:
      the ResourceId
    • getSizeInBytes

      public static int getSizeInBytes()
      Returns the number of bytes when a ResourceId is stored as a
      invalid reference
      byte[]
      Returns:
      the size, in bytes
    • randomResourceId

      public static ResourceId randomResourceId()
      Creates a new unique ResourceId, with a random NodeId. Essentially, this creates an anonymous ResourceId that will never match an actual Resource in the cluster. This is useful for making placeholder values to represent "null" in caches or other instances.
    • randomResourceIdForNode

      public static ResourceId randomResourceIdForNode(NodeId nodeId)
      Creates a new unique ResourceId, specifying the NodeId
    • resourceIdFromString

      public static ResourceId resourceIdFromString(String stringRepresentation)
      Parses a new ResourceId from the given String. The should be the string representation returned byt asString().
      Parameters:
      stringRepresentation - the String representation of the ResourceId from asString().
    • resourceIdFromBytes

      public static ResourceId resourceIdFromBytes(byte[] byteRepresentation)
      Parses a new ResourceId from the given
      invalid reference
      byte[]
      . The should be the string representation returned byt asBytes().
      Parameters:
      byteRepresentation - the
      invalid reference
      byte[]
      representation of the ResourceId from asBytes().
    • resourceIdFromByteBuffer

      public static ResourceId resourceIdFromByteBuffer(ByteBuffer byteBufferRepresentation)
      Parses a new ResourceId from the given ByteBuffer. The should be the string representation returned by asBytes().
      Parameters:
      byteBufferRepresentation - the ByteBuffer representation of the ResourceId from asBytes().
    • resourceIdFromByteBuffer

      public static ResourceId resourceIdFromByteBuffer(ByteBuffer byteBufferRepresentation, int byteBufferPosition)
      Reads a ResourceId from the supplied ByteBuffer and position, ensuring that the buffer's mark, limit, and position are unaffected.
      Parameters:
      byteBufferRepresentation - the byte buffer to read
      byteBufferPosition - the position of the node id within the byte buffer
      Returns:
      the ResourceId instance
    • compareTo

      default int compareTo(dev.getelements.elements.sdk.cluster.id.HasCompoundId<dev.getelements.elements.sdk.cluster.id.V1CompoundId> o)
      Compares this instance with the other instance.
      Specified by:
      compareTo in interface Comparable<CompoundIdT extends Comparable<CompoundIdT>>
      Parameters:
      o - the instance
      Returns: