Package org.apache.curator.x.discovery
Class ServiceInstance<T>
- java.lang.Object
-
- org.apache.curator.x.discovery.ServiceInstance<T>
-
public class ServiceInstance<T> extends java.lang.Object
POJO that represents a service instance
-
-
Constructor Summary
Constructors Constructor Description 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)
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 theenabled
field is NOT supported by default.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <T> ServiceInstanceBuilder<T>
builder()
Return a new builder.java.lang.String
buildUriSpec()
java.lang.String
buildUriSpec(java.util.Map<java.lang.String,java.lang.Object> variables)
boolean
equals(java.lang.Object o)
java.lang.String
getAddress()
java.lang.String
getId()
java.lang.String
getName()
T
getPayload()
java.lang.Integer
getPort()
long
getRegistrationTimeUTC()
ServiceType
getServiceType()
java.lang.Integer
getSslPort()
UriSpec
getUriSpec()
int
hashCode()
boolean
isEnabled()
IMPORTANT: Due to CURATOR-275 theenabled
field is NOT supported by default.java.lang.String
toString()
-
-
-
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 serviceid
- id of this instance (must be unique)address
- address of this instanceport
- the port for this instance or nullsslPort
- the SSL port for this instance or nullpayload
- the payload for this instance or nullregistrationTimeUTC
- the time (in UTC) of the registrationserviceType
- type of the serviceuriSpec
- 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 theenabled
field is NOT supported by default. If you wish to use the enabled field, you must set aInstanceSerializer
that serializes this field. The default serializer,JsonInstanceSerializer
does not serialize the field by default. You must use the alternate constructorJsonInstanceSerializer(Class, boolean)
passing false forcompatibleSerializationMode
.- Parameters:
name
- name of the serviceid
- id of this instance (must be unique)address
- address of this instanceport
- the port for this instance or nullsslPort
- the SSL port for this instance or nullpayload
- the payload for this instance or nullregistrationTimeUTC
- the time (in UTC) of the registrationserviceType
- type of the serviceuriSpec
- the uri spec or nullenabled
- 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. Theaddress
is set to the ip of the first NIC in the system. Theid
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()
-
getServiceType
public ServiceType getServiceType()
-
getUriSpec
public UriSpec getUriSpec()
-
isEnabled
public boolean isEnabled()
IMPORTANT: Due to CURATOR-275 theenabled
field is NOT supported by default. If you wish to use the enabled field, you must set aInstanceSerializer
that serializes this field. The default serializer,JsonInstanceSerializer
does not serialize the field by default. You must use the alternate constructorJsonInstanceSerializer(Class, boolean)
passing false forcompatibleSerializationMode
.- 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 classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-