Author: garyh
Date: Mon Apr 11 18:39:42 2011
New Revision: 1091165

URL: http://svn.apache.org/viewvc?rev=1091165&view=rev
Log:
HBASE-3762  HTableFactory.releaseHTableInterface() should throw IOException not 
wrap in RTE

Modified:
    hbase/trunk/CHANGES.txt
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/avro/AvroServer.java
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/client/HTableFactory.java
    
hbase/trunk/src/main/java/org/apache/hadoop/hbase/client/HTableInterfaceFactory.java
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/client/HTablePool.java
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/rest/RowResource.java

Modified: hbase/trunk/CHANGES.txt
URL: 
http://svn.apache.org/viewvc/hbase/trunk/CHANGES.txt?rev=1091165&r1=1091164&r2=1091165&view=diff
==============================================================================
--- hbase/trunk/CHANGES.txt (original)
+++ hbase/trunk/CHANGES.txt Mon Apr 11 18:39:42 2011
@@ -6,6 +6,8 @@ Release 0.91.0 - Unreleased
                changes at runtime (Gary Helmling via Andrew Purtell)
    HBASE-3677  Generate a globally unique cluster ID (changed
                ClusterStatus serialization)
+   HBASE-3762  HTableFactory.releaseHTableInterface() should throw IOException
+               instead of wrapping in RuntimeException (Ted Yu via garyh)
 
   BUG FIXES
    HBASE-3280  YouAreDeadException being swallowed in HRS getMaster

Modified: hbase/trunk/src/main/java/org/apache/hadoop/hbase/avro/AvroServer.java
URL: 
http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/avro/AvroServer.java?rev=1091165&r1=1091164&r2=1091165&view=diff
==============================================================================
--- hbase/trunk/src/main/java/org/apache/hadoop/hbase/avro/AvroServer.java 
(original)
+++ hbase/trunk/src/main/java/org/apache/hadoop/hbase/avro/AvroServer.java Mon 
Apr 11 18:39:42 2011
@@ -401,7 +401,13 @@ public class AvroServer {
        ioe.message = new Utf8(e.getMessage());
         throw ioe;
       } finally {
-        htablePool.putTable(htable);
+        try {
+          htablePool.putTable(htable);
+        } catch (IOException e) {
+          AIOError ioe = new AIOError();
+          ioe.message = new Utf8(e.getMessage());
+          throw ioe;
+        }
       }
     }
 
@@ -414,7 +420,13 @@ public class AvroServer {
        ioe.message = new Utf8(e.getMessage());
         throw ioe;
       } finally {
-        htablePool.putTable(htable);
+        try {
+          htablePool.putTable(htable);
+        } catch (IOException e) {
+          AIOError ioe = new AIOError();
+          ioe.message = new Utf8(e.getMessage());
+          throw ioe;
+        } 
       }
     }
 
@@ -428,7 +440,13 @@ public class AvroServer {
         ioe.message = new Utf8(e.getMessage());
         throw ioe;
       } finally {
-        htablePool.putTable(htable);
+        try {
+          htablePool.putTable(htable);
+        } catch (IOException e) {
+          AIOError ioe = new AIOError();
+          ioe.message = new Utf8(e.getMessage());
+          throw ioe;
+        }
       }
     }
 
@@ -442,7 +460,13 @@ public class AvroServer {
        ioe.message = new Utf8(e.getMessage());
         throw ioe;
       } finally {
-        htablePool.putTable(htable);
+        try {
+          htablePool.putTable(htable);
+        } catch (IOException e) {
+          AIOError ioe = new AIOError();
+          ioe.message = new Utf8(e.getMessage());
+          throw ioe;
+        }
       }
     }
 
@@ -455,7 +479,13 @@ public class AvroServer {
         ioe.message = new Utf8(e.getMessage());
         throw ioe;
       } finally {
-        htablePool.putTable(htable);
+        try {
+          htablePool.putTable(htable);
+        } catch (IOException e) {
+          AIOError ioe = new AIOError();
+          ioe.message = new Utf8(e.getMessage());
+          throw ioe;
+        }
       }
     }
 
@@ -473,7 +503,13 @@ public class AvroServer {
        ioe.message = new Utf8(e.getMessage());
         throw ioe;
       } finally {
-        htablePool.putTable(htable);
+        try {
+          htablePool.putTable(htable);
+        } catch (IOException e) {
+          AIOError ioe = new AIOError();
+          ioe.message = new Utf8(e.getMessage());
+          throw ioe;
+        }
       }
     }
 

Modified: 
hbase/trunk/src/main/java/org/apache/hadoop/hbase/client/HTableFactory.java
URL: 
http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/client/HTableFactory.java?rev=1091165&r1=1091164&r2=1091165&view=diff
==============================================================================
--- hbase/trunk/src/main/java/org/apache/hadoop/hbase/client/HTableFactory.java 
(original)
+++ hbase/trunk/src/main/java/org/apache/hadoop/hbase/client/HTableFactory.java 
Mon Apr 11 18:39:42 2011
@@ -40,11 +40,7 @@ public class HTableFactory implements HT
   }
 
   @Override
-  public void releaseHTableInterface(HTableInterface table) {
-    try {
-      table.close();
-    } catch (IOException ioe) {
-      throw new RuntimeException(ioe);
-    }
+  public void releaseHTableInterface(HTableInterface table) throws IOException 
{
+    table.close();
   }
 }
\ No newline at end of file

Modified: 
hbase/trunk/src/main/java/org/apache/hadoop/hbase/client/HTableInterfaceFactory.java
URL: 
http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/client/HTableInterfaceFactory.java?rev=1091165&r1=1091164&r2=1091165&view=diff
==============================================================================
--- 
hbase/trunk/src/main/java/org/apache/hadoop/hbase/client/HTableInterfaceFactory.java
 (original)
+++ 
hbase/trunk/src/main/java/org/apache/hadoop/hbase/client/HTableInterfaceFactory.java
 Mon Apr 11 18:39:42 2011
@@ -19,6 +19,8 @@
  */
 package org.apache.hadoop.hbase.client;
 
+import java.io.IOException;
+
 import org.apache.hadoop.conf.Configuration;
 
 
@@ -43,5 +45,5 @@ public interface HTableInterfaceFactory 
    * Release the HTable resource represented by the table.
    * @param table
    */
-  void releaseHTableInterface(final HTableInterface table);
+  void releaseHTableInterface(final HTableInterface table) throws IOException;
 }

Modified: 
hbase/trunk/src/main/java/org/apache/hadoop/hbase/client/HTablePool.java
URL: 
http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/client/HTablePool.java?rev=1091165&r1=1091164&r2=1091165&view=diff
==============================================================================
--- hbase/trunk/src/main/java/org/apache/hadoop/hbase/client/HTablePool.java 
(original)
+++ hbase/trunk/src/main/java/org/apache/hadoop/hbase/client/HTablePool.java 
Mon Apr 11 18:39:42 2011
@@ -19,6 +19,7 @@
  */
 package org.apache.hadoop.hbase.client;
 
+import java.io.IOException;
 import java.util.Map;
 import java.util.Queue;
 import java.util.concurrent.ConcurrentHashMap;
@@ -114,7 +115,7 @@ public class HTablePool {
    * then the table instance gets closed after flushing buffered edits.
    * @param table table
    */
-  public void putTable(HTableInterface table) {
+  public void putTable(HTableInterface table) throws IOException {
     Queue<HTableInterface> queue = 
tables.get(Bytes.toString(table.getTableName()));
     if(queue.size() >= maxSize) {
       // release table instance since we're not reusing it
@@ -137,7 +138,7 @@ public class HTablePool {
    *
    * @param tableName
    */
-  public void closeTablePool(final String tableName)  {
+  public void closeTablePool(final String tableName) throws IOException {
     Queue<HTableInterface> queue = tables.get(tableName);
     if (queue != null) {
       HTableInterface table = queue.poll();
@@ -154,7 +155,7 @@ public class HTablePool {
    *
    * @param tableName
    */
-  public void closeTablePool(final byte[] tableName)  {
+  public void closeTablePool(final byte[] tableName) throws IOException {
     closeTablePool(Bytes.toString(tableName));
   }
 

Modified: 
hbase/trunk/src/main/java/org/apache/hadoop/hbase/rest/RowResource.java
URL: 
http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/rest/RowResource.java?rev=1091165&r1=1091164&r2=1091165&view=diff
==============================================================================
--- hbase/trunk/src/main/java/org/apache/hadoop/hbase/rest/RowResource.java 
(original)
+++ hbase/trunk/src/main/java/org/apache/hadoop/hbase/rest/RowResource.java Mon 
Apr 11 18:39:42 2011
@@ -189,7 +189,12 @@ public class RowResource extends Resourc
                   Response.Status.SERVICE_UNAVAILABLE);
     } finally {
       if (table != null) {
-        pool.putTable(table);
+        try {
+          pool.putTable(table);
+        } catch (IOException ioe) {
+          throw new WebApplicationException(ioe,
+              Response.Status.SERVICE_UNAVAILABLE);
+        }
       }
     }
   }
@@ -248,7 +253,12 @@ public class RowResource extends Resourc
                   Response.Status.SERVICE_UNAVAILABLE);
     } finally {
       if (table != null) {
-        pool.putTable(table);
+        try {
+          pool.putTable(table);
+        } catch (IOException ioe) {
+          throw new WebApplicationException(ioe,
+              Response.Status.SERVICE_UNAVAILABLE);
+        }
       }
     }
   }
@@ -337,7 +347,12 @@ public class RowResource extends Resourc
                   Response.Status.SERVICE_UNAVAILABLE);
     } finally {
       if (table != null) {
-        pool.putTable(table);
+        try {
+          pool.putTable(table);
+        } catch (IOException ioe) {
+          throw new WebApplicationException(ioe,
+              Response.Status.SERVICE_UNAVAILABLE);
+        }
       }
     }
     return Response.ok().build();


Reply via email to