Package me.ahoo.cosid.machine
Class InstanceId
java.lang.Object
me.ahoo.cosid.machine.InstanceId
Represents a specific deployment instance of a service.
An InstanceId identifies a particular running instance of a service, which may be part of a deployment that provides stable machine IDs (stable=true) or a dynamic instance where machine IDs may change (stable=false).
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final InstanceIdSentinel value representing no instance. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanGets the instance identifier string.inthashCode()booleanisStable()Checks if this instance has a stable identity.static InstanceIdCreates an InstanceId from an instance ID string.static InstanceIdCreates an InstanceId from host and port.toString()
-
Field Details
-
NONE
Sentinel value representing no instance.
-
-
Constructor Details
-
InstanceId
Creates a new InstanceId.- Parameters:
instanceId- the instance identifier stringstable- whether this instance has a stable identity
-
-
Method Details
-
isStable
public boolean isStable()Checks if this instance has a stable identity.Stable instances (stable=true) are deployed with stable identities (e.g., Kubernetes StatefulSet) and can rely on having consistent machine IDs across restarts.
- Returns:
- true if the instance has a stable identity
-
getInstanceId
Gets the instance identifier string.- Returns:
- the instance ID
-
toString
-
of
Creates an InstanceId from host and port.- Parameters:
host- the host addressport- the port numberstable- whether this instance has a stable identity- Returns:
- a new InstanceId
-
of
Creates an InstanceId from an instance ID string.- Parameters:
instanceId- the instance identifierstable- whether this instance has a stable identity- Returns:
- a new InstanceId
-
equals
-
hashCode
public int hashCode()
-