-
1. Re: Custom CacheLoader for a HotRodServer's cache
pcraveiro Dec 6, 2011 12:51 PM (in response to pcraveiro)I created a testecase to startup a Hot Rod Server for debbuging. After some testes I realized that changing the marshaller to GenericJBossMarshaller my code worked.
Why the default marshaller is VersionAwareMarshaller and to create the CacheValue i have to use the GenericJBossMarshaller ?
-
2. Re: Custom CacheLoader for a HotRodServer's cache
galder.zamarreno Dec 16, 2011 9:13 AM (in response to pcraveiro)1 of 1 people found this helpfulBasically, VersionAwareMashaller is used internally by Infinispan to marshall things to the cache loader or other nodes in the cluster. The main difference with GenericJBossMarshaller is the fact that VersionAwareMarshaller uses the Externalizer arquitecture to provide highly performant serialization of known types. The GenericJBossMarshaller does not have this yet, and this is the marshaller used by Hot Rod clients to marshall/unmarshall things to/from Hot Rod server.
The documentation link above is very specific on its of the GenericJBossMarshaller.
I was wondering if you'd like to contribute your custom cache loader and provide some tests for it? It'd be interesting to see what you've done here.
-
3. Re: Custom CacheLoader for a HotRodServer's cache
pcraveiro Dec 17, 2011 8:59 AM (in response to galder.zamarreno)Thanks for the answer, but why the VersionAwareMarshaller is not used on the client as well If it is better than the GenericJBossMarshaller and is used internally by the HotRod Server ?
About the contribution, of course I can do it. I will make some refactoring on the code to externalize some configurations and remove my project's specific dependencies.
I will attach the code as soon as I finish on monday (19/12).
Regards.
-
4. Re: Custom CacheLoader for a HotRodServer's cache
galder.zamarreno Dec 19, 2011 6:40 AM (in response to pcraveiro)Pedro Igor wrote:
Thanks for the answer, but why the VersionAwareMarshaller is not used on the client as well If it is better than the GenericJBossMarshaller and is used internally by the HotRod Server ?
Cos we haven't got around to doing it. It's not simply a matter of changing the marshaller, but you also need to set up other components such as the externalizer table with the user defined externalizers on the client so that it can marshall/unmarshall user defined classes. Feel free to open a JIRA for this. Maybe you can even code that functionality? . We can help you along with any doubts you might have.
Looking forward to seeing your contribution!
-
5. Re: Custom CacheLoader for a HotRodServer's cache
pcraveiro Dec 19, 2011 11:51 AM (in response to galder.zamarreno)Galder,
Take a look at the project that is attached.
if you have any doubts please let me know.
Regards,
-
database-cacheloader.tar.gz 20.4 KB
-
-
6. Re: Custom CacheLoader for a HotRodServer's cache
galder.zamarreno Dec 19, 2011 9:40 AM (in response to pcraveiro)Hmmm, nothing's attached. What about you start a document in http://community.jboss.org/en/infinispan?view=documents and we evolve over time there? You can attach code, write up something about the use case...etc. What do you think?
-
7. Re: Custom CacheLoader for a HotRodServer's cache
pcraveiro Dec 19, 2011 11:56 AM (in response to galder.zamarreno)Now is attached.
I think it's a great idea, but could you take a look at the implementation first ? I would like to see your feedback before doing this.
Inside this project there is a test case called TestHotRodClient. You will se that I used a property called infinispan.client.hotrod.marshaller to change the default marshaller implementation. With this configuration is possible to use VersionAwareMarshaller on both sides without the need to use the GenericJBossMarshaller on the server side.
-
database-cacheloader.tar.gz 20.4 KB
-
-
8. Re: Custom CacheLoader for a HotRodServer's cache
galder.zamarreno Dec 20, 2011 3:03 AM (in response to pcraveiro)Pedro, I had a look and had a question. Couldn't you just have plugged the cache that's used by Hot Rod with our JDBCCacheStore? Wouldn't you have obtained the same thing?
Interesting to see that the client can be configured with VersionAwareMarshaller and that it does not give you problems.
-
9. Re: Custom CacheLoader for a HotRodServer's cache
pcraveiro Dec 20, 2011 6:55 AM (in response to galder.zamarreno)Galder, let me explain my scenario:
- The customer already have a table with a lot of entries. This table is maintained by an IDM (Identity Manager) to CRUD users identities. This identities will be used to authenticate users (using Picketlink IDP);
- To avoid create a batch service to populate the cache, I created this custom cache loader. That way, the cache will be loaded on-demand and even if user's identity is not present in-memory the cache will load it from the database;
- This project uses 5 nodes in cluster (DIST_ASYNC). Each of them is using this custom implementation to maintain a single database with all users identities;
- This project also uses 28 local caches running embbebed inside the IDP (geografically distributed). They act as clients for the cluster using the RemoteCacheStore (near-cache).
As you can see, the JDBCCacheStore shipped with Infinispan has it's own data structure that do not suits my needs. That is the reason, reuse a existing data model.
Actually, in this project I'm using a CacheStore and not a CacheLoader. The customer needs also to update the database when the entries in the cache are updated.
What do you think ?