Class NodeTask
java.lang.Object
org.jivesoftware.openfire.pubsub.cluster.NodeTask
- All Implemented Interfaces:
Externalizable
,Serializable
,Runnable
,ClusterTask<Void>
- Direct Known Subclasses:
AffiliationTask
,RefreshNodeTask
,RemoveNodeTask
,SubscriptionTask
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:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected String
The node identifier, unique in context of the service, for the pubsub node that is the subject of the task.protected String
The service identifier for the pubsub node that is the subject of the task.protected Node.UniqueIdentifier
The unique identifier for the pubsub node that is the subject of the task. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionThe node identifier, unique in context of the service, for the pubsub node that is the subject of the task.Finds the pubsub node that is the subject of this task.Finds the pubsub service for the pubsub node that is the subject of this task.Returns the unique identifier of the pubsub node that this task aims to update.void
void
-
Field Details
-
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 innodeId
andserviceId
, which are primarily retained in the API for backwards compatibility reasons.- See Also:
-
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 ofserviceId
inuniqueNodeIdentifier
. To retain (serialization) compatibility with older versions, the nodeId field is retained. It is, however, advisable to make use ofuniqueNodeIdentifier
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:
-
serviceId
The service identifier for the pubsub node that is the subject of the task.
-
-
Constructor Details
-
NodeTask
protected NodeTask()This no-argument constructor is provided for serialization purposes. It should generally not be used otherwise. -
NodeTask
Constructs a new task for a specific pubsub node.- Parameters:
node
- The pubsub node that this task operates on.
-
-
Method Details
-
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 ofgetNodeId()
, that returns a value that is unique only context of the pubsub service.- Returns:
- A unique node identifier.
- See Also:
-
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 ofgetUniqueNodeIdentifier()
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:
-
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
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
-
getResult
- Specified by:
getResult
in interfaceClusterTask<Void>
-
writeExternal
- Specified by:
writeExternal
in interfaceExternalizable
- Throws:
IOException
-
readExternal
- Specified by:
readExternal
in interfaceExternalizable
- Throws:
IOException
ClassNotFoundException
-