Search in sources :

Example 6 with RestorableMeter

use of org.apache.cassandra.metrics.RestorableMeter in project cassandra by apache.

the class SystemKeyspace method getSSTableReadMeter.

/**
     * Returns a RestorableMeter tracking the average read rate of a particular SSTable, restoring the last-seen rate
     * from values in system.sstable_activity if present.
     * @param keyspace the keyspace the sstable belongs to
     * @param table the table the sstable belongs to
     * @param generation the generation number for the sstable
     */
public static RestorableMeter getSSTableReadMeter(String keyspace, String table, int generation) {
    String cql = "SELECT * FROM system.%s WHERE keyspace_name=? and columnfamily_name=? and generation=?";
    UntypedResultSet results = executeInternal(format(cql, SSTABLE_ACTIVITY), keyspace, table, generation);
    if (results.isEmpty())
        return new RestorableMeter();
    UntypedResultSet.Row row = results.one();
    double m15rate = row.getDouble("rate_15m");
    double m120rate = row.getDouble("rate_120m");
    return new RestorableMeter(m15rate, m120rate);
}
Also used : UntypedResultSet(org.apache.cassandra.cql3.UntypedResultSet) RestorableMeter(org.apache.cassandra.metrics.RestorableMeter)

Aggregations

RestorableMeter (org.apache.cassandra.metrics.RestorableMeter)6 ColumnFamilyStore (org.apache.cassandra.db.ColumnFamilyStore)5 Keyspace (org.apache.cassandra.db.Keyspace)5 SSTableReader (org.apache.cassandra.io.sstable.format.SSTableReader)5 Test (org.junit.Test)5 LifecycleTransaction (org.apache.cassandra.db.lifecycle.LifecycleTransaction)4 IOException (java.io.IOException)1 ByteBuffer (java.nio.ByteBuffer)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 UntypedResultSet (org.apache.cassandra.cql3.UntypedResultSet)1 RowUpdateBuilder (org.apache.cassandra.db.RowUpdateBuilder)1 CompactionInterruptedException (org.apache.cassandra.db.compaction.CompactionInterruptedException)1