hadoop-zookeeper-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From maha...@apache.org
Subject svn commit: r761811 - in /hadoop/zookeeper/trunk: CHANGES.txt src/contrib/bookkeeper/src/java/org/apache/bookkeeper/bookie/Bookie.java src/contrib/bookkeeper/src/java/org/apache/bookkeeper/bookie/LedgerDescriptor.java
Date Fri, 03 Apr 2009 21:43:38 GMT
Author: mahadev
Date: Fri Apr  3 21:43:38 2009
New Revision: 761811

URL: http://svn.apache.org/viewvc?rev=761811&view=rev
Log:
ZOOKEEPER-360. WeakHashMap in Bookie.java causes NPE (flavio via mahadev)

Modified:
    hadoop/zookeeper/trunk/CHANGES.txt
    hadoop/zookeeper/trunk/src/contrib/bookkeeper/src/java/org/apache/bookkeeper/bookie/Bookie.java
    hadoop/zookeeper/trunk/src/contrib/bookkeeper/src/java/org/apache/bookkeeper/bookie/LedgerDescriptor.java

Modified: hadoop/zookeeper/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/CHANGES.txt?rev=761811&r1=761810&r2=761811&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/CHANGES.txt (original)
+++ hadoop/zookeeper/trunk/CHANGES.txt Fri Apr  3 21:43:38 2009
@@ -34,6 +34,9 @@
   ZOOKEEPER-341.  regression in QuorumPeerMain, 
   tickTime from config is lost, cannot start quorum (phunt via mahadev)
 
+  ZOOKEEPER-360. WeakHashMap in Bookie.java causes NPE (flavio via mahadev)
+
+
 IMPROVEMENTS:
   ZOOKEEPER-308. improve the atomic broadcast performance 3x.
   (breed via mahadev)

Modified: hadoop/zookeeper/trunk/src/contrib/bookkeeper/src/java/org/apache/bookkeeper/bookie/Bookie.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/contrib/bookkeeper/src/java/org/apache/bookkeeper/bookie/Bookie.java?rev=761811&r1=761810&r2=761811&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/contrib/bookkeeper/src/java/org/apache/bookkeeper/bookie/Bookie.java
(original)
+++ hadoop/zookeeper/trunk/src/contrib/bookkeeper/src/java/org/apache/bookkeeper/bookie/Bookie.java
Fri Apr  3 21:43:38 2009
@@ -27,7 +27,6 @@
 import java.nio.ByteBuffer;
 import java.nio.channels.FileChannel;
 import java.util.HashMap;
-import java.util.WeakHashMap;
 import java.util.LinkedList;
 import java.util.Random;
 import java.util.concurrent.LinkedBlockingQueue;
@@ -55,8 +54,6 @@
 
     final File ledgerDirectories[];
     
-    WeakHashMap<Long, ByteBuffer> masterKeys = new WeakHashMap<Long, ByteBuffer>();
-    
     public static class NoLedgerException extends IOException {
         private static final long serialVersionUID = 1L;
         private long ledgerId;
@@ -104,7 +101,7 @@
             if (handle == null) {
                 handle = createHandle(ledgerId, readonly);
                 ledgers.put(ledgerId, handle);
-                masterKeys.put(ledgerId, ByteBuffer.wrap(masterKey));
+                handle.setMasterKey(ByteBuffer.wrap(masterKey));
             } 
             handle.incRef();
         }
@@ -291,7 +288,7 @@
         long ledgerId = entry.getLong();
         LedgerDescriptor handle = getHandle(ledgerId, false, masterKey);
         
-        if(!masterKeys.get(ledgerId).equals(ByteBuffer.wrap(masterKey))){
+        if(!handle.cmpMasterKey(ByteBuffer.wrap(masterKey))){
             throw BookieException.create(BookieException.Code.UnauthorizedAccessException);
         }
         try {

Modified: hadoop/zookeeper/trunk/src/contrib/bookkeeper/src/java/org/apache/bookkeeper/bookie/LedgerDescriptor.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/contrib/bookkeeper/src/java/org/apache/bookkeeper/bookie/LedgerDescriptor.java?rev=761811&r1=761810&r2=761811&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/contrib/bookkeeper/src/java/org/apache/bookkeeper/bookie/LedgerDescriptor.java
(original)
+++ hadoop/zookeeper/trunk/src/contrib/bookkeeper/src/java/org/apache/bookkeeper/bookie/LedgerDescriptor.java
Fri Apr  3 21:43:38 2009
@@ -42,6 +42,17 @@
         this.ledger = ledger;
         this.ledgerIndex = ledgerIndex;
     }
+    
+    private ByteBuffer masterKey = null;
+    
+    void setMasterKey(ByteBuffer masterKey){
+        this.masterKey = masterKey;
+    }
+    
+    boolean cmpMasterKey(ByteBuffer masterKey){
+        return this.masterKey.equals(masterKey);
+    }
+    
     private long ledgerId;
     private FileChannel ledger;
     private FileChannel ledgerIndex;



Mime
View raw message