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;
}
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());
}
Aggregations