cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject [2/2] git commit: fix timeout reporting to dsnitch patch by vijay; reviewed by jbellis for CASSANDRA-2819
Date Fri, 22 Jun 2012 17:34:20 GMT
fix timeout reporting to dsnitch
patch by vijay; reviewed by jbellis for CASSANDRA-2819


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/f422b981
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/f422b981
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/f422b981

Branch: refs/heads/trunk
Commit: f422b98140dcec99d93858148415d43f01fa70d1
Parents: f17fbac
Author: Jonathan Ellis <jbellis@apache.org>
Authored: Fri Jun 22 12:31:52 2012 -0500
Committer: Jonathan Ellis <jbellis@apache.org>
Committed: Fri Jun 22 12:33:50 2012 -0500

----------------------------------------------------------------------
 .../org/apache/cassandra/net/MessagingService.java |    8 ++--
 .../org/apache/cassandra/utils/ExpiringMap.java    |   24 +++++++-------
 2 files changed, 16 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/f422b981/src/java/org/apache/cassandra/net/MessagingService.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/net/MessagingService.java b/src/java/org/apache/cassandra/net/MessagingService.java
index 18f3baa..e4e59cb 100644
--- a/src/java/org/apache/cassandra/net/MessagingService.java
+++ b/src/java/org/apache/cassandra/net/MessagingService.java
@@ -318,12 +318,12 @@ public final class MessagingService implements MessagingServiceMBean
         };
         StorageService.scheduledTasks.scheduleWithFixedDelay(logDropped, LOG_DROPPED_INTERVAL_IN_MS,
LOG_DROPPED_INTERVAL_IN_MS, TimeUnit.MILLISECONDS);
 
-        Function<Pair<String, CallbackInfo>, ?> timeoutReporter = new Function<Pair<String,
CallbackInfo>, Object>()
+        Function<Pair<String, ExpiringMap.CacheableObject<CallbackInfo>>,
?> timeoutReporter = new Function<Pair<String, ExpiringMap.CacheableObject<CallbackInfo>>,
Object>()
         {
-            public Object apply(Pair<String, CallbackInfo> pair)
+            public Object apply(Pair<String, ExpiringMap.CacheableObject<CallbackInfo>>
pair)
             {
-                CallbackInfo expiredCallbackInfo = pair.right;
-                maybeAddLatency(expiredCallbackInfo.callback, expiredCallbackInfo.target,
(double) expiredCallbackInfo.sentMessage.getTimeout());
+                CallbackInfo expiredCallbackInfo = pair.right.getValue();
+                maybeAddLatency(expiredCallbackInfo.callback, expiredCallbackInfo.target,
(double) pair.right.timeout);
                 totalTimeouts++;
                 String ip = expiredCallbackInfo.target.getHostAddress();
                 AtomicLong c = timeoutsPerHost.get(ip);

http://git-wip-us.apache.org/repos/asf/cassandra/blob/f422b981/src/java/org/apache/cassandra/utils/ExpiringMap.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/utils/ExpiringMap.java b/src/java/org/apache/cassandra/utils/ExpiringMap.java
index 6503b54..9b34bb8 100644
--- a/src/java/org/apache/cassandra/utils/ExpiringMap.java
+++ b/src/java/org/apache/cassandra/utils/ExpiringMap.java
@@ -34,28 +34,28 @@ public class ExpiringMap<K, V>
     private static final Logger logger = LoggerFactory.getLogger(ExpiringMap.class);
     private volatile boolean shutdown;
 
-    private static class CacheableObject<T>
+    public static class CacheableObject<T>
     {
         private final T value;
         private final long createdAt;
-        private final long expiration;
+        public final long timeout;
 
-        CacheableObject(T o, long e)
+        private CacheableObject(T value, long timeout)
         {
-            assert o != null;
-            value = o;
-            expiration = e;
-            createdAt = System.currentTimeMillis();
+            assert value != null;
+            this.value = value;
+            this.timeout = timeout;
+            this.createdAt = System.currentTimeMillis();
         }
 
-        T getValue()
+        public T getValue()
         {
             return value;
         }
 
-        boolean isReadyToDieAt(long time)
+        private boolean isReadyToDieAt(long time)
         {
-            return ((time - createdAt) > expiration);
+            return ((time - createdAt) > timeout);
         }
     }
 
@@ -74,7 +74,7 @@ public class ExpiringMap<K, V>
      *
      * @param defaultExpiration the TTL for objects in the cache in milliseconds
      */
-    public ExpiringMap(long defaultExpiration, final Function<Pair<K,V>, ?> postExpireHook)
+    public ExpiringMap(long defaultExpiration, final Function<Pair<K,CacheableObject<V>>,
?> postExpireHook)
     {
         this.defaultExpiration = defaultExpiration;
 
@@ -96,7 +96,7 @@ public class ExpiringMap<K, V>
                         cache.remove(entry.getKey());
                         n++;
                         if (postExpireHook != null)
-                            postExpireHook.apply(new Pair<K, V>(entry.getKey(), entry.getValue().getValue()));
+                            postExpireHook.apply(new Pair<K, CacheableObject<V>>(entry.getKey(),
entry.getValue()));
                     }
                 }
                 logger.trace("Expired {} entries", n);


Mime
View raw message