MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / GetPort

Method GetPort

tensorflow/core/distributed_runtime/rpc/grpc_server_lib.cc:117–142  ·  view source on GitHub ↗

Look up the port that has been requested for this task in `server_def_`.

Source from the content-addressed store, hash-verified

115
116// Look up the port that has been requested for this task in `server_def_`.
117Status GrpcServer::GetPort(int* port) const {
118 *port = -1;
119 for (const auto& job : server_def_.cluster().job()) {
120 if (job.name() == server_def_.job_name()) {
121 auto iter = job.tasks().find(server_def_.task_index());
122 if (iter == job.tasks().end()) {
123 return errors::InvalidArgument("Task ", server_def_.task_index(),
124 " was not defined in job \"",
125 server_def_.job_name(), "\"");
126 }
127 auto colon_index = iter->second.find_last_of(':');
128 if (!strings::safe_strto32(iter->second.substr(colon_index + 1), port)) {
129 return errors::InvalidArgument(
130 "Could not parse port for local server from \"", iter->second,
131 "\".");
132 }
133 break;
134 }
135 }
136 if (*port == -1) {
137 return errors::Internal("Job \"", server_def_.job_name(),
138 "\" was not defined in cluster");
139 }
140
141 return Status::OK();
142}
143
144Status GrpcServer::Init(const GrpcServerOptions& opts) {
145 mutex_lock l(mu_);

Callers

nothing calls this directly

Calls 9

InvalidArgumentFunction · 0.85
InternalFunction · 0.85
job_nameMethod · 0.80
task_indexMethod · 0.80
nameMethod · 0.65
safe_strto32Function · 0.50
jobMethod · 0.45
findMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected