Class NodeTask

  • All Implemented Interfaces:
    Externalizable, Serializable, Runnable, ClusterTask<Void>
    Direct Known Subclasses:
    AffiliationTask, RefreshNodeTask, RemoveNodeTask, SubscriptionTask

    public abstract class NodeTask
    extends Object
    implements ClusterTask<Void>
    A cluster task used work with a particular pubsub node. As with most cluster tasks, it is important to realize that these tasks are intended to interact only in a limited way with the data on the cluster node where they're executed on. Generally speaking, the cluster node that initiates the task takes responsibility for all of the 'heavy lifting', such as the persistence of data (in the backend data storage/database) for the functionality that the cluster task relates to. The other cluster nodes typically need not to repeat that effort. Specifically, the goal of executing cluster tasks on other cluster nodes should typically be limited to updating in-memory state on the cluster node.
    See Also:
    Serialized Form
    • Field Detail

      • uniqueNodeIdentifier

        protected transient Node.UniqueIdentifier uniqueNodeIdentifier
        The unique identifier for the pubsub node that is the subject of the task. This value is a combination of the data that's captured in nodeId and serviceId, which are primarily retained in the API for backwards compatibility reasons.
        See Also:
        Node.getUniqueIdentifier()
      • nodeId

        protected String nodeId
        The node identifier, unique in context of the service, for the pubsub node that is the subject of the task. The value of this field is combined with that of serviceId in uniqueNodeIdentifier. To retain (serialization) compatibility with older versions, the nodeId field is retained. It is, however, advisable to make use of uniqueNodeIdentifier instead, as that is guaranteed to provide a system-wide unique value (whereas the nodeId value is unique only context of the pubsub service).
        See Also:
        Node.getNodeID()
      • serviceId

        protected String serviceId
        The service identifier for the pubsub node that is the subject of the task.
    • Constructor Detail

      • NodeTask

        protected NodeTask()
        This no-argument constructor is provided for serialization purposes. It should generally not be used otherwise.
      • NodeTask

        protected NodeTask​(@Nonnull
                           Node node)
        Constructs a new task for a specific pubsub node.
        Parameters:
        node - The pubsub node that this task operates on.
    • Method Detail

      • getUniqueNodeIdentifier

        public Node.UniqueIdentifier getUniqueNodeIdentifier()
        Returns the unique identifier of the pubsub node that this task aims to update. Usage of this method, that provides a system-wide unique value, should generally be preferred over the use of getNodeId(), that returns a value that is unique only context of the pubsub service.
        Returns:
        A unique node identifier.
        See Also:
        Node.getUniqueIdentifier()
      • getNodeId

        public String getNodeId()
        The node identifier, unique in context of the service, for the pubsub node that is the subject of the task. It is advisable to make use of getUniqueNodeIdentifier() instead of this method, as that is guaranteed to provide a system-wide unique value (whereas the nodeId value is unique only context of the pubsub service).
        Returns:
        a node identifier
        See Also:
        getUniqueNodeIdentifier(), Node.getNodeID()
      • getNodeIfLoaded

        @Nonnull
        public Optional<Node> getNodeIfLoaded()
        Finds the pubsub node that is the subject of this task. Note that null, instead of a pubsub node instance, might be returned when the pubsub service is not currently loaded in-memory on the cluster node that the task is executing on (although there is no guarantee that when this method returns a non-null pubsub service, it was previously not loaded in-memory)! The rationale for this is that this cluster tasks does not need to operate on data that is not in memory, as such operations are the responsibility of the cluster node that initiates the cluster task.
        Returns:
        A pubsub node
      • getServiceIfLoaded

        @Nonnull
        public Optional<PubSubService> getServiceIfLoaded()
        Finds the pubsub service for the pubsub node that is the subject of this task. Note that null, instead of a pubsub service instance, might be returned when the pubsub service is not currently loaded in-memory on the cluster node that the task is executing on (although there is no guarantee that when this method returns a non-null pubsub service, it was previously not loaded in-memory)! The rationale for this is that this cluster tasks does not need to operate on data that is not in memory, as such operations are the responsibility of the cluster node that initiates the cluster task.
        Returns:
        A pubsub service