diff --git a/src/main/java/com/cloudius/urchin/api/APIClient.java b/src/main/java/com/cloudius/urchin/api/APIClient.java index 3ac7d3d..f7f1c7e 100644 --- a/src/main/java/com/cloudius/urchin/api/APIClient.java +++ b/src/main/java/com/cloudius/urchin/api/APIClient.java @@ -8,9 +8,11 @@ import java.net.InetAddress; import java.net.UnknownHostException; import java.util.ArrayList; import java.util.HashMap; +import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Map; +import java.util.Set; import javax.json.Json; import javax.json.JsonArray; @@ -193,6 +195,29 @@ public class APIClient { return false; } + public Map> getMapStringListStrValue(String string, + MultivaluedMap queryParams) { + if (string.equals("")) { + return null; + } + JsonReader reader = getReader(string, queryParams); + JsonArray arr = reader.readArray(); + Map> map = new HashMap>(); + for (int i = 0; i < arr.size(); i++) { + JsonObject obj = arr.getJsonObject(i); + if (obj.containsKey("key") && obj.containsKey("value")) { + map.put(obj.getString("key"), + listStrFromJArr(obj.getJsonArray("value"))); + } + } + reader.close(); + return map; + } + + public Map> getMapStringListStrValue(String string) { + return getMapStringListStrValue(string, null); + } + public Map, List> getMapListStrValue(String string, MultivaluedMap queryParams) { if (string.equals("")) { @@ -216,6 +241,22 @@ public class APIClient { return getMapListStrValue(string, null); } + public Set getSetStringValue(String string, + MultivaluedMap queryParams) { + JsonReader reader = getReader(string, queryParams); + JsonArray arr = reader.readArray(); + Set res = new HashSet(); + for (int i = 0; i < arr.size(); i++) { + res.add(arr.getString(i)); + } + reader.close(); + return res; + } + + public Set getSetStringValue(String string) { + return getSetStringValue(string, null); + } + public Map getMapStrValue(String string, MultivaluedMap queryParams) { if (string.equals("")) { @@ -311,9 +352,20 @@ public class APIClient { return null; } + public long[] getLongArrValue(String string, + MultivaluedMap queryParams) { + JsonReader reader = getReader(string, queryParams); + JsonArray arr = reader.readArray(); + long[] res = new long[arr.size()]; + for (int i = 0; i < arr.size(); i++) { + res[i] = arr.getJsonNumber(i).longValue(); + } + reader.close(); + return res; + } + public long[] getLongArrValue(String string) { - // TODO Auto-generated method stub - return null; + return getLongArrValue(string, null); } public Map getMapStringIntegerValue(String string) { @@ -355,7 +407,7 @@ public class APIClient { reader.close(); return map; } - + public Map getListMapStringLongValue(String string) { return getListMapStringLongValue(string, null); } @@ -370,7 +422,7 @@ public class APIClient { reader.close(); return res; } - + public JsonArray getJsonArray(String string) { return getJsonArray(string, null); } diff --git a/src/main/java/com/cloudius/urchin/main/Main.java b/src/main/java/com/cloudius/urchin/main/Main.java index 95b3cf4..0634b70 100644 --- a/src/main/java/com/cloudius/urchin/main/Main.java +++ b/src/main/java/com/cloudius/urchin/main/Main.java @@ -11,6 +11,7 @@ import org.apache.cassandra.gms.Gossiper; import org.apache.cassandra.gms.FailureDetector; import org.apache.cassandra.locator.EndpointSnitchInfo; import org.apache.cassandra.net.MessagingService; +import org.apache.cassandra.service.StorageProxy; import org.apache.cassandra.service.StorageService; public class Main { @@ -19,6 +20,7 @@ public class Main { System.out.println("Connecting to " + APIClient.getBaseUrl()); System.out.println("Starting the JMX server"); StorageService.getInstance(); + StorageProxy.getInstance(); MessagingService.getInstance(); CommitLog.getInstance(); Gossiper.getInstance(); diff --git a/src/main/java/com/cloudius/urchin/metrics/APIMetrics.java b/src/main/java/com/cloudius/urchin/metrics/APIMetrics.java index 380e136..bcdfdcb 100644 --- a/src/main/java/com/cloudius/urchin/metrics/APIMetrics.java +++ b/src/main/java/com/cloudius/urchin/metrics/APIMetrics.java @@ -144,9 +144,9 @@ public class APIMetrics { * whether or not the histogram should be biased * @return a new {@link com.yammer.metrics.core.Histogram} */ - public static Histogram newHistogram(Class klass, String name, - boolean biased) { - return DEFAULT_REGISTRY.newHistogram(klass, name, biased); + public static Histogram newHistogram(String url, Class klass, + String name, boolean biased) { + return DEFAULT_REGISTRY.newHistogram(url, klass, name, biased); } /** @@ -163,9 +163,9 @@ public class APIMetrics { * whether or not the histogram should be biased * @return a new {@link com.yammer.metrics.core.Histogram} */ - public static Histogram newHistogram(Class klass, String name, - String scope, boolean biased) { - return DEFAULT_REGISTRY.newHistogram(klass, name, scope, biased); + public static Histogram newHistogram(String url, Class klass, + String name, String scope, boolean biased) { + return DEFAULT_REGISTRY.newHistogram(url, klass, name, scope, biased); } /** @@ -178,8 +178,9 @@ public class APIMetrics { * whether or not the histogram should be biased * @return a new {@link com.yammer.metrics.core.Histogram} */ - public static Histogram newHistogram(MetricName metricName, boolean biased) { - return DEFAULT_REGISTRY.newHistogram(metricName, biased); + public static Histogram newHistogram(String url, MetricName metricName, + boolean biased) { + return DEFAULT_REGISTRY.newHistogram(url, metricName, biased); } /** @@ -192,8 +193,8 @@ public class APIMetrics { * the name of the metric * @return a new {@link com.yammer.metrics.core.Histogram} */ - public static Histogram newHistogram(Class klass, String name) { - return DEFAULT_REGISTRY.newHistogram(klass, name); + public static Histogram newHistogram(String url, Class klass, String name) { + return DEFAULT_REGISTRY.newHistogram(url, klass, name); } /** @@ -208,9 +209,9 @@ public class APIMetrics { * the scope of the metric * @return a new {@link com.yammer.metrics.core.Histogram} */ - public static Histogram newHistogram(Class klass, String name, - String scope) { - return DEFAULT_REGISTRY.newHistogram(klass, name, scope); + public static Histogram newHistogram(String url, Class klass, + String name, String scope) { + return DEFAULT_REGISTRY.newHistogram(url, klass, name, scope); } /** @@ -221,8 +222,8 @@ public class APIMetrics { * the name of the metric * @return a new {@link com.yammer.metrics.core.Histogram} */ - public static Histogram newHistogram(MetricName metricName) { - return newHistogram(metricName, false); + public static Histogram newHistogram(String url, MetricName metricName) { + return newHistogram(url, metricName, false); } /** diff --git a/src/main/java/com/yammer/metrics/core/APIMeter.java b/src/main/java/com/yammer/metrics/core/APIMeter.java index fc1a801..5c216c9 100644 --- a/src/main/java/com/yammer/metrics/core/APIMeter.java +++ b/src/main/java/com/yammer/metrics/core/APIMeter.java @@ -21,9 +21,25 @@ public class APIMeter extends Meter { url = _url; } - @Override - public long count() { + public long get_value() { return c.getLongValue(url); } + // Meter doesn't have a set value method. + // to mimic it, we clear the old value and set it to a new one. + // This is safe because the only this method would be used + // to update the values + public long set(long new_value) { + long res = super.count(); + mark(-res); + mark(new_value); + return res; + } + + @Override + void tick() { + set(get_value()); + super.tick(); + } + } diff --git a/src/main/java/org/apache/cassandra/metrics/CASClientRequestMetrics.java b/src/main/java/org/apache/cassandra/metrics/CASClientRequestMetrics.java new file mode 100644 index 0000000..8ba4edf --- /dev/null +++ b/src/main/java/org/apache/cassandra/metrics/CASClientRequestMetrics.java @@ -0,0 +1,58 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/* + * Copyright 2015 Cloudius Systems + * + * Modified by Cloudius Systems + */ + +package org.apache.cassandra.metrics; + +import com.cloudius.urchin.metrics.APIMetrics; +import com.yammer.metrics.core.*; + +public class CASClientRequestMetrics extends ClientRequestMetrics { + + public final Histogram contention; + /* Used only for write */ + public final Counter conditionNotMet; + + public final Counter unfinishedCommit; + + public CASClientRequestMetrics(String url, String scope) { + super(url, scope); + contention = APIMetrics.newHistogram(url + "contention", + factory.createMetricName("ContentionHistogram"), true); + conditionNotMet = APIMetrics.newCounter(url + "condition_not_met", + factory.createMetricName("ConditionNotMet")); + unfinishedCommit = APIMetrics.newCounter(url + "unfinished_commit", + factory.createMetricName("UnfinishedCommit")); + } + + public void release() { + super.release(); + APIMetrics.defaultRegistry().removeMetric( + factory.createMetricName("ContentionHistogram")); + APIMetrics.defaultRegistry().removeMetric( + factory.createMetricName("ConditionNotMet")); + APIMetrics.defaultRegistry().removeMetric( + factory.createMetricName("UnfinishedCommit")); + } +} diff --git a/src/main/java/org/apache/cassandra/metrics/ClientRequestMetrics.java b/src/main/java/org/apache/cassandra/metrics/ClientRequestMetrics.java new file mode 100644 index 0000000..30054d3 --- /dev/null +++ b/src/main/java/org/apache/cassandra/metrics/ClientRequestMetrics.java @@ -0,0 +1,77 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +/* + * Copyright 2015 Cloudius Systems + * + * Modified by Cloudius Systems + */ + +package org.apache.cassandra.metrics; + +import java.util.concurrent.TimeUnit; + +import com.cloudius.urchin.metrics.APIMetrics; +import com.cloudius.urchin.metrics.DefaultNameFactory; +import com.yammer.metrics.Metrics; +import com.yammer.metrics.core.Counter; +import com.yammer.metrics.core.Meter; + +public class ClientRequestMetrics extends LatencyMetrics { + @Deprecated + public static final Counter readTimeouts = Metrics + .newCounter(DefaultNameFactory.createMetricName( + "ClientRequestMetrics", "ReadTimeouts", null)); + @Deprecated + public static final Counter writeTimeouts = Metrics + .newCounter(DefaultNameFactory.createMetricName( + "ClientRequestMetrics", "WriteTimeouts", null)); + @Deprecated + public static final Counter readUnavailables = Metrics + .newCounter(DefaultNameFactory.createMetricName( + "ClientRequestMetrics", "ReadUnavailables", null)); + @Deprecated + public static final Counter writeUnavailables = Metrics + .newCounter(DefaultNameFactory.createMetricName( + "ClientRequestMetrics", "WriteUnavailables", null)); + + public final Meter timeouts; + public final Meter unavailables; + + public ClientRequestMetrics(String url, String scope) { + super(url, "ClientRequest", scope); + + timeouts = APIMetrics.newMeter(url + "timeouts", + factory.createMetricName("Timeouts"), "timeouts", + TimeUnit.SECONDS); + unavailables = APIMetrics.newMeter(url + "unavailables", + factory.createMetricName("Unavailables"), "unavailables", + TimeUnit.SECONDS); + } + + public void release() { + super.release(); + APIMetrics.defaultRegistry().removeMetric( + factory.createMetricName("Timeouts")); + APIMetrics.defaultRegistry().removeMetric( + factory.createMetricName("Unavailables")); + } +} diff --git a/src/main/java/org/apache/cassandra/metrics/LatencyMetrics.java b/src/main/java/org/apache/cassandra/metrics/LatencyMetrics.java new file mode 100644 index 0000000..67b83fd --- /dev/null +++ b/src/main/java/org/apache/cassandra/metrics/LatencyMetrics.java @@ -0,0 +1,152 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Copyright 2015 Cloudius Systems + * + * Modified by Cloudius Systems + */ +package org.apache.cassandra.metrics; + +import java.util.List; +import java.util.concurrent.TimeUnit; + +import com.cloudius.urchin.metrics.APIMetrics; +import com.cloudius.urchin.metrics.DefaultNameFactory; +import com.cloudius.urchin.metrics.MetricNameFactory; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.Lists; +import com.yammer.metrics.core.Counter; +import com.yammer.metrics.core.Timer; + +/** + * Metrics about latencies + */ +public class LatencyMetrics { + /** Latency */ + public final Timer latency; + /** Total latency in micro sec */ + public final Counter totalLatency; + + /** parent metrics to replicate any updates to **/ + private List parents = Lists.newArrayList(); + + protected final MetricNameFactory factory; + protected final String namePrefix; + + protected long lastLatency; + protected long lastOpCount; + + /** + * Create LatencyMetrics with given group, type, and scope. Name prefix for + * each metric will be empty. + * + * @param type + * Type name + * @param scope + * Scope + */ + public LatencyMetrics(String url, String type, String scope) { + this(url, type, "", scope); + } + + /** + * Create LatencyMetrics with given group, type, prefix to append to each + * metric name, and scope. + * + * @param type + * Type name + * @param namePrefix + * Prefix to append to each metric name + * @param scope + * Scope of metrics + */ + public LatencyMetrics(String url, String type, String namePrefix, + String scope) { + this(url, new DefaultNameFactory(type, scope), namePrefix); + } + + /** + * Create LatencyMetrics with given group, type, prefix to append to each + * metric name, and scope. + * + * @param factory + * MetricName factory to use + * @param namePrefix + * Prefix to append to each metric name + */ + public LatencyMetrics(String url, MetricNameFactory factory, + String namePrefix) { + this.factory = factory; + this.namePrefix = namePrefix; + + latency = APIMetrics.newTimer( + factory.createMetricName(namePrefix + "Latency"), + TimeUnit.MICROSECONDS, TimeUnit.SECONDS); + totalLatency = APIMetrics.newCounter(url + "total_latency", + factory.createMetricName(namePrefix + "TotalLatency")); + } + + /** + * Create LatencyMetrics with given group, type, prefix to append to each + * metric name, and scope. Any updates to this will also run on parent + * + * @param factory + * MetricName factory to use + * @param namePrefix + * Prefix to append to each metric name + * @param parents + * any amount of parents to replicate updates to + */ + public LatencyMetrics(String url, MetricNameFactory factory, + String namePrefix, LatencyMetrics... parents) { + this(url, factory, namePrefix); + this.parents.addAll(ImmutableList.copyOf(parents)); + } + + /** takes nanoseconds **/ + public void addNano(long nanos) { + // convert to microseconds. 1 millionth + latency.update(nanos, TimeUnit.NANOSECONDS); + totalLatency.inc(nanos / 1000); + for (LatencyMetrics parent : parents) { + parent.addNano(nanos); + } + } + + public void release() { + APIMetrics.defaultRegistry().removeMetric( + factory.createMetricName(namePrefix + "Latency")); + APIMetrics.defaultRegistry().removeMetric( + factory.createMetricName(namePrefix + "TotalLatency")); + } + + @Deprecated + public synchronized double getRecentLatency() { + long ops = latency.count(); + long n = totalLatency.count(); + if (ops == lastOpCount) + return 0; + try { + return ((double) n - lastLatency) / (ops - lastOpCount); + } finally { + lastLatency = n; + lastOpCount = ops; + } + } +} diff --git a/src/main/java/org/apache/cassandra/service/StorageProxy.java b/src/main/java/org/apache/cassandra/service/StorageProxy.java new file mode 100644 index 0000000..b9c353d --- /dev/null +++ b/src/main/java/org/apache/cassandra/service/StorageProxy.java @@ -0,0 +1,359 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Copyright 2015 Cloudius Systems + * + * Modified by Cloudius Systems + */ +package org.apache.cassandra.service; + +import java.lang.management.ManagementFactory; +import java.util.*; + +import javax.management.MBeanServer; +import javax.management.ObjectName; +import javax.ws.rs.core.MultivaluedMap; + +import com.cloudius.urchin.api.APIClient; +import com.sun.jersey.core.util.MultivaluedMapImpl; + +import org.apache.cassandra.metrics.*; + +public class StorageProxy 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(); + + public void log(String str) { + logger.info(str); + } + + private static final StorageProxy instance = new StorageProxy(); + + public static StorageProxy getInstance() { + return instance; + } + + 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() { + } + + static { + MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); + try { + mbs.registerMBean(instance, new ObjectName(MBEAN_NAME)); + } catch (Exception e) { + throw new RuntimeException(e); + } + + } + + /** + * @see org.apache.cassandra.metrics.LatencyMetrics#lastOpCount + */ + @Deprecated + public long getReadOperations() { + log(" getReadOperations()"); + return c.getLongValue(""); + } + + /** + * @see org.apache.cassandra.metrics.LatencyMetrics#totalLatencyHistogram + */ + @Deprecated + public long getTotalReadLatencyMicros() { + log(" getTotalReadLatencyMicros()"); + return c.getLongValue(""); + } + + /** + * @see org.apache.cassandra.metrics.LatencyMetrics#recentLatencyHistogram + */ + @Deprecated + public double getRecentReadLatencyMicros() { + log(" getRecentReadLatencyMicros()"); + return c.getDoubleValue(""); + } + + /** + * @see org.apache.cassandra.metrics.LatencyMetrics#totalLatencyHistogram + */ + @Deprecated + public long[] getTotalReadLatencyHistogramMicros() { + log(" getTotalReadLatencyHistogramMicros()"); + return c.getLongArrValue(""); + } + + /** + * @see org.apache.cassandra.metrics.LatencyMetrics#recentLatencyHistogram + */ + @Deprecated + public long[] getRecentReadLatencyHistogramMicros() { + log(" getRecentReadLatencyHistogramMicros()"); + return c.getLongArrValue(""); + } + + @Deprecated + public long getRangeOperations() { + log(" getRangeOperations()"); + return c.getLongValue(""); + } + + @Deprecated + public long getTotalRangeLatencyMicros() { + log(" getTotalRangeLatencyMicros()"); + return c.getLongValue(""); + } + + @Deprecated + public double getRecentRangeLatencyMicros() { + log(" getRecentRangeLatencyMicros()"); + return c.getDoubleValue(""); + } + + @Deprecated + public long[] getTotalRangeLatencyHistogramMicros() { + log(" getTotalRangeLatencyHistogramMicros()"); + return c.getLongArrValue(""); + } + + @Deprecated + public long[] getRecentRangeLatencyHistogramMicros() { + log(" getRecentRangeLatencyHistogramMicros()"); + return c.getLongArrValue(""); + } + + @Deprecated + public long getWriteOperations() { + log(" getWriteOperations()"); + return c.getLongValue(""); + } + + @Deprecated + public long getTotalWriteLatencyMicros() { + log(" getTotalWriteLatencyMicros()"); + return c.getLongValue(""); + } + + @Deprecated + public double getRecentWriteLatencyMicros() { + log(" getRecentWriteLatencyMicros()"); + return c.getDoubleValue(""); + } + + @Deprecated + public long[] getTotalWriteLatencyHistogramMicros() { + log(" getTotalWriteLatencyHistogramMicros()"); + return c.getLongArrValue(""); + } + + @Deprecated + public long[] getRecentWriteLatencyHistogramMicros() { + log(" getRecentWriteLatencyHistogramMicros()"); + return c.getLongArrValue(""); + } + + public long getTotalHints() { + log(" getTotalHints()"); + return c.getLongValue("storage_proxy/total_hints"); + } + + public boolean getHintedHandoffEnabled() { + log(" getHintedHandoffEnabled()"); + return c.getBooleanValue("storage_proxy/hinted_handoff_enabled"); + } + + public Set getHintedHandoffEnabledByDC() { + log(" getHintedHandoffEnabledByDC()"); + return c.getSetStringValue("storage_proxy/hinted_handoff_enabled_by_dc"); + } + + public void setHintedHandoffEnabled(boolean b) { + log(" setHintedHandoffEnabled(boolean b)"); + MultivaluedMap queryParams = new MultivaluedMapImpl(); + queryParams.add("enable", Boolean.toString(b)); + c.post("storage_proxy/hinted_handoff_enabled", + queryParams); + } + + public void setHintedHandoffEnabledByDCList(String dcs) { + log(" setHintedHandoffEnabledByDCList(String dcs)"); + MultivaluedMap queryParams = new MultivaluedMapImpl(); + queryParams.add("dcs", dcs); + c.post("storage_proxy/hinted_handoff_enabled_by_dc_list"); + } + + public int getMaxHintWindow() { + log(" getMaxHintWindow()"); + return c.getIntValue("storage_proxy/max_hint_window"); + } + + public void setMaxHintWindow(int ms) { + log(" setMaxHintWindow(int ms)"); + MultivaluedMap queryParams = new MultivaluedMapImpl(); + queryParams.add("ms", Integer.toString(ms)); + c.post("storage_proxy/max_hint_window", queryParams); + } + + public int getMaxHintsInProgress() { + log(" getMaxHintsInProgress()"); + return c.getIntValue("storage_proxy/max_hints_in_progress"); + } + + public void setMaxHintsInProgress(int qs) { + log(" setMaxHintsInProgress(int qs)"); + MultivaluedMap queryParams = new MultivaluedMapImpl(); + queryParams.add("qs", Integer.toString(qs)); + c.post("storage_proxy/max_hints_in_progress", queryParams); + } + + public int getHintsInProgress() { + log(" getHintsInProgress()"); + return c.getIntValue("storage_proxy/hints_in_progress"); + } + + public Long getRpcTimeout() { + log(" getRpcTimeout()"); + return c.getLongValue("storage_proxy/rpc_timeout"); + } + + public void setRpcTimeout(Long timeoutInMillis) { + log(" setRpcTimeout(Long timeoutInMillis)"); + MultivaluedMap queryParams = new MultivaluedMapImpl(); + queryParams.add("timeout", Long.toString(timeoutInMillis)); + c.post("storage_proxy/rpc_timeout", queryParams); + } + + public Long getReadRpcTimeout() { + log(" getReadRpcTimeout()"); + return c.getLongValue("storage_proxy/read_rpc_timeout"); + } + + public void setReadRpcTimeout(Long timeoutInMillis) { + log(" setReadRpcTimeout(Long timeoutInMillis)"); + MultivaluedMap queryParams = new MultivaluedMapImpl(); + queryParams.add("timeout", Long.toString(timeoutInMillis)); + c.post("storage_proxy/read_rpc_timeout", queryParams); + } + + public Long getWriteRpcTimeout() { + log(" getWriteRpcTimeout()"); + return c.getLongValue("storage_proxy/write_rpc_timeout"); + } + + public void setWriteRpcTimeout(Long timeoutInMillis) { + log(" setWriteRpcTimeout(Long timeoutInMillis)"); + MultivaluedMap queryParams = new MultivaluedMapImpl(); + queryParams.add("timeout", Long.toString(timeoutInMillis)); + c.post("storage_proxy/write_rpc_timeout", queryParams); + } + + public Long getCounterWriteRpcTimeout() { + log(" getCounterWriteRpcTimeout()"); + return c.getLongValue("storage_proxy/counter_write_rpc_timeout"); + } + + public void setCounterWriteRpcTimeout(Long timeoutInMillis) { + log(" setCounterWriteRpcTimeout(Long timeoutInMillis)"); + MultivaluedMap queryParams = new MultivaluedMapImpl(); + queryParams.add("timeout", Long.toString(timeoutInMillis)); + c.post("storage_proxy/counter_write_rpc_timeout", + queryParams); + } + + public Long getCasContentionTimeout() { + log(" getCasContentionTimeout()"); + return c.getLongValue("storage_proxy/cas_contention_timeout"); + } + + public void setCasContentionTimeout(Long timeoutInMillis) { + log(" setCasContentionTimeout(Long timeoutInMillis)"); + MultivaluedMap queryParams = new MultivaluedMapImpl(); + queryParams.add("timeout", Long.toString(timeoutInMillis)); + c.post("storage_proxy/cas_contention_timeout", + queryParams); + } + + public Long getRangeRpcTimeout() { + log(" getRangeRpcTimeout()"); + return c.getLongValue("storage_proxy/range_rpc_timeout"); + } + + public void setRangeRpcTimeout(Long timeoutInMillis) { + log(" setRangeRpcTimeout(Long timeoutInMillis)"); + MultivaluedMap queryParams = new MultivaluedMapImpl(); + queryParams.add("timeout", Long.toString(timeoutInMillis)); + c.post("storage_proxy/range_rpc_timeout", queryParams); + } + + public Long getTruncateRpcTimeout() { + log(" getTruncateRpcTimeout()"); + return c.getLongValue("storage_proxy/truncate_rpc_timeout"); + } + + public void setTruncateRpcTimeout(Long timeoutInMillis) { + log(" setTruncateRpcTimeout(Long timeoutInMillis)"); + MultivaluedMap queryParams = new MultivaluedMapImpl(); + queryParams.add("timeout", Long.toString(timeoutInMillis)); + c.post("storage_proxy/truncate_rpc_timeout", queryParams); + } + + public void reloadTriggerClasses() { + log(" reloadTriggerClasses()"); + c.post("storage_proxy/reload_trigger_classes"); + } + + public long getReadRepairAttempted() { + log(" getReadRepairAttempted()"); + return c.getLongValue("storage_proxy/read_repair_attempted"); + } + + public long getReadRepairRepairedBlocking() { + log(" getReadRepairRepairedBlocking()"); + return c.getLongValue("storage_proxy/read_repair_repaired_blocking"); + } + + public long getReadRepairRepairedBackground() { + log(" getReadRepairRepairedBackground()"); + return c.getLongValue("storage_proxy/read_repair_repaired_background"); + } + + /** Returns each live node's schema version */ + public Map> getSchemaVersions() { + log(" getSchemaVersions()"); + return c.getMapStringListStrValue("storage_proxy/schema_versions"); + } + +} diff --git a/src/main/java/org/apache/cassandra/service/StorageProxyMBean.java b/src/main/java/org/apache/cassandra/service/StorageProxyMBean.java new file mode 100644 index 0000000..a058794 --- /dev/null +++ b/src/main/java/org/apache/cassandra/service/StorageProxyMBean.java @@ -0,0 +1,143 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.cassandra.service; + +import java.util.List; +import java.util.Map; +import java.util.Set; + +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 boolean getHintedHandoffEnabled(); + + public Set getHintedHandoffEnabledByDC(); + + public void setHintedHandoffEnabled(boolean b); + + public void setHintedHandoffEnabledByDCList(String dcs); + + public int getMaxHintWindow(); + + public void setMaxHintWindow(int ms); + + public int getMaxHintsInProgress(); + + public void setMaxHintsInProgress(int qs); + + public int getHintsInProgress(); + + public Long getRpcTimeout(); + + public void setRpcTimeout(Long timeoutInMillis); + + public Long getReadRpcTimeout(); + + public void setReadRpcTimeout(Long timeoutInMillis); + + public Long getWriteRpcTimeout(); + + public void setWriteRpcTimeout(Long timeoutInMillis); + + public Long getCounterWriteRpcTimeout(); + + public void setCounterWriteRpcTimeout(Long timeoutInMillis); + + public Long getCasContentionTimeout(); + + public void setCasContentionTimeout(Long timeoutInMillis); + + public Long getRangeRpcTimeout(); + + public void setRangeRpcTimeout(Long timeoutInMillis); + + public Long getTruncateRpcTimeout(); + + public void setTruncateRpcTimeout(Long timeoutInMillis); + + public void reloadTriggerClasses(); + + public long getReadRepairAttempted(); + + public long getReadRepairRepairedBlocking(); + + public long getReadRepairRepairedBackground(); + + /** Returns each live node's schema version */ + public Map> getSchemaVersions(); +}