|
@@ -81,15 +81,15 @@ public class TestConnectionManager {
|
|
public void testCleanup() throws Exception {
|
|
public void testCleanup() throws Exception {
|
|
Map<ConnectionPoolId, ConnectionPool> poolMap = connManager.getPools();
|
|
Map<ConnectionPoolId, ConnectionPool> poolMap = connManager.getPools();
|
|
|
|
|
|
- ConnectionPool pool1 = new ConnectionPool(
|
|
|
|
- conf, TEST_NN_ADDRESS, TEST_USER1, 0, 10, 0.5f, ClientProtocol.class);
|
|
|
|
|
|
+ ConnectionPool pool1 = new ConnectionPool(conf, TEST_NN_ADDRESS, TEST_USER1,
|
|
|
|
+ 0, 10, 0.5f, ClientProtocol.class, null);
|
|
addConnectionsToPool(pool1, 9, 4);
|
|
addConnectionsToPool(pool1, 9, 4);
|
|
poolMap.put(
|
|
poolMap.put(
|
|
new ConnectionPoolId(TEST_USER1, TEST_NN_ADDRESS, ClientProtocol.class),
|
|
new ConnectionPoolId(TEST_USER1, TEST_NN_ADDRESS, ClientProtocol.class),
|
|
pool1);
|
|
pool1);
|
|
|
|
|
|
- ConnectionPool pool2 = new ConnectionPool(
|
|
|
|
- conf, TEST_NN_ADDRESS, TEST_USER2, 0, 10, 0.5f, ClientProtocol.class);
|
|
|
|
|
|
+ ConnectionPool pool2 = new ConnectionPool(conf, TEST_NN_ADDRESS, TEST_USER2,
|
|
|
|
+ 0, 10, 0.5f, ClientProtocol.class, null);
|
|
addConnectionsToPool(pool2, 10, 10);
|
|
addConnectionsToPool(pool2, 10, 10);
|
|
poolMap.put(
|
|
poolMap.put(
|
|
new ConnectionPoolId(TEST_USER2, TEST_NN_ADDRESS, ClientProtocol.class),
|
|
new ConnectionPoolId(TEST_USER2, TEST_NN_ADDRESS, ClientProtocol.class),
|
|
@@ -111,8 +111,8 @@ public class TestConnectionManager {
|
|
checkPoolConnections(TEST_USER2, 10, 10);
|
|
checkPoolConnections(TEST_USER2, 10, 10);
|
|
|
|
|
|
// Make sure the number of connections doesn't go below minSize
|
|
// Make sure the number of connections doesn't go below minSize
|
|
- ConnectionPool pool3 = new ConnectionPool(
|
|
|
|
- conf, TEST_NN_ADDRESS, TEST_USER3, 2, 10, 0.5f, ClientProtocol.class);
|
|
|
|
|
|
+ ConnectionPool pool3 = new ConnectionPool(conf, TEST_NN_ADDRESS, TEST_USER3,
|
|
|
|
+ 2, 10, 0.5f, ClientProtocol.class, null);
|
|
addConnectionsToPool(pool3, 8, 0);
|
|
addConnectionsToPool(pool3, 8, 0);
|
|
poolMap.put(
|
|
poolMap.put(
|
|
new ConnectionPoolId(TEST_USER3, TEST_NN_ADDRESS, ClientProtocol.class),
|
|
new ConnectionPoolId(TEST_USER3, TEST_NN_ADDRESS, ClientProtocol.class),
|
|
@@ -140,7 +140,7 @@ public class TestConnectionManager {
|
|
|
|
|
|
ConnectionPool pool = new ConnectionPool(
|
|
ConnectionPool pool = new ConnectionPool(
|
|
copyConf, TEST_NN_ADDRESS, TEST_USER1, 1, 10, 0.5f,
|
|
copyConf, TEST_NN_ADDRESS, TEST_USER1, 1, 10, 0.5f,
|
|
- ClientProtocol.class);
|
|
|
|
|
|
+ ClientProtocol.class, null);
|
|
poolMap.put(
|
|
poolMap.put(
|
|
new ConnectionPoolId(TEST_USER1, TEST_NN_ADDRESS, ClientProtocol.class),
|
|
new ConnectionPoolId(TEST_USER1, TEST_NN_ADDRESS, ClientProtocol.class),
|
|
pool);
|
|
pool);
|
|
@@ -174,8 +174,8 @@ public class TestConnectionManager {
|
|
public void testConnectionCreatorWithException() throws Exception {
|
|
public void testConnectionCreatorWithException() throws Exception {
|
|
// Create a bad connection pool pointing to unresolvable namenode address.
|
|
// Create a bad connection pool pointing to unresolvable namenode address.
|
|
ConnectionPool badPool = new ConnectionPool(
|
|
ConnectionPool badPool = new ConnectionPool(
|
|
- conf, UNRESOLVED_TEST_NN_ADDRESS, TEST_USER1, 0, 10, 0.5f,
|
|
|
|
- ClientProtocol.class);
|
|
|
|
|
|
+ conf, UNRESOLVED_TEST_NN_ADDRESS, TEST_USER1, 0, 10, 0.5f,
|
|
|
|
+ ClientProtocol.class, null);
|
|
BlockingQueue<ConnectionPool> queue = new ArrayBlockingQueue<>(1);
|
|
BlockingQueue<ConnectionPool> queue = new ArrayBlockingQueue<>(1);
|
|
queue.add(badPool);
|
|
queue.add(badPool);
|
|
ConnectionManager.ConnectionCreator connectionCreator =
|
|
ConnectionManager.ConnectionCreator connectionCreator =
|
|
@@ -201,7 +201,7 @@ public class TestConnectionManager {
|
|
// Create a bad connection pool pointing to unresolvable namenode address.
|
|
// Create a bad connection pool pointing to unresolvable namenode address.
|
|
ConnectionPool badPool = new ConnectionPool(
|
|
ConnectionPool badPool = new ConnectionPool(
|
|
conf, UNRESOLVED_TEST_NN_ADDRESS, TEST_USER1, 1, 10, 0.5f,
|
|
conf, UNRESOLVED_TEST_NN_ADDRESS, TEST_USER1, 1, 10, 0.5f,
|
|
- ClientProtocol.class);
|
|
|
|
|
|
+ ClientProtocol.class, null);
|
|
}
|
|
}
|
|
|
|
|
|
@Test
|
|
@Test
|
|
@@ -210,8 +210,8 @@ public class TestConnectionManager {
|
|
final int totalConns = 10;
|
|
final int totalConns = 10;
|
|
int activeConns = 5;
|
|
int activeConns = 5;
|
|
|
|
|
|
- ConnectionPool pool = new ConnectionPool(
|
|
|
|
- conf, TEST_NN_ADDRESS, TEST_USER1, 0, 10, 0.5f, ClientProtocol.class);
|
|
|
|
|
|
+ ConnectionPool pool = new ConnectionPool(conf, TEST_NN_ADDRESS, TEST_USER1,
|
|
|
|
+ 0, 10, 0.5f, ClientProtocol.class, null);
|
|
addConnectionsToPool(pool, totalConns, activeConns);
|
|
addConnectionsToPool(pool, totalConns, activeConns);
|
|
poolMap.put(
|
|
poolMap.put(
|
|
new ConnectionPoolId(TEST_USER1, TEST_NN_ADDRESS, ClientProtocol.class),
|
|
new ConnectionPoolId(TEST_USER1, TEST_NN_ADDRESS, ClientProtocol.class),
|
|
@@ -235,8 +235,8 @@ public class TestConnectionManager {
|
|
|
|
|
|
@Test
|
|
@Test
|
|
public void testValidClientIndex() throws Exception {
|
|
public void testValidClientIndex() throws Exception {
|
|
- ConnectionPool pool = new ConnectionPool(
|
|
|
|
- conf, TEST_NN_ADDRESS, TEST_USER1, 2, 2, 0.5f, ClientProtocol.class);
|
|
|
|
|
|
+ ConnectionPool pool = new ConnectionPool(conf, TEST_NN_ADDRESS, TEST_USER1,
|
|
|
|
+ 2, 2, 0.5f, ClientProtocol.class, null);
|
|
for(int i = -3; i <= 3; i++) {
|
|
for(int i = -3; i <= 3; i++) {
|
|
pool.getClientIndex().set(i);
|
|
pool.getClientIndex().set(i);
|
|
ConnectionContext conn = pool.getConnection();
|
|
ConnectionContext conn = pool.getConnection();
|
|
@@ -251,8 +251,8 @@ public class TestConnectionManager {
|
|
final int totalConns = 10;
|
|
final int totalConns = 10;
|
|
int activeConns = 5;
|
|
int activeConns = 5;
|
|
|
|
|
|
- ConnectionPool pool = new ConnectionPool(
|
|
|
|
- conf, TEST_NN_ADDRESS, TEST_USER1, 0, 10, 0.5f, NamenodeProtocol.class);
|
|
|
|
|
|
+ ConnectionPool pool = new ConnectionPool(conf, TEST_NN_ADDRESS, TEST_USER1,
|
|
|
|
+ 0, 10, 0.5f, NamenodeProtocol.class, null);
|
|
addConnectionsToPool(pool, totalConns, activeConns);
|
|
addConnectionsToPool(pool, totalConns, activeConns);
|
|
poolMap.put(
|
|
poolMap.put(
|
|
new ConnectionPoolId(
|
|
new ConnectionPoolId(
|
|
@@ -325,7 +325,7 @@ public class TestConnectionManager {
|
|
|
|
|
|
// Create one new connection pool
|
|
// Create one new connection pool
|
|
tmpConnManager.getConnection(TEST_USER1, TEST_NN_ADDRESS,
|
|
tmpConnManager.getConnection(TEST_USER1, TEST_NN_ADDRESS,
|
|
- NamenodeProtocol.class);
|
|
|
|
|
|
+ NamenodeProtocol.class, "ns0");
|
|
|
|
|
|
Map<ConnectionPoolId, ConnectionPool> poolMap = tmpConnManager.getPools();
|
|
Map<ConnectionPoolId, ConnectionPool> poolMap = tmpConnManager.getPools();
|
|
ConnectionPoolId connectionPoolId = new ConnectionPoolId(TEST_USER1,
|
|
ConnectionPoolId connectionPoolId = new ConnectionPoolId(TEST_USER1,
|
|
@@ -356,6 +356,6 @@ public class TestConnectionManager {
|
|
"Unsupported protocol for connection to NameNode: "
|
|
"Unsupported protocol for connection to NameNode: "
|
|
+ TestConnectionManager.class.getName(),
|
|
+ TestConnectionManager.class.getName(),
|
|
() -> ConnectionPool.newConnection(conf, TEST_NN_ADDRESS, TEST_USER1,
|
|
() -> ConnectionPool.newConnection(conf, TEST_NN_ADDRESS, TEST_USER1,
|
|
- TestConnectionManager.class, false, 0));
|
|
|
|
|
|
+ TestConnectionManager.class, false, 0, null));
|
|
}
|
|
}
|
|
}
|
|
}
|