cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alek...@apache.org
Subject cassandra git commit: Expose off-heap memory usage stats
Date Thu, 27 Nov 2014 23:57:18 GMT
Repository: cassandra
Updated Branches:
  refs/heads/cassandra-2.0 8b5cf6404 -> 7a14a77f2


Expose off-heap memory usage stats

patch by Benjamin Lerer; reviewed by Aleksey Yeschenko for
CASSANDRA-7897


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/7a14a77f
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/7a14a77f
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/7a14a77f

Branch: refs/heads/cassandra-2.0
Commit: 7a14a77f2cbe2ce10ac35d5853ddf9496a86e16e
Parents: 8b5cf64
Author: blerer <b_lerer@hotmail.com>
Authored: Fri Nov 28 02:55:46 2014 +0300
Committer: Aleksey Yeschenko <aleksey@apache.org>
Committed: Fri Nov 28 02:55:46 2014 +0300

----------------------------------------------------------------------
 CHANGES.txt                                     |  1 +
 .../apache/cassandra/db/ColumnFamilyStore.java  | 15 +++++
 .../cassandra/db/ColumnFamilyStoreMBean.java    | 18 +++++
 .../io/compress/CompressionMetadata.java        |  9 +++
 .../cassandra/io/sstable/IndexSummary.java      |  9 +++
 .../cassandra/io/sstable/SSTableReader.java     | 30 +++++++++
 .../cassandra/metrics/ColumnFamilyMetrics.java  | 36 ++++++++++
 .../cassandra/metrics/KeyspaceMetrics.java      | 27 ++++++++
 .../org/apache/cassandra/tools/NodeCmd.java     | 70 +++++++++++++++-----
 .../cassandra/utils/AlwaysPresentFilter.java    |  6 ++
 .../org/apache/cassandra/utils/IFilter.java     |  6 ++
 .../cassandra/utils/Murmur3BloomFilter.java     |  6 ++
 .../org/apache/cassandra/utils/obs/IBitSet.java |  6 ++
 .../cassandra/utils/obs/OffHeapBitSet.java      |  6 ++
 .../apache/cassandra/utils/obs/OpenBitSet.java  |  6 ++
 15 files changed, 234 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/7a14a77f/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 937edbb..8f4add9 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 2.0.12:
+ * Expose off-heap memory usage stats (CASSANDRA-7897)
  * Ignore Paxos commits for truncated tables (CASSANDRA-7538)
  * Validate size of indexed column values (CASSANDRA-8280)
  * Make LCS split compaction results over all data directories (CASSANDRA-8329)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/7a14a77f/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/ColumnFamilyStore.java b/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
index 6365b4f..06520ab 100644
--- a/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
+++ b/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
@@ -2164,6 +2164,21 @@ public class ColumnFamilyStore implements ColumnFamilyStoreMBean
         return metric.bloomFilterDiskSpaceUsed.value();
     }
 
+    public long getBloomFilterOffHeapMemoryUsed()
+    {
+        return metric.bloomFilterOffHeapMemoryUsed.value();
+    }
+
+    public long getIndexSummaryOffHeapMemoryUsed()
+    {
+        return metric.indexSummaryOffHeapMemoryUsed.value();
+    }
+
+    public long getCompressionMetadataOffHeapMemoryUsed()
+    {
+        return metric.compressionMetadataOffHeapMemoryUsed.value();
+    }
+
     @Override
     public String toString()
     {

http://git-wip-us.apache.org/repos/asf/cassandra/blob/7a14a77f/src/java/org/apache/cassandra/db/ColumnFamilyStoreMBean.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/ColumnFamilyStoreMBean.java b/src/java/org/apache/cassandra/db/ColumnFamilyStoreMBean.java
index 90c9f1f..53f7ba9 100644
--- a/src/java/org/apache/cassandra/db/ColumnFamilyStoreMBean.java
+++ b/src/java/org/apache/cassandra/db/ColumnFamilyStoreMBean.java
@@ -230,6 +230,24 @@ public interface ColumnFamilyStoreMBean
     public long getBloomFilterDiskSpaceUsed();
 
     /**
+     * @see org.apache.cassandra.metrics.ColumnFamilyMetrics#bloomFilterOffHeapMemoryUsed
+     */
+    @Deprecated
+    public long getBloomFilterOffHeapMemoryUsed();
+
+    /**
+     * @see org.apache.cassandra.metrics.ColumnFamilyMetrics#indexSummaryOffHeapMemoryUsed
+     */
+    @Deprecated
+    public long getIndexSummaryOffHeapMemoryUsed();
+
+    /**
+     * @see org.apache.cassandra.metrics.ColumnFamilyMetrics#compressionMetadataOffHeapMemoryUsed
+     */
+    @Deprecated
+    public long getCompressionMetadataOffHeapMemoryUsed();
+
+    /**
      * Gets the minimum number of sstables in queue before compaction kicks off
      */
     public int getMinimumCompactionThreshold();

http://git-wip-us.apache.org/repos/asf/cassandra/blob/7a14a77f/src/java/org/apache/cassandra/io/compress/CompressionMetadata.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/io/compress/CompressionMetadata.java b/src/java/org/apache/cassandra/io/compress/CompressionMetadata.java
index e75a7d7..231778a 100644
--- a/src/java/org/apache/cassandra/io/compress/CompressionMetadata.java
+++ b/src/java/org/apache/cassandra/io/compress/CompressionMetadata.java
@@ -126,6 +126,15 @@ public class CompressionMetadata
     }
 
     /**
+     * Returns the amount of memory in bytes used off heap.
+     * @return the amount of memory in bytes used off heap
+     */
+    public long offHeapSize()
+    {
+        return chunkOffsets.size();
+    }
+
+    /**
      * Read offsets of the individual chunks from the given input.
      *
      * @param input Source of the data.

http://git-wip-us.apache.org/repos/asf/cassandra/blob/7a14a77f/src/java/org/apache/cassandra/io/sstable/IndexSummary.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/io/sstable/IndexSummary.java b/src/java/org/apache/cassandra/io/sstable/IndexSummary.java
index be7977e..b66071b 100644
--- a/src/java/org/apache/cassandra/io/sstable/IndexSummary.java
+++ b/src/java/org/apache/cassandra/io/sstable/IndexSummary.java
@@ -108,6 +108,15 @@ public class IndexSummary implements Closeable
         return summary_size;
     }
 
+    /**
+     * Returns the amount of memory in bytes used off heap.
+     * @return the amount of memory in bytes used off heap
+     */
+    public long offHeapSize()
+    {
+        return bytes.size();
+    }
+
     public static class IndexSummarySerializer
     {
         public void serialize(IndexSummary t, DataOutputStream out) throws IOException

http://git-wip-us.apache.org/repos/asf/cassandra/blob/7a14a77f/src/java/org/apache/cassandra/io/sstable/SSTableReader.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/io/sstable/SSTableReader.java b/src/java/org/apache/cassandra/io/sstable/SSTableReader.java
index 87f084c..f0e9e65 100644
--- a/src/java/org/apache/cassandra/io/sstable/SSTableReader.java
+++ b/src/java/org/apache/cassandra/io/sstable/SSTableReader.java
@@ -634,6 +634,18 @@ public class SSTableReader extends SSTable implements Closeable
     }
 
     /**
+     * Returns the amount of memory in bytes used off heap by the compression meta-data.
+     * @return the amount of memory in bytes used off heap by the compression meta-data
+     */
+    public long getCompressionMetadataOffHeapSize()
+    {
+        if (!compression)
+            return 0;
+
+        return getCompressionMetadata().offHeapSize();
+    }
+
+    /**
      * For testing purposes only.
      */
     public void forceFilterFailures()
@@ -652,6 +664,24 @@ public class SSTableReader extends SSTable implements Closeable
     }
 
     /**
+     * Returns the amount of memory in bytes used off heap by the bloom filter.
+     * @return the amount of memory in bytes used off heap by the bloom filter
+     */
+    public long getBloomFilterOffHeapSize()
+    {
+        return bf.offHeapSize();
+    }
+
+    /**
+     * Returns the amount of memory in bytes used off heap by the index summary.
+     * @return the amount of memory in bytes used off heap by the index summary
+     */
+    public long getIndexSummaryOffHeapSize()
+    {
+        return indexSummary.offHeapSize();
+    }
+
+    /**
      * @return An estimate of the number of keys in this SSTable.
      */
     public long estimatedKeys()

http://git-wip-us.apache.org/repos/asf/cassandra/blob/7a14a77f/src/java/org/apache/cassandra/metrics/ColumnFamilyMetrics.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/metrics/ColumnFamilyMetrics.java b/src/java/org/apache/cassandra/metrics/ColumnFamilyMetrics.java
index c2b7d61..4dbc0f8 100644
--- a/src/java/org/apache/cassandra/metrics/ColumnFamilyMetrics.java
+++ b/src/java/org/apache/cassandra/metrics/ColumnFamilyMetrics.java
@@ -87,6 +87,12 @@ public class ColumnFamilyMetrics
     public final Gauge<Double> recentBloomFilterFalseRatio;
     /** Disk space used by bloom filter */
     public final Gauge<Long> bloomFilterDiskSpaceUsed;
+    /** Off heap memory used by bloom filter */
+    public final Gauge<Long> bloomFilterOffHeapMemoryUsed;
+    /** Off heap memory used by index summary */
+    public final Gauge<Long> indexSummaryOffHeapMemoryUsed;
+    /** Off heap memory used by compression meta data*/
+    public final Gauge<Long> compressionMetadataOffHeapMemoryUsed;
     /** Key cache hit rate  for this CF */
     public final Gauge<Double> keyCacheHitRate;
     /** Tombstones scanned in queries on this CF */
@@ -429,6 +435,36 @@ public class ColumnFamilyMetrics
                 return total;
             }
         });
+        bloomFilterOffHeapMemoryUsed = createColumnFamilyGauge("BloomFilterOffHeapMemoryUsed",
new Gauge<Long>()
+        {
+            public Long value()
+            {
+                long total = 0;
+                for (SSTableReader sst : cfs.getSSTables())
+                    total += sst.getBloomFilterOffHeapSize();
+                return total;
+            }
+        });
+        indexSummaryOffHeapMemoryUsed = createColumnFamilyGauge("IndexSummaryOffHeapMemoryUsed",
new Gauge<Long>()
+        {
+            public Long value()
+            {
+                long total = 0;
+                for (SSTableReader sst : cfs.getSSTables())
+                    total += sst.getIndexSummaryOffHeapSize();
+                return total;
+            }
+        });
+        compressionMetadataOffHeapMemoryUsed = createColumnFamilyGauge("CompressionMetadataOffHeapMemoryUsed",
new Gauge<Long>()
+        {
+            public Long value()
+            {
+                long total = 0;
+                for (SSTableReader sst : cfs.getSSTables())
+                    total += sst.getCompressionMetadataOffHeapSize();
+                return total;
+            }
+        });
         speculativeRetries = createColumnFamilyCounter("SpeculativeRetries");
         keyCacheHitRate = Metrics.newGauge(factory.createMetricName("KeyCacheHitRate"), new
RatioGauge()
         {

http://git-wip-us.apache.org/repos/asf/cassandra/blob/7a14a77f/src/java/org/apache/cassandra/metrics/KeyspaceMetrics.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/metrics/KeyspaceMetrics.java b/src/java/org/apache/cassandra/metrics/KeyspaceMetrics.java
index 0ea982e..fd89983 100644
--- a/src/java/org/apache/cassandra/metrics/KeyspaceMetrics.java
+++ b/src/java/org/apache/cassandra/metrics/KeyspaceMetrics.java
@@ -50,6 +50,12 @@ public class KeyspaceMetrics
     public final Gauge<Long> totalDiskSpaceUsed;
     /** Disk space used by bloom filter */
     public final Gauge<Long> bloomFilterDiskSpaceUsed;
+    /** Off heap memory used by bloom filter */
+    public final Gauge<Long> bloomFilterOffHeapMemoryUsed;
+    /** Off heap memory used by index summary */
+    public final Gauge<Long> indexSummaryOffHeapMemoryUsed;
+    /** Off heap memory used by compression meta data*/
+    public final Gauge<Long> compressionMetadataOffHeapMemoryUsed;
     /** (Local) read metrics */
     public final LatencyMetrics readLatency;
     /** (Local) range slice metrics */
@@ -149,6 +155,27 @@ public class KeyspaceMetrics
                 return metric.bloomFilterDiskSpaceUsed.value();
             }
         });
+        bloomFilterOffHeapMemoryUsed = createKeyspaceGauge("BloomFilterOffHeapMemoryUsed",
new MetricValue()
+        {
+            public Long getValue(ColumnFamilyMetrics metric)
+            {
+                return metric.bloomFilterOffHeapMemoryUsed.value();
+            }
+        });
+        indexSummaryOffHeapMemoryUsed = createKeyspaceGauge("IndexSummaryOffHeapMemoryUsed",
new MetricValue()
+        {
+            public Long getValue(ColumnFamilyMetrics metric)
+            {
+                return metric.indexSummaryOffHeapMemoryUsed.value();
+            }
+        });
+        compressionMetadataOffHeapMemoryUsed = createKeyspaceGauge("CompressionMetadataOffHeapMemoryUsed",
new MetricValue()
+        {
+            public Long getValue(ColumnFamilyMetrics metric)
+            {
+                return metric.compressionMetadataOffHeapMemoryUsed.value();
+            }
+        });
         // latency metrics for ColumnFamilyMetrics to update
         readLatency = new LatencyMetrics(factory, "Read");
         writeLatency = new LatencyMetrics(factory, "Write");

http://git-wip-us.apache.org/repos/asf/cassandra/blob/7a14a77f/src/java/org/apache/cassandra/tools/NodeCmd.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/tools/NodeCmd.java b/src/java/org/apache/cassandra/tools/NodeCmd.java
index 2d7809a..e4a14b2 100644
--- a/src/java/org/apache/cassandra/tools/NodeCmd.java
+++ b/src/java/org/apache/cassandra/tools/NodeCmd.java
@@ -635,41 +635,44 @@ public class NodeCmd
         // If there is just 1 token, print it now like we always have, otherwise,
         // require that -T/--tokens be passed (that output is potentially verbose).
         if (toks.size() == 1)
-            outs.printf("%-17s: %s%n", "Token", toks.get(0));
+            outs.printf("%-23s: %s%n", "Token", toks.get(0));
         else if (!cmd.hasOption(TOKENS_OPT.left))
-            outs.printf("%-17s: (invoke with -T/--tokens to see all %d tokens)%n", "Token",
toks.size());
+            outs.printf("%-23s: (invoke with -T/--tokens to see all %d tokens)%n", "Token",
toks.size());
 
-        outs.printf("%-17s: %s%n", "ID", probe.getLocalHostId());
-        outs.printf("%-17s: %s%n", "Gossip active", gossipInitialized);
-        outs.printf("%-17s: %s%n", "Thrift active", probe.isThriftServerRunning());
-        outs.printf("%-17s: %s%n", "Native Transport active", probe.isNativeTransportRunning());
-        outs.printf("%-17s: %s%n", "Load", probe.getLoadString());
+        outs.printf("%-23s: %s%n", "ID", probe.getLocalHostId());
+        outs.printf("%-23s: %s%n", "Gossip active", gossipInitialized);
+        outs.printf("%-23s: %s%n", "Thrift active", probe.isThriftServerRunning());
+        outs.printf("%-23s: %s%n", "Native Transport active", probe.isNativeTransportRunning());
+        outs.printf("%-23s: %s%n", "Load", probe.getLoadString());
         if (gossipInitialized)
-            outs.printf("%-17s: %s%n", "Generation No", probe.getCurrentGenerationNumber());
+            outs.printf("%-23s: %s%n", "Generation No", probe.getCurrentGenerationNumber());
         else
-            outs.printf("%-17s: %s%n", "Generation No", 0);
+            outs.printf("%-23s: %s%n", "Generation No", 0);
 
         // Uptime
         long secondsUp = probe.getUptime() / 1000;
-        outs.printf("%-17s: %d%n", "Uptime (seconds)", secondsUp);
+        outs.printf("%-23s: %d%n", "Uptime (seconds)", secondsUp);
 
         // Memory usage
         MemoryUsage heapUsage = probe.getHeapMemoryUsage();
         double memUsed = (double)heapUsage.getUsed() / (1024 * 1024);
         double memMax = (double)heapUsage.getMax() / (1024 * 1024);
-        outs.printf("%-17s: %.2f / %.2f%n", "Heap Memory (MB)", memUsed, memMax);
+        outs.printf("%-23s: %.2f / %.2f%n", "Heap Memory (MB)", memUsed, memMax);
+
+        // Off heap memory usage
+        outs.printf("%-23s: %.2f%n", "Off Heap Memory (MB)", getOffHeapMemoryUsed());
 
         // Data Center/Rack
-        outs.printf("%-17s: %s%n", "Data Center", probe.getDataCenter());
-        outs.printf("%-17s: %s%n", "Rack", probe.getRack());
+        outs.printf("%-23s: %s%n", "Data Center", probe.getDataCenter());
+        outs.printf("%-23s: %s%n", "Rack", probe.getRack());
 
         // Exceptions
-        outs.printf("%-17s: %s%n", "Exceptions", probe.getExceptionCount());
+        outs.printf("%-23s: %s%n", "Exceptions", probe.getExceptionCount());
 
         CacheServiceMBean cacheService = probe.getCacheServiceMBean();
 
         // Key Cache: Hits, Requests, RecentHitRate, SavePeriodInSeconds
-        outs.printf("%-17s: size %d (bytes), capacity %d (bytes), %d hits, %d requests, %.3f
recent hit rate, %d save period in seconds%n",
+        outs.printf("%-23s: size %d (bytes), capacity %d (bytes), %d hits, %d requests, %.3f
recent hit rate, %d save period in seconds%n",
                     "Key Cache",
                     cacheService.getKeyCacheSize(),
                     cacheService.getKeyCacheCapacityInBytes(),
@@ -679,7 +682,7 @@ public class NodeCmd
                     cacheService.getKeyCacheSavePeriodInSeconds());
 
         // Row Cache: Hits, Requests, RecentHitRate, SavePeriodInSeconds
-        outs.printf("%-17s: size %d (bytes), capacity %d (bytes), %d hits, %d requests, %.3f
recent hit rate, %d save period in seconds%n",
+        outs.printf("%-23s: size %d (bytes), capacity %d (bytes), %d hits, %d requests, %.3f
recent hit rate, %d save period in seconds%n",
                     "Row Cache",
                     cacheService.getRowCacheSize(),
                     cacheService.getRowCacheCapacityInBytes(),
@@ -691,8 +694,30 @@ public class NodeCmd
         if (toks.size() > 1 && cmd.hasOption(TOKENS_OPT.left))
         {
             for (String tok : toks)
-                outs.printf("%-17s: %s%n", "Token", tok);
+                outs.printf("%-23s: %s%n", "Token", tok);
+        }
+    }
+
+    /**
+     * Returns the total off heap memory used in MB.
+     * @return the total off heap memory used in MB.
+     */
+    private double getOffHeapMemoryUsed()
+    {
+        long offHeapMemUsedInBytes = 0;
+        // get a list of column family stores
+        Iterator<Map.Entry<String, ColumnFamilyStoreMBean>> cfamilies = probe.getColumnFamilyStoreMBeanProxies();
+
+        while (cfamilies.hasNext())
+        {
+            Entry<String, ColumnFamilyStoreMBean> entry = cfamilies.next();
+            ColumnFamilyStoreMBean cfsProxy = entry.getValue();
+            offHeapMemUsedInBytes += cfsProxy.getBloomFilterOffHeapMemoryUsed();
+            offHeapMemUsedInBytes += cfsProxy.getIndexSummaryOffHeapMemoryUsed();
+            offHeapMemUsedInBytes += cfsProxy.getCompressionMetadataOffHeapMemoryUsed();
         }
+
+        return offHeapMemUsedInBytes / (1024d * 1024);
     }
 
     public void printReleaseVersion(PrintStream outs)
@@ -948,8 +973,16 @@ public class NodeCmd
                             outs.println("]");
                     }
                 }
+
+                long bloomFilterOffHeapSize = cfstore.getBloomFilterOffHeapMemoryUsed();
+                long indexSummaryOffHeapSize = cfstore.getIndexSummaryOffHeapMemoryUsed();
+                long compressionMetadataOffHeapSize = cfstore.getCompressionMetadataOffHeapMemoryUsed();
+
+                long offHeapSize = bloomFilterOffHeapSize + indexSummaryOffHeapSize + compressionMetadataOffHeapSize;
+
                 outs.println("\t\tSpace used (live), bytes: " + cfstore.getLiveDiskSpaceUsed());
                 outs.println("\t\tSpace used (total), bytes: " + cfstore.getTotalDiskSpaceUsed());
+                outs.println("\t\tOff heap memory used (total), bytes: " + offHeapSize);
                 outs.println("\t\tSSTable Compression Ratio: " + cfstore.getCompressionRatio());
                 outs.println("\t\tNumber of keys (estimate): " + cfstore.estimateKeys());
                 outs.println("\t\tMemtable cell count: " + cfstore.getMemtableColumnsCount());
@@ -963,6 +996,9 @@ public class NodeCmd
                 outs.println("\t\tBloom filter false positives: " + cfstore.getBloomFilterFalsePositives());
                 outs.println("\t\tBloom filter false ratio: " + String.format("%01.5f", cfstore.getRecentBloomFilterFalseRatio()));
                 outs.println("\t\tBloom filter space used, bytes: " + cfstore.getBloomFilterDiskSpaceUsed());
+                outs.println("\t\tBloom filter off heap memory used, bytes: " + bloomFilterOffHeapSize);
+                outs.println("\t\tIndex summary off heap memory used, bytes: " + indexSummaryOffHeapSize);
+                outs.println("\t\tCompression metadata off heap memory used, bytes: " + compressionMetadataOffHeapSize);
                 outs.println("\t\tCompacted partition minimum bytes: " + cfstore.getMinRowSize());
                 outs.println("\t\tCompacted partition maximum bytes: " + cfstore.getMaxRowSize());
                 outs.println("\t\tCompacted partition mean bytes: " + cfstore.getMeanRowSize());

http://git-wip-us.apache.org/repos/asf/cassandra/blob/7a14a77f/src/java/org/apache/cassandra/utils/AlwaysPresentFilter.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/utils/AlwaysPresentFilter.java b/src/java/org/apache/cassandra/utils/AlwaysPresentFilter.java
index 0f5136b..0886edc 100644
--- a/src/java/org/apache/cassandra/utils/AlwaysPresentFilter.java
+++ b/src/java/org/apache/cassandra/utils/AlwaysPresentFilter.java
@@ -34,4 +34,10 @@ public class AlwaysPresentFilter implements IFilter
     public void close() throws IOException { }
 
     public long serializedSize() { return 0; }
+
+    @Override
+    public long offHeapSize()
+    {
+        return 0;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/7a14a77f/src/java/org/apache/cassandra/utils/IFilter.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/utils/IFilter.java b/src/java/org/apache/cassandra/utils/IFilter.java
index 10f6df2..aed5f39 100644
--- a/src/java/org/apache/cassandra/utils/IFilter.java
+++ b/src/java/org/apache/cassandra/utils/IFilter.java
@@ -29,4 +29,10 @@ public interface IFilter extends Closeable
     void clear();
 
     long serializedSize();
+
+    /**
+     * Returns the amount of memory in bytes used off heap.
+     * @return the amount of memory in bytes used off heap
+     */
+    long offHeapSize();
 }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/7a14a77f/src/java/org/apache/cassandra/utils/Murmur3BloomFilter.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/utils/Murmur3BloomFilter.java b/src/java/org/apache/cassandra/utils/Murmur3BloomFilter.java
index 3c2a47e..f7c7632 100644
--- a/src/java/org/apache/cassandra/utils/Murmur3BloomFilter.java
+++ b/src/java/org/apache/cassandra/utils/Murmur3BloomFilter.java
@@ -36,6 +36,12 @@ public class Murmur3BloomFilter extends BloomFilter
         return serializer.serializedSize(this, TypeSizes.NATIVE);
     }
 
+    @Override
+    public long offHeapSize()
+    {
+        return bitset.offHeapSize();
+    }
+
     protected void hash(ByteBuffer b, int position, int remaining, long seed, long[] result)
     {
         MurmurHash.hash3_x64_128(b, b.position(), b.remaining(), seed, result);

http://git-wip-us.apache.org/repos/asf/cassandra/blob/7a14a77f/src/java/org/apache/cassandra/utils/obs/IBitSet.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/utils/obs/IBitSet.java b/src/java/org/apache/cassandra/utils/obs/IBitSet.java
index c6fbddd..47ba492 100644
--- a/src/java/org/apache/cassandra/utils/obs/IBitSet.java
+++ b/src/java/org/apache/cassandra/utils/obs/IBitSet.java
@@ -49,4 +49,10 @@ public interface IBitSet extends Closeable
     public long serializedSize(TypeSizes type);
 
     public void clear();
+
+    /**
+     * Returns the amount of memory in bytes used off heap.
+     * @return the amount of memory in bytes used off heap
+     */
+    public long offHeapSize();
 }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/7a14a77f/src/java/org/apache/cassandra/utils/obs/OffHeapBitSet.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/utils/obs/OffHeapBitSet.java b/src/java/org/apache/cassandra/utils/obs/OffHeapBitSet.java
index 29dd848..5063d80 100644
--- a/src/java/org/apache/cassandra/utils/obs/OffHeapBitSet.java
+++ b/src/java/org/apache/cassandra/utils/obs/OffHeapBitSet.java
@@ -62,6 +62,12 @@ public class OffHeapBitSet implements IBitSet
         return bytes.size() * 8;
     }
 
+    @Override
+    public long offHeapSize()
+    {
+        return bytes.size();
+    }
+
     public boolean get(long index)
     {
         long i = index >> 3;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/7a14a77f/src/java/org/apache/cassandra/utils/obs/OpenBitSet.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/utils/obs/OpenBitSet.java b/src/java/org/apache/cassandra/utils/obs/OpenBitSet.java
index b5310fa..3e1efce 100644
--- a/src/java/org/apache/cassandra/utils/obs/OpenBitSet.java
+++ b/src/java/org/apache/cassandra/utils/obs/OpenBitSet.java
@@ -104,6 +104,12 @@ public class OpenBitSet implements IBitSet
   /** Returns the current capacity in bits (1 greater than the index of the last bit) */
   public long capacity() { return ((long)wlen) << 6; }
 
+  @Override
+  public long offHeapSize()
+  {
+      return 0;
+  }
+
  /**
   * Returns the current capacity of this set.  Included for
   * compatibility.  This is *not* equal to {@link #cardinality}


Mime
View raw message