You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aurora.apache.org by wf...@apache.org on 2014/01/25 20:01:43 UTC

git commit: Add a stat that tracks the number of threads waiting for the storage lock.

Updated Branches:
  refs/heads/master 383ccfb76 -> 964a5f355


Add a stat that tracks the number of threads waiting for the storage lock.

Reviewed at https://reviews.apache.org/r/17353/


Project: http://git-wip-us.apache.org/repos/asf/incubator-aurora/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-aurora/commit/964a5f35
Tree: http://git-wip-us.apache.org/repos/asf/incubator-aurora/tree/964a5f35
Diff: http://git-wip-us.apache.org/repos/asf/incubator-aurora/diff/964a5f35

Branch: refs/heads/master
Commit: 964a5f355bfcea6ca167f5024f394e5e4eae5929
Parents: 383ccfb
Author: Bill Farner <wf...@apache.org>
Authored: Sat Jan 25 11:01:35 2014 -0800
Committer: Bill Farner <wf...@apache.org>
Committed: Sat Jan 25 11:01:35 2014 -0800

----------------------------------------------------------------------
 .../aurora/scheduler/storage/ReadWriteLockManager.java | 13 +++++++++++--
 .../aurora/scheduler/storage/mem/MemStorage.java       |  7 +++++++
 2 files changed, 18 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/964a5f35/src/main/java/org/apache/aurora/scheduler/storage/ReadWriteLockManager.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/storage/ReadWriteLockManager.java b/src/main/java/org/apache/aurora/scheduler/storage/ReadWriteLockManager.java
index 7a4d9aa..513a159 100644
--- a/src/main/java/org/apache/aurora/scheduler/storage/ReadWriteLockManager.java
+++ b/src/main/java/org/apache/aurora/scheduler/storage/ReadWriteLockManager.java
@@ -15,7 +15,6 @@
  */
 package org.apache.aurora.scheduler.storage;
 
-import java.util.concurrent.locks.ReadWriteLock;
 import java.util.concurrent.locks.ReentrantReadWriteLock;
 
 import com.google.common.base.Preconditions;
@@ -25,7 +24,7 @@ import com.google.common.base.Preconditions;
  * a read-locked thread to a write-locked thread, which would otherwise deadlock.
  */
 public class ReadWriteLockManager {
-  private final ReadWriteLock lock = new ReentrantReadWriteLock();
+  private final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
 
   enum LockMode {
     NONE,
@@ -105,4 +104,14 @@ public class ReadWriteLockManager {
     lock.writeLock().unlock();
     lockState.get().lockReleased(LockMode.WRITE);
   }
+
+  /**
+   * Gets an approximation for the number of threads waiting to acquire the read or write lock.
+   *
+   * @see ReentrantReadWriteLock#getQueueLength()
+   * @return The estimated number of threads waiting for this lock.
+   */
+  public int getQueueLength() {
+    return lock.getQueueLength();
+  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/964a5f35/src/main/java/org/apache/aurora/scheduler/storage/mem/MemStorage.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/storage/mem/MemStorage.java b/src/main/java/org/apache/aurora/scheduler/storage/mem/MemStorage.java
index eb6f956..0769b68 100644
--- a/src/main/java/org/apache/aurora/scheduler/storage/mem/MemStorage.java
+++ b/src/main/java/org/apache/aurora/scheduler/storage/mem/MemStorage.java
@@ -21,6 +21,7 @@ import javax.inject.Inject;
 
 import com.google.common.annotations.VisibleForTesting;
 import com.twitter.common.inject.TimedInterceptor.Timed;
+import com.twitter.common.stats.StatImpl;
 import com.twitter.common.stats.Stats;
 
 import org.apache.aurora.scheduler.storage.AttributeStore;
@@ -89,6 +90,12 @@ public class MemStorage implements Storage {
         return attributeStore;
       }
     };
+
+    Stats.export(new StatImpl<Integer>("storage_lock_threads_waiting") {
+      @Override public Integer read() {
+        return lockManager.getQueueLength();
+      }
+    });
   }
 
   /**