From 332e9c09af939a14e3690be3081e20fb11b05850 Mon Sep 17 00:00:00 2001 From: Alex Demidko Date: Wed, 23 Jul 2014 11:53:13 -0700 Subject: [PATCH] Directory name and segments information exposed via JMX --- core/src/main/scala/kafka/log/Log.scala | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/core/src/main/scala/kafka/log/Log.scala b/core/src/main/scala/kafka/log/Log.scala index 46df8d9..9097fa0 100644 --- a/core/src/main/scala/kafka/log/Log.scala +++ b/core/src/main/scala/kafka/log/Log.scala @@ -18,6 +18,7 @@ package kafka.log import java.io.{IOException, File} +import java.util import java.util.concurrent.{ConcurrentNavigableMap, ConcurrentSkipListMap} import java.util.concurrent.atomic._ import kafka.utils._ @@ -79,6 +80,12 @@ class Log(val dir: File, newGauge(name + "-" + "Size", new Gauge[Long] {def value = size}) + newGauge(name + "-" + "LogSegments", + new Gauge[util.ArrayList[String]] { def value = segmentsInfo }) + + newGauge(name + "-" + "Directory", + new Gauge[String] { def value = dir.getAbsolutePath }) + /** The name of this log */ def name = dir.getName() @@ -202,6 +209,19 @@ class Log(val dir: File, * Take care! this is an O(n) operation. */ def numberOfSegments: Int = segments.size + + /** + * Returns compiled information about segments + */ + def segmentsInfo: util.ArrayList[String] = { + val list = new util.ArrayList[String]() + logSegments.foreach( + seg => list.add("baseOffset=%s, created=%s, logSize=%s, indexSize=%s".format( + seg.baseOffset, seg.created, seg.size, seg.index.sizeInBytes() + )) + ) + list + } /** * Close this log -- 1.8.5.2 (Apple Git-48)