Skip to content

Commit 46b295d

Browse files
committed
Parallelize gRPC test connections
Test connections from TfBuilder to StfSender are now executed in parallel and with a 5x5s timeout.
1 parent 2629d4e commit 46b295d

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

src/common/rpc/StfSenderRpcClient.h

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ class StfSenderRpcClient {
8484
lParam.set_tf_builder_id("-1");
8585
StfDataResponse lRet;
8686
ClientContext lContext;
87-
lContext.set_deadline(std::chrono::system_clock::now() + std::chrono::milliseconds(1000));
87+
lContext.set_deadline(std::chrono::system_clock::now() + std::chrono::milliseconds(5000));
8888
lContext.set_wait_for_ready(true);
8989

9090
auto lRetVal = mStub->StfDataRequest(&lContext, lParam, &lRet);
@@ -306,14 +306,22 @@ class StfSenderRpcClientCollection {
306306
bool lConnWorking = true;
307307
mNumWorkingClients = 0;
308308

309+
std::vector<std::thread> threads;
309310
for (auto &[ mCliId, lClient] : mClients) {
310-
// attempt the test StfDataRequest()
311-
if (!lClient->StfDataRequestTest()) {
312-
EDDLOG("StfSender gRPC connection is not working. stfs_id={} grpc_status={}", mCliId, lClient->grpc_status());
313-
lConnWorking = false;
314-
continue;
315-
}
316-
mNumWorkingClients += 1;
311+
threads.emplace_back([&, mCliId, lClient]() {
312+
// attempt the test StfDataRequest()
313+
if (!lClient->StfDataRequestTest()) {
314+
EDDLOG("StfSender gRPC connection is not working. stfs_id={} grpc_status={}", mCliId, lClient->grpc_status());
315+
lConnWorking = false;
316+
return;
317+
}
318+
mNumWorkingClients += 1;
319+
});
320+
}
321+
322+
// Join all threads
323+
for (auto &thread : threads) {
324+
thread.join();
317325
}
318326

319327
return lConnWorking;

0 commit comments

Comments
 (0)