2015-06-04 12:35:57 +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.db;
|
|
|
|
|
|
|
|
import java.lang.management.ManagementFactory;
|
2015-10-28 10:25:37 +01:00
|
|
|
import java.net.ConnectException;
|
2015-06-04 12:35:57 +02:00
|
|
|
import java.util.*;
|
|
|
|
import java.util.concurrent.*;
|
|
|
|
|
|
|
|
import javax.json.JsonArray;
|
|
|
|
import javax.json.JsonObject;
|
|
|
|
import javax.management.*;
|
2015-07-30 11:01:05 +02:00
|
|
|
import javax.management.openmbean.CompositeData;
|
|
|
|
import javax.management.openmbean.OpenDataException;
|
2015-10-28 10:25:37 +01:00
|
|
|
import javax.ws.rs.ProcessingException;
|
|
|
|
import javax.ws.rs.core.MultivaluedHashMap;
|
2015-06-21 08:46:29 +02:00
|
|
|
import javax.ws.rs.core.MultivaluedMap;
|
2015-06-04 12:35:57 +02:00
|
|
|
|
2015-06-24 10:15:26 +02:00
|
|
|
import org.apache.cassandra.metrics.ColumnFamilyMetrics;
|
|
|
|
|
2015-10-28 10:25:37 +01:00
|
|
|
import com.google.common.base.Throwables;
|
2015-12-17 08:26:19 +01:00
|
|
|
import com.scylladb.jmx.api.APIClient;
|
2015-06-04 12:35:57 +02:00
|
|
|
|
|
|
|
public class ColumnFamilyStore implements ColumnFamilyStoreMBean {
|
|
|
|
private static final java.util.logging.Logger logger = java.util.logging.Logger
|
|
|
|
.getLogger(ColumnFamilyStore.class.getName());
|
|
|
|
private APIClient c = new APIClient();
|
|
|
|
private String type;
|
|
|
|
private String keyspace;
|
|
|
|
private String name;
|
|
|
|
private String mbeanName;
|
2015-06-21 08:46:29 +02:00
|
|
|
static final int INTERVAL = 1000; // update every 1second
|
2015-06-24 10:15:26 +02:00
|
|
|
public final ColumnFamilyMetrics metric;
|
2015-06-04 12:35:57 +02:00
|
|
|
|
|
|
|
private static Map<String, ColumnFamilyStore> cf = new HashMap<String, ColumnFamilyStore>();
|
|
|
|
private static Timer timer = new Timer("Column Family");
|
|
|
|
|
|
|
|
public void log(String str) {
|
2015-12-30 07:47:32 +01:00
|
|
|
logger.finest(str);
|
2015-06-04 12:35:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public static void register_mbeans() {
|
|
|
|
TimerTask taskToExecute = new CheckRegistration();
|
2015-10-04 11:49:51 +02:00
|
|
|
timer.schedule(taskToExecute, 100, INTERVAL);
|
2015-06-04 12:35:57 +02:00
|
|
|
}
|
|
|
|
|
2015-06-21 08:46:29 +02:00
|
|
|
public ColumnFamilyStore(String type, String keyspace, String name) {
|
|
|
|
this.type = type;
|
|
|
|
this.keyspace = keyspace;
|
|
|
|
this.name = name;
|
2015-06-04 12:35:57 +02:00
|
|
|
mbeanName = getName(type, keyspace, name);
|
|
|
|
try {
|
|
|
|
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
|
|
|
|
ObjectName nameObj = new ObjectName(mbeanName);
|
|
|
|
mbs.registerMBean(this, nameObj);
|
|
|
|
} catch (Exception e) {
|
|
|
|
throw new RuntimeException(e);
|
|
|
|
}
|
2015-06-24 10:15:26 +02:00
|
|
|
metric = new ColumnFamilyMetrics(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
/** true if this CFS contains secondary index data */
|
|
|
|
/*
|
|
|
|
* It is hard coded to false until secondary index is supported
|
|
|
|
*/
|
|
|
|
public boolean isIndex() {
|
|
|
|
return false;
|
2015-06-04 12:35:57 +02:00
|
|
|
}
|
|
|
|
|
2015-06-21 08:46:29 +02:00
|
|
|
/**
|
|
|
|
* Get the column family name in the API format
|
|
|
|
*
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
public String getCFName() {
|
|
|
|
return keyspace + ":" + name;
|
|
|
|
}
|
|
|
|
|
2015-06-04 12:35:57 +02:00
|
|
|
private static String getName(String type, String keyspace, String name) {
|
|
|
|
return "org.apache.cassandra.db:type=" + type + ",keyspace=" + keyspace
|
|
|
|
+ ",columnfamily=" + name;
|
|
|
|
}
|
|
|
|
|
|
|
|
private static final class CheckRegistration extends TimerTask {
|
|
|
|
private APIClient c = new APIClient();
|
2015-09-17 12:38:01 +02:00
|
|
|
private int missed_response = 0;
|
|
|
|
// After MAX_RETRY retry we assume the API is not available
|
|
|
|
// and the jmx will shutdown
|
|
|
|
private static final int MAX_RETRY = 30;
|
2015-06-04 12:35:57 +02:00
|
|
|
@Override
|
|
|
|
public void run() {
|
|
|
|
try {
|
|
|
|
JsonArray mbeans = c.getJsonArray("/column_family/");
|
|
|
|
Set<String> all_cf = new HashSet<String>();
|
|
|
|
for (int i = 0; i < mbeans.size(); i++) {
|
|
|
|
JsonObject mbean = mbeans.getJsonObject(i);
|
|
|
|
String name = getName(mbean.getString("type"),
|
|
|
|
mbean.getString("ks"), mbean.getString("cf"));
|
|
|
|
if (!cf.containsKey(name)) {
|
|
|
|
ColumnFamilyStore cfs = new ColumnFamilyStore(
|
|
|
|
mbean.getString("type"), mbean.getString("ks"),
|
|
|
|
mbean.getString("cf"));
|
|
|
|
cf.put(name, cfs);
|
2015-06-21 08:46:29 +02:00
|
|
|
}
|
2015-06-04 12:35:57 +02:00
|
|
|
all_cf.add(name);
|
|
|
|
}
|
2015-06-21 08:46:29 +02:00
|
|
|
// removing deleted column family
|
2015-06-04 12:35:57 +02:00
|
|
|
for (String n : cf.keySet()) {
|
2015-06-21 08:46:29 +02:00
|
|
|
if (!all_cf.contains(n)) {
|
2015-06-04 12:35:57 +02:00
|
|
|
cf.remove(n);
|
|
|
|
}
|
|
|
|
}
|
2015-09-17 12:38:01 +02:00
|
|
|
missed_response = 0;
|
2016-03-22 00:19:15 +01:00
|
|
|
} catch (IllegalStateException e) {
|
|
|
|
if (missed_response++ > MAX_RETRY) {
|
|
|
|
System.err.println("API is not available, JMX is shuting down");
|
|
|
|
System.exit(-1);
|
2015-09-17 12:38:01 +02:00
|
|
|
}
|
2015-06-04 12:35:57 +02:00
|
|
|
} catch (Exception e) {
|
|
|
|
// ignoring exceptions, will retry on the next interval
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return the name of the column family
|
|
|
|
*/
|
|
|
|
public String getColumnFamilyName() {
|
|
|
|
log(" getColumnFamilyName()");
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the total amount of data stored in the memtable, including column
|
|
|
|
* related overhead.
|
|
|
|
*
|
|
|
|
* @see org.apache.cassandra.metrics.ColumnFamilyMetrics#memtableOnHeapSize
|
|
|
|
* @return The size in bytes.
|
|
|
|
* @deprecated
|
|
|
|
*/
|
|
|
|
@Deprecated
|
|
|
|
public long getMemtableDataSize() {
|
|
|
|
log(" getMemtableDataSize()");
|
2015-09-17 12:43:19 +02:00
|
|
|
return c.getLongValue("/column_family/metrics/memtable_on_heap_size/" + getCFName());
|
2015-06-04 12:35:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the total number of columns present in the memtable.
|
|
|
|
*
|
|
|
|
* @see org.apache.cassandra.metrics.ColumnFamilyMetrics#memtableColumnsCount
|
|
|
|
* @return The number of columns.
|
|
|
|
*/
|
|
|
|
@Deprecated
|
|
|
|
public long getMemtableColumnsCount() {
|
|
|
|
log(" getMemtableColumnsCount()");
|
2015-10-21 11:48:28 +02:00
|
|
|
return metric.memtableColumnsCount.value();
|
2015-06-04 12:35:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the number of times that a flush has resulted in the memtable
|
|
|
|
* being switched out.
|
|
|
|
*
|
|
|
|
* @see org.apache.cassandra.metrics.ColumnFamilyMetrics#memtableSwitchCount
|
|
|
|
* @return the number of memtable switches
|
|
|
|
*/
|
|
|
|
@Deprecated
|
|
|
|
public int getMemtableSwitchCount() {
|
|
|
|
log(" getMemtableSwitchCount()");
|
2015-09-17 12:43:19 +02:00
|
|
|
return c.getIntValue("/column_family/metrics/memtable_switch_count/" + getCFName());
|
2015-06-04 12:35:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @see org.apache.cassandra.metrics.ColumnFamilyMetrics#recentSSTablesPerRead
|
|
|
|
* @return a histogram of the number of sstable data files accessed per
|
|
|
|
* read: reading this property resets it
|
|
|
|
*/
|
|
|
|
@Deprecated
|
|
|
|
public long[] getRecentSSTablesPerReadHistogram() {
|
|
|
|
log(" getRecentSSTablesPerReadHistogram()");
|
2015-10-21 11:48:28 +02:00
|
|
|
return metric.getRecentSSTablesPerRead();
|
2015-06-04 12:35:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @see org.apache.cassandra.metrics.ColumnFamilyMetrics#sstablesPerReadHistogram
|
|
|
|
* @return a histogram of the number of sstable data files accessed per read
|
|
|
|
*/
|
|
|
|
@Deprecated
|
|
|
|
public long[] getSSTablesPerReadHistogram() {
|
|
|
|
log(" getSSTablesPerReadHistogram()");
|
2015-10-21 11:48:28 +02:00
|
|
|
return metric.sstablesPerRead.getBuckets(false);
|
2015-06-04 12:35:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @see org.apache.cassandra.metrics.ColumnFamilyMetrics#readLatency
|
|
|
|
* @return the number of read operations on this column family
|
|
|
|
*/
|
|
|
|
@Deprecated
|
|
|
|
public long getReadCount() {
|
|
|
|
log(" getReadCount()");
|
2015-09-17 12:43:19 +02:00
|
|
|
return c.getIntValue("/column_family/metrics/read/" + getCFName());
|
2015-06-04 12:35:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @see org.apache.cassandra.metrics.ColumnFamilyMetrics#readLatency
|
|
|
|
* @return total read latency (divide by getReadCount() for average)
|
|
|
|
*/
|
|
|
|
@Deprecated
|
|
|
|
public long getTotalReadLatencyMicros() {
|
|
|
|
log(" getTotalReadLatencyMicros()");
|
2015-09-17 12:43:19 +02:00
|
|
|
return c.getLongValue("/column_family/metrics/read_latency/" + getCFName());
|
2015-06-04 12:35:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @see org.apache.cassandra.metrics.ColumnFamilyMetrics#readLatency
|
|
|
|
* @return an array representing the latency histogram
|
|
|
|
*/
|
|
|
|
@Deprecated
|
|
|
|
public long[] getLifetimeReadLatencyHistogramMicros() {
|
|
|
|
log(" getLifetimeReadLatencyHistogramMicros()");
|
2015-10-21 11:48:28 +02:00
|
|
|
return metric.readLatency.totalLatencyHistogram.getBuckets(false);
|
2015-06-04 12:35:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @see org.apache.cassandra.metrics.ColumnFamilyMetrics#readLatency
|
|
|
|
* @return an array representing the latency histogram
|
|
|
|
*/
|
|
|
|
@Deprecated
|
|
|
|
public long[] getRecentReadLatencyHistogramMicros() {
|
|
|
|
log(" getRecentReadLatencyHistogramMicros()");
|
2015-10-21 11:48:28 +02:00
|
|
|
return metric.readLatency.getRecentLatencyHistogram();
|
2015-06-04 12:35:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @see org.apache.cassandra.metrics.ColumnFamilyMetrics#readLatency
|
|
|
|
* @return average latency per read operation since the last call
|
|
|
|
*/
|
|
|
|
@Deprecated
|
|
|
|
public double getRecentReadLatencyMicros() {
|
|
|
|
log(" getRecentReadLatencyMicros()");
|
2015-10-21 11:48:28 +02:00
|
|
|
return metric.readLatency.getRecentLatency();
|
2015-06-04 12:35:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @see org.apache.cassandra.metrics.ColumnFamilyMetrics#writeLatency
|
|
|
|
* @return the number of write operations on this column family
|
|
|
|
*/
|
|
|
|
@Deprecated
|
|
|
|
public long getWriteCount() {
|
|
|
|
log(" getWriteCount()");
|
2015-09-17 12:43:19 +02:00
|
|
|
return c.getLongValue("/column_family/metrics/write/" + getCFName());
|
2015-06-04 12:35:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @see org.apache.cassandra.metrics.ColumnFamilyMetrics#writeLatency
|
|
|
|
* @return total write latency (divide by getReadCount() for average)
|
|
|
|
*/
|
|
|
|
@Deprecated
|
|
|
|
public long getTotalWriteLatencyMicros() {
|
|
|
|
log(" getTotalWriteLatencyMicros()");
|
2015-09-17 12:43:19 +02:00
|
|
|
return c.getLongValue("/column_family/metrics/write_latency/" + getCFName());
|
2015-06-04 12:35:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @see org.apache.cassandra.metrics.ColumnFamilyMetrics#writeLatency
|
|
|
|
* @return an array representing the latency histogram
|
|
|
|
*/
|
|
|
|
@Deprecated
|
|
|
|
public long[] getLifetimeWriteLatencyHistogramMicros() {
|
|
|
|
log(" getLifetimeWriteLatencyHistogramMicros()");
|
2015-10-21 11:48:28 +02:00
|
|
|
return metric.writeLatency.totalLatencyHistogram.getBuckets(false);
|
2015-06-04 12:35:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @see org.apache.cassandra.metrics.ColumnFamilyMetrics#writeLatency
|
|
|
|
* @return an array representing the latency histogram
|
|
|
|
*/
|
|
|
|
@Deprecated
|
|
|
|
public long[] getRecentWriteLatencyHistogramMicros() {
|
|
|
|
log(" getRecentWriteLatencyHistogramMicros()");
|
2015-10-21 11:48:28 +02:00
|
|
|
return metric.writeLatency.getRecentLatencyHistogram();
|
2015-06-04 12:35:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @see org.apache.cassandra.metrics.ColumnFamilyMetrics#writeLatency
|
|
|
|
* @return average latency per write operation since the last call
|
|
|
|
*/
|
|
|
|
@Deprecated
|
|
|
|
public double getRecentWriteLatencyMicros() {
|
|
|
|
log(" getRecentWriteLatencyMicros()");
|
2015-10-21 11:48:28 +02:00
|
|
|
return metric.writeLatency.getRecentLatency();
|
2015-06-04 12:35:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @see org.apache.cassandra.metrics.ColumnFamilyMetrics#pendingFlushes
|
|
|
|
* @return the estimated number of tasks pending for this column family
|
|
|
|
*/
|
|
|
|
@Deprecated
|
|
|
|
public int getPendingTasks() {
|
|
|
|
log(" getPendingTasks()");
|
2015-09-17 12:43:19 +02:00
|
|
|
return c.getIntValue("/column_family/metrics/pending_flushes/" + getCFName());
|
2015-06-04 12:35:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @see org.apache.cassandra.metrics.ColumnFamilyMetrics#liveSSTableCount
|
|
|
|
* @return the number of SSTables on disk for this CF
|
|
|
|
*/
|
|
|
|
@Deprecated
|
|
|
|
public int getLiveSSTableCount() {
|
|
|
|
log(" getLiveSSTableCount()");
|
2015-09-17 12:43:19 +02:00
|
|
|
return c.getIntValue("/column_family/metrics/live_ss_table_count/" + getCFName());
|
2015-06-04 12:35:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @see org.apache.cassandra.metrics.ColumnFamilyMetrics#liveDiskSpaceUsed
|
|
|
|
* @return disk space used by SSTables belonging to this CF
|
|
|
|
*/
|
|
|
|
@Deprecated
|
|
|
|
public long getLiveDiskSpaceUsed() {
|
|
|
|
log(" getLiveDiskSpaceUsed()");
|
2015-09-17 12:43:19 +02:00
|
|
|
return c.getLongValue("/column_family/metrics/live_disk_space_used/" + getCFName());
|
2015-06-04 12:35:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @see org.apache.cassandra.metrics.ColumnFamilyMetrics#totalDiskSpaceUsed
|
|
|
|
* @return total disk space used by SSTables belonging to this CF, including
|
|
|
|
* obsolete ones waiting to be GC'd
|
|
|
|
*/
|
|
|
|
@Deprecated
|
|
|
|
public long getTotalDiskSpaceUsed() {
|
|
|
|
log(" getTotalDiskSpaceUsed()");
|
2015-09-17 12:43:19 +02:00
|
|
|
return c.getLongValue("/column_family/metrics/total_disk_space_used/" + getCFName());
|
2015-06-04 12:35:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* force a major compaction of this column family
|
|
|
|
*/
|
2015-07-30 10:37:03 +02:00
|
|
|
public void forceMajorCompaction()
|
|
|
|
throws ExecutionException, InterruptedException {
|
2015-06-04 12:35:57 +02:00
|
|
|
log(" forceMajorCompaction() throws ExecutionException, InterruptedException");
|
2015-06-21 08:46:29 +02:00
|
|
|
c.post("column_family/major_compaction/" + getCFName());
|
2015-06-04 12:35:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @see org.apache.cassandra.metrics.ColumnFamilyMetrics#minRowSize
|
|
|
|
* @return the size of the smallest compacted row
|
|
|
|
*/
|
|
|
|
@Deprecated
|
|
|
|
public long getMinRowSize() {
|
|
|
|
log(" getMinRowSize()");
|
2015-09-17 12:43:19 +02:00
|
|
|
return c.getLongValue("/column_family/metrics/min_row_size/" + getCFName());
|
2015-06-04 12:35:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @see org.apache.cassandra.metrics.ColumnFamilyMetrics#maxRowSize
|
|
|
|
* @return the size of the largest compacted row
|
|
|
|
*/
|
|
|
|
@Deprecated
|
|
|
|
public long getMaxRowSize() {
|
|
|
|
log(" getMaxRowSize()");
|
2015-09-17 12:43:19 +02:00
|
|
|
return c.getLongValue("/column_family/metrics/max_row_size/" + getCFName());
|
2015-06-04 12:35:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @see org.apache.cassandra.metrics.ColumnFamilyMetrics#meanRowSize
|
|
|
|
* @return the average row size across all the sstables
|
|
|
|
*/
|
|
|
|
@Deprecated
|
|
|
|
public long getMeanRowSize() {
|
|
|
|
log(" getMeanRowSize()");
|
2015-09-17 12:43:19 +02:00
|
|
|
return c.getLongValue("/column_family/metrics/mean_row_size/" + getCFName());
|
2015-06-04 12:35:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @see org.apache.cassandra.metrics.ColumnFamilyMetrics#bloomFilterFalsePositives
|
|
|
|
*/
|
|
|
|
@Deprecated
|
|
|
|
public long getBloomFilterFalsePositives() {
|
|
|
|
log(" getBloomFilterFalsePositives()");
|
2015-09-17 12:43:19 +02:00
|
|
|
return c.getLongValue("/column_family/metrics/bloom_filter_false_positives/" + getCFName());
|
2015-06-04 12:35:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @see org.apache.cassandra.metrics.ColumnFamilyMetrics#recentBloomFilterFalsePositives
|
|
|
|
*/
|
|
|
|
@Deprecated
|
|
|
|
public long getRecentBloomFilterFalsePositives() {
|
|
|
|
log(" getRecentBloomFilterFalsePositives()");
|
2015-09-17 12:43:19 +02:00
|
|
|
return c.getLongValue("/column_family/metrics/recent_bloom_filter_false_positives/" +getCFName());
|
2015-06-04 12:35:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @see org.apache.cassandra.metrics.ColumnFamilyMetrics#bloomFilterFalseRatio
|
|
|
|
*/
|
|
|
|
@Deprecated
|
|
|
|
public double getBloomFilterFalseRatio() {
|
|
|
|
log(" getBloomFilterFalseRatio()");
|
2015-09-17 12:43:19 +02:00
|
|
|
return c.getDoubleValue("/column_family/metrics/bloom_filter_false_ratio/" + getCFName());
|
2015-06-04 12:35:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @see org.apache.cassandra.metrics.ColumnFamilyMetrics#recentBloomFilterFalseRatio
|
|
|
|
*/
|
|
|
|
@Deprecated
|
|
|
|
public double getRecentBloomFilterFalseRatio() {
|
|
|
|
log(" getRecentBloomFilterFalseRatio()");
|
2015-09-17 12:43:19 +02:00
|
|
|
return c.getDoubleValue("/column_family/metrics/recent_bloom_filter_false_ratio/" + getCFName());
|
2015-06-04 12:35:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @see org.apache.cassandra.metrics.ColumnFamilyMetrics#bloomFilterDiskSpaceUsed
|
|
|
|
*/
|
|
|
|
@Deprecated
|
|
|
|
public long getBloomFilterDiskSpaceUsed() {
|
|
|
|
log(" getBloomFilterDiskSpaceUsed()");
|
2015-09-17 12:43:19 +02:00
|
|
|
return c.getLongValue("/column_family/metrics/bloom_filter_disk_space_used/" + getCFName());
|
2015-06-04 12:35:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @see org.apache.cassandra.metrics.ColumnFamilyMetrics#bloomFilterOffHeapMemoryUsed
|
|
|
|
*/
|
|
|
|
@Deprecated
|
|
|
|
public long getBloomFilterOffHeapMemoryUsed() {
|
|
|
|
log(" getBloomFilterOffHeapMemoryUsed()");
|
2015-09-17 12:43:19 +02:00
|
|
|
return c.getLongValue("/column_family/metrics/bloom_filter_off_heap_memory_used/" + getCFName());
|
2015-06-04 12:35:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @see org.apache.cassandra.metrics.ColumnFamilyMetrics#indexSummaryOffHeapMemoryUsed
|
|
|
|
*/
|
|
|
|
@Deprecated
|
|
|
|
public long getIndexSummaryOffHeapMemoryUsed() {
|
|
|
|
log(" getIndexSummaryOffHeapMemoryUsed()");
|
2015-09-17 12:43:19 +02:00
|
|
|
return c.getLongValue("/column_family/metrics/index_summary_off_heap_memory_used/" + getCFName());
|
2015-06-04 12:35:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @see org.apache.cassandra.metrics.ColumnFamilyMetrics#compressionMetadataOffHeapMemoryUsed
|
|
|
|
*/
|
|
|
|
@Deprecated
|
|
|
|
public long getCompressionMetadataOffHeapMemoryUsed() {
|
|
|
|
log(" getCompressionMetadataOffHeapMemoryUsed()");
|
2015-09-17 12:43:19 +02:00
|
|
|
return c.getLongValue("/column_family/metrics/compression_metadata_off_heap_memory_used/" + getCFName());
|
2015-06-04 12:35:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the minimum number of sstables in queue before compaction kicks off
|
|
|
|
*/
|
|
|
|
public int getMinimumCompactionThreshold() {
|
|
|
|
log(" getMinimumCompactionThreshold()");
|
2015-06-21 08:46:29 +02:00
|
|
|
return c.getIntValue("column_family/minimum_compaction/" + getCFName());
|
2015-06-04 12:35:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the minimum number of sstables in queue before compaction kicks off
|
|
|
|
*/
|
|
|
|
public void setMinimumCompactionThreshold(int threshold) {
|
|
|
|
log(" setMinimumCompactionThreshold(int threshold)");
|
2015-10-28 10:25:37 +01:00
|
|
|
MultivaluedMap<String, String> queryParams = new MultivaluedHashMap<String, String>();
|
2015-06-21 08:46:29 +02:00
|
|
|
queryParams.add("value", Integer.toString(threshold));
|
|
|
|
c.post("column_family/minimum_compaction/" + getCFName(), queryParams);
|
2015-06-04 12:35:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the maximum number of sstables in queue before compaction kicks off
|
|
|
|
*/
|
|
|
|
public int getMaximumCompactionThreshold() {
|
|
|
|
log(" getMaximumCompactionThreshold()");
|
2015-06-21 08:46:29 +02:00
|
|
|
return c.getIntValue("column_family/maximum_compaction/" + getCFName());
|
2015-06-04 12:35:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the maximum and maximum number of SSTables in queue before
|
|
|
|
* compaction kicks off
|
|
|
|
*/
|
|
|
|
public void setCompactionThresholds(int minThreshold, int maxThreshold) {
|
|
|
|
log(" setCompactionThresholds(int minThreshold, int maxThreshold)");
|
2015-10-28 10:25:37 +01:00
|
|
|
MultivaluedMap<String, String> queryParams = new MultivaluedHashMap<String, String>();
|
2015-06-21 08:46:29 +02:00
|
|
|
queryParams.add("minimum", Integer.toString(minThreshold));
|
|
|
|
queryParams.add("maximum", Integer.toString(maxThreshold));
|
|
|
|
c.post("column_family/compaction" + getCFName(), queryParams);
|
2015-06-04 12:35:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the maximum number of sstables in queue before compaction kicks off
|
|
|
|
*/
|
|
|
|
public void setMaximumCompactionThreshold(int threshold) {
|
|
|
|
log(" setMaximumCompactionThreshold(int threshold)");
|
2015-10-28 10:25:37 +01:00
|
|
|
MultivaluedMap<String, String> queryParams = new MultivaluedHashMap<String, String>();
|
2015-06-21 08:46:29 +02:00
|
|
|
queryParams.add("value", Integer.toString(threshold));
|
|
|
|
c.post("column_family/maximum_compaction/" + getCFName(), queryParams);
|
2015-06-04 12:35:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the compaction strategy by class name
|
2015-06-21 08:46:29 +02:00
|
|
|
*
|
2015-06-04 12:35:57 +02:00
|
|
|
* @param className
|
|
|
|
* the name of the compaction strategy class
|
|
|
|
*/
|
|
|
|
public void setCompactionStrategyClass(String className) {
|
|
|
|
log(" setCompactionStrategyClass(String className)");
|
2015-10-28 10:25:37 +01:00
|
|
|
MultivaluedMap<String, String> queryParams = new MultivaluedHashMap<String, String>();
|
2015-06-21 08:46:29 +02:00
|
|
|
queryParams.add("class_name", className);
|
|
|
|
c.post("column_family/compaction_strategy/" + getCFName(), queryParams);
|
2015-06-04 12:35:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the compaction strategy class name
|
|
|
|
*/
|
|
|
|
public String getCompactionStrategyClass() {
|
|
|
|
log(" getCompactionStrategyClass()");
|
2015-07-30 10:37:03 +02:00
|
|
|
return c.getStringValue(
|
|
|
|
"column_family/compaction_strategy/" + getCFName());
|
2015-06-04 12:35:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the compression parameters
|
|
|
|
*/
|
|
|
|
public Map<String, String> getCompressionParameters() {
|
|
|
|
log(" getCompressionParameters()");
|
2015-07-30 10:37:03 +02:00
|
|
|
return c.getMapStrValue(
|
|
|
|
"column_family/compression_parameters/" + getCFName());
|
2015-06-04 12:35:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the compression parameters
|
2015-06-21 08:46:29 +02:00
|
|
|
*
|
2015-06-04 12:35:57 +02:00
|
|
|
* @param opts
|
|
|
|
* map of string names to values
|
|
|
|
*/
|
|
|
|
public void setCompressionParameters(Map<String, String> opts) {
|
|
|
|
log(" setCompressionParameters(Map<String,String> opts)");
|
2015-10-28 10:25:37 +01:00
|
|
|
MultivaluedMap<String, String> queryParams = new MultivaluedHashMap<String, String>();
|
2015-06-21 08:46:29 +02:00
|
|
|
queryParams.add("opts", APIClient.mapToString(opts));
|
|
|
|
c.post("column_family/compression_parameters/" + getCFName(),
|
|
|
|
queryParams);
|
2015-06-04 12:35:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set new crc check chance
|
|
|
|
*/
|
|
|
|
public void setCrcCheckChance(double crcCheckChance) {
|
|
|
|
log(" setCrcCheckChance(double crcCheckChance)");
|
2015-10-28 10:25:37 +01:00
|
|
|
MultivaluedMap<String, String> queryParams = new MultivaluedHashMap<String, String>();
|
2015-06-21 08:46:29 +02:00
|
|
|
queryParams.add("check_chance", Double.toString(crcCheckChance));
|
|
|
|
c.post("column_family/crc_check_chance/" + getCFName(), queryParams);
|
2015-06-04 12:35:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isAutoCompactionDisabled() {
|
|
|
|
log(" isAutoCompactionDisabled()");
|
2015-06-21 08:46:29 +02:00
|
|
|
return c.getBooleanValue("column_family/autocompaction/" + getCFName());
|
2015-06-04 12:35:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/** Number of tombstoned cells retreived during the last slicequery */
|
|
|
|
@Deprecated
|
|
|
|
public double getTombstonesPerSlice() {
|
|
|
|
log(" getTombstonesPerSlice()");
|
|
|
|
return c.getDoubleValue("");
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Number of live cells retreived during the last slicequery */
|
|
|
|
@Deprecated
|
|
|
|
public double getLiveCellsPerSlice() {
|
|
|
|
log(" getLiveCellsPerSlice()");
|
|
|
|
return c.getDoubleValue("");
|
|
|
|
}
|
|
|
|
|
|
|
|
public long estimateKeys() {
|
|
|
|
log(" estimateKeys()");
|
2015-06-21 08:46:29 +02:00
|
|
|
return c.getLongValue("column_family/estimate_keys/" + getCFName());
|
2015-06-04 12:35:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @see org.apache.cassandra.metrics.ColumnFamilyMetrics#estimatedRowSizeHistogram
|
|
|
|
*/
|
|
|
|
@Deprecated
|
|
|
|
public long[] getEstimatedRowSizeHistogram() {
|
|
|
|
log(" getEstimatedRowSizeHistogram()");
|
2015-10-21 11:48:28 +02:00
|
|
|
return metric.estimatedRowSizeHistogram.value();
|
2015-06-04 12:35:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @see org.apache.cassandra.metrics.ColumnFamilyMetrics#estimatedColumnCountHistogram
|
|
|
|
*/
|
|
|
|
@Deprecated
|
|
|
|
public long[] getEstimatedColumnCountHistogram() {
|
|
|
|
log(" getEstimatedColumnCountHistogram()");
|
2015-10-21 11:48:28 +02:00
|
|
|
return metric.estimatedColumnCountHistogram.value();
|
2015-06-04 12:35:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @see org.apache.cassandra.metrics.ColumnFamilyMetrics#compressionRatio
|
|
|
|
*/
|
|
|
|
@Deprecated
|
|
|
|
public double getCompressionRatio() {
|
|
|
|
log(" getCompressionRatio()");
|
2015-09-17 12:43:19 +02:00
|
|
|
return c.getDoubleValue("/column_family/metrics/compression_ratio/" + getCFName());
|
2015-06-04 12:35:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a list of the names of the built column indexes for current store
|
2015-06-21 08:46:29 +02:00
|
|
|
*
|
2015-06-04 12:35:57 +02:00
|
|
|
* @return list of the index names
|
|
|
|
*/
|
|
|
|
public List<String> getBuiltIndexes() {
|
|
|
|
log(" getBuiltIndexes()");
|
2015-06-21 08:46:29 +02:00
|
|
|
return c.getListStrValue("column_family/built_indexes/" + getCFName());
|
2015-06-04 12:35:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a list of filenames that contain the given key on this node
|
2015-06-21 08:46:29 +02:00
|
|
|
*
|
2015-06-04 12:35:57 +02:00
|
|
|
* @param key
|
|
|
|
* @return list of filenames containing the key
|
|
|
|
*/
|
|
|
|
public List<String> getSSTablesForKey(String key) {
|
|
|
|
log(" getSSTablesForKey(String key)");
|
2015-10-28 10:25:37 +01:00
|
|
|
MultivaluedMap<String, String> queryParams = new MultivaluedHashMap<String, String>();
|
2015-06-21 08:46:29 +02:00
|
|
|
queryParams.add("key", key);
|
2015-07-30 10:37:03 +02:00
|
|
|
return c.getListStrValue("column_family/sstables/by_key/" + getCFName(),
|
|
|
|
queryParams);
|
2015-06-04 12:35:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Scan through Keyspace/ColumnFamily's data directory determine which
|
|
|
|
* SSTables should be loaded and load them
|
|
|
|
*/
|
|
|
|
public void loadNewSSTables() {
|
|
|
|
log(" loadNewSSTables()");
|
2015-06-21 08:46:29 +02:00
|
|
|
c.post("column_family/sstable/" + getCFName());
|
2015-06-04 12:35:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return the number of SSTables in L0. Always return 0 if Leveled
|
|
|
|
* compaction is not enabled.
|
|
|
|
*/
|
|
|
|
public int getUnleveledSSTables() {
|
|
|
|
log(" getUnleveledSSTables()");
|
2015-06-21 08:46:29 +02:00
|
|
|
return c.getIntValue("column_family/sstables/unleveled/" + getCFName());
|
2015-06-04 12:35:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return sstable count for each level. null unless leveled compaction is
|
|
|
|
* used. array index corresponds to level(int[0] is for level 0,
|
|
|
|
* ...).
|
|
|
|
*/
|
|
|
|
public int[] getSSTableCountPerLevel() {
|
|
|
|
log(" getSSTableCountPerLevel()");
|
2015-12-03 11:15:15 +01:00
|
|
|
int[] res = c.getIntArrValue(
|
2015-07-30 10:37:03 +02:00
|
|
|
"column_family/sstables/per_level/" + getCFName());
|
2015-12-03 11:15:15 +01:00
|
|
|
if (res.length == 0) {
|
|
|
|
// no sstable count
|
|
|
|
// should return null
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
return res;
|
2015-06-04 12:35:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the ratio of droppable tombstones to real columns (and non-droppable
|
|
|
|
* tombstones)
|
2015-06-21 08:46:29 +02:00
|
|
|
*
|
2015-06-04 12:35:57 +02:00
|
|
|
* @return ratio
|
|
|
|
*/
|
|
|
|
public double getDroppableTombstoneRatio() {
|
|
|
|
log(" getDroppableTombstoneRatio()");
|
2015-06-21 08:46:29 +02:00
|
|
|
return c.getDoubleValue("column_family/droppable_ratio/" + getCFName());
|
2015-06-04 12:35:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return the size of SSTables in "snapshots" subdirectory which aren't
|
|
|
|
* live anymore
|
|
|
|
*/
|
|
|
|
public long trueSnapshotsSize() {
|
|
|
|
log(" trueSnapshotsSize()");
|
2015-12-02 11:52:24 +01:00
|
|
|
return c.getLongValue("column_family/metrics/snapshots_size/" + getCFName());
|
2015-06-04 12:35:57 +02:00
|
|
|
}
|
|
|
|
|
2015-06-24 10:15:26 +02:00
|
|
|
public String getKeyspace() {
|
|
|
|
return keyspace;
|
|
|
|
}
|
|
|
|
|
2015-07-30 11:01:05 +02:00
|
|
|
@Override
|
|
|
|
public long getRangeCount() {
|
|
|
|
log("getRangeCount()");
|
2015-10-21 11:48:28 +02:00
|
|
|
return metric.rangeLatency.latency.count();
|
2015-07-30 11:01:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public long getTotalRangeLatencyMicros() {
|
|
|
|
log("getTotalRangeLatencyMicros()");
|
2015-10-21 11:48:28 +02:00
|
|
|
return metric.rangeLatency.totalLatency.count();
|
2015-07-30 11:01:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public long[] getLifetimeRangeLatencyHistogramMicros() {
|
|
|
|
log("getLifetimeRangeLatencyHistogramMicros()");
|
2015-10-21 11:48:28 +02:00
|
|
|
return metric.rangeLatency.totalLatencyHistogram.getBuckets(false);
|
2015-07-30 11:01:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public long[] getRecentRangeLatencyHistogramMicros() {
|
|
|
|
log("getRecentRangeLatencyHistogramMicros()");
|
2015-10-21 11:48:28 +02:00
|
|
|
return metric.rangeLatency.getRecentLatencyHistogram();
|
2015-07-30 11:01:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public double getRecentRangeLatencyMicros() {
|
|
|
|
log("getRecentRangeLatencyMicros()");
|
2015-10-21 11:48:28 +02:00
|
|
|
return metric.rangeLatency.getRecentLatency();
|
2015-07-30 11:01:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void beginLocalSampling(String sampler, int capacity) {
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
log("beginLocalSampling()");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public CompositeData finishLocalSampling(String sampler, int count)
|
|
|
|
throws OpenDataException {
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
log("finishLocalSampling()");
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2015-06-04 12:35:57 +02:00
|
|
|
}
|