Cache data not being distributed in WildFly 8.2
rbenkovitz Jul 28, 2015 8:07 PMHello:
Trying to set up a simple distributed cache in a full-ha WildFly deployment. I've followed the rules (I believe) and have set up a simple distributed cache. The application boots fine, and I'm seeing what I believe are proper JGroup messages stating that the cluster is working. However, when I attempt to use it, each node in the cluster seems to have its own local copy.
Included are some details:
Cache config in the infinispan subsystem:
<cache-container name="processTracker" default-cache="dist" jndi-name="java:jboss/infinispan/processTracker">
<transport lock-timeout="60000"/>
<distributed-cache name="dist" batching="true" mode="SYNC" owners="2" l1-lifespan="0">
<locking isolation="REPEATABLE_READ" acquire-timeout="15000" concurrency-level="1000"/>
<file-store/>
</distributed-cache>
</cache-container>
Singleton EJB code snippet that sets it up. I initialize the cache by seeding it with Maps based upon values in an enum (ProcessTracker.Process). There are different methods which will put and remove values in these underlying Maps:
@Singleton
@Startup
@AccessTimeout(value = 60, unit = TimeUnit.SECONDS)
public class ProcessTrackerCache implements ProcessTracker {
@Resource(lookup = "java:jboss/infinispan/cache/processTracker/dist")
private Cache<Process, Map<String, DateTime>> processMap;
@PostConstruct
public void initialize() {
System.out.println("ProcessTracker Constructor");
System.out.println("processMap=" + this.processMap);
if (this.processMap != null) {
for (Process process : ProcessTracker.Process.values()) {
processMap.put(process, new HashMap<String,DateTime>());
}
}
}
... other transactional methods put values in cache and read cache.
When starting up each node, it seems to attempt to initialize it in four threads twice (could this be some clue?) - the first attempt the cache is null - the second time it is set to the proper cache. Here is the output from the server log:
2015-07-28 18:19:50,578 INFO [stdout] (ServerService Thread Pool -- 70) ProcessTracker Constructor
2015-07-28 18:19:50,579 INFO [stdout] (ServerService Thread Pool -- 72) ProcessTracker Constructor
2015-07-28 18:19:50,579 INFO [stdout] (ServerService Thread Pool -- 58) ProcessTracker Constructor
2015-07-28 18:19:50,580 INFO [stdout] (ServerService Thread Pool -- 62) ProcessTracker Constructor
2015-07-28 18:19:50,583 INFO [stdout] (ServerService Thread Pool -- 58) processMap=null
2015-07-28 18:19:50,585 INFO [stdout] (ServerService Thread Pool -- 72) processMap=null
2015-07-28 18:19:50,585 INFO [stdout] (ServerService Thread Pool -- 70) processMap=null
2015-07-28 18:19:50,586 INFO [stdout] (ServerService Thread Pool -- 62) processMap=null
2015-07-28 18:19:50,628 INFO [stdout] (ServerService Thread Pool -- 58) ProcessTracker Constructor
2015-07-28 18:19:50,628 INFO [stdout] (ServerService Thread Pool -- 72) ProcessTracker Constructor
2015-07-28 18:19:50,628 INFO [stdout] (ServerService Thread Pool -- 62) ProcessTracker Constructor
2015-07-28 18:19:50,629 INFO [stdout] (ServerService Thread Pool -- 70) ProcessTracker Constructor
2015-07-28 18:19:50,629 INFO [stdout] (ServerService Thread Pool -- 62) processMap=Cache 'dist'@bpc-111:node1/processTracker
2015-07-28 18:19:50,629 INFO [stdout] (ServerService Thread Pool -- 72) processMap=Cache 'dist'@bpc-111:node1/processTracker
2015-07-28 18:19:50,630 INFO [stdout] (ServerService Thread Pool -- 58) processMap=Cache 'dist'@bpc-111:node1/processTracker
2015-07-28 18:19:50,630 INFO [stdout] (ServerService Thread Pool -- 70) processMap=Cache 'dist'@bpc-111:node1/processTracker
Also, I seem to be getting correct JGroup messages about the cache being clustered (bpc-111 is the machine name - cluster has two nodes, node1 and node2, both on the same box):
2015-07-28 18:20:19,907 INFO [org.infinispan.remoting.transport.jgroups.JGroupsTransport] (Incoming-2,shared=udp) ISPN000094: Received new cluster view: [bpc-111:node1/processTracker|1] (2) [bpc-111:node1/processTracker, bpc-111:node2/processTracker]
There was an earlier thread on a similar topic (https://developer.jboss.org/thread/194878) - the answer was something about "bundling the infinispan libraries. When I changed the scope of the infinispan-core to provided, cache values were replicated on all nodes." I'm not sure what that means or how to go about doing that.
Any help would be appreciated - seem to be at a dead end.
- Rob