hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject svn commit: r1214871 - in /hbase/trunk/src/test/java/org/apache/hadoop/hbase: ResourceChecker.java client/HConnectionTestingUtility.java client/TestAdmin.java
Date Thu, 15 Dec 2011 17:13:35 GMT
Author: stack
Date: Thu Dec 15 17:13:34 2011
New Revision: 1214871

URL: http://svn.apache.org/viewvc?rev=1214871&view=rev
Log:
HBASE-5027 HConnection.create(final Connection conf) does not clone, it creates a new Configuration
reading *.xmls and then does a merge.

Modified:
    hbase/trunk/src/test/java/org/apache/hadoop/hbase/ResourceChecker.java
    hbase/trunk/src/test/java/org/apache/hadoop/hbase/client/HConnectionTestingUtility.java
    hbase/trunk/src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java

Modified: hbase/trunk/src/test/java/org/apache/hadoop/hbase/ResourceChecker.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/test/java/org/apache/hadoop/hbase/ResourceChecker.java?rev=1214871&r1=1214870&r2=1214871&view=diff
==============================================================================
--- hbase/trunk/src/test/java/org/apache/hadoop/hbase/ResourceChecker.java (original)
+++ hbase/trunk/src/test/java/org/apache/hadoop/hbase/ResourceChecker.java Thu Dec 15 17:13:34
2011
@@ -23,6 +23,7 @@ package org.apache.hadoop.hbase;
 import com.sun.management.UnixOperatingSystemMXBean;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.hadoop.hbase.client.HConnectionTestingUtility;
 
 import java.lang.management.ManagementFactory;
 import java.lang.management.OperatingSystemMXBean;
@@ -64,6 +65,10 @@ public class ResourceChecker {
       }
     }
 
+    public long getConnectionCount(){
+      return HConnectionTestingUtility.getConnectionCount();
+    }
+
     static {
       osStats =
         ManagementFactory.getOperatingSystemMXBean();
@@ -92,6 +97,8 @@ public class ResourceChecker {
 
   private long initialThreadsCount;
   private long initialFileHandlesCount;
+  private long initialConnectionCount;
+
 
   public boolean checkThreads(String tagLine) {
     boolean isOk = true;
@@ -126,8 +133,11 @@ public class ResourceChecker {
     }
 
     logInfo(tagLine);
+
     initialThreadsCount = rc.getThreadsCount();
     initialFileHandlesCount = rc.getOpenFileDescriptorCount();
+    initialConnectionCount= rc.getConnectionCount();
+
     check(tagLine);
   }
 
@@ -140,11 +150,17 @@ public class ResourceChecker {
         rc.getOpenFileDescriptorCount() + " file descriptors" +
         (initialFileHandlesCount > 0 ?
           " (was " + initialFileHandlesCount + "). " : " ") +
+        rc.getConnectionCount() + " connections" +
+        (initialConnectionCount > 0 ?
+          " (was " + initialConnectionCount + "), " : ", ") +
         (initialThreadsCount > 0 && rc.getThreadsCount() > initialThreadsCount
?
           " -thread leak?- " : "") +
         (initialFileHandlesCount > 0 &&
           rc.getOpenFileDescriptorCount() > initialFileHandlesCount ?
-          " -file handle leak?- " : "")
+          " -file handle leak?- " : "") +
+        (initialConnectionCount > 0 &&
+          rc.getConnectionCount() > initialConnectionCount ?
+          " -connection leak?- " : "" )
     );
   }
 

Modified: hbase/trunk/src/test/java/org/apache/hadoop/hbase/client/HConnectionTestingUtility.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/test/java/org/apache/hadoop/hbase/client/HConnectionTestingUtility.java?rev=1214871&r1=1214870&r2=1214871&view=diff
==============================================================================
--- hbase/trunk/src/test/java/org/apache/hadoop/hbase/client/HConnectionTestingUtility.java
(original)
+++ hbase/trunk/src/test/java/org/apache/hadoop/hbase/client/HConnectionTestingUtility.java
Thu Dec 15 17:13:34 2011
@@ -28,7 +28,6 @@ import org.mockito.Mockito;
 /**
  * {@link HConnection} testing utility.
  */
-@Category(SmallTests.class)
 public class HConnectionTestingUtility {
   /*
    * Not part of {@link HBaseTestingUtility} because this class is not
@@ -85,4 +84,14 @@ public class HConnectionTestingUtility {
       return connection;
     }
   }
+
+
+  /**
+   * @return Count of extant connection instances
+   */
+  public static int getConnectionCount() {
+    synchronized (HConnectionManager.HBASE_INSTANCES) {
+      return HConnectionManager.HBASE_INSTANCES.size();
+    }
+  }
 }

Modified: hbase/trunk/src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java?rev=1214871&r1=1214870&r2=1214871&view=diff
==============================================================================
--- hbase/trunk/src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java (original)
+++ hbase/trunk/src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java Thu Dec 15 17:13:34
2011
@@ -49,11 +49,7 @@ import org.apache.hadoop.hbase.regionser
 import org.apache.hadoop.hbase.regionserver.wal.HLogUtilsForTests;
 import org.apache.hadoop.hbase.InvalidFamilyOperationException;
 import org.apache.hadoop.hbase.util.Bytes;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.*;
 import org.junit.experimental.categories.Category;
 
 
@@ -1481,9 +1477,12 @@ public class TestAdmin {
   @Test
   public void testCheckHBaseAvailableClosesConnection() throws Exception {
     Configuration conf = TEST_UTIL.getConfiguration();
-    for(int i=0; i<1000;i++) {
-      HBaseAdmin.checkHBaseAvailable(conf);
-    }
+
+    int initialCount = HConnectionTestingUtility.getConnectionCount();
+    HBaseAdmin.checkHBaseAvailable(conf);
+    int finalCount = HConnectionTestingUtility.getConnectionCount();
+
+    Assert.assertEquals(initialCount, finalCount) ;
   }
 
   @org.junit.Rule



Mime
View raw message