Author |
Message |
07/16/2008 01:18:44
|
william
neo
Joined: 07/16/2008 01:07:27
Messages: 4
Offline
|
------------------- ______--------------------
Project1_______________Project2
------------------- ______ --------------------
Cache A
----------------------------------------------------
______ TC Cache B
I used the TC ehcache for my project1 & 2( like the pic), and the Cache B is the shared cache. But Cache A is only for project1. When the project1 used Cache A.
I got the error:
"com.tc.exception.TCNonPortableObjectError"
<instrumented-classes>
<include>
<class-expression>xxx.xxx.xxx</class-expression>
</include>
</instrumented-classes>
I do not want to let Cache A to be shared.
How can I do? Thanks
|
|
|
07/16/2008 06:55:31
|
gbevin
praetor
Joined: 07/04/2007 09:09:42
Messages: 210
Offline
|
Hi,
Terracotta works in such a way that when Terracotta is active and a class is loaded with Terracotta support, it will have that Terracotta support activated for every use of that class. There isn't much that we can do about that. So if cache A runs in the same JVM as cache B, then it'll be a Terracotta EhCache.
Sorry, I can't really think of a solution with the current EhCache support to have both a shared and an unshared cache live together in the same Terracotta application.
If this is really important to you, I suggest you file an enhancement request in our issue tracker, which can be found here: https://jira.terracotta.org
Best regards,
Geert
|
Want to post to this forum? Join the Terracotta Community |
|
|
07/16/2008 08:42:04
|
tgautier
seraphim
Joined: 06/05/2006 12:19:26
Messages: 1781
Offline
|
Actually, we could provide some way to configure which caches are clustered and which are not, but right now due to our implementation of the EHCache integration, all are clustered.
As Geert points out you should file a bug, this has been asked for maybe once before, but I don't think the requester filed a bug about it.
|
|
|
07/16/2008 15:30:24
|
ari
seraphim
Joined: 05/24/2006 14:23:21
Messages: 1665
Location: San Francisco, CA
Offline
|
the other user was instructed how to take apart our EHCache TIM and change the clustered root.
We should do the same here, no?
(and file the JIRA as well.)
--Ari
|
|
|
07/16/2008 18:48:14
|
william
neo
Joined: 07/16/2008 01:07:27
Messages: 4
Offline
|
Hi, guys, thanks a lot for reply me. I was filed the JIRA.
Now I will try use another cache like JBossCache to solute this issue.
Thanks,
Best Regards.
|
|
|
07/16/2008 23:31:02
|
ari
seraphim
Joined: 05/24/2006 14:23:21
Messages: 1665
Location: San Francisco, CA
Offline
|
Do you mean clustering JBossCache w/ Terracotta? I think the change to EHCache TIM is very easy. And Terracotta with EHCache is probably a better way to go then Terracotta with JBossCache. Can someone from Terracotta reply here with the link or instructions on how to change the TIM to not have all EHCache instances inside the Cache Manager clustered?
Cheers,
--Ari
|
|
|
07/16/2008 23:49:33
|
gbevin
praetor
Joined: 07/04/2007 09:09:42
Messages: 210
Offline
|
You could work around it as follows, note that I haven't tried this out with an example, but it should work. The version numbers in the instructions are for the latest and greatest of everything, adapt accordingly if you need it.
1. get the binary version of the ehcache tim from http://forge.terracotta.org/releases/downloads/tim-ehcache/tags/release-1.1.2/
2. unzip the archive:
Code:
unzip tim-ehcache-1.1.2-bin.zip
3. go into the archive directory:
Code:
4. extract the terracotta configuration file for the TIM:
Code:
unzip tim-ehcache-1.3-1.1.2.jar terracotta.xml
5. edit the configuration file, find the snippet below and remove it:
Code:
<root>
<field-name>net.sf.ehcache.CacheManager.ALL_CACHE_MANAGERS</field-name>
</root>
<root>
<field-name>net.sf.ehcache.CacheManager.singleton</field-name>
</root>
6. save the configuration file
7. put it back into the TIM:
Code:
zip tim-ehcache-1.3-1.1.2.jar terracotta.xml
8. put the new TIM jars in the modules directory of your Terracotta installation (make sure that none of the old TIM jars are there anymore)
Code:
mv tim-ehcache-*.jar $TC_INSTALL_DIR/modules
What you did here is make none of the caches and the cache managers shared. So instead of having all of them being shared, you can now cherry pick the ones that should be shared for your use case.
To do this, you could work with different CacheManager instances or even different Cache instances I think. The ones that are shared should be put into a collection field, or individual fields of one of your application classes. You should then adapt your tc-config.xml file to include those fields as shared Terracotta roots.
Let me know how this goes.
Take care,
Geert
|
Want to post to this forum? Join the Terracotta Community |
|
|
07/17/2008 00:25:00
|
gbevin
praetor
Joined: 07/04/2007 09:09:42
Messages: 210
Offline
|
Just to make sure, I quickly wrote an example to verify that this works, and it does. This example has one unshared cache manager, one shared cache and one unshared cache. You can find the sources in attachment. Note that you should properly name your caches when you create them so that they are isolated.
An easy way to verify that they are shared/unshared, is to simply execute the 'run.sh' script several times. You'll see that the shared cache will retain the entries from the previous runs, the unshared cache will not.
Don't forget to start the Terracotta server before trying this out.
Hope this helps,
Geert
Filename |
ehcache-cherrypicking.zip |
Download
|
Description |
|
Filesize |
255 Kbytes
|
Downloaded: |
204 time(s) |
|
Want to post to this forum? Join the Terracotta Community |
|
|
07/17/2008 00:27:09
|
rreja
journeyman
Joined: 05/16/2008 13:04:24
Messages: 30
Offline
|
You should be able to achieve this by not using the singleton cache manager for the cache you dont want to share. Singleton cache manager is by default shared with TC. If you create a new CacheManager and create CacheA with in that CacheManager that cache wont be shared until you explicitly declare the root with that CacheManager.
Thanks,
Rohit Reja
Terracotta Engineer.
|
|
|
07/17/2008 07:09:31
|
gbevin
praetor
Joined: 07/04/2007 09:09:42
Messages: 210
Offline
|
rreja wrote:
You should be able to achieve this by not using the singleton cache manager for the cache you dont want to share. Singleton cache manager is by default shared with TC. If you create a new CacheManager and create CacheA with in that CacheManager that cache wont be shared until you explicitly declare the root with that CacheManager.
I don't think that this will work since by default the ALL_CACHE_MANAGERS field is also shared. Which means that every cache manager instance will be shared, singleton or not.
|
Want to post to this forum? Join the Terracotta Community |
|
|
07/17/2008 20:53:27
|
william
neo
Joined: 07/16/2008 01:07:27
Messages: 4
Offline
|
gbevin wrote:
You could work around it as follows, note that I haven't tried this out with an example, but it should work. The version numbers in the instructions are for the latest and greatest of everything, adapt accordingly if you need it.
1. get the binary version of the ehcache tim from http://forge.terracotta.org/releases/downloads/tim-ehcache/tags/release-1.1.2/
2. unzip the archive:
Code:
unzip tim-ehcache-1.1.2-bin.zip
3. go into the archive directory:
Code:
4. extract the terracotta configuration file for the TIM:
Code:
unzip tim-ehcache-1.3-1.1.2.jar terracotta.xml
5. edit the configuration file, find the snippet below and remove it:
Code:
<root>
<field-name>net.sf.ehcache.CacheManager.ALL_CACHE_MANAGERS</field-name>
</root>
<root>
<field-name>net.sf.ehcache.CacheManager.singleton</field-name>
</root>
6. save the configuration file
7. put it back into the TIM:
Code:
zip tim-ehcache-1.3-1.1.2.jar terracotta.xml
8. put the new TIM jars in the modules directory of your Terracotta installation (make sure that none of the old TIM jars are there anymore)
Code:
mv tim-ehcache-*.jar $TC_INSTALL_DIR/modules
What you did here is make none of the caches and the cache managers shared. So instead of having all of them being shared, you can now cherry pick the ones that should be shared for your use case.
To do this, you could work with different CacheManager instances or even different Cache instances I think. The ones that are shared should be put into a collection field, or individual fields of one of your application classes. You should then adapt your tc-config.xml file to include those fields as shared Terracotta roots.
Let me know how this goes.
Take care,
Geert
Hi gbevin, I have used your example to my work. It is worked. Thanks a lot your detailed example! Thank you very much!
|
|
|
07/17/2008 23:05:43
|
gbevin
praetor
Joined: 07/04/2007 09:09:42
Messages: 210
Offline
|
Cool, glad I could help!
|
Want to post to this forum? Join the Terracotta Community |
|
|
|