0 Replies Latest reply on Apr 2, 2014 9:42 AM by Alex Fité

    Hotrod client using versioned api

    Alex Fité Newbie

      I have a Standalone Hotrod Server running in infinispan 6.0.0 (via standalone.sh script)  and 2 clients  updating a counter object using  replaceWithVersion function.

      The test is to simulate a high speed registration.

       

      Code example:

       

      long getCount(String counterName)

      {

           VersionedValue valueBinary;

           long oldCount;

           boolean state=false;

           while(!state)

           {

                 valueBinary=cache.getVersioned(counterName);         

                oldCount=(long)valueBinary.getValue();

                newValue=oldValue+1;

                state=(boolean)cache.replaceWithVersion(counterName,newValue,valueBinary.getVersion());

           }

       

           return newValue;

      }

       

      The value returned by getCount is used as key for a another object, If inserted using putIfAbsent sometimes the call finds another object with the same key inserted by the other client.

      So sometimes both clients gets the same value using getCount.

       

      ¿Is there any special configuration needed to use versioned api?