cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jasobr...@apache.org
Subject git commit: Create backup directories for commitlog archiving during startup
Date Tue, 14 Oct 2014 13:32:04 GMT
Repository: cassandra
Updated Branches:
  refs/heads/cassandra-2.0 7497399d0 -> d828643f5


Create backup directories for commitlog archiving during startup

patch by Jan Karlsson, reviewed by jasobrown for CASSANDRA-8111


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

Branch: refs/heads/cassandra-2.0
Commit: d828643f555aac14be59e7f8b35ac67cb06da20b
Parents: 7497399
Author: Jason Brown <jasedbrown@gmail.com>
Authored: Tue Oct 14 06:31:20 2014 -0700
Committer: Jason Brown <jasedbrown@gmail.com>
Committed: Tue Oct 14 06:31:20 2014 -0700

----------------------------------------------------------------------
 CHANGES.txt                                         |  1 +
 .../cassandra/db/commitlog/CommitLogArchiver.java   | 16 ++++++++++++++--
 2 files changed, 15 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/d828643f/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 84bbe75..2faea63 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 2.0.11:
+ * Create backup directories for commitlog archiving during startup (CASSANDRA-8111)
  * Reduce totalBlockFor() for LOCAL_* consistency levels (CASSANDRA-8058)
  * Fix merging schemas with re-dropped keyspaces (CASSANDRA-7256)
  * Fix counters in supercolumns during live upgrades from 1.2 (CASSANDRA-7188)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/d828643f/src/java/org/apache/cassandra/db/commitlog/CommitLogArchiver.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/commitlog/CommitLogArchiver.java b/src/java/org/apache/cassandra/db/commitlog/CommitLogArchiver.java
index f020182..e30443e 100644
--- a/src/java/org/apache/cassandra/db/commitlog/CommitLogArchiver.java
+++ b/src/java/org/apache/cassandra/db/commitlog/CommitLogArchiver.java
@@ -45,6 +45,7 @@ public class CommitLogArchiver
 {
     private static final Logger logger = LoggerFactory.getLogger(CommitLogArchiver.class);
     public static final SimpleDateFormat format = new SimpleDateFormat("yyyy:MM:dd HH:mm:ss");
+    private static final String DELIMITER = ",";
     static
     {
         format.setTimeZone(TimeZone.getTimeZone("GMT"));
@@ -81,6 +82,17 @@ public class CommitLogArchiver
                 archiveCommand = commitlog_commands.getProperty("archive_command");
                 restoreCommand = commitlog_commands.getProperty("restore_command");
                 restoreDirectories = commitlog_commands.getProperty("restore_directories");
+                for (String dir : restoreDirectories.split(DELIMITER))
+                {
+                    File directory = new File(dir);
+                    if (!directory.exists())
+                    {
+                        if (!directory.mkdir())
+                        {
+                            throw new RuntimeException("Unable to create directory " + dir);
+                        }
+                    }
+                }
                 String targetTime = commitlog_commands.getProperty("restore_point_in_time");
                 precision = TimeUnit.valueOf(commitlog_commands.getProperty("precision",
"MICROSECONDS"));
                 try
@@ -151,12 +163,12 @@ public class CommitLogArchiver
         if (Strings.isNullOrEmpty(restoreDirectories))
             return;
 
-        for (String dir : restoreDirectories.split(","))
+        for (String dir : restoreDirectories.split(DELIMITER))
         {
             File[] files = new File(dir).listFiles();
             if (files == null)
             {
-                throw new RuntimeException("Unable to list director " + dir);
+                throw new RuntimeException("Unable to list directory " + dir);
             }
             for (File fromFile : files)
             {


Mime
View raw message