Question

System Layout

I have a system in place where a Cache is made up of many Cache Nodes. When one is added, a CacheNodeAdded event is raised by the Cache. The Cache has a redundant set of Monitors listening for this event. Monitors are responsible for notifying on Cache events.

Since I have multiple Monitors, but only want to be notified once, Step 3 is what I am looking to implement.

Solutions I can't use:

  • Cache notifying directly. Monitors must be used.
  • Have each Monitor check the log to see if the notification has been sent. Since they all run separately, they could all access the list of notifications at the same time, see the notification hasn't been sent, and notify multiple times as a result.

Solution I'm toying with:

  • When event is received, get a list of all Monitor IDs (GUID), order the list, and the first Monitor in the list gets to send the notification. This is a simple solution but it seems a little inelegant.

Are there any other simple solutions that I may be overlooking?

Was it helpful?

Solution 3

I ended up implementing the solution discussed in my question.

•When event is received, get a list of all Monitor IDs (GUID), order the list, and the first Monitor in the list gets to send the notification.

OTHER TIPS

A write-lock can be acquired by the Monitor that has received the event over the log, do logging and set the logged flag to 'true' in the global logging context which all Monitors can look up and update has a reference of. Subsequent monitors may skip the logging step after reading the logged flag status.

Lookup of in memory context flag is expected less costly than that of the log itself.

It isn't really clear what your other monitors are for if they aren't going to be sending notifications.

Is there some reason why you can't add or have a single monitor instance that is responsible for passing on the notifications?

Licensed under: CC-BY-SA with attribution
scroll top