Skip to content

Commit

Permalink
Make federated client more robust (#8351)
Browse files Browse the repository at this point in the history
  • Loading branch information
rongou committed Oct 18, 2022
1 parent 5647fc6 commit 521086d
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions plugin/federated/federated_client.h
Expand Up @@ -28,8 +28,11 @@ class FederatedClient {
options.pem_cert_chain = client_cert;
grpc::ChannelArguments args;
args.SetMaxReceiveMessageSize(std::numeric_limits<int>::max());
return Federated::NewStub(
grpc::CreateCustomChannel(server_address, grpc::SslCredentials(options), args));
auto channel =
grpc::CreateCustomChannel(server_address, grpc::SslCredentials(options), args);
channel->WaitForConnected(
gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), gpr_time_from_seconds(60, GPR_TIMESPAN)));
return Federated::NewStub(channel);
}()},
rank_{rank} {}

Expand All @@ -51,6 +54,7 @@ class FederatedClient {

AllgatherReply reply;
grpc::ClientContext context;
context.set_wait_for_ready(true);
grpc::Status status = stub_->Allgather(&context, request, &reply);

if (status.ok()) {
Expand All @@ -72,6 +76,7 @@ class FederatedClient {

AllreduceReply reply;
grpc::ClientContext context;
context.set_wait_for_ready(true);
grpc::Status status = stub_->Allreduce(&context, request, &reply);

if (status.ok()) {
Expand All @@ -91,6 +96,7 @@ class FederatedClient {

BroadcastReply reply;
grpc::ClientContext context;
context.set_wait_for_ready(true);
grpc::Status status = stub_->Broadcast(&context, request, &reply);

if (status.ok()) {
Expand Down

0 comments on commit 521086d

Please sign in to comment.