incubator-connectors-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kwri...@apache.org
Subject svn commit: r1210934 - /incubator/lcf/branches/CONNECTORS-286/warthog/src/test/java/org/apache/warthog/tests/InMemAtomicNativeNonblockingKeyValueStore.java
Date Tue, 06 Dec 2011 14:33:46 GMT
Author: kwright
Date: Tue Dec  6 14:33:45 2011
New Revision: 1210934

URL: http://svn.apache.org/viewvc?rev=1210934&view=rev
Log:
Output contention keys in perf test so we can see what's colliding

Modified:
    incubator/lcf/branches/CONNECTORS-286/warthog/src/test/java/org/apache/warthog/tests/InMemAtomicNativeNonblockingKeyValueStore.java

Modified: incubator/lcf/branches/CONNECTORS-286/warthog/src/test/java/org/apache/warthog/tests/InMemAtomicNativeNonblockingKeyValueStore.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog/src/test/java/org/apache/warthog/tests/InMemAtomicNativeNonblockingKeyValueStore.java?rev=1210934&r1=1210933&r2=1210934&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-286/warthog/src/test/java/org/apache/warthog/tests/InMemAtomicNativeNonblockingKeyValueStore.java
(original)
+++ incubator/lcf/branches/CONNECTORS-286/warthog/src/test/java/org/apache/warthog/tests/InMemAtomicNativeNonblockingKeyValueStore.java
Tue Dec  6 14:33:45 2011
@@ -108,7 +108,7 @@ public class InMemAtomicNativeNonblockin
           continue;
         if (value != null && otherValue != null && value.equals(otherValue))
           continue;
-        //System.out.println("Type of key in check contention = "+key.getClass().getName());
+        System.out.println("Type of key in check contention = "+key.getClass().getName());
         throw new WHConcurrencyException();
       }
       // We got all the read locks and passed the checks!  Get the write locks now.  These
represent
@@ -179,32 +179,48 @@ public class InMemAtomicNativeNonblockin
   protected void grabLock(LockKey key, Long threadID)
     throws WHConcurrencyException
   {
-    Map database = databaseArray[key.hashCode() & databaseMask];
-    synchronized (database)
+    try
     {
-      LockValue lockValue = (LockValue)database.get(key);
-      if (lockValue == null)
+      Map database = databaseArray[key.hashCode() & databaseMask];
+      synchronized (database)
       {
-        lockValue = new LockValue();
-        database.put(key,lockValue);
+        LockValue lockValue = (LockValue)database.get(key);
+        if (lockValue == null)
+        {
+          lockValue = new LockValue();
+          database.put(key,lockValue);
+        }
+        lockValue.addReadLock(threadID);
       }
-      lockValue.addReadLock(threadID);
+    }
+    catch (WHConcurrencyException e)
+    {
+      System.out.println("Read lock concurrency: "+key.getKey().getClass().getName());
+      throw e;
     }
   }
   
   protected void grabWriteLock(LockKey key, Long threadID)
     throws WHConcurrencyException
   {
-    Map database = databaseArray[key.hashCode() & databaseMask];
-    synchronized (database)
+    try
     {
-      LockValue lockValue = (LockValue)database.get(key);
-      if (lockValue == null)
+      Map database = databaseArray[key.hashCode() & databaseMask];
+      synchronized (database)
       {
-        lockValue = new LockValue();
-        database.put(key,lockValue);
+        LockValue lockValue = (LockValue)database.get(key);
+        if (lockValue == null)
+        {
+          lockValue = new LockValue();
+          database.put(key,lockValue);
+        }
+        lockValue.addWriteLock(threadID);
       }
-      lockValue.addWriteLock(threadID);
+    }
+    catch (WHConcurrencyException e)
+    {
+      System.out.println("Write lock concurrency: "+key.getKey().getClass().getName());
+      throw e;
     }
   }
   
@@ -252,6 +268,11 @@ public class InMemAtomicNativeNonblockin
         return false;
       return ((LockKey)o).key.equals(key);
     }
+    
+    public WHKey getKey()
+    {
+      return key;
+    }
   }
   
   // Lock value class



Mime
View raw message