From 39e4cd8f3f537cb52fe57e249b48639b26279bb8 Mon Sep 17 00:00:00 2001 From: Calle Wilund Date: Wed, 17 Aug 2016 08:30:46 +0000 Subject: [PATCH] CommitLog: update to c3 compat --- .../cassandra/db/commitlog/CommitLog.java | 61 ++++++++----------- .../db/commitlog/CommitLogMBean.java | 46 ++++++-------- 2 files changed, 45 insertions(+), 62 deletions(-) diff --git a/src/main/java/org/apache/cassandra/db/commitlog/CommitLog.java b/src/main/java/org/apache/cassandra/db/commitlog/CommitLog.java index 784b8bb..e943351 100644 --- a/src/main/java/org/apache/cassandra/db/commitlog/CommitLog.java +++ b/src/main/java/org/apache/cassandra/db/commitlog/CommitLog.java @@ -22,9 +22,14 @@ */ package org.apache.cassandra.db.commitlog; -import java.io.*; +import java.io.IOException; import java.lang.management.ManagementFactory; -import java.util.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; import javax.management.MBeanServer; import javax.management.ObjectName; @@ -65,39 +70,6 @@ public class CommitLog implements CommitLogMBean { } } - /** - * Get the number of completed tasks - * - * @see org.apache.cassandra.metrics.CommitLogMetrics#completedTasks - */ - @Deprecated - public long getCompletedTasks() { - log(" getCompletedTasks()"); - return c.getLongValue(""); - } - - /** - * Get the number of tasks waiting to be executed - * - * @see org.apache.cassandra.metrics.CommitLogMetrics#pendingTasks - */ - @Deprecated - public long getPendingTasks() { - log(" getPendingTasks()"); - return c.getLongValue(""); - } - - /** - * Get the current size used by all the commitlog segments. - * - * @see org.apache.cassandra.metrics.CommitLogMetrics#totalCommitLogSize - */ - @Deprecated - public long getTotalCommitlogSize() { - log(" getTotalCommitlogSize()"); - return c.getLongValue(""); - } - /** * Recover a single file. */ @@ -170,4 +142,23 @@ public class CommitLog implements CommitLogMBean { return c.getStringValue(""); } + @Override + public long getActiveContentSize() { + // scylla does not compress commit log, so this is equivalent + return getActiveOnDiskSize(); + } + + @Override + public long getActiveOnDiskSize() { + return c.getLongValue("/commitlog/metrics/total_commit_log_size"); + } + + @Override + public Map getActiveSegmentCompressionRatios() { + HashMap res = new HashMap<>(); + for (String name : getActiveSegmentNames()) { + res.put(name, 1.0); + } + return res; + } } diff --git a/src/main/java/org/apache/cassandra/db/commitlog/CommitLogMBean.java b/src/main/java/org/apache/cassandra/db/commitlog/CommitLogMBean.java index 1ab3a91..e0cfd3c 100644 --- a/src/main/java/org/apache/cassandra/db/commitlog/CommitLogMBean.java +++ b/src/main/java/org/apache/cassandra/db/commitlog/CommitLogMBean.java @@ -17,36 +17,14 @@ */ package org.apache.cassandra.db.commitlog; + import java.io.IOException; import java.util.List; +import java.util.Map; public interface CommitLogMBean { /** - * Get the number of completed tasks - * - * @see org.apache.cassandra.metrics.CommitLogMetrics#completedTasks - */ - @Deprecated - public long getCompletedTasks(); - - /** - * Get the number of tasks waiting to be executed - * - * @see org.apache.cassandra.metrics.CommitLogMetrics#pendingTasks - */ - @Deprecated - public long getPendingTasks(); - - /** - * Get the current size used by all the commitlog segments. - * - * @see org.apache.cassandra.metrics.CommitLogMetrics#totalCommitLogSize - */ - @Deprecated - public long getTotalCommitlogSize(); - - /** - * Command to execute to archive a commitlog segment. Blank to disabled. + * Command to execute to archive a commitlog segment. Blank to disabled. */ public String getArchiveCommand(); @@ -88,8 +66,22 @@ public interface CommitLogMBean { public List getActiveSegmentNames(); /** - * @return Files which are pending for archival attempt. Does NOT include - * failed archive attempts. + * @return Files which are pending for archival attempt. Does NOT include failed archive attempts. */ public List getArchivingSegmentNames(); + + /** + * @return The size of the mutations in all active commit log segments (uncompressed). + */ + public long getActiveContentSize(); + + /** + * @return The space taken on disk by the commit log (compressed). + */ + public long getActiveOnDiskSize(); + + /** + * @return A map between active log segments and the compression ratio achieved for each. + */ + public Map getActiveSegmentCompressionRatios(); }