Github user aarondav commented on a diff in the pull request:
https://github.com/apache/spark/pull/3625#discussion_r21413733
--- Diff:
network/common/src/test/java/org/apache/spark/network/TransportClientFactorySuite.java
---
@@ -57,16 +62,113 @@ public void tearDown() {
JavaUtils.closeQuietly(server2);
}
+ /**
+ * Request a bunch of clients to a single server to test
+ * we create up to maxConnections of clients.
+ */
+ private void testClientReuse(final int maxConnections) throws
IOException {
+ TransportConf conf = new TransportConf(new ConfigProvider() {
+ @Override
+ public String get(String name) {
+ if (name.equals("spark.shuffle.io.numConnectionsPerPeer")) {
+ return Integer.toString(maxConnections);
+ } else {
+ throw new NoSuchElementException();
+ }
+ }
+ });
+
+ RpcHandler rpcHandler = new NoOpRpcHandler();
+ TransportContext context = new TransportContext(conf, rpcHandler);
+ TransportClientFactory factory = context.createClientFactory();
+ HashSet<TransportClient> clients = new HashSet<TransportClient>();
+ for (int i = 0; i < maxConnections * 10; i++) {
+ TransportClient client =
factory.createClient(TestUtils.getLocalHost(), server1.getPort());
+ assert(client.isActive());
+ clients.add(client);
+ }
+
+ assert(clients.size() == maxConnections);
--- End diff --
seems like we should close the clients afterwards
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]