Author: gtrasuk
Date: Tue Apr  7 01:46:43 2015
New Revision: 1671722

URL: http://svn.apache.org/r1671722
Log:
The hello-service tutorial now includes a discussion of registrar leasing and 
lease expiry.

Added:
    
river/river-examples/river-examples/trunk/src/site/resources/hello-service/duplicate-hello-services.png
   (with props)
Modified:
    
river/river-examples/river-examples/trunk/src/site/markdown/hello-service/hello-service.md

Modified: 
river/river-examples/river-examples/trunk/src/site/markdown/hello-service/hello-service.md
URL: 
http://svn.apache.org/viewvc/river/river-examples/river-examples/trunk/src/site/markdown/hello-service/hello-service.md?rev=1671722&r1=1671721&r2=1671722&view=diff
==============================================================================
--- 
river/river-examples/river-examples/trunk/src/site/markdown/hello-service/hello-service.md
 (original)
+++ 
river/river-examples/river-examples/trunk/src/site/markdown/hello-service/hello-service.md
 Tue Apr  7 01:46:43 2015
@@ -293,5 +293,59 @@ in the browser.
 
 ![Hello service in the browser](hello-svc-in-browser.png)
 
+You may notice something interesting if you happen to stop the service by 
hitting ctrl-C, and
+then restart it.  You will appear to get duplicate services in the browser.
+
+![Duplicate Hello services](duplicate-hello-services.png)
+
+They will even appear to "work", i.e. you'll be able to see their info and 
browse them.
+But, you're really just looking at the registration info that the service 
registered with the 
+service registrar before it was stopped.  Neither Reggie nor the browser make 
any
+attempt to contact the actual service.
+
+If you wait a little while, you'll notice something else interesting - the 
duplicate 
+services will disappear on their own.
+
+Here's what's happening:
+
+When the service registers itself with Reggie, it takes out a lease on the 
registration. 
+That lease is usually renewed periodically by the service’s JoinManager 
(that 
+isn’t quite the whole story, but it’ll do for now).  When you kill the 
service 
+unexpectedly with ctrl-c, the service doesn’t de-register itself, however 
the 
+lease eventually runs out (now that it’s not being renewed by the service) 
and 
+then the registration expires, allowing Reggie to reclaim its resources and 
+notify any registrar listeners. 
+
+It would be possible to register a vm shutdown hook to de-register the service 
+before the vm exits, but that's left out of this example, so as to demonstrate 
+that a dead  service (or at least a dead 
+JoinManager) eventually gets dropped from the registrar.
+
+The duplicate service instances appear to “work”, in that you can show 
info and 
+browse the service, but of course, you’re really just looking at the 
information 
+that’s in the registry - the registrar and service browser don’t actually 
contact 
+the service.  Reggie has no knowledge of the “liveness” of the service, 
and 
+doesn’t attempt to do any sort of “health check”.  
+
+In fact, it’s a common misconception that if the service renews the lease, 
it must 
+be “live”.  This idea turns out to be false for many reasons. Some of 
those reasons are:
+(1) The service could 
+have delegated its lease renewals to a different service.  (2) There’s no 
guarantee 
+that failure of the actual service thread would also cause failure of the 
lease 
+renewal thread, even if they are in the same process (embedded programmers 
might 
+recognize this as being similar to the “resetting the watchdog in a 
timer-triggered 
+interrupt service routine” problem).  (3) Even if there were a health check 
+task, the service could fail in the instant just after the health check.  The 
+most a health check, monitor or heartbeat can do is place a limit on how long 
it 
+takes to find out a service has failed.  The only way to say with certainty 
+that a service “works” is to attempt to use it.
+
+The lease is purely for the convenience of the registrar (or generically, the 
+service granting the lease).  If ever the lease is not renewed, the landlord 
+can go ahead and reclaim whatever resources were dedicated to the lease.  In 
+the case of Reggie, if the lease isn’t renewed, Reggie drops the 
registration.  
+So there’s little risk of “stuck registrations”.  And since the lease 
can be 
+renewed, there’s no need for any kind of extended default timeout.
+
 Next, we'll need a [client](../hello-client/hello-client.html).
 

Added: 
river/river-examples/river-examples/trunk/src/site/resources/hello-service/duplicate-hello-services.png
URL: 
http://svn.apache.org/viewvc/river/river-examples/river-examples/trunk/src/site/resources/hello-service/duplicate-hello-services.png?rev=1671722&view=auto
==============================================================================
Binary file - no diff available.

Propchange: 
river/river-examples/river-examples/trunk/src/site/resources/hello-service/duplicate-hello-services.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream


Reply via email to