Class SubscriptionMatcher
java.lang.Object
org.ovirt.vdsm.jsonrpc.client.events.SubscriptionMatcher
Matcher is responsible for holding all subscriptions and match them to incoming events.
Matching process is based on subscription id which is represented by 4 subscription types:
<receiver>.<component>.<operation_id>.<unique_id>
<receiver> - Uniquely identifies host from which event arrived
<component> - Logical component like: Storage, Virt etc
<operation_id> - Operation identifier like Image.create
<unique_id> - Identifier of a specific operation
User can subscribe to all events by defining '*' for each subscription type.
Registration for all possible events like '*|*|*|*' is not allowed.
User can register for specific component operation using '*|storage|*|*' which
means that all events triggered by storage component are delivered to a subscriber.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate List<SubscriptionHolder> private ConcurrentMap<String, List<SubscriptionHolder>> private ConcurrentMap<String, List<SubscriptionHolder>> private ConcurrentMap<String, List<SubscriptionHolder>> private ConcurrentMap<String, SubscriptionHolder> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(SubscriptionHolder holder) Adds aSubscriptionHolderwhich will be used for event matchingprivate voidaddHolders(Set<SubscriptionHolder> holders, ConcurrentMap<String, List<SubscriptionHolder>> map, int key, String[] ids, SubscriptionMatcher.Predicate predicate) private voidclean(ConcurrentMap<String, List<SubscriptionHolder>> map, String key, SubscriptionHolder holder) match(JsonRpcEvent event) Matches current subscriptions to an event and returns aSetcontaining all subscriptions that match for this event processing.voidremove(SubscriptionHolder holder) Used during removal of a subscription.private voidupdate(ConcurrentMap<String, List<SubscriptionHolder>> map, String key, SubscriptionHolder holder) private voidvalidateKey(String key)
-
Field Details
-
receiver
-
component
-
operation
-
unique_id
-
allSubscriptions
-
-
Constructor Details
-
SubscriptionMatcher
public SubscriptionMatcher()
-
-
Method Details
-
add
Adds aSubscriptionHolderwhich will be used for event matching- Parameters:
holder- Instance holding subscription information.
-
update
private void update(ConcurrentMap<String, List<SubscriptionHolder>> map, String key, SubscriptionHolder holder) -
validateKey
-
match
Matches current subscriptions to an event and returns aSetcontaining all subscriptions that match for this event processing.- Parameters:
event- Incoming event used to match subscribers.- Returns:
- A
Setwith matched subscriptions.
-
addHolders
private void addHolders(Set<SubscriptionHolder> holders, ConcurrentMap<String, List<SubscriptionHolder>> map, int key, String[] ids, SubscriptionMatcher.Predicate predicate) -
remove
Used during removal of a subscription.- Parameters:
holder- Object holding information about subscription being removed.
-
clean
private void clean(ConcurrentMap<String, List<SubscriptionHolder>> map, String key, SubscriptionHolder holder) -
getAllSubscriptions
-