StorageProxy: update to c3 compat

This commit is contained in:
Calle Wilund 2016-08-17 08:40:59 +00:00
parent de28e68532
commit b4e483b179
2 changed files with 65 additions and 181 deletions

View File

@ -23,8 +23,12 @@
*/ */
package org.apache.cassandra.service; package org.apache.cassandra.service;
import static java.util.Collections.emptySet;
import java.lang.management.ManagementFactory; import java.lang.management.ManagementFactory;
import java.util.*; import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.management.MBeanServer; import javax.management.MBeanServer;
import javax.management.ObjectName; import javax.management.ObjectName;
@ -33,8 +37,6 @@ import javax.ws.rs.core.MultivaluedMap;
import com.scylladb.jmx.api.APIClient; import com.scylladb.jmx.api.APIClient;
import org.apache.cassandra.metrics.*;
public class StorageProxy implements StorageProxyMBean { public class StorageProxy implements StorageProxyMBean {
public static final String MBEAN_NAME = "org.apache.cassandra.db:type=StorageProxy"; public static final String MBEAN_NAME = "org.apache.cassandra.db:type=StorageProxy";
private static final java.util.logging.Logger logger = java.util.logging.Logger private static final java.util.logging.Logger logger = java.util.logging.Logger
@ -54,19 +56,6 @@ public class StorageProxy implements StorageProxyMBean {
public static final String UNREACHABLE = "UNREACHABLE"; public static final String UNREACHABLE = "UNREACHABLE";
private static final ClientRequestMetrics readMetrics = new ClientRequestMetrics(
"storage_proxy/metrics/read", "Read");
private static final ClientRequestMetrics rangeMetrics = new ClientRequestMetrics(
"storage_proxy/metrics/range", "RangeSlice");
private static final ClientRequestMetrics writeMetrics = new ClientRequestMetrics(
"storage_proxy/metrics/write", "Write");
private static final CASClientRequestMetrics casWriteMetrics = new CASClientRequestMetrics(
"storage_proxy/metrics/cas_write", "CASWrite");
private static final CASClientRequestMetrics casReadMetrics = new CASClientRequestMetrics(
"storage_proxy/metrics/cas_read", "CASRead");
private static final double CONCURRENT_SUBREQUESTS_MARGIN = 0.10;
private StorageProxy() { private StorageProxy() {
} }
@ -80,127 +69,26 @@ public class StorageProxy implements StorageProxyMBean {
} }
/** @Override
* @see org.apache.cassandra.metrics.LatencyMetrics#lastOpCount
*/
@Deprecated
public long getReadOperations() {
log(" getReadOperations()");
return readMetrics.latency.count();
}
/**
* @see org.apache.cassandra.metrics.LatencyMetrics#totalLatencyHistogram
*/
@Deprecated
public long getTotalReadLatencyMicros() {
log(" getTotalReadLatencyMicros()");
return readMetrics.totalLatency.count();
}
/**
* @see org.apache.cassandra.metrics.LatencyMetrics#recentLatencyHistogram
*/
@Deprecated
public double getRecentReadLatencyMicros() {
log(" getRecentReadLatencyMicros()");
return readMetrics.getRecentLatency();
}
/**
* @see org.apache.cassandra.metrics.LatencyMetrics#totalLatencyHistogram
*/
@Deprecated
public long[] getTotalReadLatencyHistogramMicros() {
log(" getTotalReadLatencyHistogramMicros()");
return readMetrics.totalLatencyHistogram.getBuckets(false);
}
/**
* @see org.apache.cassandra.metrics.LatencyMetrics#recentLatencyHistogram
*/
@Deprecated
public long[] getRecentReadLatencyHistogramMicros() {
log(" getRecentReadLatencyHistogramMicros()");
return readMetrics.getRecentLatencyHistogram();
}
@Deprecated
public long getRangeOperations() {
log(" getRangeOperations()");
return rangeMetrics.latency.count();
}
@Deprecated
public long getTotalRangeLatencyMicros() {
log(" getTotalRangeLatencyMicros()");
return rangeMetrics.totalLatency.count();
}
@Deprecated
public double getRecentRangeLatencyMicros() {
log(" getRecentRangeLatencyMicros()");
return rangeMetrics.getRecentLatency();
}
@Deprecated
public long[] getTotalRangeLatencyHistogramMicros() {
log(" getTotalRangeLatencyHistogramMicros()");
return rangeMetrics.totalLatencyHistogram.getBuckets(false);
}
@Deprecated
public long[] getRecentRangeLatencyHistogramMicros() {
log(" getRecentRangeLatencyHistogramMicros()");
return rangeMetrics.getRecentLatencyHistogram();
}
@Deprecated
public long getWriteOperations() {
log(" getWriteOperations()");
return writeMetrics.latency.count();
}
@Deprecated
public long getTotalWriteLatencyMicros() {
log(" getTotalWriteLatencyMicros()");
return writeMetrics.totalLatency.count();
}
@Deprecated
public double getRecentWriteLatencyMicros() {
log(" getRecentWriteLatencyMicros()");
return writeMetrics.getRecentLatency();
}
@Deprecated
public long[] getTotalWriteLatencyHistogramMicros() {
log(" getTotalWriteLatencyHistogramMicros()");
return writeMetrics.totalLatencyHistogram.getBuckets(false);
}
@Deprecated
public long[] getRecentWriteLatencyHistogramMicros() {
log(" getRecentWriteLatencyHistogramMicros()");
return writeMetrics.getRecentLatencyHistogram();
}
public long getTotalHints() { public long getTotalHints() {
log(" getTotalHints()"); log(" getTotalHints()");
return c.getLongValue("storage_proxy/total_hints"); return c.getLongValue("storage_proxy/total_hints");
} }
@Override
public boolean getHintedHandoffEnabled() { public boolean getHintedHandoffEnabled() {
log(" getHintedHandoffEnabled()"); log(" getHintedHandoffEnabled()");
return c.getBooleanValue("storage_proxy/hinted_handoff_enabled"); return c.getBooleanValue("storage_proxy/hinted_handoff_enabled");
} }
@Override
public Set<String> getHintedHandoffEnabledByDC() { public Set<String> getHintedHandoffEnabledByDC() {
log(" getHintedHandoffEnabledByDC()"); log(" getHintedHandoffEnabledByDC()");
return c.getSetStringValue( return c.getSetStringValue(
"storage_proxy/hinted_handoff_enabled_by_dc"); "storage_proxy/hinted_handoff_enabled_by_dc");
} }
@Override
public void setHintedHandoffEnabled(boolean b) { public void setHintedHandoffEnabled(boolean b) {
log(" setHintedHandoffEnabled(boolean b)"); log(" setHintedHandoffEnabled(boolean b)");
MultivaluedMap<String, String> queryParams = new MultivaluedHashMap<String, String>(); MultivaluedMap<String, String> queryParams = new MultivaluedHashMap<String, String>();
@ -208,6 +96,7 @@ public class StorageProxy implements StorageProxyMBean {
c.post("storage_proxy/hinted_handoff_enabled", queryParams); c.post("storage_proxy/hinted_handoff_enabled", queryParams);
} }
@Override
public void setHintedHandoffEnabledByDCList(String dcs) { public void setHintedHandoffEnabledByDCList(String dcs) {
log(" setHintedHandoffEnabledByDCList(String dcs)"); log(" setHintedHandoffEnabledByDCList(String dcs)");
MultivaluedMap<String, String> queryParams = new MultivaluedHashMap<String, String>(); MultivaluedMap<String, String> queryParams = new MultivaluedHashMap<String, String>();
@ -215,11 +104,13 @@ public class StorageProxy implements StorageProxyMBean {
c.post("storage_proxy/hinted_handoff_enabled_by_dc_list"); c.post("storage_proxy/hinted_handoff_enabled_by_dc_list");
} }
@Override
public int getMaxHintWindow() { public int getMaxHintWindow() {
log(" getMaxHintWindow()"); log(" getMaxHintWindow()");
return c.getIntValue("storage_proxy/max_hint_window"); return c.getIntValue("storage_proxy/max_hint_window");
} }
@Override
public void setMaxHintWindow(int ms) { public void setMaxHintWindow(int ms) {
log(" setMaxHintWindow(int ms)"); log(" setMaxHintWindow(int ms)");
MultivaluedMap<String, String> queryParams = new MultivaluedHashMap<String, String>(); MultivaluedMap<String, String> queryParams = new MultivaluedHashMap<String, String>();
@ -227,11 +118,13 @@ public class StorageProxy implements StorageProxyMBean {
c.post("storage_proxy/max_hint_window", queryParams); c.post("storage_proxy/max_hint_window", queryParams);
} }
@Override
public int getMaxHintsInProgress() { public int getMaxHintsInProgress() {
log(" getMaxHintsInProgress()"); log(" getMaxHintsInProgress()");
return c.getIntValue("storage_proxy/max_hints_in_progress"); return c.getIntValue("storage_proxy/max_hints_in_progress");
} }
@Override
public void setMaxHintsInProgress(int qs) { public void setMaxHintsInProgress(int qs) {
log(" setMaxHintsInProgress(int qs)"); log(" setMaxHintsInProgress(int qs)");
MultivaluedMap<String, String> queryParams = new MultivaluedHashMap<String, String>(); MultivaluedMap<String, String> queryParams = new MultivaluedHashMap<String, String>();
@ -239,16 +132,19 @@ public class StorageProxy implements StorageProxyMBean {
c.post("storage_proxy/max_hints_in_progress", queryParams); c.post("storage_proxy/max_hints_in_progress", queryParams);
} }
@Override
public int getHintsInProgress() { public int getHintsInProgress() {
log(" getHintsInProgress()"); log(" getHintsInProgress()");
return c.getIntValue("storage_proxy/hints_in_progress"); return c.getIntValue("storage_proxy/hints_in_progress");
} }
@Override
public Long getRpcTimeout() { public Long getRpcTimeout() {
log(" getRpcTimeout()"); log(" getRpcTimeout()");
return c.getLongValue("storage_proxy/rpc_timeout"); return c.getLongValue("storage_proxy/rpc_timeout");
} }
@Override
public void setRpcTimeout(Long timeoutInMillis) { public void setRpcTimeout(Long timeoutInMillis) {
log(" setRpcTimeout(Long timeoutInMillis)"); log(" setRpcTimeout(Long timeoutInMillis)");
MultivaluedMap<String, String> queryParams = new MultivaluedHashMap<String, String>(); MultivaluedMap<String, String> queryParams = new MultivaluedHashMap<String, String>();
@ -256,11 +152,13 @@ public class StorageProxy implements StorageProxyMBean {
c.post("storage_proxy/rpc_timeout", queryParams); c.post("storage_proxy/rpc_timeout", queryParams);
} }
@Override
public Long getReadRpcTimeout() { public Long getReadRpcTimeout() {
log(" getReadRpcTimeout()"); log(" getReadRpcTimeout()");
return c.getLongValue("storage_proxy/read_rpc_timeout"); return c.getLongValue("storage_proxy/read_rpc_timeout");
} }
@Override
public void setReadRpcTimeout(Long timeoutInMillis) { public void setReadRpcTimeout(Long timeoutInMillis) {
log(" setReadRpcTimeout(Long timeoutInMillis)"); log(" setReadRpcTimeout(Long timeoutInMillis)");
MultivaluedMap<String, String> queryParams = new MultivaluedHashMap<String, String>(); MultivaluedMap<String, String> queryParams = new MultivaluedHashMap<String, String>();
@ -268,11 +166,13 @@ public class StorageProxy implements StorageProxyMBean {
c.post("storage_proxy/read_rpc_timeout", queryParams); c.post("storage_proxy/read_rpc_timeout", queryParams);
} }
@Override
public Long getWriteRpcTimeout() { public Long getWriteRpcTimeout() {
log(" getWriteRpcTimeout()"); log(" getWriteRpcTimeout()");
return c.getLongValue("storage_proxy/write_rpc_timeout"); return c.getLongValue("storage_proxy/write_rpc_timeout");
} }
@Override
public void setWriteRpcTimeout(Long timeoutInMillis) { public void setWriteRpcTimeout(Long timeoutInMillis) {
log(" setWriteRpcTimeout(Long timeoutInMillis)"); log(" setWriteRpcTimeout(Long timeoutInMillis)");
MultivaluedMap<String, String> queryParams = new MultivaluedHashMap<String, String>(); MultivaluedMap<String, String> queryParams = new MultivaluedHashMap<String, String>();
@ -280,11 +180,13 @@ public class StorageProxy implements StorageProxyMBean {
c.post("storage_proxy/write_rpc_timeout", queryParams); c.post("storage_proxy/write_rpc_timeout", queryParams);
} }
@Override
public Long getCounterWriteRpcTimeout() { public Long getCounterWriteRpcTimeout() {
log(" getCounterWriteRpcTimeout()"); log(" getCounterWriteRpcTimeout()");
return c.getLongValue("storage_proxy/counter_write_rpc_timeout"); return c.getLongValue("storage_proxy/counter_write_rpc_timeout");
} }
@Override
public void setCounterWriteRpcTimeout(Long timeoutInMillis) { public void setCounterWriteRpcTimeout(Long timeoutInMillis) {
log(" setCounterWriteRpcTimeout(Long timeoutInMillis)"); log(" setCounterWriteRpcTimeout(Long timeoutInMillis)");
MultivaluedMap<String, String> queryParams = new MultivaluedHashMap<String, String>(); MultivaluedMap<String, String> queryParams = new MultivaluedHashMap<String, String>();
@ -292,11 +194,13 @@ public class StorageProxy implements StorageProxyMBean {
c.post("storage_proxy/counter_write_rpc_timeout", queryParams); c.post("storage_proxy/counter_write_rpc_timeout", queryParams);
} }
@Override
public Long getCasContentionTimeout() { public Long getCasContentionTimeout() {
log(" getCasContentionTimeout()"); log(" getCasContentionTimeout()");
return c.getLongValue("storage_proxy/cas_contention_timeout"); return c.getLongValue("storage_proxy/cas_contention_timeout");
} }
@Override
public void setCasContentionTimeout(Long timeoutInMillis) { public void setCasContentionTimeout(Long timeoutInMillis) {
log(" setCasContentionTimeout(Long timeoutInMillis)"); log(" setCasContentionTimeout(Long timeoutInMillis)");
MultivaluedMap<String, String> queryParams = new MultivaluedHashMap<String, String>(); MultivaluedMap<String, String> queryParams = new MultivaluedHashMap<String, String>();
@ -304,11 +208,13 @@ public class StorageProxy implements StorageProxyMBean {
c.post("storage_proxy/cas_contention_timeout", queryParams); c.post("storage_proxy/cas_contention_timeout", queryParams);
} }
@Override
public Long getRangeRpcTimeout() { public Long getRangeRpcTimeout() {
log(" getRangeRpcTimeout()"); log(" getRangeRpcTimeout()");
return c.getLongValue("storage_proxy/range_rpc_timeout"); return c.getLongValue("storage_proxy/range_rpc_timeout");
} }
@Override
public void setRangeRpcTimeout(Long timeoutInMillis) { public void setRangeRpcTimeout(Long timeoutInMillis) {
log(" setRangeRpcTimeout(Long timeoutInMillis)"); log(" setRangeRpcTimeout(Long timeoutInMillis)");
MultivaluedMap<String, String> queryParams = new MultivaluedHashMap<String, String>(); MultivaluedMap<String, String> queryParams = new MultivaluedHashMap<String, String>();
@ -316,11 +222,13 @@ public class StorageProxy implements StorageProxyMBean {
c.post("storage_proxy/range_rpc_timeout", queryParams); c.post("storage_proxy/range_rpc_timeout", queryParams);
} }
@Override
public Long getTruncateRpcTimeout() { public Long getTruncateRpcTimeout() {
log(" getTruncateRpcTimeout()"); log(" getTruncateRpcTimeout()");
return c.getLongValue("storage_proxy/truncate_rpc_timeout"); return c.getLongValue("storage_proxy/truncate_rpc_timeout");
} }
@Override
public void setTruncateRpcTimeout(Long timeoutInMillis) { public void setTruncateRpcTimeout(Long timeoutInMillis) {
log(" setTruncateRpcTimeout(Long timeoutInMillis)"); log(" setTruncateRpcTimeout(Long timeoutInMillis)");
MultivaluedMap<String, String> queryParams = new MultivaluedHashMap<String, String>(); MultivaluedMap<String, String> queryParams = new MultivaluedHashMap<String, String>();
@ -328,27 +236,32 @@ public class StorageProxy implements StorageProxyMBean {
c.post("storage_proxy/truncate_rpc_timeout", queryParams); c.post("storage_proxy/truncate_rpc_timeout", queryParams);
} }
@Override
public void reloadTriggerClasses() { public void reloadTriggerClasses() {
log(" reloadTriggerClasses()"); log(" reloadTriggerClasses()");
c.post("storage_proxy/reload_trigger_classes"); c.post("storage_proxy/reload_trigger_classes");
} }
@Override
public long getReadRepairAttempted() { public long getReadRepairAttempted() {
log(" getReadRepairAttempted()"); log(" getReadRepairAttempted()");
return c.getLongValue("storage_proxy/read_repair_attempted"); return c.getLongValue("storage_proxy/read_repair_attempted");
} }
@Override
public long getReadRepairRepairedBlocking() { public long getReadRepairRepairedBlocking() {
log(" getReadRepairRepairedBlocking()"); log(" getReadRepairRepairedBlocking()");
return c.getLongValue("storage_proxy/read_repair_repaired_blocking"); return c.getLongValue("storage_proxy/read_repair_repaired_blocking");
} }
@Override
public long getReadRepairRepairedBackground() { public long getReadRepairRepairedBackground() {
log(" getReadRepairRepairedBackground()"); log(" getReadRepairRepairedBackground()");
return c.getLongValue("storage_proxy/read_repair_repaired_background"); return c.getLongValue("storage_proxy/read_repair_repaired_background");
} }
/** Returns each live node's schema version */ /** Returns each live node's schema version */
@Override
public Map<String, List<String>> getSchemaVersions() { public Map<String, List<String>> getSchemaVersions() {
log(" getSchemaVersions()"); log(" getSchemaVersions()");
return c.getMapStringListStrValue("storage_proxy/schema_versions"); return c.getMapStringListStrValue("storage_proxy/schema_versions");
@ -369,4 +282,22 @@ public class StorageProxy implements StorageProxyMBean {
return c.getLongValue(""); return c.getLongValue("");
} }
@Override
public void enableHintsForDC(String dc) {
// TODO if/when scylla uses hints
log(" enableHintsForDC()");
}
@Override
public void disableHintsForDC(String dc) {
// TODO if/when scylla uses hints
log(" disableHintsForDC()");
}
@Override
public Set<String> getHintedHandoffDisabledDCs() {
// TODO if/when scylla uses hints
log(" getHintedHandoffDisabledDCs()");
return emptySet();
}
} }

View File

@ -15,6 +15,13 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
/*
* Copyright 2015 Cloudius Systems
*
* Modified by Cloudius Systems
*/
package org.apache.cassandra.service; package org.apache.cassandra.service;
import java.util.List; import java.util.List;
@ -22,66 +29,6 @@ import java.util.Map;
import java.util.Set; import java.util.Set;
public interface StorageProxyMBean { public interface StorageProxyMBean {
/**
* @see org.apache.cassandra.metrics.LatencyMetrics#lastOpCount
*/
@Deprecated
public long getReadOperations();
/**
* @see org.apache.cassandra.metrics.LatencyMetrics#totalLatencyHistogram
*/
@Deprecated
public long getTotalReadLatencyMicros();
/**
* @see org.apache.cassandra.metrics.LatencyMetrics#recentLatencyHistogram
*/
@Deprecated
public double getRecentReadLatencyMicros();
/**
* @see org.apache.cassandra.metrics.LatencyMetrics#totalLatencyHistogram
*/
@Deprecated
public long[] getTotalReadLatencyHistogramMicros();
/**
* @see org.apache.cassandra.metrics.LatencyMetrics#recentLatencyHistogram
*/
@Deprecated
public long[] getRecentReadLatencyHistogramMicros();
@Deprecated
public long getRangeOperations();
@Deprecated
public long getTotalRangeLatencyMicros();
@Deprecated
public double getRecentRangeLatencyMicros();
@Deprecated
public long[] getTotalRangeLatencyHistogramMicros();
@Deprecated
public long[] getRecentRangeLatencyHistogramMicros();
@Deprecated
public long getWriteOperations();
@Deprecated
public long getTotalWriteLatencyMicros();
@Deprecated
public double getRecentWriteLatencyMicros();
@Deprecated
public long[] getTotalWriteLatencyHistogramMicros();
@Deprecated
public long[] getRecentWriteLatencyHistogramMicros();
public long getTotalHints(); public long getTotalHints();
public boolean getHintedHandoffEnabled(); public boolean getHintedHandoffEnabled();
@ -92,6 +39,12 @@ public interface StorageProxyMBean {
public void setHintedHandoffEnabledByDCList(String dcs); public void setHintedHandoffEnabledByDCList(String dcs);
public void enableHintsForDC(String dc);
public void disableHintsForDC(String dc);
public Set<String> getHintedHandoffDisabledDCs();
public int getMaxHintWindow(); public int getMaxHintWindow();
public void setMaxHintWindow(int ms); public void setMaxHintWindow(int ms);