Beispiel #1
0
        public void OnEntryEvent(IData keyData, IData valueData, IData oldValueData, IData mergingValue,
                                 int eventTypeInt, string uuid,
                                 int numberOfAffectedEntries, bool includeValue, IEntryListener <TKey, TValue> listener)
        {
            var value    = default(TValue);
            var oldValue = default(TValue);

            if (includeValue)
            {
                value    = ToObject <TValue>(valueData);
                oldValue = ToObject <TValue>(oldValueData);
            }
            var key       = ToObject <TKey>(keyData);
            var member    = GetContext().GetClusterService().GetMember(uuid);
            var eventType = (EntryEventType)eventTypeInt;

            switch (eventType)
            {
            case EntryEventType.Added:
            {
                listener.EntryAdded(new EntryEvent <TKey, TValue>(GetName(), member, eventType, key, oldValue, value));
                break;
            }

            case EntryEventType.Removed:
            {
                listener.EntryRemoved(new EntryEvent <TKey, TValue>(GetName(), member, eventType, key, oldValue,
                                                                    value));
                break;
            }

            case EntryEventType.Updated:
            {
                listener.EntryUpdated(new EntryEvent <TKey, TValue>(GetName(), member, eventType, key, oldValue,
                                                                    value));
                break;
            }

            case EntryEventType.Evicted:
            {
                listener.EntryEvicted(new EntryEvent <TKey, TValue>(GetName(), member, eventType, key, oldValue,
                                                                    value));
                break;
            }

            case EntryEventType.EvictAll:
            {
                listener.MapEvicted(new MapEvent(GetName(), member, eventType, numberOfAffectedEntries));
                break;
            }

            case EntryEventType.ClearAll:
            {
                listener.MapCleared(new MapEvent(GetName(), member, eventType, numberOfAffectedEntries));
                break;
            }
            }
        }
        public virtual string AddEntryListener(IEntryListener <K, V> listener, bool includeValue)
        {
            var request = MultiMapAddEntryListenerCodec.EncodeRequest(GetName(), includeValue, false);

            DistributedEventHandler handler =
                eventData => MultiMapAddEntryListenerCodec.AbstractEventHandler.Handle(eventData,
                                                                                       (key, value, oldValue, mergingValue, type, uuid, entries) =>
                                                                                       OnEntryEvent(key, value, oldValue, mergingValue, (EntryEventType)type, uuid, entries, includeValue, listener)
                                                                                       );

            return(Listen(request, message => MultiMapAddEntryListenerCodec.DecodeResponse(message).response, handler));
        }
Beispiel #3
0
        public string AddEntryListener(IEntryListener <TKey, TValue> listener, bool includeValue)
        {
            var listenerFlags = GetListenerFlags(listener);
            var request       = MapAddEntryListenerCodec.EncodeRequest(GetName(), includeValue, listenerFlags, false);
            DistributedEventHandler handler =
                eventData => MapAddEntryListenerCodec.AbstractEventHandler.Handle(eventData,
                                                                                  (key, value, oldValue, mergingValue, type, uuid, entries) =>
            {
                OnEntryEvent(key, value, oldValue, mergingValue, type, uuid, entries, includeValue, listener);
            });

            return(Listen(request, message => MapAddEntryListenerCodec.DecodeResponse(message).response, handler));
        }
        public string AddEntryListener(IEntryListener <K, V> listener, IPredicate <K, V> predicate, bool includeValue)
        {
            var predicateData = ToData(predicate);
            var flags         = GetListenerFlags(listener);
            var request       = MapAddEntryListenerWithPredicateCodec.EncodeRequest(GetName(), predicateData, includeValue, flags, false);
            DistributedEventHandler handler =
                eventData => MapAddEntryListenerWithPredicateCodec.AbstractEventHandler.Handle(eventData,
                                                                                               (key, value, oldValue, mergingValue, type, uuid, entries) =>
            {
                OnEntryEvent(key, value, oldValue, mergingValue, type, uuid, entries, includeValue, listener);
            });

            return(Listen(request, message => MapAddEntryListenerWithPredicateCodec.DecodeResponse(message).response, null,
                          handler));
        }
        public virtual string AddEntryListener(IEntryListener <TKey, TValue> listener, TKey key, bool includeValue)
        {
            var keyData = ToData(key);
            var request = MultiMapAddEntryListenerToKeyCodec.EncodeRequest(GetName(), keyData, includeValue, IsSmart());

            DistributedEventHandler handler =
                eventData => MultiMapAddEntryListenerToKeyCodec.AbstractEventHandler.Handle(eventData,
                                                                                            (thekey, value, oldValue, mergingValue, type, uuid, entries) =>
                                                                                            OnEntryEvent(thekey, value, oldValue, mergingValue, (EntryEventType)type, uuid, entries,
                                                                                                         includeValue, listener)
                                                                                            );

            return(RegisterListener(request, message => MultiMapAddEntryListenerToKeyCodec.DecodeResponse(message).response,
                                    id => MultiMapRemoveEntryListenerCodec.EncodeRequest(GetName(), id), handler));
        }
Beispiel #6
0
        public virtual string AddEntryListener(IEntryListener <TKey, TValue> listener, bool includeValue)
        {
            var listenerAdapter =
                EntryListenerAdapter <TKey, TValue> .CreateAdapter(listener, GetContext().GetSerializationService());

            var request = MultiMapAddEntryListenerCodec.EncodeRequest(GetName(), includeValue, IsSmart());

            DistributedEventHandler handler =
                eventData => MultiMapAddEntryListenerCodec.EventHandler.HandleEvent(eventData,
                                                                                    (key, value, oldValue, mergingValue, type, uuid, entries) =>
            {
                OnEntryEvent(key, value, oldValue, mergingValue, type, uuid, entries, listenerAdapter);
            });

            return(RegisterListener(request, message => MultiMapAddEntryListenerCodec.DecodeResponse(message).response,
                                    id => MultiMapRemoveEntryListenerCodec.EncodeRequest(GetName(), id), handler));
        }
        public Guid AddEntryListener(IEntryListener <TKey, TValue> listener)
        {
            var listenerAdapter =
                EntryListenerAdapter <TKey, TValue> .CreateAdapter(listener, Client.SerializationService);

            var request = ReplicatedMapAddEntryListenerCodec.EncodeRequest(Name, IsSmart());
            DistributedEventHandler handler =
                eventData => ReplicatedMapAddEntryListenerCodec.EventHandler.HandleEvent(eventData,
                                                                                         (key, value, oldValue, mergingValue, type, uuid, entries) =>
            {
                OnEntryEvent(key, value, oldValue, mergingValue, type, uuid, entries, listenerAdapter);
            });

            return(RegisterListener(request,
                                    message => ReplicatedMapAddEntryListenerCodec.DecodeResponse(message).Response,
                                    id => ReplicatedMapRemoveEntryListenerCodec.EncodeRequest(Name, id), handler));
        }
        public virtual Guid AddEntryListener(IEntryListener <TKey, TValue> listener, TKey key, bool includeValue)
        {
            var listenerAdapter =
                EntryListenerAdapter <TKey, TValue> .CreateAdapter(listener, Client.SerializationService);

            var keyData = ToData(key);
            var request = MultiMapAddEntryListenerToKeyCodec.EncodeRequest(Name, keyData, includeValue, IsSmart());

            DistributedEventHandler handler =
                eventData => MultiMapAddEntryListenerToKeyCodec.EventHandler.HandleEvent(eventData,
                                                                                         (k, value, oldValue, mergingValue, type, uuid, entries) =>
            {
                OnEntryEvent(k, value, oldValue, mergingValue, type, uuid, entries, listenerAdapter);
            });

            return(RegisterListener(request, message => MultiMapAddEntryListenerToKeyCodec.DecodeResponse(message).Response,
                                    id => MultiMapRemoveEntryListenerCodec.EncodeRequest(Name, id), handler));
        }
Beispiel #9
0
        public string AddEntryListener(IEntryListener <TKey, TValue> listener, IPredicate predicate)
        {
            var predicateData   = ToData(predicate);
            var listenerAdapter =
                EntryListenerAdapter <TKey, TValue> .CreateAdapter(listener, GetContext().GetSerializationService());

            var request =
                ReplicatedMapAddEntryListenerWithPredicateCodec.EncodeRequest(GetName(), predicateData, IsSmart());
            DistributedEventHandler handler =
                eventData => ReplicatedMapAddEntryListenerWithPredicateCodec.EventHandler.HandleEvent(eventData,
                                                                                                      (k, value, oldValue, mergingValue, type, uuid, entries) =>
            {
                OnEntryEvent(k, value, oldValue, mergingValue, type, uuid, entries, listenerAdapter);
            });

            return(RegisterListener(request,
                                    message => ReplicatedMapAddEntryListenerWithPredicateCodec.DecodeResponse(message).response,
                                    id => ReplicatedMapRemoveEntryListenerCodec.EncodeRequest(GetName(), id), handler));
        }
        public string AddEntryListener(IEntryListener <TKey, TValue> listener, IPredicate predicate,
                                       TKey key,
                                       bool includeValue)
        {
            var keyData       = ToData(key);
            var predicateData = ToData(predicate);
            var flags         = GetListenerFlags(listener);
            var request       = MapAddEntryListenerToKeyWithPredicateCodec.EncodeRequest(GetName(), keyData, predicateData,
                                                                                         includeValue, flags, IsSmart());
            DistributedEventHandler handler =
                eventData => MapAddEntryListenerToKeyWithPredicateCodec.AbstractEventHandler.Handle(eventData,
                                                                                                    (k, value, oldValue, mergingValue, type, uuid, entries) =>
            {
                OnEntryEvent(k, value, oldValue, mergingValue, type, uuid, entries, includeValue, listener);
            });

            return(RegisterListener(request, message => MapAddEntryListenerCodec.DecodeResponse(message).response,
                                    id => MapRemoveEntryListenerCodec.EncodeRequest(GetName(), id), handler));
        }
 private int GetListenerFlags(IEntryListener <K, V> listener)
 {
     return((int)EntryEventType.All);
 }
Beispiel #12
0
 public Guid AddEntryListener(IEntryListener <TKey, TValue> listener, bool includeValue)
 {
     return(AddEntryListener((MapListener)listener, includeValue));
 }
Beispiel #13
0
 public Guid AddEntryListener(IEntryListener <TKey, TValue> listener, IPredicate predicate, TKey key, bool includeValue)
 {
     return(AddEntryListener((MapListener)listener, predicate, key, includeValue));
 }
Beispiel #14
0
 private static int GetListenerFlags(IEntryListener <TKey, TValue> listener)
 {
     return((int)EntryEventType.All);
 }
Beispiel #15
0
 public string AddEntryListener(IEntryListener <TKey, TValue> listener, IPredicate predicate, bool includeValue)
 {
     return(AddEntryListener((MapListener)listener, predicate, includeValue));
 }
Beispiel #16
0
 public string AddEntryListener(IEntryListener <TKey, TValue> listener, TKey key, bool includeValue)
 {
     return(AddEntryListener((MapListener)listener, key, includeValue));
 }