I've setup an ehcache that uses a disk store to cache some files. This is working, and I can see the cache file created on disk, but I want to have this behaviour also in a terracotta server, so the cache can be accessed by multiple clients.
I've setup the terracotta server, tweaked the ehcache configuration, I can see that the cache is working, but I'm not sure if it is using memory or disk. I only want to use disk for this cache.
I also get some warnings like this one: WARN - Asking for a large amount of memory: 26179740 bytes
Terracotta config:
<servers>
<mirror-group>
<server host="localhost" name="localhost" >
<data>/opt/terracotta/data</data>
<tsa-port>9510</tsa-port>
<management-port>9540</management-port>
<tsa-group-port>9530</tsa-group-port>
<dataStorage size="2g">
<offheap size="100m"/>
<hybrid/>
</dataStorage>
<logs>stdout:</logs>
</server>
</mirror-group>
I'm configuring ehcache programmatically, and I'm certain the following config is wrong, but maybe close to what is needed.
TerracottaConfiguration config = new TerracottaConfiguration()
.clustered(true)
.compressionEnabled(true);
Cache httpCache = new Cache(new CacheConfiguration()
.name(HTTP_CACHE)
.maxEntriesLocalHeap(1)
.memoryStoreEvictionPolicy(MemoryStoreEvictionPolicy.LRU)
.diskExpiryThreadIntervalSeconds(Properties.CACHE_HTTP_EXPIRY)
.persistence(new PersistenceConfiguration().strategy(PersistenceConfiguration.Strategy.DISTRIBUTED))
.terracotta(config));
Given the configuration and version information given in comments:
Open source Terracotta server only uses in-memory storage.
<dataStorage size="2g">
<offheap size="2g"/>
</dataStorage>
In this example, you have 2Gb of data storage, all using offheap. And of course there will be no on disk content. This means that if the server is shut down, all data is lost. Of course you can have two servers in a single mirror group to gain high availability.
With Enterprise feature, you can effectively have data persisted on disk to enable restartability.
<dataStorage size="2g">
<offheap size="200m"/>
<hybrid/>
</dataStorage>
The example above declares 2Gb of Storage of which 200Mb will be served from memory and the rest from disk.
Note that in order to have full server restartability, you need to enable it through: <restartable enabled="true"/>
in each server element.
For more details on all this, please refer to the product documentation.
Note also that you should use the same versions for the client and the server. While the 4.3 line supports different client and server version, it is aimed at rolling upgrades and is not a recommended long running setup.