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.

+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.
+
+
+
+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