ColumnFamilyStore: update to c3 compat

Note: some calls still unimplemented
This commit is contained in:
Calle Wilund 2016-08-17 08:30:04 +00:00
parent 9a44228c71
commit 85b39d7fbe
2 changed files with 114 additions and 299 deletions

View File

@ -23,29 +23,43 @@
*/
package org.apache.cassandra.db;
import static java.lang.String.valueOf;
import static javax.json.Json.createObjectBuilder;
import static javax.json.Json.createReader;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
import java.io.StringReader;
import java.lang.management.ManagementFactory;
import java.net.ConnectException;
import java.util.*;
import java.util.concurrent.*;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.ExecutionException;
import javax.json.JsonArray;
import javax.json.JsonObject;
import javax.management.*;
import javax.json.JsonObjectBuilder;
import javax.json.JsonValue;
import javax.management.MBeanServer;
import javax.management.ObjectName;
import javax.management.openmbean.CompositeData;
import javax.management.openmbean.OpenDataException;
import javax.ws.rs.ProcessingException;
import javax.ws.rs.core.MultivaluedHashMap;
import javax.ws.rs.core.MultivaluedMap;
import org.apache.cassandra.metrics.ColumnFamilyMetrics;
import com.google.common.base.Throwables;
import com.scylladb.jmx.api.APIClient;
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();
@SuppressWarnings("unused")
private String type;
private String keyspace;
private String name;
@ -156,6 +170,7 @@ public class ColumnFamilyStore implements ColumnFamilyStoreMBean {
/**
* @return the name of the column family
*/
@Override
public String getColumnFamilyName() {
log(" getColumnFamilyName()");
return name;
@ -476,6 +491,7 @@ public class ColumnFamilyStore implements ColumnFamilyStoreMBean {
/**
* Gets the minimum number of sstables in queue before compaction kicks off
*/
@Override
public int getMinimumCompactionThreshold() {
log(" getMinimumCompactionThreshold()");
return c.getIntValue("column_family/minimum_compaction/" + getCFName());
@ -484,6 +500,7 @@ public class ColumnFamilyStore implements ColumnFamilyStoreMBean {
/**
* Sets the minimum number of sstables in queue before compaction kicks off
*/
@Override
public void setMinimumCompactionThreshold(int threshold) {
log(" setMinimumCompactionThreshold(int threshold)");
MultivaluedMap<String, String> queryParams = new MultivaluedHashMap<String, String>();
@ -494,6 +511,7 @@ public class ColumnFamilyStore implements ColumnFamilyStoreMBean {
/**
* Gets the maximum number of sstables in queue before compaction kicks off
*/
@Override
public int getMaximumCompactionThreshold() {
log(" getMaximumCompactionThreshold()");
return c.getIntValue("column_family/maximum_compaction/" + getCFName());
@ -503,6 +521,7 @@ public class ColumnFamilyStore implements ColumnFamilyStoreMBean {
* Sets the maximum and maximum number of SSTables in queue before
* compaction kicks off
*/
@Override
public void setCompactionThresholds(int minThreshold, int maxThreshold) {
log(" setCompactionThresholds(int minThreshold, int maxThreshold)");
MultivaluedMap<String, String> queryParams = new MultivaluedHashMap<String, String>();
@ -514,6 +533,7 @@ public class ColumnFamilyStore implements ColumnFamilyStoreMBean {
/**
* Sets the maximum number of sstables in queue before compaction kicks off
*/
@Override
public void setMaximumCompactionThreshold(int threshold) {
log(" setMaximumCompactionThreshold(int threshold)");
MultivaluedMap<String, String> queryParams = new MultivaluedHashMap<String, String>();
@ -546,6 +566,7 @@ public class ColumnFamilyStore implements ColumnFamilyStoreMBean {
/**
* Get the compression parameters
*/
@Override
public Map<String, String> getCompressionParameters() {
log(" getCompressionParameters()");
return c.getMapStrValue(
@ -558,6 +579,7 @@ public class ColumnFamilyStore implements ColumnFamilyStoreMBean {
* @param opts
* map of string names to values
*/
@Override
public void setCompressionParameters(Map<String, String> opts) {
log(" setCompressionParameters(Map<String,String> opts)");
MultivaluedMap<String, String> queryParams = new MultivaluedHashMap<String, String>();
@ -569,6 +591,7 @@ public class ColumnFamilyStore implements ColumnFamilyStoreMBean {
/**
* Set new crc check chance
*/
@Override
public void setCrcCheckChance(double crcCheckChance) {
log(" setCrcCheckChance(double crcCheckChance)");
MultivaluedMap<String, String> queryParams = new MultivaluedHashMap<String, String>();
@ -576,6 +599,7 @@ public class ColumnFamilyStore implements ColumnFamilyStoreMBean {
c.post("column_family/crc_check_chance/" + getCFName(), queryParams);
}
@Override
public boolean isAutoCompactionDisabled() {
log(" isAutoCompactionDisabled()");
return c.getBooleanValue("column_family/autocompaction/" + getCFName());
@ -595,6 +619,7 @@ public class ColumnFamilyStore implements ColumnFamilyStoreMBean {
return c.getDoubleValue("");
}
@Override
public long estimateKeys() {
log(" estimateKeys()");
return c.getLongValue("column_family/estimate_keys/" + getCFName());
@ -632,6 +657,7 @@ public class ColumnFamilyStore implements ColumnFamilyStoreMBean {
*
* @return list of the index names
*/
@Override
public List<String> getBuiltIndexes() {
log(" getBuiltIndexes()");
return c.getListStrValue("column_family/built_indexes/" + getCFName());
@ -643,6 +669,7 @@ public class ColumnFamilyStore implements ColumnFamilyStoreMBean {
* @param key
* @return list of filenames containing the key
*/
@Override
public List<String> getSSTablesForKey(String key) {
log(" getSSTablesForKey(String key)");
MultivaluedMap<String, String> queryParams = new MultivaluedHashMap<String, String>();
@ -655,6 +682,7 @@ public class ColumnFamilyStore implements ColumnFamilyStoreMBean {
* Scan through Keyspace/ColumnFamily's data directory determine which
* SSTables should be loaded and load them
*/
@Override
public void loadNewSSTables() {
log(" loadNewSSTables()");
c.post("column_family/sstable/" + getCFName());
@ -664,6 +692,7 @@ public class ColumnFamilyStore implements ColumnFamilyStoreMBean {
* @return the number of SSTables in L0. Always return 0 if Leveled
* compaction is not enabled.
*/
@Override
public int getUnleveledSSTables() {
log(" getUnleveledSSTables()");
return c.getIntValue("column_family/sstables/unleveled/" + getCFName());
@ -674,6 +703,7 @@ public class ColumnFamilyStore implements ColumnFamilyStoreMBean {
* used. array index corresponds to level(int[0] is for level 0,
* ...).
*/
@Override
public int[] getSSTableCountPerLevel() {
log(" getSSTableCountPerLevel()");
int[] res = c.getIntArrValue(
@ -692,6 +722,7 @@ public class ColumnFamilyStore implements ColumnFamilyStoreMBean {
*
* @return ratio
*/
@Override
public double getDroppableTombstoneRatio() {
log(" getDroppableTombstoneRatio()");
return c.getDoubleValue("column_family/droppable_ratio/" + getCFName());
@ -701,6 +732,7 @@ public class ColumnFamilyStore implements ColumnFamilyStoreMBean {
* @return the size of SSTables in "snapshots" subdirectory which aren't
* live anymore
*/
@Override
public long trueSnapshotsSize() {
log(" trueSnapshotsSize()");
return c.getLongValue("column_family/metrics/snapshots_size/" + getCFName());
@ -709,41 +741,70 @@ public class ColumnFamilyStore implements ColumnFamilyStoreMBean {
public String getKeyspace() {
return keyspace;
}
@Override
public long getRangeCount() {
log("getRangeCount()");
return metric.rangeLatency.latency.count();
public String getTableName() {
log(" getTableName()");
return name;
}
@Override
public long getTotalRangeLatencyMicros() {
log("getTotalRangeLatencyMicros()");
return metric.rangeLatency.totalLatency.count();
public void forceMajorCompaction(boolean splitOutput) throws ExecutionException, InterruptedException {
log(" forceMajorCompaction(boolean) throws ExecutionException, InterruptedException");
MultivaluedMap<String, String> queryParams = new MultivaluedHashMap<String, String>();
queryParams.putSingle("value", valueOf(splitOutput));
c.post("column_family/major_compaction/" + getCFName(), queryParams);
}
@Override
public long[] getLifetimeRangeLatencyHistogramMicros() {
log("getLifetimeRangeLatencyHistogramMicros()");
return metric.rangeLatency.totalLatencyHistogram.getBuckets(false);
public void setCompactionParametersJson(String options) {
log(" setCompactionParametersJson");
c.post("column_family/compaction_parameters/" + getCFName(), null, options, APPLICATION_JSON);
}
@Override
public long[] getRecentRangeLatencyHistogramMicros() {
log("getRecentRangeLatencyHistogramMicros()");
return metric.rangeLatency.getRecentLatencyHistogram();
public String getCompactionParametersJson() {
log(" getCompactionParametersJson");
return c.getStringValue("column_family/compaction_parameters/" + getCFName());
}
@Override
public double getRecentRangeLatencyMicros() {
log("getRecentRangeLatencyMicros()");
return metric.rangeLatency.getRecentLatency();
public void setCompactionParameters(Map<String, String> options) {
JsonObjectBuilder b = createObjectBuilder();
for (Map.Entry<String, String> e : options.entrySet()) {
b.add(e.getKey(), e.getValue());
}
setCompactionParametersJson(b.build().toString());
}
@Override
public Map<String, String> getCompactionParameters() {
String s = getCompactionParametersJson();
JsonObject o = createReader(new StringReader(s)).readObject();
HashMap<String, String> res = new HashMap<>();
for (Entry<String, JsonValue> e : o.entrySet()) {
res.put(e.getKey(), e.getValue().toString());
}
return res;
}
@Override
public boolean isCompactionDiskSpaceCheckEnabled() {
// TODO Auto-generated method stub
log(" isCompactionDiskSpaceCheckEnabled()");
return false;
}
@Override
public void compactionDiskSpaceCheck(boolean enable) {
// TODO Auto-generated method stub
log(" compactionDiskSpaceCheck()");
}
@Override
public void beginLocalSampling(String sampler, int capacity) {
// TODO Auto-generated method stub
log("beginLocalSampling()");
log(" beginLocalSampling()");
}
@ -751,8 +812,7 @@ public class ColumnFamilyStore implements ColumnFamilyStoreMBean {
public CompositeData finishLocalSampling(String sampler, int count)
throws OpenDataException {
// TODO Auto-generated method stub
log("finishLocalSampling()");
log(" finishLocalSampling()");
return null;
}
}

View File

@ -32,258 +32,17 @@ public interface ColumnFamilyStoreMBean
/**
* @return the name of the column family
*/
@Deprecated
public String getColumnFamilyName();
/**
* 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();
/**
* 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();
/**
* 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();
/**
* @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();
/**
* @see org.apache.cassandra.metrics.ColumnFamilyMetrics#sstablesPerReadHistogram
* @return a histogram of the number of sstable data files accessed per read
*/
@Deprecated
public long[] getSSTablesPerReadHistogram();
/**
* @see org.apache.cassandra.metrics.ColumnFamilyMetrics#readLatency
* @return the number of read operations on this column family
*/
@Deprecated
public long getReadCount();
/**
* @see org.apache.cassandra.metrics.ColumnFamilyMetrics#readLatency
* @return total read latency (divide by getReadCount() for average)
*/
@Deprecated
public long getTotalReadLatencyMicros();
/**
* @see org.apache.cassandra.metrics.ColumnFamilyMetrics#readLatency
* @return an array representing the latency histogram
*/
@Deprecated
public long[] getLifetimeReadLatencyHistogramMicros();
/**
* @see org.apache.cassandra.metrics.ColumnFamilyMetrics#readLatency
* @return an array representing the latency histogram
*/
@Deprecated
public long[] getRecentReadLatencyHistogramMicros();
/**
* @see org.apache.cassandra.metrics.ColumnFamilyMetrics#readLatency
* @return average latency per read operation since the last call
*/
@Deprecated
public double getRecentReadLatencyMicros();
/**
* @see org.apache.cassandra.metrics.ColumnFamilyMetrics#writeLatency
* @return the number of write operations on this column family
*/
@Deprecated
public long getWriteCount();
/**
* @see org.apache.cassandra.metrics.ColumnFamilyMetrics#writeLatency
* @return total write latency (divide by getReadCount() for average)
*/
@Deprecated
public long getTotalWriteLatencyMicros();
/**
* @see org.apache.cassandra.metrics.ColumnFamilyMetrics#writeLatency
* @return an array representing the latency histogram
*/
@Deprecated
public long[] getLifetimeWriteLatencyHistogramMicros();
/**
* @see org.apache.cassandra.metrics.ColumnFamilyMetrics#writeLatency
* @return an array representing the latency histogram
*/
@Deprecated
public long[] getRecentWriteLatencyHistogramMicros();
/**
* @see org.apache.cassandra.metrics.ColumnFamilyMetrics#writeLatency
* @return average latency per write operation since the last call
*/
@Deprecated
public double getRecentWriteLatencyMicros();
/**
* @see org.apache.cassandra.metrics.ColumnFamilyMetrics#rangeLatency
* @return the number of range slice operations on this column family
*/
@Deprecated
public long getRangeCount();
/**
* @see org.apache.cassandra.metrics.ColumnFamilyMetrics#rangeLatency
* @return total range slice latency (divide by getRangeCount() for average)
*/
@Deprecated
public long getTotalRangeLatencyMicros();
/**
* @see org.apache.cassandra.metrics.ColumnFamilyMetrics#rangeLatency
* @return an array representing the latency histogram
*/
@Deprecated
public long[] getLifetimeRangeLatencyHistogramMicros();
/**
* @see org.apache.cassandra.metrics.ColumnFamilyMetrics#rangeLatency
* @return an array representing the latency histogram
*/
@Deprecated
public long[] getRecentRangeLatencyHistogramMicros();
/**
* @see org.apache.cassandra.metrics.ColumnFamilyMetrics#rangeLatency
* @return average latency per range slice operation since the last call
*/
@Deprecated
public double getRecentRangeLatencyMicros();
/**
* @see org.apache.cassandra.metrics.ColumnFamilyMetrics#pendingFlushes
* @return the estimated number of tasks pending for this column family
*/
@Deprecated
public int getPendingTasks();
/**
* @see org.apache.cassandra.metrics.ColumnFamilyMetrics#liveSSTableCount
* @return the number of SSTables on disk for this CF
*/
@Deprecated
public int getLiveSSTableCount();
/**
* @see org.apache.cassandra.metrics.ColumnFamilyMetrics#liveDiskSpaceUsed
* @return disk space used by SSTables belonging to this CF
*/
@Deprecated
public long getLiveDiskSpaceUsed();
/**
* @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();
public String getTableName();
/**
* force a major compaction of this column family
*
* @param splitOutput true if the output of the major compaction should be split in several sstables
*/
public void forceMajorCompaction() throws ExecutionException, InterruptedException;
/**
* @see org.apache.cassandra.metrics.ColumnFamilyMetrics#minRowSize
* @return the size of the smallest compacted row
*/
@Deprecated
public long getMinRowSize();
/**
* @see org.apache.cassandra.metrics.ColumnFamilyMetrics#maxRowSize
* @return the size of the largest compacted row
*/
@Deprecated
public long getMaxRowSize();
/**
* @see org.apache.cassandra.metrics.ColumnFamilyMetrics#meanRowSize
* @return the average row size across all the sstables
*/
@Deprecated
public long getMeanRowSize();
/**
* @see org.apache.cassandra.metrics.ColumnFamilyMetrics#bloomFilterFalsePositives
*/
@Deprecated
public long getBloomFilterFalsePositives();
/**
* @see org.apache.cassandra.metrics.ColumnFamilyMetrics#recentBloomFilterFalsePositives
*/
@Deprecated
public long getRecentBloomFilterFalsePositives();
/**
* @see org.apache.cassandra.metrics.ColumnFamilyMetrics#bloomFilterFalseRatio
*/
@Deprecated
public double getBloomFilterFalseRatio();
/**
* @see org.apache.cassandra.metrics.ColumnFamilyMetrics#recentBloomFilterFalseRatio
*/
@Deprecated
public double getRecentBloomFilterFalseRatio();
/**
* @see org.apache.cassandra.metrics.ColumnFamilyMetrics#bloomFilterDiskSpaceUsed
*/
@Deprecated
public long getBloomFilterDiskSpaceUsed();
/**
* @see org.apache.cassandra.metrics.ColumnFamilyMetrics#bloomFilterOffHeapMemoryUsed
*/
@Deprecated
public long getBloomFilterOffHeapMemoryUsed();
/**
* @see org.apache.cassandra.metrics.ColumnFamilyMetrics#indexSummaryOffHeapMemoryUsed
*/
@Deprecated
public long getIndexSummaryOffHeapMemoryUsed();
/**
* @see org.apache.cassandra.metrics.ColumnFamilyMetrics#compressionMetadataOffHeapMemoryUsed
*/
@Deprecated
public long getCompressionMetadataOffHeapMemoryUsed();
public void forceMajorCompaction(boolean splitOutput) throws ExecutionException, InterruptedException;
/**
* Gets the minimum number of sstables in queue before compaction kicks off
@ -311,15 +70,24 @@ public interface ColumnFamilyStoreMBean
public void setMaximumCompactionThreshold(int threshold);
/**
* Sets the compaction strategy by class name
* @param className the name of the compaction strategy class
* Sets the compaction parameters locally for this node
*
* Note that this will be set until an ALTER with compaction = {..} is executed or the node is restarted
*
* @param options compaction options with the same syntax as when doing ALTER ... WITH compaction = {..}
*/
public void setCompactionStrategyClass(String className);
public void setCompactionParametersJson(String options);
public String getCompactionParametersJson();
/**
* Gets the compaction strategy class name
* Sets the compaction parameters locally for this node
*
* Note that this will be set until an ALTER with compaction = {..} is executed or the node is restarted
*
* @param options compaction options map
*/
public String getCompactionStrategyClass();
public void setCompactionParameters(Map<String, String> options);
public Map<String, String> getCompactionParameters();
/**
* Get the compression parameters
@ -339,31 +107,8 @@ public interface ColumnFamilyStoreMBean
public boolean isAutoCompactionDisabled();
/** Number of tombstoned cells retreived during the last slicequery */
@Deprecated
public double getTombstonesPerSlice();
/** Number of live cells retreived during the last slicequery */
@Deprecated
public double getLiveCellsPerSlice();
public long estimateKeys();
/**
* @see org.apache.cassandra.metrics.ColumnFamilyMetrics#estimatedRowSizeHistogram
*/
@Deprecated
public long[] getEstimatedRowSizeHistogram();
/**
* @see org.apache.cassandra.metrics.ColumnFamilyMetrics#estimatedColumnCountHistogram
*/
@Deprecated
public long[] getEstimatedColumnCountHistogram();
/**
* @see org.apache.cassandra.metrics.ColumnFamilyMetrics#compressionRatio
*/
@Deprecated
public double getCompressionRatio();
/**
* Returns a list of the names of the built column indexes for current store
@ -416,4 +161,14 @@ public interface ColumnFamilyStoreMBean
* @return top <i>count</i> items for the sampler since beginLocalSampling was called
*/
public CompositeData finishLocalSampling(String sampler, int count) throws OpenDataException;
/*
Is Compaction space check enabled
*/
public boolean isCompactionDiskSpaceCheckEnabled();
/*
Enable/Disable compaction space check
*/
public void compactionDiskSpaceCheck(boolean enable);
}