Search in sources :

Example 1 with BatchMetrics

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

the class BatchMetricsTable method data.

@Override
public DataSet data() {
    SimpleDataSet result = new SimpleDataSet(metadata());
    BatchMetrics metrics = BatchStatement.metrics;
    addRow(result, PARTITIONS_PER_LOGGED_BATCH, metrics.partitionsPerLoggedBatch.getSnapshot());
    addRow(result, PARTITIONS_PER_UNLOGGED_BATCH, metrics.partitionsPerUnloggedBatch.getSnapshot());
    addRow(result, PARTITIONS_PER_COUNTER_BATCH, metrics.partitionsPerCounterBatch.getSnapshot());
    return result;
}
Also used : BatchMetrics(org.apache.cassandra.metrics.BatchMetrics)

Example 2 with BatchMetrics

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

the class BatchMetricsTableTest method testSelectAll.

@Test
public void testSelectAll() throws Throwable {
    BatchMetrics metrics = BatchStatement.metrics;
    for (int i = 0; i < 10; i++) {
        metrics.partitionsPerLoggedBatch.update(i);
        metrics.partitionsPerUnloggedBatch.update(i + 10);
        metrics.partitionsPerCounterBatch.update(i * 10);
    }
    ResultSet result = executeNet(format("SELECT * FROM %s.batch_metrics", KS_NAME));
    assertEquals(5, result.getColumnDefinitions().size());
    AtomicInteger rowCount = new AtomicInteger(0);
    result.forEach(r -> {
        Snapshot snapshot = getExpectedHistogram(metrics, r.getString("name")).getSnapshot();
        assertEquals(snapshot.getMedian(), r.getDouble("p50th"), 0.0);
        assertEquals(snapshot.get99thPercentile(), r.getDouble("p99th"), 0.0);
        rowCount.addAndGet(1);
    });
    assertEquals(3, rowCount.get());
}
Also used : Snapshot(com.codahale.metrics.Snapshot) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) BatchMetrics(org.apache.cassandra.metrics.BatchMetrics) ResultSet(com.datastax.driver.core.ResultSet) Test(org.junit.Test)

Aggregations

BatchMetrics (org.apache.cassandra.metrics.BatchMetrics)2 Snapshot (com.codahale.metrics.Snapshot)1 ResultSet (com.datastax.driver.core.ResultSet)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 Test (org.junit.Test)1