1 Reply Latest reply on Oct 9, 2012 1:36 PM by jacob1111

    HotRod symmetric input produces asymmetric output

    jacob1111

      Symmetric input produces asymmetric output

       

      Hi,

       

      I have problem using HotRod clients - they produce unexpected output

      from simple client code.

       

      I have two nodes running exactly the same software:

      CentOS 5,5, JDK 1.6.0_31 and infinispan-5.2.0.Beta1-all.

       

      When I start the HotRod servers they form a cluster and I can see

      the content of the named cache in both servers. But when I add objects

      to the shared cache, my 2nd client overrides the 1st object in

      the shared cache. The 1st client always works properly always adding

      objects to the cache. If I start the 3nd client first, the behavior

      reverses accordingly.

       

      Because my HotRod servers and clients are exactly the same I expect

      symmetric behavior, but I don't get it.

       

      Another assymmetrical behavior that I am getting infinispan.log on one

      node, but not on the 2nd one.

       

      Here is my client:

      ==============================================================================

      import java.net.URL;

       

      import java.util.Set;

      import java.util.Map;

      import java.util.Iterator;

       

      import org.infinispan.client.hotrod.RemoteCache;

      import org.infinispan.client.hotrod.RemoteCacheManager;

       

      public class HotRodRemoteClient

      {

        public void start() 

        {

          URL resource = Thread.currentThread().getContextClassLoader().getResource("hotrod-client.properties");

          RemoteCacheManager remoteCacheManager = new RemoteCacheManager(resource, true);

         

          RemoteCache<Integer, Ticket> remoteCache = remoteCacheManager.getCache("clusteredCache");

       

          String command = ""; // Line read from standard in

          int ticketid = 1;

       

          IOUtils.dumpWelcomeMessage();

       

          while (true)

          {

            command = IOUtils.readLine("Enter command name > ");

            if (command.equals("book"))

            {

       

              String name = IOUtils.readLine("Enter name: ");

              String show = IOUtils.readLine("Enter show: ");

       

              Ticket ticket = new Ticket(name,show);

              remoteCache.put(ticketid, ticket);

              log("Booked ticket: "+ticket);

              ticketid++;

            }

            else if (command.equals("pay"))

            {

              Integer id = new Integer(IOUtils.readLine("Enter ticketid "));

              Ticket ticket = remoteCache.remove(id);

              log("Checked out ticket: "+ticket);

            }

            else if (command.equals("list"))

            {

              Map<Integer, Ticket> mp = remoteCache.getBulk();

              Set s = mp.entrySet();

             

              //Move next key and value of Map by iterator

              Iterator it=s.iterator();

       

              while(it.hasNext())

              {

                  // key=value separator this by Map.Entry to get key and value

                  Map.Entry m =(Map.Entry)it.next();

                 

                  // getValue is used to get value of key in Map

                  Ticket ticket=(Ticket)m.getValue();

                  System.out.println(ticket);

              }

            }

            else if (command.equals("quit"))

            {

              Map<Integer, Ticket> mp = remoteCache.getBulk();

              log("Tickets in RemoteCache : "+mp.size());

       

              remoteCacheManager.stop();

              log("Bye");

              break;

            }

            else

            {

              log("Unknown command "+command);

              IOUtils.dumpWelcomeMessage();

            }

          }

        }

       

        public static void main(String[] args)

        {

          new HotRodRemoteClient().start();

        }

       

        public static void log(String s)

        {

          System.out.println(s);

        }

      }

      ==============================================================================

       

      My 1st client (the one that I started the first) stores 2 objects:

      Input new command > list

      Ticket{name='a', show='b'}

      Ticket{name='c', show='d'}

       

      My 2nd client tries to add new object, but instead overrides the first object:

      Input new command > book

      Enter name: e

      Enter show: f

      Booked ticket Ticket{name='e', show='f'}

      Input new command > list

      Ticket{name='e', show='f'}

      Ticket{name='c', show='d'}

       

      My 1st client adds abother object and shows all three objects correctly.

      Input new command > book

      Enter name: g

      Enter show: h

      Booked ticket Ticket{name='g', show='h'}

      Input new command > list

      Ticket{name='e', show='f'}

      Ticket{name='c', show='d'}

      Ticket{name='g', show='h'}

       

      I did not change anything in the JGroups jgroups-udp.xml files on both nodes.

      I am attaching the startup files, config files and trace logs for this issue.

       

      So, I really don't understand the following issues:

      1. Why second server overrides the 1st stored in cache object?

      2. Why 2nd server does not have infinispan.log file?

      3. How to change this behavior to produce symmetrical and correct output?

       

      If you could help me I would appreciate it very much.

       

      Best regards,

       

      Jacob Nikom

       

      Explanation for the files:

      1. infinispan.log - log from infinispan HotRod server. It only exists on the 1st server

      2. cluster.xml     - configuration for HotRod 1st server

      3. HotRodRemoteClientExecute.sh  - startup file for HotRod 1st client

      4. RemoteCache_52_01.log - log of 1st node HotRod server

      5. runHotRodServer.sh - Startup file for 1st node HotRod server

      6. HotRodRemoteClient.java - HotRod client for the 1st server

      7. cluster_node2.xml - configuration for HotRod 2nd server

      8. HotRodRemoteClientExecute_node2.sh - startup file for HotRod 2nd client

      9. RemoteCache_node2_52_01.log - log of 2nd node HotRod server

      10. runHotRodServer_node2.sh - Startup file for 2nd node HotRod server

       

      Difference in log times relates to not precise time setting in both servers.

       

      Best regards,

       

      Jacob Nikom