Class ServiceInstance<T>


  • public class ServiceInstance<T>
    extends java.lang.Object
    POJO that represents a service instance
    • Constructor Detail

      • ServiceInstance

        public ServiceInstance​(java.lang.String name,
                               java.lang.String id,
                               java.lang.String address,
                               java.lang.Integer port,
                               java.lang.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​(java.lang.String name,
                               java.lang.String id,
                               java.lang.String address,
                               java.lang.Integer port,
                               java.lang.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 Detail

      • builder

        public static <T> ServiceInstanceBuilder<T> builder()
                                                     throws java.lang.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:
        java.lang.Exception - errors getting the local IP
      • getName

        public java.lang.String getName()
      • getId

        public java.lang.String getId()
      • getAddress

        public java.lang.String getAddress()
      • getPort

        public java.lang.Integer getPort()
      • getSslPort

        public java.lang.Integer getSslPort()
      • getPayload

        public T getPayload()
      • getRegistrationTimeUTC

        public long getRegistrationTimeUTC()
      • 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 java.lang.String buildUriSpec()
      • buildUriSpec

        public java.lang.String buildUriSpec​(java.util.Map<java.lang.String,​java.lang.Object> variables)
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

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

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object