You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by jx...@apache.org on 2014/03/13 21:26:23 UTC
svn commit: r1577306 - in /hbase/branches/0.98:
hbase-client/src/main/java/org/apache/hadoop/hbase/client/
hbase-server/src/test/java/org/apache/hadoop/hbase/client/
Author: jxiang
Date: Thu Mar 13 20:26:22 2014
New Revision: 1577306
URL: http://svn.apache.org/r1577306
Log:
HBASE-10737 HConnectionImplementation should stop RpcClient on close
Modified:
hbase/branches/0.98/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java
hbase/branches/0.98/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java
hbase/branches/0.98/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestClientTimeouts.java
hbase/branches/0.98/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestHCM.java
Modified: hbase/branches/0.98/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.98/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java?rev=1577306&r1=1577305&r2=1577306&view=diff
==============================================================================
--- hbase/branches/0.98/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java (original)
+++ hbase/branches/0.98/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java Thu Mar 13 20:26:22 2014
@@ -2534,6 +2534,9 @@ public class HConnectionManager {
if (clusterStatusListener != null) {
clusterStatusListener.close();
}
+ if (rpcClient != null) {
+ rpcClient.stop();
+ }
}
@Override
Modified: hbase/branches/0.98/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.98/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java?rev=1577306&r1=1577305&r2=1577306&view=diff
==============================================================================
--- hbase/branches/0.98/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java (original)
+++ hbase/branches/0.98/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java Thu Mar 13 20:26:22 2014
@@ -26,8 +26,6 @@ import static org.junit.Assert.fail;
import java.io.IOException;
import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
@@ -58,7 +56,6 @@ import org.apache.hadoop.hbase.TableNotE
import org.apache.hadoop.hbase.TableNotFoundException;
import org.apache.hadoop.hbase.ZooKeeperConnectionException;
import org.apache.hadoop.hbase.catalog.CatalogTracker;
-import org.apache.hadoop.hbase.catalog.MetaReader;
import org.apache.hadoop.hbase.constraint.ConstraintException;
import org.apache.hadoop.hbase.executor.EventHandler;
import org.apache.hadoop.hbase.master.AssignmentManager;
Modified: hbase/branches/0.98/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestClientTimeouts.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.98/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestClientTimeouts.java?rev=1577306&r1=1577305&r2=1577306&view=diff
==============================================================================
--- hbase/branches/0.98/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestClientTimeouts.java (original)
+++ hbase/branches/0.98/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestClientTimeouts.java Thu Mar 13 20:26:22 2014
@@ -81,14 +81,7 @@ public class TestClientTimeouts {
HConnection lastConnection = null;
boolean lastFailed = false;
int initialInvocations = RandomTimeoutBlockingRpcChannel.invokations.get();
- RpcClient rpcClient = new RpcClient(TEST_UTIL.getConfiguration(), TEST_UTIL.getClusterKey()) {
- // Return my own instance, one that does random timeouts
- @Override
- public BlockingRpcChannel createBlockingRpcChannel(ServerName sn,
- User ticket, int rpcTimeout) {
- return new RandomTimeoutBlockingRpcChannel(this, sn, ticket, rpcTimeout);
- }
- };
+ RpcClient rpcClient = newRandomTimeoutRpcClient();
try {
for (int i = 0; i < 5 || (lastFailed && i < 100); ++i) {
lastFailed = false;
@@ -102,7 +95,12 @@ public class TestClientTimeouts {
assertFalse(connection == lastConnection);
lastConnection = connection;
// Override the connection's rpc client for timeout testing
- ((HConnectionManager.HConnectionImplementation)connection).setRpcClient(rpcClient);
+ RpcClient oldRpcClient =
+ ((HConnectionManager.HConnectionImplementation)connection).setRpcClient(
+ rpcClient);
+ if (oldRpcClient != null) {
+ oldRpcClient.stop();
+ }
// run some admin commands
HBaseAdmin.checkHBaseAvailable(conf);
admin.setBalancerRunning(false, false);
@@ -112,6 +110,9 @@ public class TestClientTimeouts {
lastFailed = true;
} finally {
admin.close();
+ if (admin.getConnection().isClosed()) {
+ rpcClient = newRandomTimeoutRpcClient();
+ }
}
}
// Ensure the RandomTimeoutRpcEngine is actually being used.
@@ -122,6 +123,18 @@ public class TestClientTimeouts {
}
}
+ private static RpcClient newRandomTimeoutRpcClient() {
+ return new RpcClient(
+ TEST_UTIL.getConfiguration(), TEST_UTIL.getClusterKey()) {
+ // Return my own instance, one that does random timeouts
+ @Override
+ public BlockingRpcChannel createBlockingRpcChannel(ServerName sn,
+ User ticket, int rpcTimeout) {
+ return new RandomTimeoutBlockingRpcChannel(this, sn, ticket, rpcTimeout);
+ }
+ };
+ }
+
/**
* Blocking rpc channel that goes via hbase rpc.
*/
Modified: hbase/branches/0.98/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestHCM.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.98/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestHCM.java?rev=1577306&r1=1577305&r2=1577306&view=diff
==============================================================================
--- hbase/branches/0.98/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestHCM.java (original)
+++ hbase/branches/0.98/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestHCM.java Thu Mar 13 20:26:22 2014
@@ -225,6 +225,7 @@ public class TestHCM {
}
});
+ t.close();
hci.getClient(sn); // will throw an exception: RegionServerStoppedException
}
@@ -524,7 +525,7 @@ public class TestHCM {
*/
@Test
public void testConnectionManagement() throws Exception{
- TEST_UTIL.createTable(TABLE_NAME1, FAM_NAM);
+ HTable table0 = TEST_UTIL.createTable(TABLE_NAME1, FAM_NAM);
HConnection conn = HConnectionManager.createConnection(TEST_UTIL.getConfiguration());
HTableInterface table = conn.getTable(TABLE_NAME1.getName());
table.close();
@@ -535,6 +536,7 @@ public class TestHCM {
assertFalse(((HTable)table).getPool().isShutdown());
conn.close();
assertTrue(((HTable)table).getPool().isShutdown());
+ table0.close();
}
/**
@@ -583,6 +585,7 @@ public class TestHCM {
ServerName.valueOf("127.0.0.1", nextPort, 0), location.getSeqNum() - 1);
location = conn.getCachedLocation(TABLE_NAME2, ROW);
Assert.assertEquals(nextPort - 1, location.getPort());
+ table.close();
}
/**