You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by Kisu San <Ki...@gmail.com> on 2007/12/19 11:47:18 UTC

Changing CacheManager settings - Example in wiki is not working

Guys 
I have a problem with Jackrabbit Cache.  I am trying to create around 10K
nodes of type "nt:file". Each of these nodes are attached with a binary file
of around 10 KB each.  I am getting out of memory errors.
Below is the code

        InputStream fileInputStream = new FileInputStream(f);
        Node fileNode = currentNode.addNode(f.getName(), "nt:file");
        Node fileNodeContent = fileNode.addNode("jcr:content",
"nt:resource");
        fileNodeContent.setProperty("jcr:mimeType", "text");
        fileNodeContent.setProperty("jcr:data",
session().getValueFactory().createValue(fileInputStream));
        fileNodeContent.setProperty("jcr:lastModified",
session().getValueFactory().createValue(System.currentTimeMillis()));
       session().save();

I have the following questions

1)How does cache mechanism work in Jackrabbit for inserts work. I try to
change the cache manager setting using example given at 
http://wiki.apache.org/jackrabbit/CacheManager

It is not working because,  2nd line in this code attempt cast parent to
child.  Because TransientRepository is child of Repository.

repository = new TransientRepository();
"CacheManager manager = ((RepositoryImpl) repository).getCacheManager();"

Anyone have any idea how to make this work or change the cacheManager
settings.

2) I am calling Jackrabbit from tomcat.  I am thinking of increasing tomcat
jvm memory setting to increase the heap size. Is it a good idea to do that. 

3) I am using one session for many of these operations. Would there be one
cache created per session?
if I have to evit the cache how can I do it? May be I evit or clean the
cache once I complete one set of operations or before going for another set
of operations.

4) Most importantly in a transient repository for creating of nodes does
cache be used? Instead of clearing cache can I clear the transient
repository? I don't know if this is possible.

Help pls?



-- 
View this message in context: http://www.nabble.com/Changing-CacheManager-settings---Example-in-wiki-is-not-working-tp14414844p14414844.html
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.


Re: Changing CacheManager settings - Example in wiki is not working

Posted by Vish <vn...@gmail.com>.
I also need to understand caching in jackrabbit a bit more.
1. how does the conent caching works.
2. how does content in caching gets disposed. e.g. if conent is idle for
long time, does cache take cares to dispose those content automtically.
3. Is there any alternative way of cleaning the cache by invoking an method
call...I meant from a client applicaiton not from Jackrabbit apis.

Thanks in advance


--
View this message in context: http://jackrabbit.510166.n4.nabble.com/Changing-CacheManager-settings-Example-in-wiki-is-not-working-tp516251p4372066.html
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.

Re: Changing CacheManager settings - Example in wiki is not working

Posted by Thomas Mueller <th...@gmail.com>.
Hi,

I have updated the section and source code example in the wiki:

The CacheManager does not control the memory used by unsaved data
(data in the transient space). If you get out of memory exceptions,
check that your application calls Node.save() or (even better)
Session.save() from time to time. Unsaved changes are kept in memory
with the current Jackrabbit.

Session session = new TransientRepository()
                .login(new SimpleCredentials("", new char[0]));
RepositoryImpl repository = (RepositoryImpl)session.getRepository();
CacheManager manager = ((RepositoryImpl) repository).getCacheManager();
manager.setMaxMemory(8 * 1024 * 1024); // default is 16 * 1024 * 1024
manager.setMaxMemoryPerCache(1024 * 1024); // default is 4 * 1024 * 1024
manager.setMinMemoryPerCache(64 * 1024); // default is 128 * 1024]

>        session().save();

Does the method session() return the same session as the one used to
create the nodes? Did you call Session.save() for each node?

> 1)How does cache mechanism work in Jackrabbit for inserts work. I try to
> change the cache manager setting using example given at
> http://wiki.apache.org/jackrabbit/CacheManager

The cache is not only for inserts, it is also used for read access.

> 2) I am calling Jackrabbit from tomcat.  I am thinking of increasing tomcat
> jvm memory setting to increase the heap size. Is it a good idea to do that.

Maybe other modules are using the main chunk of memory. Could you try
to analyze the memory usage using a profiler tool? The YourKit Java
Profiler (http://www.yourkit.com/) is great for that, and there is a
trial version available. There may be other tools as well.

> 3) I am using one session for many of these operations.

That's good.

> Would there be one cache created per session?

Yes. The cache manager adaptively changes the size for each of these
caches. However if you have a lot of sessions, this will not work
correctly.

> if I have to evit the cache how can I do it?

This should not be required.

> can I clear the transient
> repository?

Session.save()

Regards,
Thomas