From 6f910352dc4fe1772248dae0d2a0f8e5e2fb1921 Mon Sep 17 00:00:00 2001 From: Alexander Dejanovski Date: Wed, 21 Jun 2017 08:08:27 +0200 Subject: [PATCH] Fix issue with C* <= 2.1.9 not having the StorageServiceMBean.getEndpointToHostId() method --- .../java/com/spotify/reaper/cassandra/JmxProxy.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/spotify/reaper/cassandra/JmxProxy.java b/src/main/java/com/spotify/reaper/cassandra/JmxProxy.java index 7483a4618..03995123d 100644 --- a/src/main/java/com/spotify/reaper/cassandra/JmxProxy.java +++ b/src/main/java/com/spotify/reaper/cassandra/JmxProxy.java @@ -16,6 +16,7 @@ import static com.google.common.base.Preconditions.checkNotNull; import java.io.IOException; +import java.lang.reflect.UndeclaredThrowableException; import java.math.BigInteger; import java.net.InetSocketAddress; import java.net.MalformedURLException; @@ -58,7 +59,7 @@ import com.google.common.base.Function; import com.google.common.base.Optional; import com.google.common.collect.Lists; - +import com.google.common.collect.Maps; import com.datastax.driver.core.policies.EC2MultiRegionAddressTranslator; import com.spotify.reaper.ReaperException; import com.spotify.reaper.core.Cluster; @@ -252,9 +253,12 @@ public List tokenRangeToEndpoint(String keyspace, RingRange tokenRange) @NotNull public Map getEndpointToHostId() { checkNotNull(ssProxy, "Looks like the proxy is not connected"); - Map hosts = - ((StorageServiceMBean) ssProxy).getEndpointToHostId(); - + Map hosts = Maps.newHashMap(); + try{ + hosts = ((StorageServiceMBean) ssProxy).getEndpointToHostId(); + } catch(UndeclaredThrowableException e){ + hosts = ((StorageServiceMBean) ssProxy).getHostIdMap(); + } return hosts; }