Memcached Storage Service Code Review
Marvin S. Addison
marvin.addison at gmail.com
Thu Jun 6 10:13:28 EDT 2013
I have thoughtfully reviewed the memcached implementation of
StorageService that Scott pointed out:
https://wiki.shibboleth.net/confluence/display/SHIB2/Memcached+StorageService
The component does a fair bit of wrangling to provide special handling
for certain types (e.g. login context, session, some special case
objects that are not entirely serializable). That special handling looks
overly complicated to me, but I trust it works. The use of a plain Map
as a dual store was surprising, but I believe it's required as a simple
solution to the problem of capturing all state changes. (In lieu of
Terracotta's complex bytecode instrumentation that hooks setters/fields
deep inside an object graph.) In any case the use of a JVM-local data
structure limits the functionality of this solution, but the limitations
and requirements for proper use are clearly documented.
The use of a servlet filter to push session state to memcached on the
output side of the request processing pipeline was clever. Again this
appears to be needed since IdPv2 components don't explicitly persist
changes on every mutation, so the session is stored wholesale at the end
of the request processing pipeline just to be safe.
The only real mechanical thing that jumped out at me was a spin lock
that had no failsafe condition:
// Try to acquire a lock
while(!client.add("lock:"+name, 30, "").get().booleanValue()) {
log.trace("LOCKED... trying again: {}", name);
Thread.sleep(100);
}
Overall this looks like a viable if limited alternative to Terracotta
for the documented purpose.
M
More information about the dev
mailing list