cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r923416 - in /cassandra/trunk: src/java/org/apache/cassandra/db/ src/java/org/apache/cassandra/io/sstable/ src/java/org/apache/cassandra/service/ test/unit/org/apache/cassandra/io/sstable/
Date Mon, 15 Mar 2010 20:11:15 GMT
Author: jbellis
Date: Mon Mar 15 20:11:15 2010
New Revision: 923416

URL: http://svn.apache.org/viewvc?rev=923416&view=rev
Log:
make Table.open throw IOError instead of IOException.  patch by Rodrigo Peinado; reviewed
by jbellis for CASSANDRA-756

Modified:
    cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
    cassandra/trunk/src/java/org/apache/cassandra/db/Table.java
    cassandra/trunk/src/java/org/apache/cassandra/io/sstable/SSTable.java
    cassandra/trunk/src/java/org/apache/cassandra/service/AntiEntropyService.java
    cassandra/trunk/src/java/org/apache/cassandra/service/StorageService.java
    cassandra/trunk/test/unit/org/apache/cassandra/io/sstable/SSTableUtils.java

Modified: cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java?rev=923416&r1=923415&r2=923416&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java Mon Mar 15 20:11:15
2010
@@ -20,6 +20,7 @@ package org.apache.cassandra.db;
 
 import java.io.Closeable;
 import java.io.File;
+import java.io.IOError;
 import java.io.IOException;
 import java.lang.management.ManagementFactory;
 import java.util.*;
@@ -32,8 +33,6 @@ import java.util.regex.Pattern;
 import javax.management.MBeanServer;
 import javax.management.ObjectName;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 import org.apache.commons.collections.IteratorUtils;
 
 import com.google.common.base.Predicate;
@@ -50,7 +49,6 @@ import org.apache.cassandra.dht.Abstract
 import org.apache.cassandra.dht.Bounds;
 import org.apache.cassandra.dht.Range;
 import org.apache.cassandra.dht.Token;
-import org.apache.cassandra.io.*;
 import org.apache.cassandra.io.sstable.SSTable;
 import org.apache.cassandra.io.sstable.SSTableReader;
 import org.apache.cassandra.io.sstable.SSTableScanner;
@@ -59,6 +57,8 @@ import org.apache.cassandra.io.util.File
 import org.apache.cassandra.service.StorageService;
 import org.apache.cassandra.thrift.SliceRange;
 import org.apache.cassandra.utils.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class ColumnFamilyStore implements ColumnFamilyStoreMBean
 {
@@ -125,7 +125,7 @@ public class ColumnFamilyStore implement
     private long rowsCompactedTotalSize = 0L;
     private long rowsCompactedCount = 0L;
     
-    ColumnFamilyStore(String table, String columnFamilyName, boolean isSuper, int indexValue)
throws IOException
+    ColumnFamilyStore(String table, String columnFamilyName, boolean isSuper, int indexValue)
     {
         table_ = table;
         columnFamily_ = columnFamilyName;
@@ -151,14 +151,28 @@ public class ColumnFamilyStore implement
                 if (!new File(basePath + "-Data.db").exists())
                 {
                     logger_.info(String.format("Removing orphan %s", file.getAbsolutePath()));
-                    FileUtils.deleteWithConfirm(file);
+                    try
+                    {
+                        FileUtils.deleteWithConfirm(file);
+                    }
+                    catch (IOException e)
+                    {
+                        throw new IOError(e);
+                    }
                     continue;
                 }
             }
 
             if (((file.length() == 0 && !filename.endsWith("-Compacted")) || (filename.contains("-"
+ SSTable.TEMPFILE_MARKER))))
             {
-                FileUtils.deleteWithConfirm(file);
+                try
+                {
+                    FileUtils.deleteWithConfirm(file);
+                }
+                catch (IOException e)
+                {
+                    throw new IOError(e);
+                }
                 continue;
             }
 
@@ -221,7 +235,7 @@ public class ColumnFamilyStore implement
             return 0L;
     }
 
-    public static ColumnFamilyStore createColumnFamilyStore(String table, String columnFamily)
throws IOException
+    public static ColumnFamilyStore createColumnFamilyStore(String table, String columnFamily)
     {
         /*
          * Get all data files associated with old Memtables for this table.
@@ -560,14 +574,7 @@ public class ColumnFamilyStore implement
 
     public Table getTable()
     {
-        try
-        {
-            return Table.open(table_);
-        }
-        catch (IOException e)
-        {
-            throw new RuntimeException(e);
-        }
+        return Table.open(table_);
     }
 
     void markCompacted(Collection<SSTableReader> sstables) throws IOException

Modified: cassandra/trunk/src/java/org/apache/cassandra/db/Table.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/db/Table.java?rev=923416&r1=923415&r2=923416&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/db/Table.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/db/Table.java Mon Mar 15 20:11:15 2010
@@ -85,7 +85,7 @@ public class Table 
     // cache application CFs since Range queries ask for them a _lot_
     private SortedSet<String> applicationColumnFamilies;
     
-    public static Table open(String table) throws IOException
+    public static Table open(String table)
     {
         Table tableInstance = instances.get(table);
         if (tableInstance == null)
@@ -229,7 +229,7 @@ public class Table 
         return list;
     }
 
-    private Table(String table) throws IOException
+    private Table(String table)
     {
         name = table;
         waitForCommitLog = DatabaseDescriptor.getCommitLogSync() == DatabaseDescriptor.CommitLogSync.batch;
@@ -282,7 +282,7 @@ public class Table 
     }
     
     /** adds a cf to internal structures, ends up creating disk files). */
-    public void addCf(String cfName) throws IOException
+    public void addCf(String cfName)
     {
         assert !columnFamilyStores.containsKey(cfName) : cfName;
         columnFamilyStores.put(cfName, ColumnFamilyStore.createColumnFamilyStore(name, cfName));
@@ -430,14 +430,7 @@ public class Table 
         {
             public Table apply(String tableName)
             {
-                try
-                {
-                    return Table.open(tableName);
-                }
-                catch (IOException e)
-                {
-                    throw new RuntimeException(e);
-                }
+                return Table.open(tableName);
             }
         };
         return Iterables.transform(DatabaseDescriptor.getTables(), transformer);

Modified: cassandra/trunk/src/java/org/apache/cassandra/io/sstable/SSTable.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/io/sstable/SSTable.java?rev=923416&r1=923415&r2=923416&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/io/sstable/SSTable.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/io/sstable/SSTable.java Mon Mar 15 20:11:15
2010
@@ -20,6 +20,7 @@
 package org.apache.cassandra.io.sstable;
 
 import java.io.File;
+import java.io.IOError;
 import java.io.IOException;
 import java.util.List;
 import java.util.Arrays;
@@ -122,14 +123,21 @@ public abstract class SSTable
      *
      * @return true if the file was deleted
      */
-    public static boolean deleteIfCompacted(String dataFilename) throws IOException
+    public static boolean deleteIfCompacted(String dataFilename)
     {
         if (new File(compactedFilename(dataFilename)).exists())
         {
-            FileUtils.deleteWithConfirm(new File(dataFilename));
-            FileUtils.deleteWithConfirm(new File(SSTable.indexFilename(dataFilename)));
-            FileUtils.deleteWithConfirm(new File(SSTable.filterFilename(dataFilename)));
-            FileUtils.deleteWithConfirm(new File(SSTable.compactedFilename(dataFilename)));
+            try
+            {
+                FileUtils.deleteWithConfirm(new File(dataFilename));
+                FileUtils.deleteWithConfirm(new File(SSTable.indexFilename(dataFilename)));
+                FileUtils.deleteWithConfirm(new File(SSTable.filterFilename(dataFilename)));
+                FileUtils.deleteWithConfirm(new File(SSTable.compactedFilename(dataFilename)));
+            }
+            catch (IOException e)
+            {
+                throw new IOError(e);
+            }
             logger.info("Deleted " + dataFilename);
             return true;
         }

Modified: cassandra/trunk/src/java/org/apache/cassandra/service/AntiEntropyService.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/service/AntiEntropyService.java?rev=923416&r1=923415&r2=923416&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/service/AntiEntropyService.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/service/AntiEntropyService.java Mon Mar
15 20:11:15 2010
@@ -358,14 +358,7 @@ public class AntiEntropyService
         {
             List<DecoratedKey> keys = new ArrayList<DecoratedKey>();
             ColumnFamilyStore cfs;
-            try
-            {
-                cfs = Table.open(cf.left).getColumnFamilyStore(cf.right);
-            }
-            catch (IOException e)
-            {
-                throw new IOError(e);
-            }
+            cfs = Table.open(cf.left).getColumnFamilyStore(cf.right);
             if (cfs != null) // TODO test w/ valid CF definitions, this if{} shouldn't be
necessary
             {
                 for (DecoratedKey sample : cfs.allKeySamples())

Modified: cassandra/trunk/src/java/org/apache/cassandra/service/StorageService.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/service/StorageService.java?rev=923416&r1=923415&r2=923416&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/service/StorageService.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/service/StorageService.java Mon Mar 15 20:11:15
2010
@@ -857,15 +857,7 @@ public class StorageService implements I
         double bytes = 0;
         for (String tableName : DatabaseDescriptor.getTables())
         {
-            Table table;
-            try
-            {
-                table = Table.open(tableName);
-            }
-            catch (IOException e)
-            {
-                throw new IOError(e);
-            }
+            Table table = Table.open(tableName);
             for (String cfName : table.getColumnFamilies())
             {
                 ColumnFamilyStore cfs = table.getColumnFamilyStore(cfName);

Modified: cassandra/trunk/test/unit/org/apache/cassandra/io/sstable/SSTableUtils.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/test/unit/org/apache/cassandra/io/sstable/SSTableUtils.java?rev=923416&r1=923415&r2=923416&view=diff
==============================================================================
--- cassandra/trunk/test/unit/org/apache/cassandra/io/sstable/SSTableUtils.java (original)
+++ cassandra/trunk/test/unit/org/apache/cassandra/io/sstable/SSTableUtils.java Mon Mar 15
20:11:15 2010
@@ -45,15 +45,8 @@ public class SSTableUtils
     public static String CFNAME;
     static
     {
-        try
-        {
-            TABLENAME = DatabaseDescriptor.getTables().iterator().next();
-            CFNAME = Table.open(TABLENAME).getColumnFamilies().iterator().next();
-        }
-        catch(IOException e)
-        {
-            throw new RuntimeException(e);
-        }
+        TABLENAME = DatabaseDescriptor.getTables().iterator().next();
+        CFNAME = Table.open(TABLENAME).getColumnFamilies().iterator().next();
     }
 
     public static File tempSSTableFile(String tablename, String cfname) throws IOException



Mime
View raw message