0

Hello everyone I am new to Infinispan and I have some questions in regards to distributed mode and quickstarts provided in infinispan/infinispan-quickstart · GitHub in particular clustered-cache-quickstart.

First of all, as far as I understand distributed mode allows to have defined number of entry copies rather than replicated mode, which replicates entries within all nodes. For example, if we had 3 entries (1, 2, 3) and 3 caches (A, B, C) where numOwners(2) the resulting view of cluster in distributed mode might result as: A containing 1,2 B containing 2,3 C containing 3,1 Where replicated mode cluster would result in: A,B and C containing 1,2,3 Please correct me if my assumption is wrong.

What is more, then I run infinispan-quickstart/clustered-cache · GitHub this quickstart using these instructions

To try with a distributed cache, run the following command in separated terminals:

Terminal 1

mvn compile exec:java -Djava.net.preferIPv4Stack=true -Dexec.mainClass="org.infinispan.quickstart.clusteredcache.Node" -Dexec.args="-d A"

Terminal 2

mvn compile exec:java -Djava.net.preferIPv4Stack=true -Dexec.mainClass="org.infinispan.quickstart.clusteredcache.Node" -Dexec.args="-d B"

Terminal 3

mvn compile exec:java -Djava.net.preferIPv4Stack=true -Dexec.mainClass="org.infinispan.quickstart.clusteredcache.Node" -Dexec.args="-d C"

All my nodes result in having the same entries (I limited entry number to 10) :

Node A

    Cache contents on node A-29339
    key-0 = A-29339-0
    key-1 = A-29339-1
    key-2 = A-29339-2
    key-3 = A-29339-3
    key-4 = A-29339-4
    key-5 = A-29339-5
    key-6 = A-29339-6
    key-7 = A-29339-7
    key-8 = A-29339-8
    key-9 = A-29339-9

Node B

    Cache contents on node B-36604
    key-0 = A-29339-0
    key-1 = A-29339-1
    key-2 = A-29339-2
    key-3 = A-29339-3
    key-4 = A-29339-4
    key-5 = A-29339-5
    key-6 = A-29339-6
    key-7 = A-29339-7
    key-8 = A-29339-8
    key-9 = A-29339-9

Node C

    Cache contents on node C-26839
    key-0 = A-29339-0
    key-1 = A-29339-1
    key-2 = A-29339-2
    key-3 = A-29339-3
    key-4 = A-29339-4
    key-5 = A-29339-5
    key-6 = A-29339-6
    key-7 = A-29339-7
    key-8 = A-29339-8
    key-9 = A-29339-9

However, in the documentation Getting Started with Infinispan it said that: You can also see that each node holds a different set of entries by pressing Enter. Nevertheless, my output shows that all entries are basically replicated as would be done in replicated mode. Any ideas why this is happening like this?

DonatasD
  • 651
  • 6
  • 14
  • Seems that nodes B and C did not write anything into the cache, while the caches were clustered, since A's entries are replicated. Could you upload & link logs? – Radim Vansa May 04 '15 at 11:51
  • Cross-linking to JBoss forums: https://developer.jboss.org/message/928129 – Radim Vansa May 04 '15 at 11:52

1 Answers1

2

Answered on JBoss Forums by Tristan Tarrant, copy-pasting the reply:

That is because the quickstart wasn't correctly updated when we changed the behaviour of entrySet/keySet in 7.0. Previously those methods only returned the data on the local node, but now they return data from all nodes. To get the old behaviour (i.e. only local content) you need to specify the CACHE_MODE_LOCAL flag so that other remote nodes are not queried for data.

So, change Node.java @ line 133 from:

ArrayList<Map.Entry<String, String>> entries = new ArrayList<>(cache.entrySet());  

to

ArrayList<Map.Entry<String, String>> entries = new ArrayList<>(cache.getAdvancedCache().withFlags(Flag.CACHE_MODE_LOCAL).entrySet());  
Radim Vansa
  • 5,686
  • 2
  • 25
  • 40