From 1292bd9ba4bd5668e91565c9856ed8377d7161c4 Mon Sep 17 00:00:00 2001 From: Amnon Heiman Date: Tue, 17 Nov 2015 11:57:07 +0200 Subject: [PATCH] MessagingService: Add the depricated getRecentTimeoutsPerHost and getRecentTotalTimeouts This patch adds the impelementation for the depricated method getRecentTimeoutsPerHost and getRecentTotalTimeouts. The implementatin is based on origin, the recent version of the method, return the delta from the last call to the method. Signed-off-by: Amnon Heiman --- .../cassandra/net/MessagingService.java | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/apache/cassandra/net/MessagingService.java b/src/main/java/org/apache/cassandra/net/MessagingService.java index c9dd910..dceb9bb 100644 --- a/src/main/java/org/apache/cassandra/net/MessagingService.java +++ b/src/main/java/org/apache/cassandra/net/MessagingService.java @@ -42,8 +42,10 @@ public final class MessagingService implements MessagingServiceMBean { .getLogger(MessagingService.class.getName()); Map dropped; private APIClient c = new APIClient(); - + Map resent_timeout = new HashMap(); private final ObjectName jmxObjectName; + private long recentTimeoutCount; + /* All verb handler identifiers */ public enum Verb { @@ -230,7 +232,10 @@ public final class MessagingService implements MessagingServiceMBean { */ public long getRecentTotalTimouts() { log(" getRecentTotalTimouts()"); - return c.getLongValue(""); + long timeoutCount = getTotalTimeouts(); + long recent = timeoutCount - recentTimeoutCount; + recentTimeoutCount = timeoutCount; + return recent; } /** @@ -238,7 +243,16 @@ public final class MessagingService implements MessagingServiceMBean { */ public Map getRecentTimeoutsPerHost() { log(" getRecentTimeoutsPerHost()"); - return c.getMapStringLongValue(""); + Map timeouts = getTimeoutsPerHost(); + Map result = new HashMap(); + for ( Entry e : timeouts.entrySet()) { + long res = e.getValue().longValue() - + ((resent_timeout.containsKey(e.getKey()))? (resent_timeout.get(e.getKey())).longValue() + : 0); + resent_timeout.put(e.getKey(), e.getValue()); + result.put(e.getKey(),res); + } + return result; } public int getVersion(String address) throws UnknownHostException {