| 49 | } |
| 50 | |
| 51 | Status VerbsServer::ChannelCacheFactory(const ServerDef& server_def, |
| 52 | GrpcChannelCache** channel_cache) { |
| 53 | string name_prefix = |
| 54 | strings::StrCat("/job:", server_def.job_name(), "/replica:0", |
| 55 | "/task:", server_def.task_index()); |
| 56 | |
| 57 | GrpcChannelSpec channel_spec; |
| 58 | TF_RETURN_IF_ERROR(ParseChannelSpec(server_def, &channel_spec)); |
| 59 | |
| 60 | *channel_cache = |
| 61 | NewGrpcChannelCache(channel_spec, GetChannelCreationFunction()); |
| 62 | |
| 63 | const string host_port = (*channel_cache)->TranslateTask(name_prefix); |
| 64 | int requested_port; |
| 65 | |
| 66 | if (!strings::safe_strto32(str_util::Split(host_port, ':')[1], |
| 67 | &requested_port)) { |
| 68 | return errors::Internal("Could not parse port for local server from \"", |
| 69 | (*channel_cache)->TranslateTask(name_prefix), |
| 70 | "\"."); |
| 71 | } |
| 72 | if (requested_port != bound_port()) { |
| 73 | return errors::InvalidArgument("Requested port ", requested_port, |
| 74 | " differs from expected port ", |
| 75 | bound_port()); |
| 76 | } |
| 77 | |
| 78 | return Status::OK(); |
| 79 | } |
| 80 | |
| 81 | Status VerbsServer::Init(ServiceInitFunction service_func, |
| 82 | RendezvousMgrCreationFunction rendezvous_mgr_func) { |
nothing calls this directly
no test coverage detected