2015-06-18 10:55:38 +02:00
|
|
|
/*
|
|
|
|
* 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;
|
|
|
|
|
2016-08-17 10:40:59 +02:00
|
|
|
import static java.util.Collections.emptySet;
|
|
|
|
|
2015-06-18 10:55:38 +02:00
|
|
|
import java.lang.management.ManagementFactory;
|
2016-08-17 10:40:59 +02:00
|
|
|
import java.util.List;
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.Set;
|
2015-06-18 10:55:38 +02:00
|
|
|
|
|
|
|
import javax.management.MBeanServer;
|
|
|
|
import javax.management.ObjectName;
|
2015-10-28 10:25:37 +01:00
|
|
|
import javax.ws.rs.core.MultivaluedHashMap;
|
2015-06-18 10:55:38 +02:00
|
|
|
import javax.ws.rs.core.MultivaluedMap;
|
|
|
|
|
2015-12-17 08:26:19 +01:00
|
|
|
import com.scylladb.jmx.api.APIClient;
|
2015-06-18 10:55:38 +02:00
|
|
|
|
|
|
|
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) {
|
2015-12-30 07:47:32 +01:00
|
|
|
logger.finest(str);
|
2015-06-18 10:55:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-08-17 10:40:59 +02:00
|
|
|
@Override
|
2015-06-18 10:55:38 +02:00
|
|
|
public long getTotalHints() {
|
|
|
|
log(" getTotalHints()");
|
|
|
|
return c.getLongValue("storage_proxy/total_hints");
|
|
|
|
}
|
|
|
|
|
2016-08-17 10:40:59 +02:00
|
|
|
@Override
|
2015-06-18 10:55:38 +02:00
|
|
|
public boolean getHintedHandoffEnabled() {
|
|
|
|
log(" getHintedHandoffEnabled()");
|
|
|
|
return c.getBooleanValue("storage_proxy/hinted_handoff_enabled");
|
|
|
|
}
|
|
|
|
|
2016-08-17 10:40:59 +02:00
|
|
|
@Override
|
2015-06-18 10:55:38 +02:00
|
|
|
public Set<String> getHintedHandoffEnabledByDC() {
|
|
|
|
log(" getHintedHandoffEnabledByDC()");
|
2015-07-30 10:37:03 +02:00
|
|
|
return c.getSetStringValue(
|
|
|
|
"storage_proxy/hinted_handoff_enabled_by_dc");
|
2015-06-18 10:55:38 +02:00
|
|
|
}
|
|
|
|
|
2016-08-17 10:40:59 +02:00
|
|
|
@Override
|
2015-06-18 10:55:38 +02:00
|
|
|
public void setHintedHandoffEnabled(boolean b) {
|
|
|
|
log(" setHintedHandoffEnabled(boolean b)");
|
2015-10-28 10:25:37 +01:00
|
|
|
MultivaluedMap<String, String> queryParams = new MultivaluedHashMap<String, String>();
|
2015-06-18 10:55:38 +02:00
|
|
|
queryParams.add("enable", Boolean.toString(b));
|
2015-07-30 10:37:03 +02:00
|
|
|
c.post("storage_proxy/hinted_handoff_enabled", queryParams);
|
2015-06-18 10:55:38 +02:00
|
|
|
}
|
|
|
|
|
2016-08-17 10:40:59 +02:00
|
|
|
@Override
|
2015-06-18 10:55:38 +02:00
|
|
|
public void setHintedHandoffEnabledByDCList(String dcs) {
|
|
|
|
log(" setHintedHandoffEnabledByDCList(String dcs)");
|
2015-10-28 10:25:37 +01:00
|
|
|
MultivaluedMap<String, String> queryParams = new MultivaluedHashMap<String, String>();
|
2015-06-18 10:55:38 +02:00
|
|
|
queryParams.add("dcs", dcs);
|
|
|
|
c.post("storage_proxy/hinted_handoff_enabled_by_dc_list");
|
|
|
|
}
|
|
|
|
|
2016-08-17 10:40:59 +02:00
|
|
|
@Override
|
2015-06-18 10:55:38 +02:00
|
|
|
public int getMaxHintWindow() {
|
|
|
|
log(" getMaxHintWindow()");
|
|
|
|
return c.getIntValue("storage_proxy/max_hint_window");
|
|
|
|
}
|
|
|
|
|
2016-08-17 10:40:59 +02:00
|
|
|
@Override
|
2015-06-18 10:55:38 +02:00
|
|
|
public void setMaxHintWindow(int ms) {
|
|
|
|
log(" setMaxHintWindow(int ms)");
|
2015-10-28 10:25:37 +01:00
|
|
|
MultivaluedMap<String, String> queryParams = new MultivaluedHashMap<String, String>();
|
2015-06-18 10:55:38 +02:00
|
|
|
queryParams.add("ms", Integer.toString(ms));
|
|
|
|
c.post("storage_proxy/max_hint_window", queryParams);
|
|
|
|
}
|
|
|
|
|
2016-08-17 10:40:59 +02:00
|
|
|
@Override
|
2015-06-18 10:55:38 +02:00
|
|
|
public int getMaxHintsInProgress() {
|
|
|
|
log(" getMaxHintsInProgress()");
|
|
|
|
return c.getIntValue("storage_proxy/max_hints_in_progress");
|
|
|
|
}
|
|
|
|
|
2016-08-17 10:40:59 +02:00
|
|
|
@Override
|
2015-06-18 10:55:38 +02:00
|
|
|
public void setMaxHintsInProgress(int qs) {
|
|
|
|
log(" setMaxHintsInProgress(int qs)");
|
2015-10-28 10:25:37 +01:00
|
|
|
MultivaluedMap<String, String> queryParams = new MultivaluedHashMap<String, String>();
|
2015-06-18 10:55:38 +02:00
|
|
|
queryParams.add("qs", Integer.toString(qs));
|
|
|
|
c.post("storage_proxy/max_hints_in_progress", queryParams);
|
|
|
|
}
|
|
|
|
|
2016-08-17 10:40:59 +02:00
|
|
|
@Override
|
2015-06-18 10:55:38 +02:00
|
|
|
public int getHintsInProgress() {
|
|
|
|
log(" getHintsInProgress()");
|
|
|
|
return c.getIntValue("storage_proxy/hints_in_progress");
|
|
|
|
}
|
|
|
|
|
2016-08-17 10:40:59 +02:00
|
|
|
@Override
|
2015-06-18 10:55:38 +02:00
|
|
|
public Long getRpcTimeout() {
|
|
|
|
log(" getRpcTimeout()");
|
|
|
|
return c.getLongValue("storage_proxy/rpc_timeout");
|
|
|
|
}
|
|
|
|
|
2016-08-17 10:40:59 +02:00
|
|
|
@Override
|
2015-06-18 10:55:38 +02:00
|
|
|
public void setRpcTimeout(Long timeoutInMillis) {
|
|
|
|
log(" setRpcTimeout(Long timeoutInMillis)");
|
2015-10-28 10:25:37 +01:00
|
|
|
MultivaluedMap<String, String> queryParams = new MultivaluedHashMap<String, String>();
|
2015-06-18 10:55:38 +02:00
|
|
|
queryParams.add("timeout", Long.toString(timeoutInMillis));
|
|
|
|
c.post("storage_proxy/rpc_timeout", queryParams);
|
|
|
|
}
|
|
|
|
|
2016-08-17 10:40:59 +02:00
|
|
|
@Override
|
2015-06-18 10:55:38 +02:00
|
|
|
public Long getReadRpcTimeout() {
|
|
|
|
log(" getReadRpcTimeout()");
|
|
|
|
return c.getLongValue("storage_proxy/read_rpc_timeout");
|
|
|
|
}
|
|
|
|
|
2016-08-17 10:40:59 +02:00
|
|
|
@Override
|
2015-06-18 10:55:38 +02:00
|
|
|
public void setReadRpcTimeout(Long timeoutInMillis) {
|
|
|
|
log(" setReadRpcTimeout(Long timeoutInMillis)");
|
2015-10-28 10:25:37 +01:00
|
|
|
MultivaluedMap<String, String> queryParams = new MultivaluedHashMap<String, String>();
|
2015-06-18 10:55:38 +02:00
|
|
|
queryParams.add("timeout", Long.toString(timeoutInMillis));
|
|
|
|
c.post("storage_proxy/read_rpc_timeout", queryParams);
|
|
|
|
}
|
|
|
|
|
2016-08-17 10:40:59 +02:00
|
|
|
@Override
|
2015-06-18 10:55:38 +02:00
|
|
|
public Long getWriteRpcTimeout() {
|
|
|
|
log(" getWriteRpcTimeout()");
|
|
|
|
return c.getLongValue("storage_proxy/write_rpc_timeout");
|
|
|
|
}
|
|
|
|
|
2016-08-17 10:40:59 +02:00
|
|
|
@Override
|
2015-06-18 10:55:38 +02:00
|
|
|
public void setWriteRpcTimeout(Long timeoutInMillis) {
|
|
|
|
log(" setWriteRpcTimeout(Long timeoutInMillis)");
|
2015-10-28 10:25:37 +01:00
|
|
|
MultivaluedMap<String, String> queryParams = new MultivaluedHashMap<String, String>();
|
2015-06-18 10:55:38 +02:00
|
|
|
queryParams.add("timeout", Long.toString(timeoutInMillis));
|
|
|
|
c.post("storage_proxy/write_rpc_timeout", queryParams);
|
|
|
|
}
|
|
|
|
|
2016-08-17 10:40:59 +02:00
|
|
|
@Override
|
2015-06-18 10:55:38 +02:00
|
|
|
public Long getCounterWriteRpcTimeout() {
|
|
|
|
log(" getCounterWriteRpcTimeout()");
|
|
|
|
return c.getLongValue("storage_proxy/counter_write_rpc_timeout");
|
|
|
|
}
|
|
|
|
|
2016-08-17 10:40:59 +02:00
|
|
|
@Override
|
2015-06-18 10:55:38 +02:00
|
|
|
public void setCounterWriteRpcTimeout(Long timeoutInMillis) {
|
|
|
|
log(" setCounterWriteRpcTimeout(Long timeoutInMillis)");
|
2015-10-28 10:25:37 +01:00
|
|
|
MultivaluedMap<String, String> queryParams = new MultivaluedHashMap<String, String>();
|
2015-06-18 10:55:38 +02:00
|
|
|
queryParams.add("timeout", Long.toString(timeoutInMillis));
|
2015-07-30 10:37:03 +02:00
|
|
|
c.post("storage_proxy/counter_write_rpc_timeout", queryParams);
|
2015-06-18 10:55:38 +02:00
|
|
|
}
|
|
|
|
|
2016-08-17 10:40:59 +02:00
|
|
|
@Override
|
2015-06-18 10:55:38 +02:00
|
|
|
public Long getCasContentionTimeout() {
|
|
|
|
log(" getCasContentionTimeout()");
|
|
|
|
return c.getLongValue("storage_proxy/cas_contention_timeout");
|
|
|
|
}
|
|
|
|
|
2016-08-17 10:40:59 +02:00
|
|
|
@Override
|
2015-06-18 10:55:38 +02:00
|
|
|
public void setCasContentionTimeout(Long timeoutInMillis) {
|
|
|
|
log(" setCasContentionTimeout(Long timeoutInMillis)");
|
2015-10-28 10:25:37 +01:00
|
|
|
MultivaluedMap<String, String> queryParams = new MultivaluedHashMap<String, String>();
|
2015-06-18 10:55:38 +02:00
|
|
|
queryParams.add("timeout", Long.toString(timeoutInMillis));
|
2015-07-30 10:37:03 +02:00
|
|
|
c.post("storage_proxy/cas_contention_timeout", queryParams);
|
2015-06-18 10:55:38 +02:00
|
|
|
}
|
|
|
|
|
2016-08-17 10:40:59 +02:00
|
|
|
@Override
|
2015-06-18 10:55:38 +02:00
|
|
|
public Long getRangeRpcTimeout() {
|
|
|
|
log(" getRangeRpcTimeout()");
|
|
|
|
return c.getLongValue("storage_proxy/range_rpc_timeout");
|
|
|
|
}
|
|
|
|
|
2016-08-17 10:40:59 +02:00
|
|
|
@Override
|
2015-06-18 10:55:38 +02:00
|
|
|
public void setRangeRpcTimeout(Long timeoutInMillis) {
|
|
|
|
log(" setRangeRpcTimeout(Long timeoutInMillis)");
|
2015-10-28 10:25:37 +01:00
|
|
|
MultivaluedMap<String, String> queryParams = new MultivaluedHashMap<String, String>();
|
2015-06-18 10:55:38 +02:00
|
|
|
queryParams.add("timeout", Long.toString(timeoutInMillis));
|
|
|
|
c.post("storage_proxy/range_rpc_timeout", queryParams);
|
|
|
|
}
|
|
|
|
|
2016-08-17 10:40:59 +02:00
|
|
|
@Override
|
2015-06-18 10:55:38 +02:00
|
|
|
public Long getTruncateRpcTimeout() {
|
|
|
|
log(" getTruncateRpcTimeout()");
|
|
|
|
return c.getLongValue("storage_proxy/truncate_rpc_timeout");
|
|
|
|
}
|
|
|
|
|
2016-08-17 10:40:59 +02:00
|
|
|
@Override
|
2015-06-18 10:55:38 +02:00
|
|
|
public void setTruncateRpcTimeout(Long timeoutInMillis) {
|
|
|
|
log(" setTruncateRpcTimeout(Long timeoutInMillis)");
|
2015-10-28 10:25:37 +01:00
|
|
|
MultivaluedMap<String, String> queryParams = new MultivaluedHashMap<String, String>();
|
2015-06-18 10:55:38 +02:00
|
|
|
queryParams.add("timeout", Long.toString(timeoutInMillis));
|
|
|
|
c.post("storage_proxy/truncate_rpc_timeout", queryParams);
|
|
|
|
}
|
|
|
|
|
2016-08-17 10:40:59 +02:00
|
|
|
@Override
|
2015-06-18 10:55:38 +02:00
|
|
|
public void reloadTriggerClasses() {
|
|
|
|
log(" reloadTriggerClasses()");
|
|
|
|
c.post("storage_proxy/reload_trigger_classes");
|
|
|
|
}
|
|
|
|
|
2016-08-17 10:40:59 +02:00
|
|
|
@Override
|
2015-06-18 10:55:38 +02:00
|
|
|
public long getReadRepairAttempted() {
|
|
|
|
log(" getReadRepairAttempted()");
|
|
|
|
return c.getLongValue("storage_proxy/read_repair_attempted");
|
|
|
|
}
|
|
|
|
|
2016-08-17 10:40:59 +02:00
|
|
|
@Override
|
2015-06-18 10:55:38 +02:00
|
|
|
public long getReadRepairRepairedBlocking() {
|
|
|
|
log(" getReadRepairRepairedBlocking()");
|
|
|
|
return c.getLongValue("storage_proxy/read_repair_repaired_blocking");
|
|
|
|
}
|
|
|
|
|
2016-08-17 10:40:59 +02:00
|
|
|
@Override
|
2015-06-18 10:55:38 +02:00
|
|
|
public long getReadRepairRepairedBackground() {
|
|
|
|
log(" getReadRepairRepairedBackground()");
|
|
|
|
return c.getLongValue("storage_proxy/read_repair_repaired_background");
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Returns each live node's schema version */
|
2016-08-17 10:40:59 +02:00
|
|
|
@Override
|
2015-06-18 10:55:38 +02:00
|
|
|
public Map<String, List<String>> getSchemaVersions() {
|
|
|
|
log(" getSchemaVersions()");
|
|
|
|
return c.getMapStringListStrValue("storage_proxy/schema_versions");
|
|
|
|
}
|
|
|
|
|
2015-07-30 11:01:05 +02:00
|
|
|
@Override
|
|
|
|
public void setNativeTransportMaxConcurrentConnections(
|
|
|
|
Long nativeTransportMaxConcurrentConnections) {
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
log(" setNativeTransportMaxConcurrentConnections()");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Long getNativeTransportMaxConcurrentConnections() {
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
log(" getNativeTransportMaxConcurrentConnections()");
|
|
|
|
return c.getLongValue("");
|
|
|
|
}
|
|
|
|
|
2016-08-17 10:40:59 +02:00
|
|
|
@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();
|
|
|
|
}
|
2015-06-18 10:55:38 +02:00
|
|
|
}
|