[jbosscache-commits] JBoss Cache SVN: r6843 - benchmarks/benchmark-fwk/trunk/src/org/cachebench/tests.

jbosscache-commits at lists.jboss.org jbosscache-commits at lists.jboss.org
Mon Oct 6 09:14:38 EDT 2008


Author: mircea.markus
Date: 2008-10-06 09:14:38 -0400 (Mon, 06 Oct 2008)
New Revision: 6843

Modified:
   benchmarks/benchmark-fwk/trunk/src/org/cachebench/tests/SessionSimulatorTest.java
Log:
enhanced session simulator

Modified: benchmarks/benchmark-fwk/trunk/src/org/cachebench/tests/SessionSimulatorTest.java
===================================================================
--- benchmarks/benchmark-fwk/trunk/src/org/cachebench/tests/SessionSimulatorTest.java	2008-10-06 11:21:05 UTC (rev 6842)
+++ benchmarks/benchmark-fwk/trunk/src/org/cachebench/tests/SessionSimulatorTest.java	2008-10-06 13:14:38 UTC (rev 6843)
@@ -148,9 +148,9 @@
          List<String> path = Arrays.asList(key);
          Set received = new HashSet();
          int clusterSize = configuration.getClusterConfig().getClusterSize();
-         while (received.size() < clusterSize)
+         while (notAllAck(path, cacheWrapper))
          {
-            cacheWrapper.put(path, key + getNodeIndex(), "value" + getNodeIndex());
+            cacheWrapper.put(path, key + getNodeIndex(), getNodeIndex());
             for (int i = 0; i < clusterSize; i++)
             {
                Object replicatedValue = cacheWrapper.get(path, key + i);
@@ -158,6 +158,7 @@
                if (replicatedValue != null)
                {
                   received.add(replicatedValue);
+                  cacheWrapper.put(path, buildAckKey(Integer.parseInt(String.valueOf(replicatedValue)), getNodeIndex()), "recieved");
                }
             }
             if (received.size() < clusterSize)
@@ -173,6 +174,24 @@
       return replicationDelay;
    }
 
+   private String buildAckKey(int sender, int receiver )
+   {
+      return sender + "->" + receiver;
+   }
+
+   private boolean notAllAck(List path, CacheWrapper cacheWrapper) throws Exception
+   {
+      for (int i = 0; i < configuration.getClusterConfig().getClusterSize(); i++)
+      {
+         for (int j = 0; j < configuration.getClusterConfig().getClusterSize(); j++)
+         {
+            if (cacheWrapper.get(path, buildAckKey(i,j)) == null) return false;
+            
+         }
+      }
+      return true;
+   }
+
    private void logRunCount(int i)
    {
       if (((i + 1) % LOG_AFTER_OPERATION_COUNT == 0) || (i == 0))
@@ -221,9 +240,9 @@
             + numberOfAttributes + ", writePercentage=" + writePercentage + ", sizeOfAnAttribute=" + sizeOfAnAttribute + " ]");
    }
 
-   public String getNodeIndex()
+   public int getNodeIndex()
    {
-      return configuration.isLocalOnly() ? "0" : configuration.getClusterConfig().getCurrentNodeIndex() + "";
+      return configuration.isLocalOnly() ? 0 : configuration.getClusterConfig().getCurrentNodeIndex();
    }
 
 }




More information about the jbosscache-commits mailing list