Package org.kiwiproject.registry.model
Class ServiceInstance
- java.lang.Object
-
- org.kiwiproject.registry.model.ServiceInstance
-
public final class ServiceInstance extends Object
Model containing information about a running service
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classServiceInstance.ServiceInstanceBuilderstatic classServiceInstance.StatusThe status of a service
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static ServiceInstance.ServiceInstanceBuilderbuilder()booleanequals(Object o)static ServiceInstancefromServiceInfo(ServiceInfo serviceInfo)Returns a newServiceInstanceBuilderbuilt from a givenServiceInfo.PortgetAdminPort()Returns the admin port of this instance, preferring the secure port (if both secure and insecure exist).PortgetApplicationPort()Returns the application port of this instance, preferring the secure port (if both secure and insecure exist).StringgetCommitRef()StringgetDescription()StringgetHostName()StringgetInstanceId()StringgetIp()Map<String,String>getMetadata()Used to store extra data in a discovery service for this instanceMap<String,Object>getNativeRegistryData()Used to store native registry data that includes data mapped intoServiceInstanceas well as any additional information that is not mapped.ServicePathsgetPaths()List<Port>getPorts()StringgetServiceName()ServiceInstance.StatusgetStatus()InstantgetUpSince()Returns the Instant this service has been up since, orInstant.EPOCHif no value was provided when this instance was created.longgetUpSinceMillis()Returns the time since the epoch this service has been up since, or zero (the epoch), if no value was provided when this instance was created.StringgetVersion()inthashCode()ServiceInstance.ServiceInstanceBuildertoBuilder()StringtoString()ServiceInstancewithHostName(String hostName)ServiceInstancewithInstanceId(String instanceId)ServiceInstancewithMetadata(Map<String,String> metadata)Used to store extra data in a discovery service for this instanceServiceInstancewithNativeRegistryData(Map<String,Object> nativeRegistryData)Used to store native registry data that includes data mapped intoServiceInstanceas well as any additional information that is not mapped.ServiceInstancewithStatus(ServiceInstance.Status status)
-
-
-
Method Detail
-
fromServiceInfo
public static ServiceInstance fromServiceInfo(ServiceInfo serviceInfo)
Returns a newServiceInstanceBuilderbuilt from a givenServiceInfo.Note that a copy of
ServiceInfo.getMetadata()is made usingMap.copyOf(Map), so the metadata is unmodifiable.- Parameters:
serviceInfo- The information about the service used to initialize theServiceInstanceBuilder- Returns:
- a
ServiceInstanceBuilderwith values copied from the givenServiceInfo
-
getUpSince
public Instant getUpSince()
Returns the Instant this service has been up since, orInstant.EPOCHif no value was provided when this instance was created.- Returns:
- a non-null Instant representing the instant this service was started, or the epoch if no value provided
-
getUpSinceMillis
public long getUpSinceMillis()
Returns the time since the epoch this service has been up since, or zero (the epoch), if no value was provided when this instance was created.- Returns:
- the number of milliseconds since the epoch that this service was started, or zero if no value provided
-
getApplicationPort
public Port getApplicationPort()
Returns the application port of this instance, preferring the secure port (if both secure and insecure exist).- Returns:
- the application port
- See Also:
Ports.findFirstPortPreferSecure(List, PortType)
-
getAdminPort
public Port getAdminPort()
Returns the admin port of this instance, preferring the secure port (if both secure and insecure exist).- Returns:
- the admin port
- See Also:
Ports.findFirstPortPreferSecure(List, PortType)
-
builder
public static ServiceInstance.ServiceInstanceBuilder builder()
-
toBuilder
public ServiceInstance.ServiceInstanceBuilder toBuilder()
-
getInstanceId
public String getInstanceId()
-
getStatus
public ServiceInstance.Status getStatus()
-
getServiceName
public String getServiceName()
-
getHostName
public String getHostName()
-
getIp
public String getIp()
-
getPaths
public ServicePaths getPaths()
-
getCommitRef
public String getCommitRef()
-
getDescription
public String getDescription()
-
getVersion
public String getVersion()
-
getMetadata
public Map<String,String> getMetadata()
Used to store extra data in a discovery service for this instance
-
getNativeRegistryData
public Map<String,Object> getNativeRegistryData()
Used to store native registry data that includes data mapped intoServiceInstanceas well as any additional information that is not mapped. This will only be populated if the registry configuration specifies to include native data.
-
withInstanceId
public ServiceInstance withInstanceId(String instanceId)
- Returns:
- a clone of this object, except with this updated property (returns
thisif an identical value is passed).
-
withStatus
public ServiceInstance withStatus(ServiceInstance.Status status)
- Returns:
- a clone of this object, except with this updated property (returns
thisif an identical value is passed).
-
withHostName
public ServiceInstance withHostName(String hostName)
- Returns:
- a clone of this object, except with this updated property (returns
thisif an identical value is passed).
-
withMetadata
public ServiceInstance withMetadata(Map<String,String> metadata)
Used to store extra data in a discovery service for this instance- Returns:
- a clone of this object, except with this updated property (returns
thisif an identical value is passed).
-
withNativeRegistryData
public ServiceInstance withNativeRegistryData(Map<String,Object> nativeRegistryData)
Used to store native registry data that includes data mapped intoServiceInstanceas well as any additional information that is not mapped. This will only be populated if the registry configuration specifies to include native data.- Returns:
- a clone of this object, except with this updated property (returns
thisif an identical value is passed).
-
-