public final class Namespace extends AbstractValueType<String>
A namespace is used to identify instances of coordination services. All nodes using the a coordination service must use the same namespace.
For example, if distributed queues are used, the namespace will identify a specific instance of a queue so a process puts and takes elements from the right queue.
Modifier and Type | Method and Description |
---|---|
static Namespace |
forReplicatedProcess(Class<?> replicatedProcess)
Creates a namespace to be used when all the nodes run the same code and
use a single instance of a distributed service (Like queues).
|
static Namespace |
valueOf(String serviceId)
Creates a custom namespace.
|
static Namespace |
valueOf(String serviceId,
String componentId)
Creates a custom namespace.
|
equals, getValue, hashCode, toString
public static Namespace valueOf(String serviceId) throws NullPointerException, IllegalArgumentException
Use this factory method if:
serviceId
- id of the distributed service, for example id (or
name) of a queue, map, lock, etc.NullPointerException
- if serviceId
is null
IllegalArgumentException
- if serviceId
is emptypublic static Namespace valueOf(String serviceId, String componentId) throws NullPointerException, IllegalArgumentException
This method is similar to valueOf(String)
and thus it should
be used in the same cases. However this method makes explicit that
multiple components (or applications) are used and thus another level
of namespace is needed to avoid conflicts when two components (or
applications) define the same id (or name) for a distributed service
(Like queues).
serviceId
- id of the distributed service, for example id (or
name) of a queue, map, lock, etc.componentId
- id of the component or applicationNullPointerException
- if either serviceId
or
componentId
is null
IllegalArgumentException
- if either serviceId
or
componentId
is emptypublic static Namespace forReplicatedProcess(Class<?> replicatedProcess) throws NullPointerException
This factory method is convenient because the namespace is guaranteed to be unique among different processes types.
replicatedProcess
- process replicated in all nodes that will make
use of a coordination serviceNullPointerException
- if replicatedProcess
is
null
Copyright © 2015. All Rights Reserved.