Class ServiceRecord

java.lang.Object
org.apache.hadoop.registry.client.types.ServiceRecord
All Implemented Interfaces:
Cloneable

@Public @Evolving public class ServiceRecord extends Object implements Cloneable
JSON-marshallable description of a single component. It supports the deserialization of unknown attributes, but does not support their creation.
  • Field Details

    • RECORD_TYPE

      public static final String RECORD_TYPE
      A type string which MUST be in the serialized json. This permits fast discarding of invalid entries
      See Also:
    • type

      public String type
      The type field. This must be the string RECORD_TYPE
    • description

      public String description
      Description string
    • external

      public List<Endpoint> external
      List of endpoints intended for use to external callers
    • internal

      public List<Endpoint> internal
      List of endpoints for use within an application.
  • Constructor Details

    • ServiceRecord

      public ServiceRecord()
      Create a service record with no ID, description or registration time. Endpoint lists are set to empty lists.
    • ServiceRecord

      public ServiceRecord(ServiceRecord that)
      Deep cloning constructor
      Parameters:
      that - service record source
  • Method Details

    • addExternalEndpoint

      public void addExternalEndpoint(Endpoint endpoint)
      Add an external endpoint
      Parameters:
      endpoint - endpoint to set
    • addInternalEndpoint

      public void addInternalEndpoint(Endpoint endpoint)
      Add an internal endpoint
      Parameters:
      endpoint - endpoint to set
    • getInternalEndpoint

      public Endpoint getInternalEndpoint(String api)
      Look up an internal endpoint
      Parameters:
      api - API
      Returns:
      the endpoint or null if there was no match
    • getExternalEndpoint

      public Endpoint getExternalEndpoint(String api)
      Look up an external endpoint
      Parameters:
      api - API
      Returns:
      the endpoint or null if there was no match
    • set

      public void set(String key, Object value)
      Handle unknown attributes by storing them in the attributes map
      Parameters:
      key - attribute name
      value - attribute value.
    • attributes

      public Map<String,String> attributes()
      The map of "other" attributes set when parsing. These are not included in the JSON value of this record when it is generated.
      Returns:
      a map of any unknown attributes in the deserialized JSON.
    • get

      public String get(String key)
      Get the "other" attribute with a specific key
      Parameters:
      key - key to look up
      Returns:
      the value or null
    • get

      public String get(String key, String defVal)
      Get the "other" attribute with a specific key.
      Parameters:
      key - key to look up
      defVal - default value
      Returns:
      the value as a string, or defval if the value was not present
    • toString

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

      protected Object clone() throws CloneNotSupportedException
      Shallow clone: all endpoints will be shared across instances
      Overrides:
      clone in class Object
      Returns:
      a clone of the instance
      Throws:
      CloneNotSupportedException
    • hashCode

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

      public boolean equals(Object obj)
      Overrides:
      equals in class Object