Return-Path: X-Original-To: apmail-cassandra-commits-archive@www.apache.org Delivered-To: apmail-cassandra-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 5204C175A3 for ; Tue, 14 Oct 2014 13:32:05 +0000 (UTC) Received: (qmail 75193 invoked by uid 500); 14 Oct 2014 13:32:05 -0000 Delivered-To: apmail-cassandra-commits-archive@cassandra.apache.org Received: (qmail 75155 invoked by uid 500); 14 Oct 2014 13:32:05 -0000 Mailing-List: contact commits-help@cassandra.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cassandra.apache.org Delivered-To: mailing list commits@cassandra.apache.org Received: (qmail 75143 invoked by uid 99); 14 Oct 2014 13:32:04 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 14 Oct 2014 13:32:04 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 954BD92D561; Tue, 14 Oct 2014 13:32:04 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: jasobrown@apache.org To: commits@cassandra.apache.org Message-Id: <2a715f7d6d2d4c529a5e9988c5ffe724@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: git commit: Create backup directories for commitlog archiving during startup Date: Tue, 14 Oct 2014 13:32:04 +0000 (UTC) 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 Authored: Tue Oct 14 06:31:20 2014 -0700 Committer: Jason Brown 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) {