| 309 | } |
| 310 | |
| 311 | Status StarServerBase::ParseChannelSpec( |
| 312 | const WorkerCacheFactoryOptions& options, |
| 313 | StarChannelSpec* channel_spec) { |
| 314 | for (const auto& job : options.cluster_def->job()) { |
| 315 | std::map<int, string> host_ports; |
| 316 | for (const auto& task : job.tasks()) { |
| 317 | string& host_port = host_ports[task.first]; |
| 318 | if (!host_port.empty()) { |
| 319 | return errors::InvalidArgument( |
| 320 | "[Distributed] JobDef for job \"", |
| 321 | job.name(), "\" specified two addresses for task \"", |
| 322 | task.first, "\": ", host_port, " and ", task.second); |
| 323 | } |
| 324 | if (job.name() == *options.job_name && |
| 325 | task.first == options.task_index) { |
| 326 | host_port = strings::StrCat("localhost:", star_bound_port_); |
| 327 | } else { |
| 328 | host_port = task.second; |
| 329 | std::string star_host_port; |
| 330 | int grpc_port = -1; |
| 331 | const auto& vec = str_util::Split(host_port, ':'); |
| 332 | if (vec.size() != 2 || |
| 333 | !strings::safe_strto32(vec[1], &grpc_port)) { |
| 334 | LOG(ERROR) << "[Distributed] Error host port schema " |
| 335 | << host_port; |
| 336 | return errors::Cancelled( |
| 337 | "[Distributed] error host port schema ", |
| 338 | host_port); |
| 339 | } |
| 340 | |
| 341 | star_host_port = star_port_mgr_->GetStarIpPort( |
| 342 | job.name(), task.first); |
| 343 | LOG(INFO) << "[Distributed] host port: " |
| 344 | << host_port << ", remote star host port: " |
| 345 | << star_host_port; |
| 346 | host_port = star_host_port; |
| 347 | } |
| 348 | } |
| 349 | |
| 350 | TF_RETURN_IF_ERROR( |
| 351 | channel_spec->AddHostPortsJob(job.name(), host_ports)); |
| 352 | } |
| 353 | |
| 354 | return Status::OK(); |
| 355 | } |
| 356 | |
| 357 | size_t StarServerBase::ParseServers( |
| 358 | const WorkerCacheFactoryOptions& options) { |
nothing calls this directly
no test coverage detected