Class ServiceId
java.lang.Object
eu.cloudnetservice.driver.service.ServiceId
- All Implemented Interfaces:
Named
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedServiceId(@NonNull String taskName, @NonNull String nameSplitter, @NonNull Set<String> allowedNodes, @NonNull UUID uniqueId, int taskServiceId, @Nullable String nodeUniqueId, @NonNull String environmentName, @Nullable ServiceEnvironmentType environment) Creates a new service identity instance. -
Method Summary
Modifier and TypeMethodDescriptionGet the unique ids of all nodes which are allowed to pick up and manage the underlying service.static @NonNull ServiceId.Builderbuilder()Constructs a new builder for a service id instance.static @NonNull ServiceId.BuilderConstructs a new builder for a service id which has the same properties set as the given service id.Get the resolved environment type object which was used to create the service.Get the name of the environment which should be used when starting the service.name()Get the unique name identifier of this object in the related scope.Get the splitter to put between the name of the task and the numeric id of it when creating a full display name variant of the underlying service.Get the unique id of the node which is responsible to pick up and manage the underlying service.taskName()The name of the task which was used to construct the service.intGet the numeric id of the service within CloudNet.toString()Constructs a stringified version of service id, containing the full display name and unique id of it.uniqueId()Get the unique id (version 4) of the service.
-
Field Details
-
taskName
-
nameSplitter
-
allowedNodes
-
uniqueId
-
taskServiceId
protected final int taskServiceId -
nodeUniqueId
-
environmentName
-
environment
-
-
Constructor Details
-
ServiceId
protected ServiceId(@NonNull @NonNull String taskName, @NonNull @NonNull String nameSplitter, @NonNull @NonNull Set<String> allowedNodes, @NonNull @NonNull UUID uniqueId, int taskServiceId, @Nullable @Nullable String nodeUniqueId, @NonNull @NonNull String environmentName, @Nullable @Nullable ServiceEnvironmentType environment) Creates a new service identity instance.- Parameters:
taskName- the name of the task this service is based on.nameSplitter- the splitter of the service name, to put between the task name and task service id.allowedNodes- the nodes which are allowed to start the service.uniqueId- the unique id (version 4) of the service, there is never a duplicate within CloudNet.taskServiceId- the numeric id of the service within the task.nodeUniqueId- the unique id of the node which picked up the service, null if not yet elected.environmentName- the name of the environment type of the service.environment- the resolved environment type, null if not yet resolved.- Throws:
NullPointerException- if any given parameter is null, except for the resolved environment type and node.
-
-
Method Details
-
builder
Constructs a new builder for a service id instance.- Returns:
- a new service id builder.
-
builder
Constructs a new builder for a service id which has the same properties set as the given service id.When calling build directly after constructing a builder using this method, it will result in a service id which is equal but not the same as the given one.
- Parameters:
serviceId- the service id to copy the properties of.- Returns:
- a new builder for a service id with the properties of the given one already set.
- Throws:
NullPointerException- if the given service id is null.
-
name
-
uniqueId
-
nodeUniqueId
Get the unique id of the node which is responsible to pick up and manage the underlying service. This is null if not specific node was chosen to start the service on, but will never be null after initially choosing one.- Returns:
- the node unique id which is responsible to pick up and manage the underlying service.
-
allowedNodes
Get the unique ids of all nodes which are allowed to pick up and manage the underlying service. This method returns an empty collection if all nodes are allowed to pick up the service, but never null.Note: this method might return an empty collection if a specific node was already chosen, you might need to check that too.
- Returns:
- the unique ids of the nodes which are allowed to pick up and manage the underlying service.
-
taskName
-
nameSplitter
-
environmentName
Get the name of the environment which should be used when starting the service. The returned environment must be registered on the node which is picking up and managing the service in order to work correctly.- Returns:
- the name of the environment to use for the service.
-
taskServiceId
public int taskServiceId()Get the numeric id of the service within CloudNet. This id is bound to the task name, meaning that if a service based on a task with 5 registered services (their ids are 1 - 5) gets created it will use the numeric id 6. Services created based on other tasks are not included in the calculation.- Returns:
- the numeric id of the service within the task based on which the service was created.
-
environment
Get the resolved environment type object which was used to create the service. This method returns null when no specific environment type was given and no node picked up the service yet and therefore the given environment name was not resolved.Note: this method returns never null after a service was successfully prepared at least once.
- Returns:
- the resolved service environment type, might be null if not yet resolved.
-
toString
-