/** Total number of bytes compacted since server [re]start */
public final Counter bytesCompacted;
public CompactionMetrics(final ThreadPoolExecutor... collectors)
{
pendingTasks = Metrics.newGauge(new MetricName(GROUP_NAME, TYPE_NAME, "PendingTasks"), new Gauge<Integer>()
{
public Integer value()
{
int n = 0;
for (String tableName : Schema.instance.getTables())
{
for (ColumnFamilyStore cfs : Table.open(tableName).getColumnFamilyStores())
n += cfs.getCompactionStrategy().getEstimatedRemainingTasks();
}
for (ThreadPoolExecutor collector : collectors)
n += collector.getTaskCount() - collector.getCompletedTaskCount();
return n;
}
});
completedTasks = Metrics.newGauge(new MetricName(GROUP_NAME, TYPE_NAME, "CompletedTasks"), new Gauge<Long>()
{
public Long value()
{
long completedTasks = 0;
for (ThreadPoolExecutor collector : collectors)
completedTasks += collector.getCompletedTaskCount();
return completedTasks;
}
});
totalCompactionsCompleted = Metrics.newMeter(new MetricName(GROUP_NAME, TYPE_NAME, "TotalCompactionsCompleted"), "compaction completed", TimeUnit.SECONDS);
bytesCompacted = Metrics.newCounter(new MetricName(GROUP_NAME, TYPE_NAME, "BytesCompacted"));
}