Hmmm, you could enable fetchPersistentState in the cache loader configuration so that when a node starts up, it overrides it's persistent state with the in-memory state of the cluster. That only works in your scenario where each node has its own cache store. See http://docs.jboss.org/infinispan/5.1/configdocs/urn_infinispan_config_5.1/complexType/configuration.loaders.loader.html
Alternatively, use a share cache store and you won't have that problem, where all nodes point to the same database for example.
Galder, thanks for your respose. However the result is not what I'm expecting even wiht fetchPersistentState enabled.
Here is my configuration:
<?xml version="1.0" encoding="UTF-8"?>
<property name="configurationFile" value="jgroups-tcp.xml" />
<!-- Configure a synchronous replication cache -->
<hash numOwners="2" />
<loaders passivation="false" shared="false" preload="true">
<property name="location" value="/tmp/ispn/store" />
<eviction strategy="LIRS" maxEntries="5" />
My simple application takes inputs from the console and does INSERT (to the cache), REMOVE (from the cache) and GET (the value from the cache). I run it on 3 different machines. Here is what I had
- On server #1 I let the application to insert (k1, v1) into the cache and saw the pair was distributed to the files on both server #1 and #2. I could get v1 with Cache.get("k1") from ANY of the 3 consoles.
- Then I stopped the instance on server #2 with (k1, v1) left in its file.
- Again on server #1 I let the application to remove (k1, v1) from the cache, which also removed the pair from the file on server #1.
- So far so good.
- On server #2, I restarted the application.
- On each server, I let the application to get the value with Cache.get("k1"). Both server #1 and #3 returned nothing as expected by server #2 returned v1 back again.
My questions are:
- If server #2 reloaded (k1, v1) from its file to the cache, why did I fail to get it from server #1 and #3?
- I'm expecting server #2 can sync up with the cache on startup, but it seems it doesn't even with fetchPersistentState enabled.
Did I miss anything else here? Thanks in advance.
Re 1. Had you already retrieved data from #2 when you requested data from #1 and #3? If it was the other way around, it makes sense for #1 to not look in all other nodes cache stores cos this would be expensive.
Re 2. Hmmm, I think fetchPersistentState does not work with distribution mode. It only works with replicated or invalidation modes.
It's probably best if you shared a cache store if you're using distribution as clustering mode