Class SubscriptionHolder
java.lang.Object
org.ovirt.vdsm.jsonrpc.client.events.SubscriptionHolder
Holds subscription information such as amount of messages requested by
EventSubscriber. When events are not
processed immediately they are queued in here. This holder contains instance of subscription itself.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final AtomicLongstatic final LongUnaryOperatorprivate final Deque<JsonRpcEvent> private final Lockprivate final String[]private final EventSubscriber -
Constructor Summary
ConstructorsConstructorDescriptionSubscriptionHolder(EventSubscriber subscriber) Creates a holder which subscriber instance and count and it prepares subscription id representation for event matching. -
Method Summary
Modifier and TypeMethodDescriptionbooleanvoidclean()Clean event queue.private voidfilter()getId()intString[]longincrementCount(long n) voidpurgeOldEventsIfNotConsumed(int eventTimeoutInHours) Purge old events if they have not been consumed in a specified amount of time.voidputEvent(JsonRpcEvent event) Queues not processed event for later processing.
-
Field Details
-
DECREMENT_ONLY_POSITIVE
-
subscriber
-
events
-
count
-
parsedId
-
filteredId
-
lock
-
-
Constructor Details
-
SubscriptionHolder
Creates a holder which subscriber instance and count and it prepares subscription id representation for event matching.- Parameters:
subscriber- Instance of @linkEventSubscriber.
-
-
Method Details
-
getId
- Returns:
- subscription id as complete string e.q. <receiver>.<component>.<operation_id>.<unique_id>.
-
getParsedId
- Returns:
- parsed subscription id as string array. Each entry represents subscription type.
-
filter
private void filter() -
getFilteredId
- Returns:
- Filtered subscription id which do not contains all filter '*'
-
canProcess
public boolean canProcess()- Returns:
- Checks and return information whether subscriber can process events based on count defined.
-
canProcessMore
- Returns:
- An event for processing if there is any and if subscriber is willing to process more events.
-
putEvent
Queues not processed event for later processing. When adding an event to the queue, set the arrival time of the event.- Parameters:
event- An event to be queued.
-
getNumberOfEvents
public int getNumberOfEvents() -
purgeOldEventsIfNotConsumed
public void purgeOldEventsIfNotConsumed(int eventTimeoutInHours) Purge old events if they have not been consumed in a specified amount of time.- Parameters:
eventTimeoutInHours- the timeout after which the events are purged from the queue.
-
getSubscriber
- Returns:
- Subscribed hold by this instance.
-
clean
public void clean()Clean event queue. -
incrementCount
public long incrementCount(long n)
-