hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject svn commit: r888201 - in /hadoop/hbase/branches/0.20: CHANGES.txt src/java/org/apache/hadoop/hbase/HBaseConfiguration.java src/java/org/apache/hadoop/hbase/client/HConnectionManager.java
Date Tue, 08 Dec 2009 00:23:01 GMT
Author: stack
Date: Tue Dec  8 00:23:01 2009
New Revision: 888201

URL: http://svn.apache.org/viewvc?rev=888201&view=rev
Log:
HBASE-2027 HConnectionManager.HBASE_INSTANCES leaks TableServers

Modified:
    hadoop/hbase/branches/0.20/CHANGES.txt
    hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/HBaseConfiguration.java
    hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/client/HConnectionManager.java

Modified: hadoop/hbase/branches/0.20/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/hbase/branches/0.20/CHANGES.txt?rev=888201&r1=888200&r2=888201&view=diff
==============================================================================
--- hadoop/hbase/branches/0.20/CHANGES.txt (original)
+++ hadoop/hbase/branches/0.20/CHANGES.txt Tue Dec  8 00:23:01 2009
@@ -29,6 +29,8 @@
    HBASE-2018  Updates to .META. blocked under high MemStore load
    HBASE-2029  Reduce shell exception dump on console
                (Lars George and J-D via Stack)
+   HBASE-2027 HConnectionManager.HBASE_INSTANCES leaks TableServers
+              (Dave Latham via Stack)
 
 Release 0.20.2 - November 18th, 2009
   INCOMPATIBLE CHANGES

Modified: hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/HBaseConfiguration.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/HBaseConfiguration.java?rev=888201&r1=888200&r2=888201&view=diff
==============================================================================
--- hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/HBaseConfiguration.java (original)
+++ hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/HBaseConfiguration.java Tue
Dec  8 00:23:01 2009
@@ -52,7 +52,7 @@
   
   /**
    * Returns the hash code value for this HBaseConfiguration. The hash code of a
-   * HBaseConfiguration is defined by the sum of the hash codes of its entries.
+   * HBaseConfiguration is defined by the xor of the hash codes of its entries.
    * 
    * @see Configuration#iterator() How the entries are obtained.
    */
@@ -66,5 +66,32 @@
     }
     return hash;
   }
+
+  @Override
+  public boolean equals(Object obj) {
+    if (this == obj)
+      return true;
+    if (obj == null)
+      return false;
+    if (!(obj instanceof HBaseConfiguration))
+      return false;
+    
+    HBaseConfiguration otherConf = (HBaseConfiguration) obj;
+    if (size() != otherConf.size()) {
+      return false;
+    }
+    Iterator<Entry<String, String>> propertyIterator = this.iterator();
+    while (propertyIterator.hasNext()) {
+      Entry<String, String> entry = propertyIterator.next();
+      String key = entry.getKey();
+      String value = entry.getValue();
+      if (!value.equals(otherConf.getRaw(key))) {
+        return false;
+      }
+    }
+    
+    return true;
+  }
+  
   
 }

Modified: hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/client/HConnectionManager.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/client/HConnectionManager.java?rev=888201&r1=888200&r2=888201&view=diff
==============================================================================
--- hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/client/HConnectionManager.java
(original)
+++ hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/client/HConnectionManager.java
Tue Dec  8 00:23:01 2009
@@ -24,10 +24,10 @@
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashMap;
+import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.TreeSet;
-import java.util.WeakHashMap;
 import java.util.concurrent.ConcurrentHashMap;
 
 import org.apache.commons.logging.Log;
@@ -85,12 +85,20 @@
     super();
   }
   
-  // A Map of master HBaseConfiguration -> connection information for that 
-  // instance. Note that although the Map is synchronized, the objects it 
-  // contains are mutable and hence require synchronized access to them
+  private static final int MAX_CACHED_HBASE_INSTANCES=31;
+  // A LRU Map of master HBaseConfiguration -> connection information for that 
+  // instance. The objects it contains are mutable and hence require
+  // synchronized access to them.  We set instances to 31.  The zk default max
+  // connections is 30 so should run into zk issues before hit this value of 31.
   private static 
   final Map<HBaseConfiguration, TableServers> HBASE_INSTANCES =
-    new WeakHashMap<HBaseConfiguration, TableServers>();
+    new LinkedHashMap<HBaseConfiguration, TableServers>
+      ((int) (MAX_CACHED_HBASE_INSTANCES/0.75F)+1, 0.75F, true) {
+      @Override
+      protected boolean removeEldestEntry(Map.Entry<HBaseConfiguration, TableServers>
eldest) {
+        return size() > MAX_CACHED_HBASE_INSTANCES;
+      }
+  };
   
   private static final Map<String, ClientZKWatcher> ZK_WRAPPERS = 
     new HashMap<String, ClientZKWatcher>();



Mime
View raw message