4 Replies Latest reply on Apr 29, 2014 2:34 PM by dmc dev

    default cache not updated by hotrod client ?

    dmc dev Newbie

      I am just getting started with infinispan version 6.0.2.Final,

       

      I can created a 2 node cluster, running the servers using  ./cluster.sh

      I can see in the logs that the cluster has formed

      14:43:30,955 INFO  [org.infinispan.remoting.transport.jgroups.JGroupsTransport] (Incoming-1,shared=udp) ISPN000094: Received new cluster view: [dev2/clustered|1] (2) [dev2/clustered, dev4/clustered]

      Then using the command line tool, I can interact with the default cache from either node, and changes are reflected as expected.

       

      I have written a very simple Client,  to connect to the remote cluster, and interact with the default cache.  from the logs, it looks like the client is connect to the cluster.

      however the changes made by the client to the default cache, are not reflected on any server node ?

      What is it I am doing wrong ?

       

       

      client invocation

      java -jar infini2-binding-0.1.4.jar 192.168.2.102 default

       

      out put

      com.yahoo.ycsb.db.infini2.SimpleInfinispanClient

      Apr 21, 2014 3:18:22 PM org.infinispan.client.hotrod.impl.protocol.Codec10 readNewTopologyAndHash

      INFO: ISPN004006: /192.168.2.102:11222 sent new topology view (id=2) containing 2 addresses: [/192.168.2.102:11222, /192.168.2.104:11222]

      Apr 21, 2014 3:18:22 PM org.infinispan.client.hotrod.impl.transport.tcp.TcpTransportFactory updateServers

      INFO: ISPN004014: New server added(/192.168.2.104:11222), adding to the pool.

      Apr 21, 2014 3:18:22 PM org.infinispan.client.hotrod.RemoteCacheManager start

      INFO: ISPN004021: Infinispan version: null

      before0==>value0

      after0==>value0

      before1==>value1

      after1==>value1

      before2==>value2

      after2==>value2

      before3==>value3

      .......

       

       

       

      Client Code

       

      public class SimpleInfinispanClient{

       

         public RemoteCacheManager remoteCacheManager;

       

         public SimpleInfinispanClient(String hostPort) {

              System.err.println(this.getClass().getName());

              remoteCacheManager = new RemoteCacheManager(hostPort);

         }

       

         public void insert(String table, String key, String value) {

              RemoteCache<String, String> cache = remoteCacheManager.getCache(table);

              cache.put(key, value);

         }

       

         public String read(String table, String key) {

              RemoteCache<String, String> cache = remoteCacheManager.getCache(table);

              return cache.get(key);

         }

       

         public int size(String table) {

              RemoteCache<String, String> cache = remoteCacheManager.getCache(table);

              return cache.size();

         }

       

         public static void main(String[] args){

              SimpleInfinispanClient c = new SimpleInfinispanClient(args[0]);

              String table = args[1];

       

              for(int i=0; i<10; i++){

                 

                  String val = c.read(table, Integer.toString(i));

                  System.err.println("before"+i+"==>"+val);

       

                  c.insert(table, Integer.toString(i), "value"+i);

       

                  val = c.read(table, Integer.toString(i));

                  System.err.println("after"+i+"==>"+val);

              }

          }

      }

        • 1. Re: default cache not updated by hotrod client ?
          Wolf-Dieter Fink Master

          What you mean by

          however the changes made by the client to the default cache, are not reflected on any server node ?

          not all the nodes are updated if the cache is distributed, that depends on the configuration.

          Or did I misunderstand your question?

          • 2. Re: default cache not updated by hotrod client ?
            dmc dev Newbie

            In a 1 node cluster, (remote server nodes started using the cluster.sh script)

             

            A hotrod client (coded as above) connects, and puts  key value pairs into the "default" cache.

            then i check, the key/value from server nodes, using the command line tool, the value comes back as null ?

             

            However I Note that.

             

            on the 1st invocation of the client i get

            before0==>null

            after0==>value0

             

            on the 2nd invocation of the client i get

            before0==>value0

            after0==>value0

             

             

            so, the server must be holding the values as the values persist the client JVM shut down,

            but why cant I see the values using the command line tool on the server nodes  ?

             

            also as a side question, how to configure a named cache, when using the ./cluster.sh to start the remote server nodes ?

            can i pass the name of the config.xml file as an argument ?  or call it a special name and put it in the correct place ?

             

            Thanks

            • 3. Re: default cache not updated by hotrod client ?
              Wolf-Dieter Fink Master

              If you use the command line tool you receive only the key/value from the local node. As the default cache is distributed you might not see all keys.

               

              From the command line you can change the configuration with --server-config <your.xml> and set a different file as standalone or clustered.xml

              • 4. Re: default cache not updated by hotrod client ?
                dmc dev Newbie

                If you use the command line tool you receive only the key/value from the local node. ?

                 

                but I was using a 1 node cluster. and 1 HotRod client connecting to this cluster putting key values, then its JVM is terminated,  then the next time the test client is run, the key values have been persisted, to the 1 node.  so your logic can hold ?

                 

                it would also be reasonable to assume that, the command line tool of the server would fetch the key/value from the node who owned partition for that key if that node did not own it all ready ?