Rework service.* beans
This commit is contained in:
parent
fec8b44942
commit
4ec7d58249
@ -24,22 +24,19 @@
|
||||
|
||||
package org.apache.cassandra.service;
|
||||
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.management.MBeanServer;
|
||||
import javax.management.ObjectName;
|
||||
import javax.ws.rs.core.MultivaluedHashMap;
|
||||
import javax.ws.rs.core.MultivaluedMap;
|
||||
|
||||
import org.apache.cassandra.metrics.CacheMetrics;
|
||||
|
||||
import com.scylladb.jmx.api.APIClient;
|
||||
import com.scylladb.jmx.metrics.MetricsMBean;
|
||||
|
||||
public class CacheService implements CacheServiceMBean {
|
||||
private static final java.util.logging.Logger logger = java.util.logging.Logger
|
||||
.getLogger(CacheService.class.getName());
|
||||
private APIClient c = new APIClient();
|
||||
public class CacheService extends MetricsMBean implements CacheServiceMBean {
|
||||
private static final Logger logger = Logger.getLogger(CacheService.class.getName());
|
||||
|
||||
public void log(String str) {
|
||||
logger.finest(str);
|
||||
@ -47,33 +44,15 @@ public class CacheService implements CacheServiceMBean {
|
||||
|
||||
public static final String MBEAN_NAME = "org.apache.cassandra.db:type=Caches";
|
||||
|
||||
public final CacheMetrics keyCache;
|
||||
public final CacheMetrics rowCache;
|
||||
public final CacheMetrics counterCache;
|
||||
public final static CacheService instance = new CacheService();
|
||||
|
||||
public static CacheService getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
private CacheService() {
|
||||
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
|
||||
|
||||
try {
|
||||
mbs.registerMBean(this, new ObjectName(MBEAN_NAME));
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
keyCache = new CacheMetrics("KeyCache", null);
|
||||
rowCache = new CacheMetrics("RowCache", "row");
|
||||
counterCache = new CacheMetrics("CounterCache", null);
|
||||
public CacheService(APIClient client) {
|
||||
super(MBEAN_NAME, client, new CacheMetrics("KeyCache", "key"), new CacheMetrics("RowCache", "row"),
|
||||
new CacheMetrics("CounterCache", "counter"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRowCacheSavePeriodInSeconds() {
|
||||
log(" getRowCacheSavePeriodInSeconds()");
|
||||
return c.getIntValue("cache_service/row_cache_save_period");
|
||||
return client.getIntValue("cache_service/row_cache_save_period");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -81,13 +60,13 @@ public class CacheService implements CacheServiceMBean {
|
||||
log(" setRowCacheSavePeriodInSeconds(int rcspis)");
|
||||
MultivaluedMap<String, String> queryParams = new MultivaluedHashMap<String, String>();
|
||||
queryParams.add("period", Integer.toString(rcspis));
|
||||
c.post("cache_service/row_cache_save_period", queryParams);
|
||||
client.post("cache_service/row_cache_save_period", queryParams);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getKeyCacheSavePeriodInSeconds() {
|
||||
log(" getKeyCacheSavePeriodInSeconds()");
|
||||
return c.getIntValue("cache_service/key_cache_save_period");
|
||||
return client.getIntValue("cache_service/key_cache_save_period");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -95,13 +74,13 @@ public class CacheService implements CacheServiceMBean {
|
||||
log(" setKeyCacheSavePeriodInSeconds(int kcspis)");
|
||||
MultivaluedMap<String, String> queryParams = new MultivaluedHashMap<String, String>();
|
||||
queryParams.add("period", Integer.toString(kcspis));
|
||||
c.post("cache_service/key_cache_save_period", queryParams);
|
||||
client.post("cache_service/key_cache_save_period", queryParams);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCounterCacheSavePeriodInSeconds() {
|
||||
log(" getCounterCacheSavePeriodInSeconds()");
|
||||
return c.getIntValue("cache_service/counter_cache_save_period");
|
||||
return client.getIntValue("cache_service/counter_cache_save_period");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -109,13 +88,13 @@ public class CacheService implements CacheServiceMBean {
|
||||
log(" setCounterCacheSavePeriodInSeconds(int ccspis)");
|
||||
MultivaluedMap<String, String> queryParams = new MultivaluedHashMap<String, String>();
|
||||
queryParams.add("ccspis", Integer.toString(ccspis));
|
||||
c.post("cache_service/counter_cache_save_period", queryParams);
|
||||
client.post("cache_service/counter_cache_save_period", queryParams);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRowCacheKeysToSave() {
|
||||
log(" getRowCacheKeysToSave()");
|
||||
return c.getIntValue("cache_service/row_cache_keys_to_save");
|
||||
return client.getIntValue("cache_service/row_cache_keys_to_save");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -123,13 +102,13 @@ public class CacheService implements CacheServiceMBean {
|
||||
log(" setRowCacheKeysToSave(int rckts)");
|
||||
MultivaluedMap<String, String> queryParams = new MultivaluedHashMap<String, String>();
|
||||
queryParams.add("rckts", Integer.toString(rckts));
|
||||
c.post("cache_service/row_cache_keys_to_save", queryParams);
|
||||
client.post("cache_service/row_cache_keys_to_save", queryParams);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getKeyCacheKeysToSave() {
|
||||
log(" getKeyCacheKeysToSave()");
|
||||
return c.getIntValue("cache_service/key_cache_keys_to_save");
|
||||
return client.getIntValue("cache_service/key_cache_keys_to_save");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -137,13 +116,13 @@ public class CacheService implements CacheServiceMBean {
|
||||
log(" setKeyCacheKeysToSave(int kckts)");
|
||||
MultivaluedMap<String, String> queryParams = new MultivaluedHashMap<String, String>();
|
||||
queryParams.add("kckts", Integer.toString(kckts));
|
||||
c.post("cache_service/key_cache_keys_to_save", queryParams);
|
||||
client.post("cache_service/key_cache_keys_to_save", queryParams);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCounterCacheKeysToSave() {
|
||||
log(" getCounterCacheKeysToSave()");
|
||||
return c.getIntValue("cache_service/counter_cache_keys_to_save");
|
||||
return client.getIntValue("cache_service/counter_cache_keys_to_save");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -151,7 +130,7 @@ public class CacheService implements CacheServiceMBean {
|
||||
log(" setCounterCacheKeysToSave(int cckts)");
|
||||
MultivaluedMap<String, String> queryParams = new MultivaluedHashMap<String, String>();
|
||||
queryParams.add("cckts", Integer.toString(cckts));
|
||||
c.post("cache_service/counter_cache_keys_to_save", queryParams);
|
||||
client.post("cache_service/counter_cache_keys_to_save", queryParams);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -160,7 +139,7 @@ public class CacheService implements CacheServiceMBean {
|
||||
@Override
|
||||
public void invalidateKeyCache() {
|
||||
log(" invalidateKeyCache()");
|
||||
c.post("cache_service/invalidate_key_cache");
|
||||
client.post("cache_service/invalidate_key_cache");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -169,13 +148,13 @@ public class CacheService implements CacheServiceMBean {
|
||||
@Override
|
||||
public void invalidateRowCache() {
|
||||
log(" invalidateRowCache()");
|
||||
c.post("cache_service/invalidate_row_cache");
|
||||
client.post("cache_service/invalidate_row_cache");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidateCounterCache() {
|
||||
log(" invalidateCounterCache()");
|
||||
c.post("cache_service/invalidate_counter_cache");
|
||||
client.post("cache_service/invalidate_counter_cache");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -183,7 +162,7 @@ public class CacheService implements CacheServiceMBean {
|
||||
log(" setRowCacheCapacityInMB(long capacity)");
|
||||
MultivaluedMap<String, String> queryParams = new MultivaluedHashMap<String, String>();
|
||||
queryParams.add("capacity", Long.toString(capacity));
|
||||
c.post("cache_service/row_cache_capacity", queryParams);
|
||||
client.post("cache_service/row_cache_capacity", queryParams);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -191,7 +170,7 @@ public class CacheService implements CacheServiceMBean {
|
||||
log(" setKeyCacheCapacityInMB(long capacity)");
|
||||
MultivaluedMap<String, String> queryParams = new MultivaluedHashMap<String, String>();
|
||||
queryParams.add("capacity", Long.toString(capacity));
|
||||
c.post("cache_service/key_cache_capacity", queryParams);
|
||||
client.post("cache_service/key_cache_capacity", queryParams);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -199,7 +178,7 @@ public class CacheService implements CacheServiceMBean {
|
||||
log(" setCounterCacheCapacityInMB(long capacity)");
|
||||
MultivaluedMap<String, String> queryParams = new MultivaluedHashMap<String, String>();
|
||||
queryParams.add("capacity", Long.toString(capacity));
|
||||
c.post("cache_service/counter_cache_capacity_in_mb", queryParams);
|
||||
client.post("cache_service/counter_cache_capacity_in_mb", queryParams);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -216,6 +195,6 @@ public class CacheService implements CacheServiceMBean {
|
||||
@Override
|
||||
public void saveCaches() throws ExecutionException, InterruptedException {
|
||||
log(" saveCaches() throws ExecutionException, InterruptedException");
|
||||
c.post("cache_service/save_caches");
|
||||
client.post("cache_service/save_caches");
|
||||
}
|
||||
}
|
||||
|
@ -24,259 +24,18 @@
|
||||
|
||||
package org.apache.cassandra.service;
|
||||
|
||||
import java.lang.management.GarbageCollectorMXBean;
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.lang.management.MemoryUsage;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import com.scylladb.jmx.api.APIClient;
|
||||
import com.scylladb.jmx.metrics.APIMBean;
|
||||
|
||||
import javax.management.MBeanServer;
|
||||
import javax.management.Notification;
|
||||
import javax.management.NotificationListener;
|
||||
import javax.management.ObjectName;
|
||||
import javax.management.openmbean.CompositeData;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.sun.management.GarbageCollectionNotificationInfo;
|
||||
import com.sun.management.GcInfo;
|
||||
|
||||
@SuppressWarnings("restriction")
|
||||
public class GCInspector implements NotificationListener, GCInspectorMXBean
|
||||
{
|
||||
public class GCInspector extends APIMBean implements GCInspectorMXBean {
|
||||
public static final String MBEAN_NAME = "org.apache.cassandra.service:type=GCInspector";
|
||||
private static final Logger logger = LoggerFactory.getLogger(GCInspector.class);
|
||||
final static long MIN_LOG_DURATION = 200;
|
||||
final static long MIN_LOG_DURATION_TPSTATS = 1000;
|
||||
|
||||
static final class State
|
||||
{
|
||||
final double maxRealTimeElapsed;
|
||||
final double totalRealTimeElapsed;
|
||||
final double sumSquaresRealTimeElapsed;
|
||||
final double totalBytesReclaimed;
|
||||
final double count;
|
||||
final long startNanos;
|
||||
|
||||
State(double extraElapsed, double extraBytes, State prev)
|
||||
{
|
||||
this.totalRealTimeElapsed = prev.totalRealTimeElapsed + extraElapsed;
|
||||
this.totalBytesReclaimed = prev.totalBytesReclaimed + extraBytes;
|
||||
this.sumSquaresRealTimeElapsed = prev.sumSquaresRealTimeElapsed + (extraElapsed * extraElapsed);
|
||||
this.startNanos = prev.startNanos;
|
||||
this.count = prev.count + 1;
|
||||
this.maxRealTimeElapsed = Math.max(prev.maxRealTimeElapsed, extraElapsed);
|
||||
}
|
||||
|
||||
State()
|
||||
{
|
||||
count = maxRealTimeElapsed = sumSquaresRealTimeElapsed = totalRealTimeElapsed = totalBytesReclaimed = 0;
|
||||
startNanos = System.nanoTime();
|
||||
}
|
||||
public GCInspector(APIClient client) {
|
||||
super(client);
|
||||
}
|
||||
|
||||
static final class GCState
|
||||
{
|
||||
final GarbageCollectorMXBean gcBean;
|
||||
final boolean assumeGCIsPartiallyConcurrent;
|
||||
final boolean assumeGCIsOldGen;
|
||||
private String[] keys;
|
||||
long lastGcTotalDuration = 0;
|
||||
|
||||
|
||||
GCState(GarbageCollectorMXBean gcBean, boolean assumeGCIsPartiallyConcurrent, boolean assumeGCIsOldGen)
|
||||
{
|
||||
this.gcBean = gcBean;
|
||||
this.assumeGCIsPartiallyConcurrent = assumeGCIsPartiallyConcurrent;
|
||||
this.assumeGCIsOldGen = assumeGCIsOldGen;
|
||||
}
|
||||
|
||||
String[] keys(GarbageCollectionNotificationInfo info)
|
||||
{
|
||||
if (keys != null)
|
||||
return keys;
|
||||
|
||||
keys = info.getGcInfo().getMemoryUsageBeforeGc().keySet().toArray(new String[0]);
|
||||
Arrays.sort(keys);
|
||||
|
||||
return keys;
|
||||
}
|
||||
}
|
||||
|
||||
final AtomicReference<State> state = new AtomicReference<>(new State());
|
||||
|
||||
final Map<String, GCState> gcStates = new HashMap<>();
|
||||
|
||||
public GCInspector()
|
||||
{
|
||||
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
|
||||
|
||||
try
|
||||
{
|
||||
ObjectName gcName = new ObjectName(ManagementFactory.GARBAGE_COLLECTOR_MXBEAN_DOMAIN_TYPE + ",*");
|
||||
for (ObjectName name : mbs.queryNames(gcName, null))
|
||||
{
|
||||
GarbageCollectorMXBean gc = ManagementFactory.newPlatformMXBeanProxy(mbs, name.getCanonicalName(), GarbageCollectorMXBean.class);
|
||||
gcStates.put(gc.getName(), new GCState(gc, assumeGCIsPartiallyConcurrent(gc), assumeGCIsOldGen(gc)));
|
||||
}
|
||||
|
||||
mbs.registerMBean(this, new ObjectName(MBEAN_NAME));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static void register() throws Exception
|
||||
{
|
||||
GCInspector inspector = new GCInspector();
|
||||
MBeanServer server = ManagementFactory.getPlatformMBeanServer();
|
||||
ObjectName gcName = new ObjectName(ManagementFactory.GARBAGE_COLLECTOR_MXBEAN_DOMAIN_TYPE + ",*");
|
||||
for (ObjectName name : server.queryNames(gcName, null))
|
||||
{
|
||||
server.addNotificationListener(name, inspector, null, null);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Assume that a GC type is at least partially concurrent and so a side channel method
|
||||
* should be used to calculate application stopped time due to the GC.
|
||||
*
|
||||
* If the GC isn't recognized then assume that is concurrent and we need to do our own calculation
|
||||
* via the the side channel.
|
||||
*/
|
||||
private static boolean assumeGCIsPartiallyConcurrent(GarbageCollectorMXBean gc)
|
||||
{
|
||||
switch (gc.getName())
|
||||
{
|
||||
//First two are from the serial collector
|
||||
case "Copy":
|
||||
case "MarkSweepCompact":
|
||||
//Parallel collector
|
||||
case "PS MarkSweep":
|
||||
case "PS Scavenge":
|
||||
case "G1 Young Generation":
|
||||
//CMS young generation collector
|
||||
case "ParNew":
|
||||
return false;
|
||||
case "ConcurrentMarkSweep":
|
||||
case "G1 Old Generation":
|
||||
return true;
|
||||
default:
|
||||
//Assume possibly concurrent if unsure
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Assume that a GC type is an old generation collection so SSTableDeletingTask.rescheduleFailedTasks()
|
||||
* should be invoked.
|
||||
*
|
||||
* Defaults to not invoking SSTableDeletingTask.rescheduleFailedTasks() on unrecognized GC names
|
||||
*/
|
||||
private static boolean assumeGCIsOldGen(GarbageCollectorMXBean gc)
|
||||
{
|
||||
switch (gc.getName())
|
||||
{
|
||||
case "Copy":
|
||||
case "PS Scavenge":
|
||||
case "G1 Young Generation":
|
||||
case "ParNew":
|
||||
return false;
|
||||
case "MarkSweepCompact":
|
||||
case "PS MarkSweep":
|
||||
case "ConcurrentMarkSweep":
|
||||
case "G1 Old Generation":
|
||||
return true;
|
||||
default:
|
||||
//Assume not old gen otherwise, don't call
|
||||
//SSTableDeletingTask.rescheduleFailedTasks()
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void handleNotification(final Notification notification, final Object handback)
|
||||
{
|
||||
String type = notification.getType();
|
||||
if (type.equals(GarbageCollectionNotificationInfo.GARBAGE_COLLECTION_NOTIFICATION))
|
||||
{
|
||||
// retrieve the garbage collection notification information
|
||||
CompositeData cd = (CompositeData) notification.getUserData();
|
||||
GarbageCollectionNotificationInfo info = GarbageCollectionNotificationInfo.from(cd);
|
||||
String gcName = info.getGcName();
|
||||
GcInfo gcInfo = info.getGcInfo();
|
||||
|
||||
long duration = gcInfo.getDuration();
|
||||
|
||||
/*
|
||||
* The duration supplied in the notification info includes more than just
|
||||
* application stopped time for concurrent GCs. Try and do a better job coming up with a good stopped time
|
||||
* value by asking for and tracking cumulative time spent blocked in GC.
|
||||
*/
|
||||
GCState gcState = gcStates.get(gcName);
|
||||
if (gcState.assumeGCIsPartiallyConcurrent)
|
||||
{
|
||||
long previousTotal = gcState.lastGcTotalDuration;
|
||||
long total = gcState.gcBean.getCollectionTime();
|
||||
gcState.lastGcTotalDuration = total;
|
||||
duration = total - previousTotal; // may be zero for a really fast collection
|
||||
}
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(info.getGcName()).append(" GC in ").append(duration).append("ms. ");
|
||||
long bytes = 0;
|
||||
Map<String, MemoryUsage> beforeMemoryUsage = gcInfo.getMemoryUsageBeforeGc();
|
||||
Map<String, MemoryUsage> afterMemoryUsage = gcInfo.getMemoryUsageAfterGc();
|
||||
for (String key : gcState.keys(info))
|
||||
{
|
||||
MemoryUsage before = beforeMemoryUsage.get(key);
|
||||
MemoryUsage after = afterMemoryUsage.get(key);
|
||||
if (after != null && after.getUsed() != before.getUsed())
|
||||
{
|
||||
sb.append(key).append(": ").append(before.getUsed());
|
||||
sb.append(" -> ");
|
||||
sb.append(after.getUsed());
|
||||
if (!key.equals(gcState.keys[gcState.keys.length - 1]))
|
||||
sb.append("; ");
|
||||
bytes += before.getUsed() - after.getUsed();
|
||||
}
|
||||
}
|
||||
|
||||
while (true)
|
||||
{
|
||||
State prev = state.get();
|
||||
if (state.compareAndSet(prev, new State(duration, bytes, prev)))
|
||||
break;
|
||||
}
|
||||
|
||||
String st = sb.toString();
|
||||
if (duration > MIN_LOG_DURATION)
|
||||
logger.trace(st);
|
||||
else if (logger.isDebugEnabled())
|
||||
logger.debug(st);
|
||||
}
|
||||
}
|
||||
|
||||
public State getTotalSinceLastCheck()
|
||||
{
|
||||
return state.getAndSet(new State());
|
||||
}
|
||||
|
||||
public double[] getAndResetStats()
|
||||
{
|
||||
State state = getTotalSinceLastCheck();
|
||||
double[] r = new double[6];
|
||||
r[0] = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - state.startNanos);
|
||||
r[1] = state.maxRealTimeElapsed;
|
||||
r[2] = state.totalRealTimeElapsed;
|
||||
r[3] = state.sumSquaresRealTimeElapsed;
|
||||
r[4] = state.totalBytesReclaimed;
|
||||
r[5] = state.count;
|
||||
return r;
|
||||
@Override
|
||||
public double[] getAndResetStats() {
|
||||
return new double[6];
|
||||
}
|
||||
}
|
||||
|
@ -25,67 +25,54 @@ package org.apache.cassandra.service;
|
||||
|
||||
import static java.util.Collections.emptySet;
|
||||
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.management.MBeanServer;
|
||||
import javax.management.ObjectName;
|
||||
import javax.ws.rs.core.MultivaluedHashMap;
|
||||
import javax.ws.rs.core.MultivaluedMap;
|
||||
|
||||
import org.apache.cassandra.metrics.CASClientRequestMetrics;
|
||||
import org.apache.cassandra.metrics.ClientRequestMetrics;
|
||||
|
||||
import com.scylladb.jmx.api.APIClient;
|
||||
import com.scylladb.jmx.metrics.MetricsMBean;
|
||||
|
||||
public class StorageProxy implements StorageProxyMBean {
|
||||
public class StorageProxy extends MetricsMBean implements StorageProxyMBean {
|
||||
public static final String MBEAN_NAME = "org.apache.cassandra.db:type=StorageProxy";
|
||||
private static final java.util.logging.Logger logger = java.util.logging.Logger
|
||||
.getLogger(StorageProxy.class.getName());
|
||||
|
||||
private APIClient c = new APIClient();
|
||||
private static final Logger logger = Logger.getLogger(StorageProxy.class.getName());
|
||||
|
||||
public void log(String str) {
|
||||
logger.finest(str);
|
||||
}
|
||||
|
||||
private static final StorageProxy instance = new StorageProxy();
|
||||
|
||||
public static StorageProxy getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
public static final String UNREACHABLE = "UNREACHABLE";
|
||||
|
||||
private StorageProxy() {
|
||||
}
|
||||
|
||||
static {
|
||||
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
|
||||
try {
|
||||
mbs.registerMBean(instance, new ObjectName(MBEAN_NAME));
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
public StorageProxy(APIClient client) {
|
||||
super(MBEAN_NAME, client, new ClientRequestMetrics("Read", "storage_proxy/metrics/read"),
|
||||
new ClientRequestMetrics("RangeSlice", "/storage_proxy/metrics/range"),
|
||||
new ClientRequestMetrics("Write", "storage_proxy/metrics/write"),
|
||||
new CASClientRequestMetrics("CASWrite", "storage_proxy/metrics/cas_write"),
|
||||
new CASClientRequestMetrics("CASRead", "storage_proxy/metrics/cas_read"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getTotalHints() {
|
||||
log(" getTotalHints()");
|
||||
return c.getLongValue("storage_proxy/total_hints");
|
||||
return client.getLongValue("storage_proxy/total_hints");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getHintedHandoffEnabled() {
|
||||
log(" getHintedHandoffEnabled()");
|
||||
return c.getBooleanValue("storage_proxy/hinted_handoff_enabled");
|
||||
return client.getBooleanValue("storage_proxy/hinted_handoff_enabled");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getHintedHandoffEnabledByDC() {
|
||||
log(" getHintedHandoffEnabledByDC()");
|
||||
return c.getSetStringValue(
|
||||
"storage_proxy/hinted_handoff_enabled_by_dc");
|
||||
return client.getSetStringValue("storage_proxy/hinted_handoff_enabled_by_dc");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -93,7 +80,7 @@ public class StorageProxy implements StorageProxyMBean {
|
||||
log(" setHintedHandoffEnabled(boolean b)");
|
||||
MultivaluedMap<String, String> queryParams = new MultivaluedHashMap<String, String>();
|
||||
queryParams.add("enable", Boolean.toString(b));
|
||||
c.post("storage_proxy/hinted_handoff_enabled", queryParams);
|
||||
client.post("storage_proxy/hinted_handoff_enabled", queryParams);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -101,13 +88,13 @@ public class StorageProxy implements StorageProxyMBean {
|
||||
log(" setHintedHandoffEnabledByDCList(String dcs)");
|
||||
MultivaluedMap<String, String> queryParams = new MultivaluedHashMap<String, String>();
|
||||
queryParams.add("dcs", dcs);
|
||||
c.post("storage_proxy/hinted_handoff_enabled_by_dc_list");
|
||||
client.post("storage_proxy/hinted_handoff_enabled_by_dc_list");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxHintWindow() {
|
||||
log(" getMaxHintWindow()");
|
||||
return c.getIntValue("storage_proxy/max_hint_window");
|
||||
return client.getIntValue("storage_proxy/max_hint_window");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -115,13 +102,13 @@ public class StorageProxy implements StorageProxyMBean {
|
||||
log(" setMaxHintWindow(int ms)");
|
||||
MultivaluedMap<String, String> queryParams = new MultivaluedHashMap<String, String>();
|
||||
queryParams.add("ms", Integer.toString(ms));
|
||||
c.post("storage_proxy/max_hint_window", queryParams);
|
||||
client.post("storage_proxy/max_hint_window", queryParams);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxHintsInProgress() {
|
||||
log(" getMaxHintsInProgress()");
|
||||
return c.getIntValue("storage_proxy/max_hints_in_progress");
|
||||
return client.getIntValue("storage_proxy/max_hints_in_progress");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -129,19 +116,19 @@ public class StorageProxy implements StorageProxyMBean {
|
||||
log(" setMaxHintsInProgress(int qs)");
|
||||
MultivaluedMap<String, String> queryParams = new MultivaluedHashMap<String, String>();
|
||||
queryParams.add("qs", Integer.toString(qs));
|
||||
c.post("storage_proxy/max_hints_in_progress", queryParams);
|
||||
client.post("storage_proxy/max_hints_in_progress", queryParams);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHintsInProgress() {
|
||||
log(" getHintsInProgress()");
|
||||
return c.getIntValue("storage_proxy/hints_in_progress");
|
||||
return client.getIntValue("storage_proxy/hints_in_progress");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getRpcTimeout() {
|
||||
log(" getRpcTimeout()");
|
||||
return c.getLongValue("storage_proxy/rpc_timeout");
|
||||
return client.getLongValue("storage_proxy/rpc_timeout");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -149,13 +136,13 @@ public class StorageProxy implements StorageProxyMBean {
|
||||
log(" setRpcTimeout(Long timeoutInMillis)");
|
||||
MultivaluedMap<String, String> queryParams = new MultivaluedHashMap<String, String>();
|
||||
queryParams.add("timeout", Long.toString(timeoutInMillis));
|
||||
c.post("storage_proxy/rpc_timeout", queryParams);
|
||||
client.post("storage_proxy/rpc_timeout", queryParams);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getReadRpcTimeout() {
|
||||
log(" getReadRpcTimeout()");
|
||||
return c.getLongValue("storage_proxy/read_rpc_timeout");
|
||||
return client.getLongValue("storage_proxy/read_rpc_timeout");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -163,13 +150,13 @@ public class StorageProxy implements StorageProxyMBean {
|
||||
log(" setReadRpcTimeout(Long timeoutInMillis)");
|
||||
MultivaluedMap<String, String> queryParams = new MultivaluedHashMap<String, String>();
|
||||
queryParams.add("timeout", Long.toString(timeoutInMillis));
|
||||
c.post("storage_proxy/read_rpc_timeout", queryParams);
|
||||
client.post("storage_proxy/read_rpc_timeout", queryParams);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getWriteRpcTimeout() {
|
||||
log(" getWriteRpcTimeout()");
|
||||
return c.getLongValue("storage_proxy/write_rpc_timeout");
|
||||
return client.getLongValue("storage_proxy/write_rpc_timeout");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -177,13 +164,13 @@ public class StorageProxy implements StorageProxyMBean {
|
||||
log(" setWriteRpcTimeout(Long timeoutInMillis)");
|
||||
MultivaluedMap<String, String> queryParams = new MultivaluedHashMap<String, String>();
|
||||
queryParams.add("timeout", Long.toString(timeoutInMillis));
|
||||
c.post("storage_proxy/write_rpc_timeout", queryParams);
|
||||
client.post("storage_proxy/write_rpc_timeout", queryParams);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getCounterWriteRpcTimeout() {
|
||||
log(" getCounterWriteRpcTimeout()");
|
||||
return c.getLongValue("storage_proxy/counter_write_rpc_timeout");
|
||||
return client.getLongValue("storage_proxy/counter_write_rpc_timeout");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -191,13 +178,13 @@ public class StorageProxy implements StorageProxyMBean {
|
||||
log(" setCounterWriteRpcTimeout(Long timeoutInMillis)");
|
||||
MultivaluedMap<String, String> queryParams = new MultivaluedHashMap<String, String>();
|
||||
queryParams.add("timeout", Long.toString(timeoutInMillis));
|
||||
c.post("storage_proxy/counter_write_rpc_timeout", queryParams);
|
||||
client.post("storage_proxy/counter_write_rpc_timeout", queryParams);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getCasContentionTimeout() {
|
||||
log(" getCasContentionTimeout()");
|
||||
return c.getLongValue("storage_proxy/cas_contention_timeout");
|
||||
return client.getLongValue("storage_proxy/cas_contention_timeout");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -205,13 +192,13 @@ public class StorageProxy implements StorageProxyMBean {
|
||||
log(" setCasContentionTimeout(Long timeoutInMillis)");
|
||||
MultivaluedMap<String, String> queryParams = new MultivaluedHashMap<String, String>();
|
||||
queryParams.add("timeout", Long.toString(timeoutInMillis));
|
||||
c.post("storage_proxy/cas_contention_timeout", queryParams);
|
||||
client.post("storage_proxy/cas_contention_timeout", queryParams);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getRangeRpcTimeout() {
|
||||
log(" getRangeRpcTimeout()");
|
||||
return c.getLongValue("storage_proxy/range_rpc_timeout");
|
||||
return client.getLongValue("storage_proxy/range_rpc_timeout");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -219,13 +206,13 @@ public class StorageProxy implements StorageProxyMBean {
|
||||
log(" setRangeRpcTimeout(Long timeoutInMillis)");
|
||||
MultivaluedMap<String, String> queryParams = new MultivaluedHashMap<String, String>();
|
||||
queryParams.add("timeout", Long.toString(timeoutInMillis));
|
||||
c.post("storage_proxy/range_rpc_timeout", queryParams);
|
||||
client.post("storage_proxy/range_rpc_timeout", queryParams);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getTruncateRpcTimeout() {
|
||||
log(" getTruncateRpcTimeout()");
|
||||
return c.getLongValue("storage_proxy/truncate_rpc_timeout");
|
||||
return client.getLongValue("storage_proxy/truncate_rpc_timeout");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -233,43 +220,42 @@ public class StorageProxy implements StorageProxyMBean {
|
||||
log(" setTruncateRpcTimeout(Long timeoutInMillis)");
|
||||
MultivaluedMap<String, String> queryParams = new MultivaluedHashMap<String, String>();
|
||||
queryParams.add("timeout", Long.toString(timeoutInMillis));
|
||||
c.post("storage_proxy/truncate_rpc_timeout", queryParams);
|
||||
client.post("storage_proxy/truncate_rpc_timeout", queryParams);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reloadTriggerClasses() {
|
||||
log(" reloadTriggerClasses()");
|
||||
c.post("storage_proxy/reload_trigger_classes");
|
||||
client.post("storage_proxy/reload_trigger_classes");
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getReadRepairAttempted() {
|
||||
log(" getReadRepairAttempted()");
|
||||
return c.getLongValue("storage_proxy/read_repair_attempted");
|
||||
return client.getLongValue("storage_proxy/read_repair_attempted");
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getReadRepairRepairedBlocking() {
|
||||
log(" getReadRepairRepairedBlocking()");
|
||||
return c.getLongValue("storage_proxy/read_repair_repaired_blocking");
|
||||
return client.getLongValue("storage_proxy/read_repair_repaired_blocking");
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getReadRepairRepairedBackground() {
|
||||
log(" getReadRepairRepairedBackground()");
|
||||
return c.getLongValue("storage_proxy/read_repair_repaired_background");
|
||||
return client.getLongValue("storage_proxy/read_repair_repaired_background");
|
||||
}
|
||||
|
||||
/** Returns each live node's schema version */
|
||||
@Override
|
||||
public Map<String, List<String>> getSchemaVersions() {
|
||||
log(" getSchemaVersions()");
|
||||
return c.getMapStringListStrValue("storage_proxy/schema_versions");
|
||||
return client.getMapStringListStrValue("storage_proxy/schema_versions");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNativeTransportMaxConcurrentConnections(
|
||||
Long nativeTransportMaxConcurrentConnections) {
|
||||
public void setNativeTransportMaxConcurrentConnections(Long nativeTransportMaxConcurrentConnections) {
|
||||
// TODO Auto-generated method stub
|
||||
log(" setNativeTransportMaxConcurrentConnections()");
|
||||
|
||||
@ -279,21 +265,21 @@ public class StorageProxy implements StorageProxyMBean {
|
||||
public Long getNativeTransportMaxConcurrentConnections() {
|
||||
// TODO Auto-generated method stub
|
||||
log(" getNativeTransportMaxConcurrentConnections()");
|
||||
return c.getLongValue("");
|
||||
return client.getLongValue("");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enableHintsForDC(String dc) {
|
||||
// TODO if/when scylla uses hints
|
||||
// TODO if/when scylla uses hints
|
||||
log(" enableHintsForDC()");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disableHintsForDC(String dc) {
|
||||
// TODO if/when scylla uses hints
|
||||
// TODO if/when scylla uses hints
|
||||
log(" disableHintsForDC()");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Set<String> getHintedHandoffDisabledDCs() {
|
||||
// TODO if/when scylla uses hints
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user