aparna0522 commented on code in PR #4445:
URL: https://github.com/apache/cassandra/pull/4445#discussion_r2491897495


##########
src/java/org/apache/cassandra/journal/Journal.java:
##########
@@ -832,6 +832,32 @@ private void shutDown() throws InterruptedException
         }
     }
 
+    public long getDiskSpaceUsed()
+    {
+        long totalSize = 0;
+
+        try (ReferencedSegments<K, V> refs = selectAndReference(s -> true))
+        {
+            for (Segment<K, V> segment : refs.all())
+            {
+                File dataFile = segment.descriptor.fileFor(Component.DATA);
+                if (dataFile.exists())
+                    totalSize += dataFile.length();
+            }
+        }
+
+        // Add current active segment
+        ActiveSegment<K, V> active = currentSegment;

Review Comment:
   I believe you are correct... I traced through the code and I see that 
`selectAndReference(s -> true)` already includes the active segment. When a new 
active segment is created, it calls `addNewActiveSegment(currentSegment = 
availableSegment)` which is adding the active segment to the segments 
collection, Also, since I am using the predicate `s -> true` does ensure that 
activeSegment is a part of it. 
   
   Thanks for catching this!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to