cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dbros...@apache.org
Subject git commit: have BulkLoader ignore snapshot directories patch by jaymé reviewed by dbrosius for cassandra-5587
Date Sun, 02 Jun 2013 03:45:08 GMT
Updated Branches:
  refs/heads/cassandra-1.2 452b1bef5 -> c0c149266


have BulkLoader ignore snapshot directories
patch by jaymé reviewed by dbrosius for cassandra-5587


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

Branch: refs/heads/cassandra-1.2
Commit: c0c1492666e44612ec4f3ca5b47ffcd68e85e210
Parents: 452b1be
Author: Dave Brosius <dbrosius@apache.org>
Authored: Sat Jun 1 23:42:49 2013 -0400
Committer: Dave Brosius <dbrosius@apache.org>
Committed: Sat Jun 1 23:42:49 2013 -0400

----------------------------------------------------------------------
 CHANGES.txt                                        |    1 +
 .../org/apache/cassandra/io/sstable/SSTable.java   |   11 ++++++++++-
 .../apache/cassandra/io/sstable/SSTableLoader.java |    2 ++
 .../cassandra/io/sstable/DescriptorTest.java       |    8 ++++++++
 4 files changed, 21 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/c0c14926/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index a746c09..83bbc04 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -13,6 +13,7 @@
  * Reuse prepared statements in hot auth queries (CASSANDRA-5594)
  * cqlsh: add vertical output option (see EXPAND) (CASSANDRA-5597)
  * Add a rate limit option to stress (CASSANDRA-5004)
+ * have BulkLoader ignore snapshots directories (CASSANDRA-5587) 
 Merged from 1.1:
  * Remove buggy thrift max message length option (CASSANDRA-5529)
  * Fix NPE in Pig's widerow mode (CASSANDRA-5488)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/c0c14926/src/java/org/apache/cassandra/io/sstable/SSTable.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/io/sstable/SSTable.java b/src/java/org/apache/cassandra/io/sstable/SSTable.java
index c7486ba..47b2612 100644
--- a/src/java/org/apache/cassandra/io/sstable/SSTable.java
+++ b/src/java/org/apache/cassandra/io/sstable/SSTable.java
@@ -191,7 +191,16 @@ public abstract class SSTable
      */
     public static Pair<Descriptor,Component> tryComponentFromFilename(File dir, String
name)
     {
-        return Component.fromFilename(dir, name);
+        try
+        {
+            return Component.fromFilename(dir, name);
+        }
+        catch (NoSuchElementException e)
+        {
+            // A NoSuchElementException is thrown if the name does not match the Descriptor
format
+            // This is the less impacting change (all calls to this method test for null
return)
+            return null;
+        }
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/cassandra/blob/c0c14926/src/java/org/apache/cassandra/io/sstable/SSTableLoader.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/io/sstable/SSTableLoader.java b/src/java/org/apache/cassandra/io/sstable/SSTableLoader.java
index 67c6a02..68bb423 100644
--- a/src/java/org/apache/cassandra/io/sstable/SSTableLoader.java
+++ b/src/java/org/apache/cassandra/io/sstable/SSTableLoader.java
@@ -68,6 +68,8 @@ public class SSTableLoader
         {
             public boolean accept(File dir, String name)
             {
+                if (new File(dir, name).isDirectory())
+                    return false;
                 Pair<Descriptor, Component> p = SSTable.tryComponentFromFilename(dir,
name);
                 Descriptor desc = p == null ? null : p.left;
                 if (p == null || !p.right.equals(Component.DATA) || desc.temporary)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/c0c14926/test/unit/org/apache/cassandra/io/sstable/DescriptorTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/io/sstable/DescriptorTest.java b/test/unit/org/apache/cassandra/io/sstable/DescriptorTest.java
index 007e0ca..9d31d7e 100644
--- a/test/unit/org/apache/cassandra/io/sstable/DescriptorTest.java
+++ b/test/unit/org/apache/cassandra/io/sstable/DescriptorTest.java
@@ -21,6 +21,7 @@ package org.apache.cassandra.io.sstable;
  */
 
 import org.apache.cassandra.utils.FilterFactory;
+import org.apache.cassandra.utils.Pair;
 import org.junit.Test;
 import static org.junit.Assert.*;
 
@@ -64,4 +65,11 @@ public class DescriptorTest
         assertEquals("ia", desc.version.toString());
         assertEquals(desc.version.filterType, FilterFactory.Type.MURMUR3);
     }
+
+    @Test
+    public void testInvalidnameFormat()
+    {
+        Pair<Descriptor, Component> p = SSTable.tryComponentFromFilename(null, "snapshot");
+        assertNull(p);
+    }
 }


Mime
View raw message