[Design of JBossCache] - Re: Default classloader for deserialization
by bstansberry@jboss.com
The region-based configuration thing is somewhat of a holdover from the pre-JGroups-multiplexer days, when a cache was an expensive object due to the need for its own JChannel. It allows multiple deployments with different type systems to use the same underlying cache, as long as they store their data in separate regions. HTTP session repl with FIELD granularity uses this, since MarshalledValue wouldn't work properly with what PojoCache needs.
My instinct is that with the multiplexer it makes more sense to have an architecture where deployments that need a cache instantiate their own -- see comments on the second half of http://www.jboss.com/index.html?module=bb&op=viewtopic&t=93825 for some thoughts on this. But this takes some thought. It goes in the opposite direction, for example, from an idea Sacha raised last winter about having all data related to a Seam app be stored in the same cache so there could just be one replication event per request.
JGroups does provide the needed hooks for applications to do marshalling/unmarshalling of messages as they see fit. JBC makes extensive use of these (as does HAPartition). So JGroups isn't naive in this respect. It's more that JBC is naive, if the overly complex region-based thing isn't used.
anonymous wrote : The default configuration of the serialization aspect needs to be triggered by an application level aspect, which could pick up the app thread context class loader.
OK, sounds like we're moving toward something like:
1) JBC exposes an API that allows registration of a default classloader but which doesn't trigger the whole region-based marshalling overhead. I suppose registration can be a simple setter in the Configuration object graph.
2) We have a wrapper class that in create() picks up the TCCL and registers it, then calls create on the cache. In destroy() it calls destroy() on the cache and then unregisters the classloader.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3989478#3989478
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3989478
17 years, 10 months
[Design of JBossCache] - Re: Default classloader for deserialization
by scott.stark@jboss.org
Ok, then the disconnect is why control of serialization requires a region based configuration. The first problem would seem to be that even the typed rpc functionality of jgroups should have a serialization api that allows shared use of a channel with marshalling/unmarshalling of types based on application endpoints with different type systems. Serialization is an aspect of the user, not an inherent function of the jbc or jgroups. The default configuration of the serialization aspect needs to be triggered by an application level aspect, which could pick up the app thread context class loader.
It seems we are picking up a naive standalone component behavior where serialization is an inherent function of the messaging layer. That is not the case for any service that needs to integrate into jbossas, esb, etc.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3989465#3989465
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3989465
17 years, 10 months
[Design of JBossCache] - Re: Default classloader for deserialization
by bstansberry@jboss.com
This thread is about independent usage of JBC, not as part of ejb3/hibernate/httpsession repl where we have an integration layer that can take advantage of the existing region-based marshalling API.
Here's the problem:
EAR packages class Foo, and also deploys a JBC instance via a -service.xml or -beans.xml. Application places instances of Foo in the cache, which then get replicated.
When the replication message is received, Foo needs to be deserialized. This is done by the thread coming up from JGroups. This deserialization is done using the classloader for server/all/lib, which is where the JBC and JGroups jars are located. Thus class Foo is not visible to the classloader. Replication fails with a CNFE. Same problem occurs with state transfer when a 2nd node joins a cluster where there's existing data.
Solutions to this problem are:
1) Place Foo.class in server/all/lib.
2) Turn on region-based marshalling and register a classloader with the cache, effectively saying for example, for any replication traffic related to Fqn's below "/a", use this classloader to deserialize the message. If this feature is turned on, all replication messages consist of two components -- first a serialized Fqn that identifies which region the message pertains to (used by the recipient to look up the classloader) and then the regular serialized MethodCall.
anonymous wrote : To me this is another wrapper that integrates well with this usage. Its an mbean service/mc bean that performs the same deployment level integration as the other jboss cache based aspects.
This is one possible solution, and perhaps the best. The downside to it is it adds the overhead of including the region-identifier Fqn in each replication message -- which isn't really needed if there is only one correct classloader for the whole cache.
So, the purpose of this thread is to explore that and possibly other solutions.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3989459#3989459
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3989459
17 years, 10 months