cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sn...@apache.org
Subject cassandra git commit: Post-fix TimeoutExceptions during unit tests
Date Tue, 03 Feb 2015 19:36:01 GMT
Repository: cassandra
Updated Branches:
  refs/heads/trunk 0cfeab60a -> 3dd1bf104


Post-fix TimeoutExceptions during unit tests

Patch by Robert Stupp; Reviewed by Joshua McKenzie for CASSANDRA-8308


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

Branch: refs/heads/trunk
Commit: 3dd1bf10441a86a620976b479a66fe428acc2d66
Parents: 0cfeab6
Author: Robert Stupp <snazy@snazy.de>
Authored: Tue Feb 3 20:34:31 2015 +0100
Committer: Robert Stupp <snazy@snazy.de>
Committed: Tue Feb 3 20:34:31 2015 +0100

----------------------------------------------------------------------
 .../db/commitlog/CommitLogSegmentManager.java   | 32 ++++++++++++++++++--
 1 file changed, 29 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/3dd1bf10/src/java/org/apache/cassandra/db/commitlog/CommitLogSegmentManager.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/commitlog/CommitLogSegmentManager.java b/src/java/org/apache/cassandra/db/commitlog/CommitLogSegmentManager.java
index 3f7e793..e184640 100644
--- a/src/java/org/apache/cassandra/db/commitlog/CommitLogSegmentManager.java
+++ b/src/java/org/apache/cassandra/db/commitlog/CommitLogSegmentManager.java
@@ -93,11 +93,16 @@ public class CommitLogSegmentManager
      */
     private volatile boolean createReserveSegments = false;
 
-    private final Thread managerThread;
+    private Thread managerThread;
     private volatile boolean run = true;
 
     public CommitLogSegmentManager()
     {
+        start();
+    }
+
+    private void start()
+    {
         // The run loop for the manager thread
         Runnable runnable = new WrappedRunnable()
         {
@@ -169,6 +174,8 @@ public class CommitLogSegmentManager
             }
         };
 
+        run = true;
+
         managerThread = new Thread(runnable, "COMMIT-LOG-ALLOCATOR");
         managerThread.start();
     }
@@ -453,9 +460,10 @@ public class CommitLogSegmentManager
 
     private long unusedCapacity()
     {
+        long total = DatabaseDescriptor.getTotalCommitlogSpaceInMB() * 1024 * 1024;
         long currentSize = size.get();
-        logger.debug("Total active commitlog segment space used is {}", currentSize);
-        return DatabaseDescriptor.getTotalCommitlogSpaceInMB() * 1024 * 1024 - currentSize;
+        logger.debug("Total active commitlog segment space used is {} out of {}", currentSize,
total);
+        return total - currentSize;
     }
 
     /**
@@ -518,6 +526,16 @@ public class CommitLogSegmentManager
         while (!segmentManagementTasks.isEmpty())
             Thread.yield();
 
+        shutdown();
+        try
+        {
+            awaitTermination();
+        }
+        catch (InterruptedException e)
+        {
+            throw new RuntimeException(e);
+        }
+
         for (CommitLogSegment segment : activeSegments)
             segment.close();
         activeSegments.clear();
@@ -527,6 +545,14 @@ public class CommitLogSegmentManager
         availableSegments.clear();
 
         allocatingFrom = null;
+
+        size.set(0L);
+
+        logger.debug("Done with closing and clearing existing commit log segments.");
+
+        start();
+
+        wakeManager();
     }
 
     /**


Mime
View raw message