Class ServiceInstance<T>

java.lang.Object
org.apache.curator.x.discovery.ServiceInstance<T>

public class ServiceInstance<T> extends Object
POJO that represents a service instance
  • Constructor Details

    • ServiceInstance

      public ServiceInstance(String name, String id, String address, Integer port, Integer sslPort, T payload, long registrationTimeUTC, ServiceType serviceType, UriSpec uriSpec)
      Parameters:
      name - name of the service
      id - id of this instance (must be unique)
      address - address of this instance
      port - the port for this instance or null
      sslPort - the SSL port for this instance or null
      payload - the payload for this instance or null
      registrationTimeUTC - the time (in UTC) of the registration
      serviceType - type of the service
      uriSpec - the uri spec or null
    • ServiceInstance

      public ServiceInstance(String name, String id, String address, Integer port, Integer sslPort, T payload, long registrationTimeUTC, ServiceType serviceType, UriSpec uriSpec, boolean enabled)
      IMPORTANT: Due to CURATOR-275 the enabled field is NOT supported by default. If you wish to use the enabled field, you must set a InstanceSerializer that serializes this field. The default serializer, JsonInstanceSerializer does not serialize the field by default. You must use the alternate constructor JsonInstanceSerializer(Class, boolean) passing false for compatibleSerializationMode.
      Parameters:
      name - name of the service
      id - id of this instance (must be unique)
      address - address of this instance
      port - the port for this instance or null
      sslPort - the SSL port for this instance or null
      payload - the payload for this instance or null
      registrationTimeUTC - the time (in UTC) of the registration
      serviceType - type of the service
      uriSpec - the uri spec or null
      enabled - true if the instance should be considered enabled
  • Method Details

    • builder

      public static <T> ServiceInstanceBuilder<T> builder() throws Exception
      Return a new builder. The address is set to the ip of the first NIC in the system. The id is set to a random UUID.
      Returns:
      builder
      Throws:
      Exception - errors getting the local IP
    • getName

      public String getName()
    • getId

      public String getId()
    • getAddress

      public String getAddress()
    • getPort

      public Integer getPort()
    • getSslPort

      public Integer getSslPort()
    • getPayload

      public T getPayload()
    • getRegistrationTimeUTC

      public long getRegistrationTimeUTC()
    • getServiceType

      public ServiceType getServiceType()
    • getUriSpec

      public UriSpec getUriSpec()
    • isEnabled

      public boolean isEnabled()
      IMPORTANT: Due to CURATOR-275 the enabled field is NOT supported by default. If you wish to use the enabled field, you must set a InstanceSerializer that serializes this field. The default serializer, JsonInstanceSerializer does not serialize the field by default. You must use the alternate constructor JsonInstanceSerializer(Class, boolean) passing false for compatibleSerializationMode.
      Returns:
      true/false
    • buildUriSpec

      public String buildUriSpec()
    • buildUriSpec

      public String buildUriSpec(Map<String,Object> variables)
    • 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