1
votes

I am trying to setup a replicated cache using Jgroups in Ehcache.I am having problems in clustering the cache.I created 2 projects in eclipse each refering to different ehcache.xml configuration file.

Both the configuration files are identical and is given beolw.

<?xml version="1.0"?>

<cacheManagerPeerProviderFactory
    class="net.sf.ehcache.distribution.jgroups.JGroupsCacheManagerPeerProviderFactory"
    properties="connect=TCP(bind_port=7800):
    TCPPING(initial_hosts=localhost[7800],localhost[7801];port_range=10;timeout=3000;
    num_initial_members=3):
    VERIFY_SUSPECT(timeout=1500):
    pbcast.NAKACK(retransmit_timeout=3000):
    pbcast.GMS(join_timeout=50000;print_local_addr=true)"
propertySeparator="::" />

 <cache name="sampleCache"
        maxElementsInMemory="1000000"
        eternal="true"
        overflowToDisk="false">
        <cacheEventListenerFactory
        class="net.sf.ehcache.distribution.jgroups.JGroupsCacheReplicatorFactory"
        properties="replicateAsynchronously=true"/>
</cache>

I am using the following jar files in my classpath.

-ehcache-2.9.0.jar -ehcache-jgroupsreplication-1.7.jar -jgroups-3.6.0.Final.jar -log4j-1.2.16

When I run the programs project1 shows

63511 [main] DEBUG org.jgroups.protocols.pbcast.NAKACK  - 
[SBSPBWSVM110-42986 setDigest()]
existing digest:  []
new digest:       SBSPBWSVM110-42986: [0 (0)]
resulting digest: SBSPBWSVM110-42986: [0 (0)]
63511 [main] DEBUG org.jgroups.protocols.pbcast.GMS  - SBSPBWSVM110-42986: installing view [SBSPBWSVM110-42986|0] (1) [SBSPBWSVM110-42986]
63543 [main] DEBUG org.jgroups.protocols.pbcast.GMS  - SBSPBWSVM110-42986: created cluster (first member). My view is [SBSPBWSVM110-42986|0], impl is org.jgroups.protocols.pbcast.CoordGmsImpl
Jan 09, 2015 11:49:51 AM net.sf.ehcache.distribution.jgroups.JGroupsCacheManagerPeerProvider init

INFO:JGroups Replication started for 'EH_CACHE'. JChannel: local_addr=SBSPBWSVM110-42986
cluster_name=EH_CACHE
my_view=[SBSPBWSVM110-42986|0] (1) [SBSPBWSVM110-42986]
state=CONNECTED
discard_own_messages=true
state_transfer_supported=false

When I run the programs project2 shows

63451 [main] DEBUG org.jgroups.protocols.pbcast.NAKACK  - 
[SBSPBWSVM110-20554 setDigest()]
existing digest:  []
new digest:       SBSPBWSVM110-20554: [0 (0)]
resulting digest: SBSPBWSVM110-20554: [0 (0)]
63451 [main] DEBUG org.jgroups.protocols.pbcast.GMS  - SBSPBWSVM110-20554: installing view [SBSPBWSVM110-20554|0] (1) [SBSPBWSVM110-20554]
63452 [main] DEBUG org.jgroups.protocols.pbcast.GMS  - SBSPBWSVM110-20554: created cluster (first member). My view is [SBSPBWSVM110-20554|0], impl is org.jgroups.protocols.pbcast.CoordGmsImpl
Jan 09, 2015 11:49:51 AM net.sf.ehcache.distribution.jgroups.JGroupsCacheManagerPeerProvider init

INFO: JGroups Replication started for 'EH_CACHE'. JChannel: local_addr=SBSPBWSVM110-20554
cluster_name=EH_CACHE
my_view=[SBSPBWSVM110-20554|0] (1) [SBSPBWSVM110-20554]
state=CONNECTED
discard_own_messages=true
state_transfer_supported=false

But the replication simply isnt happening.I have done the RMIreplication using Ehcache and following the same approach here also. So I am assuming nothing is wrong in my java code.

I am unable to find the issue here.Is my configuration wrong??Please help me with this issue..

1

1 Answers

2
votes

The config you use is strange: it's mising some protocols. Can't ehcache refer to a JGroups config file, e.g. udp.xml ? Also you you set bind_addr in TCP or use -Djgroups.bind_addr=1.2.3.4 where 1.2.3.4 is the network interface. Then, in TCPPING.initial_hosts, you'll need to list all the members with the bind addresses you used above, e.g. 1.2.3.4[7800],5.6.7.8[7800] etc.