Tom's technique below is nice for automatic failover.  Just for a point
of reference, I'll describe the hot-standby approach we've taken at
Avid.

 * Declare that your IFooService is an IRedundantService
 * The IFooService instances in the group discover each other and hold
an election
 * The winner calls joinMgr.modifyAttributes() to mark itself as primary
 * The IFooService instances ping each other and if any one stops
responding, another election is triggered
 * Clients search for the IFooService that is marked primary=true and
talk only to it

Limitations of this approach:
 * need for IFooService instances to inter-communicate
 * moments during election when there is no primary
 * rare partial-disconnect conditions where you get two primaries

Wins of this approach:
 * election protocol is entirely up to the IFooServices, no client logic
except to trust the Entry that says primary=true
 * only one primary at a time
 * the IFooService instances are already in contact, so adding state
synchronization requires little extra infrastructure

Good-and-bad aspects:
 * clients can decide how to handle the no-primary case themselves.
More code, but more control too.


I'd love to hear comments/criticisms of our approach, and if anyone has
implemented something similar.

Chris

-----Original Message-----
From: Tom Hobbs [mailto:[email protected]] 
Sent: Tuesday, February 09, 2010 4:21 AM
To: [email protected]
Subject: Service Wrapper Example

Hi,

I mentioned in another thread that I had come across code which provides
service fail over and auto-rediscovery.  I've posted details of the kind
of
code that was used to (note this has been reinvented in my head just now
and
only loosely tested);

http://wiki.apache.org/river/AutomaticServiceReplacement

I hope that someone finds it useful and/or interesting.

It's important to note that in the interests of simplicity the
ServiceWrapper class in the article is explicitly linked to the dummy
service described.  Obviously using more reflection magic it's possible
to
remove this linkage so that ServiceWrapper can wrap any service you like
and
it's invoke method would invoke the method supplied to it, rather than
the
only method available in the dummy article.

Thanks to Jukka for his Wiki account suggestion.

Enjoy,

Tom

Reply via email to