[jboss-dev-forums] [Design of JBossCache] - Re: Implicit marshalled values - a better way of handling re

bstansberry@jboss.com do-not-reply at jboss.com
Thu Dec 20 14:41:24 EST 2007


anonymous wrote : 
  | AFAIK - and please correct me if I am wrong - Brian, for HTTP sessions, your "cached objects" are MarshalledValue instances that only unmarshall when you do a MarshalledValue.get() as opposed to when the JBC marshaller unmarshalls.
  | 
  | I presume this means we have 2 levels of marshalling/unmarshalling, which could be wasteful. 

By default, region based marshalling is not enabled.  You have to enable it if you want to use FIELD (which doesn't use MarshalledValue).  But if you enabled it for FIELD and also had non-FIELD apps, yes, you'd have double marshalling.

Plus, having to change the cache config to support FIELD is crappy.

anonymous wrote : 2. When an object is put in cache (cache.put()) I create a MarshalledValue and store the object as well as the thread's class loader. 

We have to be careful with the classloader ref, as leaking classloaders is a big no-no. It could be stored as a WeakReference, but need to think through how much that buys you versus not storing it at all and just using the TCCL. Particularly since on remote nodes the classloader ref will be null.

I know in the standard AS use cases the read is always done with the correct TCCL.

anonymous wrote : 3. When the object is requested (cache.get()) I inspect the object and if it is a MarshalledValue, I return the object. If the object is not present, I deserialize the byte stream, first with the associated class loader, and if one is not present, the calling thread's class loader.

... and throw away the ref to the byte[] -- i.e. no double memory usage.


I'll need to find my scribbled design notes from when I thought about shared HTTP sessions, but I know that one thing that came out of my thinking was a need to flush the type system by converting everything back to a byte[].  This would be done on a redeploy, where we want to preserve cached data but the types are no longer usable. The MarshalledValue impl I was thinking of would have a method for that. I was assuming the session managment layer would walk the tree, get the marshalled values and invoke the "flush" method on them; if this is instead an internal detail of JBC there would need to be an API (probably on Node) to tell it to do the same thing.


Other random thoughts...

1) Shouldn't use the MarshalledValue for primitive types.
2) For collections, should probably just use it rather than doing something like trying to determine the type of all collection elements.
2) Perhaps its a behavior that should be cache-wide configurable. So, if I'm storing a bunch of Sets whose elements are all Strings, I could turn this off.

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4114774#4114774

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4114774



More information about the jboss-dev-forums mailing list