Package org.apache.curator.x.discovery
Class ServiceInstance<T>
java.lang.Object
org.apache.curator.x.discovery.ServiceInstance<T>
POJO that represents a service instance
-
Constructor Summary
ConstructorDescriptionServiceInstance
(String name, String id, String address, Integer port, Integer sslPort, T payload, long registrationTimeUTC, ServiceType serviceType, UriSpec uriSpec) 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 theenabled
field is NOT supported by default. -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> ServiceInstanceBuilder
<T> builder()
Return a new builder.buildUriSpec
(Map<String, Object> variables) boolean
getId()
getName()
getPort()
long
int
hashCode()
boolean
IMPORTANT: Due to CURATOR-275 theenabled
field is NOT supported by default.toString()
-
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 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(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 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 Details
-
builder
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:
Exception
- errors getting the local IP
-
getName
-
getId
-
getAddress
-
getPort
-
getSslPort
-
getPayload
-
getRegistrationTimeUTC
public long getRegistrationTimeUTC() -
getServiceType
-
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
-
buildUriSpec
-
equals
-
hashCode
public int hashCode() -
toString
-