Class ClusterEvent
java.lang.Object
org.gcube.informationsystem.resourceregistry.cluster.ClusterEvent
One immutable notification broadcast over the
ClusterEventBus.
Carries its own identity (getEventId()) and the identity of the instance that
emitted it (getOriginId()). Both exist because the bus delivers over two independent
channels: the identity lets a receiver discard the second copy of an event it has already
handled, and the origin lets it discard the echo of an event it emitted itself.
- Author:
- Luca Frosini (ISTI - CNR)
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringField name of the event identifier, in JSON and on the Live Query backstop record alike.static final StringField name of the event type, in JSON and on the Live Query backstop record alike.static final StringField name of the emitting instance identifier, in JSON and on the Live Query backstop record alike.static final StringField name of the event payload, in JSON and on the Live Query backstop record alike.static final StringField name of the emission timestamp, in JSON and on the Live Query backstop record alike. -
Constructor Summary
ConstructorsConstructorDescriptionClusterEvent(UUID eventId, ClusterEventType eventType, String payload, String originId, long timestamp) Creates an event with every field supplied explicitly. -
Method Summary
Modifier and TypeMethodDescriptionstatic ClusterEventDeserializes an event from the JSON form produced bytoJson().Returns the event's own identifier, unique across every instance.Returns the kind of event.Returns the identifier of the instance that emitted this event.Returns the type-specific payload.longReturns the emission time.toJson()Serializes this event to the JSON form used as the Redis pub/sub message payload.
-
Field Details
-
EVENT_ID_FIELD
Field name of the event identifier, in JSON and on the Live Query backstop record alike.- See Also:
-
EVENT_TYPE_FIELD
Field name of the event type, in JSON and on the Live Query backstop record alike.- See Also:
-
PAYLOAD_FIELD
Field name of the event payload, in JSON and on the Live Query backstop record alike.- See Also:
-
ORIGIN_ID_FIELD
Field name of the emitting instance identifier, in JSON and on the Live Query backstop record alike.- See Also:
-
TIMESTAMP_FIELD
Field name of the emission timestamp, in JSON and on the Live Query backstop record alike.- See Also:
-
-
Constructor Details
-
ClusterEvent
public ClusterEvent(UUID eventId, ClusterEventType eventType, String payload, String originId, long timestamp) Creates an event with every field supplied explicitly. Used by deserialization and by the Live Query backstop, which rebuilds an event from a stored record.- Parameters:
eventId- the event's own identifier, unique across every instanceeventType- the kind of eventpayload- the type-specific payload, may benulloriginId- the identifier of the instance that emitted the eventtimestamp- the emission time, in milliseconds since the epoch
-
-
Method Details
-
getEventId
Returns the event's own identifier, unique across every instance.- Returns:
- the event identifier
-
getEventType
Returns the kind of event.- Returns:
- the event type
-
getPayload
Returns the type-specific payload.- Returns:
- the payload, or
nullif this event kind carries none
-
getOriginId
Returns the identifier of the instance that emitted this event.- Returns:
- the emitting instance identifier
-
getTimestamp
public long getTimestamp()Returns the emission time.- Returns:
- the emission time, in milliseconds since the epoch
-
toJson
Serializes this event to the JSON form used as the Redis pub/sub message payload.- Returns:
- the serialized event
- Throws:
Exception- if serialization fails
-
fromJson
Deserializes an event from the JSON form produced bytoJson().- Parameters:
json- the serialized event- Returns:
- the deserialized event
- Throws:
Exception- if deserialization fails
-