Skip to content

Commit

Permalink
fix for getPendingTasks() that disappeared in C* 3.0 (using JMX direc…
Browse files Browse the repository at this point in the history
…tly to get pending compactions)

disabled primary range repair for incremental repair as it leaves unrepaired data on disk
  • Loading branch information
adejanovski committed Aug 26, 2016
1 parent 1a72c1c commit 970f934
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions src/main/java/com/spotify/reaper/cassandra/JmxProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ public class JmxProxy implements NotificationListener, AutoCloseable {
private static final String SS_OBJECT_NAME = "org.apache.cassandra.db:type=StorageService";
private static final String AES_OBJECT_NAME =
"org.apache.cassandra.internal:type=AntiEntropySessions";
private static final String COMP_OBJECT_NAME =
"org.apache.cassandra.metrics:type=Compaction";

private final JMXConnector jmxConnector;
private final ObjectName ssMbeanName;
Expand Down Expand Up @@ -255,7 +257,23 @@ public Set<String> getTableNamesForKeyspace(String keyspace) throws ReaperExcept
*/
public int getPendingCompactions() {
checkNotNull(cmProxy, "Looks like the proxy is not connected");
return cmProxy.getPendingTasks();
try {
ObjectName name = new ObjectName(COMP_OBJECT_NAME);
int pendingCount = (int) mbeanServer.getAttribute(name, "PendingTasks");
return pendingCount;
} catch (IOException ignored) {
LOG.warn("Failed to connect to " + host + " using JMX");
} catch (MalformedObjectNameException ignored) {
LOG.error("Internal error, malformed name");
} catch (InstanceNotFoundException e) {
// This happens if no repair has yet been run on the node
// The AntiEntropySessions object is created on the first repair
return 0;
} catch (Exception e) {
LOG.error("Error getting attribute from JMX", e);
}
// If uncertain, assume it's running
return 0;
}

/**
Expand Down Expand Up @@ -365,7 +383,7 @@ public int triggerRepair(BigInteger beginToken, BigInteger endToken, String keys
columnFamilies.toArray(new String[columnFamilies.size()]));
}
else {
return ssProxy.forceRepairAsync(keyspace, Boolean.FALSE, Boolean.FALSE, Boolean.TRUE, fullRepair, columnFamilies.toArray(new String[columnFamilies.size()]));
return ssProxy.forceRepairAsync(keyspace, Boolean.FALSE, Boolean.FALSE, Boolean.FALSE, fullRepair, columnFamilies.toArray(new String[columnFamilies.size()]));
}
}

Expand Down

0 comments on commit 970f934

Please sign in to comment.