hadoop-zookeeper-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r781173 - in /hadoop/zookeeper/trunk: ./ src/contrib/bookkeeper/src/java/org/apache/bookkeeper/client/ src/contrib/bookkeeper/test/org/apache/bookkeeper/test/
Date Tue, 02 Jun 2009 21:15:23 GMT
Author: breed
Date: Tue Jun  2 21:15:23 2009
New Revision: 781173

URL: http://svn.apache.org/viewvc?rev=781173&view=rev
Log:
ZOOKEEPER-358. Throw exception when ledger does not exist

Modified:
    hadoop/zookeeper/trunk/CHANGES.txt
    hadoop/zookeeper/trunk/src/contrib/bookkeeper/src/java/org/apache/bookkeeper/client/BKException.java
    hadoop/zookeeper/trunk/src/contrib/bookkeeper/src/java/org/apache/bookkeeper/client/BookKeeper.java
    hadoop/zookeeper/trunk/src/contrib/bookkeeper/test/org/apache/bookkeeper/test/BookieReadWriteTest.java

Modified: hadoop/zookeeper/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/CHANGES.txt?rev=781173&r1=781172&r2=781173&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/CHANGES.txt (original)
+++ hadoop/zookeeper/trunk/CHANGES.txt Tue Jun  2 21:15:23 2009
@@ -181,6 +181,8 @@
   include in release (phunt via breed)
 
   ZOOKEEPER-383. Asynchronous version of createLedger(). (flavio via mahadev)
+
+  ZOOKEEPER-358. Throw exception when ledger does not exist. (flavio via breed)
  
 NEW FEATURES:
 

Modified: hadoop/zookeeper/trunk/src/contrib/bookkeeper/src/java/org/apache/bookkeeper/client/BKException.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/contrib/bookkeeper/src/java/org/apache/bookkeeper/client/BKException.java?rev=781173&r1=781172&r2=781173&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/contrib/bookkeeper/src/java/org/apache/bookkeeper/client/BKException.java
(original)
+++ hadoop/zookeeper/trunk/src/contrib/bookkeeper/src/java/org/apache/bookkeeper/client/BKException.java
Tue Jun  2 21:15:23 2009
@@ -48,6 +48,8 @@
             return new BKDigestNotInitializedException();
         case Code.DigestMatchException:
             return new BKDigestMatchException();
+        case Code.NoSuchLedgerExistsException:
+            return new BKNoSuchLedgerExistsException();
         default:
             return new BKIllegalOpException();
         }
@@ -60,6 +62,7 @@
         int NoBookieAvailableException = -3;
         int DigestNotInitializedException = -4;
         int DigestMatchException = -5;
+        int NoSuchLedgerExistsException = -6;
         
         int IllegalOpException = -100;
     }
@@ -86,6 +89,8 @@
             return "Digest engine not initialized";
         case Code.DigestMatchException:
             return "Entry digest does not match";
+        case Code.NoSuchLedgerExistsException:
+            return "No such ledger exists";
         default:
             return "Invalid operation";
         }
@@ -126,5 +131,11 @@
             super(Code.IllegalOpException);
         }   
     }
+    
+    public static class BKNoSuchLedgerExistsException extends BKException {
+        public BKNoSuchLedgerExistsException(){
+            super(Code.NoSuchLedgerExistsException);
+        }   
+    }
 }
     

Modified: hadoop/zookeeper/trunk/src/contrib/bookkeeper/src/java/org/apache/bookkeeper/client/BookKeeper.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/contrib/bookkeeper/src/java/org/apache/bookkeeper/client/BookKeeper.java?rev=781173&r1=781172&r2=781173&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/contrib/bookkeeper/src/java/org/apache/bookkeeper/client/BookKeeper.java
(original)
+++ hadoop/zookeeper/trunk/src/contrib/bookkeeper/src/java/org/apache/bookkeeper/client/BookKeeper.java
Tue Jun  2 21:15:23 2009
@@ -303,7 +303,7 @@
          */
         if(zk.exists(BKDefs.prefix + getZKStringId(lId), false) == null){
             LOG.error("Ledger " + getZKStringId(lId) + " doesn't exist.");
-            return null;
+            throw BKException.create(Code.NoSuchLedgerExistsException);
         }
         
         /*

Modified: hadoop/zookeeper/trunk/src/contrib/bookkeeper/test/org/apache/bookkeeper/test/BookieReadWriteTest.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/contrib/bookkeeper/test/org/apache/bookkeeper/test/BookieReadWriteTest.java?rev=781173&r1=781172&r2=781173&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/contrib/bookkeeper/test/org/apache/bookkeeper/test/BookieReadWriteTest.java
(original)
+++ hadoop/zookeeper/trunk/src/contrib/bookkeeper/test/org/apache/bookkeeper/test/BookieReadWriteTest.java
Tue Jun  2 21:15:23 2009
@@ -111,6 +111,18 @@
 		}    	
     }
     
+    @Test
+    public void testOpenException() 
+    throws KeeperException, IOException, InterruptedException {
+        bkc = new BookKeeper("127.0.0.1");
+        try{
+            lh = bkc.openLedger(0, ledgerPassword);
+            fail("Haven't thrown exception");
+        } catch (BKException e) {
+            LOG.warn("Successfully thrown and caught exception:", e);
+        }
+    }
+    
     /**
      * test the streaming api for reading
      * and writing



Mime
View raw message