[Logo] Terracotta Discussion Forums (LEGACY READ-ONLY ARCHIVE)
  [Search] Search   [Recent Topics] Recent Topics   [Members]  Member Listing   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
[Expert]
How can extends the cache's size in the runtime?  XML
Forum Index -> BigMemory
Author Message
lijie

journeyman

Joined: 09/04/2012 23:10:13
Messages: 19
Offline

I got a cache like this:

CacheManager cm = CacheManager.create();
CacheConfiguration ccf = new CacheConfiguration();
ccf.setName("test");
ccf.setMaxEntriesLocalHeap(5000);
ccf.setOverflowToOffHeap(Boolean.TRUE);
ccf.setMaxMemoryOffHeap("100M");
Cache cache = new Cache(ccf);
cm.addCache(cache);

Can bigmemory go support cache size dynamic extend?
How can I extend the offheap size in the running time?

Thx.
rajoshi

seraphim

Joined: 07/04/2011 04:36:10
Messages: 1491
Offline

You can do this dynamically using "maxBytesLocalOffHeap" parameter.

so if you have only one cache in your application using 100M of Bigmemory your example configuration would be like :


CacheManager cm = CacheManager.create();
CacheConfiguration ccf = new CacheConfiguration();
ccf.setName("test");
ccf.setMaxEntriesLocalHeap(5000);
ccf.setOverflowToOffHeap(Boolean.TRUE);
ccf.setmaxBytesLocalOffHeap("100M");
Cache cache = new Cache(ccf);
cm.addCache(cache);

This will create a cache with 100M Bigmemory at runtime. Apart from this on the client side you have to set jvm argument -XX:MaxDirectMemorySize=150M( i.e Little larger than the Bigmemory you assign to the application)

Rakesh Joshi
Senior Consultant
Terracotta.
lijie

journeyman

Joined: 09/04/2012 23:10:13
Messages: 19
Offline

Hi Joshi,thanks for your quickly reply.

Maybe I am not clarified the question.

I want add size to an already initialized cache.

For example I have got the cache which initialized 100M:

CacheManager cm = CacheManager.create();
CacheConfiguration ccf = new CacheConfiguration();
ccf.setName("test");
ccf.setMaxEntriesLocalHeap(5000);
ccf.setOverflowToOffHeap(Boolean.TRUE);
ccf.setMaxBytesLocalOffHeap("100M");
Cache cache = new Cache(ccf);
cm.addCache(cache);
return cache

then put data to the cache. When I found the cache nearly full, so I want add 50M to the cache dynamicly (then the cache size changed to 150M, and the data also can use). How can I add 50M to the cache dynamicly?

Thanks.
rajoshi

seraphim

Joined: 07/04/2011 04:36:10
Messages: 1491
Offline

You can add the 50M offheap to a running cache(i.e mycache here) like this :

Cache cache = manager.getCache("mycache");
CacheConfiguration config = cache.getCacheConfiguration();
configuration.setMaxBytesLocalOffHeap("150M");

So if earlier the offheap was 100M now it will be 150M.

Rakesh Joshi
Senior Consultant
Terracotta.
lijie

journeyman

Joined: 09/04/2012 23:10:13
Messages: 19
Offline

ok,I see.

Thank you very much for your quickly reply again.
 
Forum Index -> BigMemory
Go to:   
Powered by JForum 2.1.7 © JForum Team