cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject [7/10] git commit: avoid streaming empty files with bulk loader if sstablewriter errors out patch by yukim; reviewed by jbellis for CASSANDRA-3946
Date Tue, 17 Apr 2012 21:27:42 GMT
avoid streaming empty files with bulk loader if sstablewriter errors out
patch by yukim; reviewed by jbellis for CASSANDRA-3946


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

Branch: refs/heads/trunk
Commit: 10a64bd681c8f7e213fc74f04ac598cad2427464
Parents: 5434ac4
Author: Jonathan Ellis <jbellis@apache.org>
Authored: Tue Apr 17 16:21:50 2012 -0500
Committer: Jonathan Ellis <jbellis@apache.org>
Committed: Tue Apr 17 16:21:50 2012 -0500

----------------------------------------------------------------------
 CHANGES.txt                                        |    2 +
 .../io/sstable/AbstractSSTableSimpleWriter.java    |    2 +-
 .../io/sstable/SSTableSimpleUnsortedWriter.java    |   18 +++++++++++---
 .../cassandra/io/sstable/SSTableSimpleWriter.java  |   14 +++++++++--
 4 files changed, 28 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/10a64bd6/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index f370ebc..814fe99 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,6 @@
 1.0.10
+ * avoid streaming empty files with bulk loader if sstablewriter errors out
+   (CASSANDRA-3946)
  * support PropertyFileSnitch in bulk loader (CASSANDRA-4145)
  * add auto_snapshot option allowing disabling snapshot before drop/truncate
    (CASSANDRA-3710)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/10a64bd6/src/java/org/apache/cassandra/io/sstable/AbstractSSTableSimpleWriter.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/io/sstable/AbstractSSTableSimpleWriter.java b/src/java/org/apache/cassandra/io/sstable/AbstractSSTableSimpleWriter.java
index 163bbbd..80531e6 100644
--- a/src/java/org/apache/cassandra/io/sstable/AbstractSSTableSimpleWriter.java
+++ b/src/java/org/apache/cassandra/io/sstable/AbstractSSTableSimpleWriter.java
@@ -79,7 +79,7 @@ public abstract class AbstractSSTableSimpleWriter
         int maxGen = 0;
         for (Descriptor desc : existing)
             maxGen = Math.max(maxGen, desc.generation);
-        return new Descriptor(directory, keyspace, columnFamily, maxGen + 1, false).filenameFor(Component.DATA);
+        return new Descriptor(directory, keyspace, columnFamily, maxGen + 1, true).filenameFor(Component.DATA);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/cassandra/blob/10a64bd6/src/java/org/apache/cassandra/io/sstable/SSTableSimpleUnsortedWriter.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/io/sstable/SSTableSimpleUnsortedWriter.java b/src/java/org/apache/cassandra/io/sstable/SSTableSimpleUnsortedWriter.java
index 40e37e2..175512e 100644
--- a/src/java/org/apache/cassandra/io/sstable/SSTableSimpleUnsortedWriter.java
+++ b/src/java/org/apache/cassandra/io/sstable/SSTableSimpleUnsortedWriter.java
@@ -105,12 +105,22 @@ public class SSTableSimpleUnsortedWriter extends AbstractSSTableSimpleWriter
         if (keys.isEmpty())
             return;
 
-        SSTableWriter writer = getWriter();
-        for (Map.Entry<DecoratedKey, ColumnFamily> entry : keys.entrySet())
+        SSTableWriter writer = null;
+        try
         {
-            writer.append(entry.getKey(), entry.getValue());
+            writer = getWriter();
+            for (Map.Entry<DecoratedKey, ColumnFamily> entry : keys.entrySet())
+            {
+                writer.append(entry.getKey(), entry.getValue());
+            }
+            writer.closeAndOpenReader();
+        }
+        catch (IOException e)
+        {
+            if (writer != null)
+                writer.abort();
+            throw e;
         }
-        writer.closeAndOpenReader();
         currentSize = 0;
         keys.clear();
     }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/10a64bd6/src/java/org/apache/cassandra/io/sstable/SSTableSimpleWriter.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/io/sstable/SSTableSimpleWriter.java b/src/java/org/apache/cassandra/io/sstable/SSTableSimpleWriter.java
index 340fb4f..92a7ba9 100644
--- a/src/java/org/apache/cassandra/io/sstable/SSTableSimpleWriter.java
+++ b/src/java/org/apache/cassandra/io/sstable/SSTableSimpleWriter.java
@@ -67,9 +67,17 @@ public class SSTableSimpleWriter extends AbstractSSTableSimpleWriter
 
     public void close() throws IOException
     {
-        if (currentKey != null)
-            writeRow(currentKey, columnFamily);
-        writer.closeAndOpenReader();
+        try
+        {
+            if (currentKey != null)
+                writeRow(currentKey, columnFamily);
+            writer.closeAndOpenReader();
+        }
+        catch (IOException e)
+        {
+            writer.abort();
+            throw e;
+        }
     }
 
     protected void writeRow(DecoratedKey key, ColumnFamily columnFamily) throws IOException


Mime
View raw message