| 98 | } |
| 99 | |
| 100 | Status GrpcServer::LoadGraphAndIndex() { |
| 101 | auto& options = server_def_.options; |
| 102 | auto it = options.find("data_path"); |
| 103 | if (it == options.end()) { |
| 104 | return Status::InvalidArgument( |
| 105 | "Server options[data_path] must be specified!"); |
| 106 | } |
| 107 | |
| 108 | auto& data_path = it->second; |
| 109 | |
| 110 | std::unique_ptr<FileIO> data_dir; |
| 111 | RETURN_IF_ERROR(Env::Default()->NewFileIO(data_path, true, &data_dir)); |
| 112 | if (!data_dir->initialized() || !data_dir->IsDirectory()) { |
| 113 | EULER_LOG(ERROR) << "No such directory found, path: " << data_path; |
| 114 | return Status::NotFound("Directory ", data_path, " not found!"); |
| 115 | } |
| 116 | |
| 117 | std::string sampler_type = "node"; |
| 118 | it = options.find("global_sampler_type"); |
| 119 | if (it != options.end()) { |
| 120 | sampler_type = it->second; |
| 121 | } |
| 122 | |
| 123 | std::string load_data_type = "node"; |
| 124 | it = options.find("load_data_type"); |
| 125 | if (it != options.end()) { |
| 126 | load_data_type = it->second; |
| 127 | } |
| 128 | |
| 129 | auto& graph = Graph::Instance(); |
| 130 | |
| 131 | // Load Graph |
| 132 | RETURN_IF_ERROR(graph.Init(server_def_.shard_index, |
| 133 | server_def_.shard_number, |
| 134 | sampler_type, data_path, load_data_type)); |
| 135 | |
| 136 | it = options.find("zk_server"); |
| 137 | if (it == options.end()) { |
| 138 | return Status::InvalidArgument( |
| 139 | "Server options[zk_server] must be specified!"); |
| 140 | } |
| 141 | zk_server_ = it->second; |
| 142 | |
| 143 | it = options.find("zk_path"); |
| 144 | if (it == options.end()) { |
| 145 | return Status::InvalidArgument( |
| 146 | "Server options[zk_path] must be specified!"); |
| 147 | } |
| 148 | zk_path_ = it->second; |
| 149 | |
| 150 | host_port_ = GetIP(); |
| 151 | it = options.find("server"); |
| 152 | if (it != options.end()) { |
| 153 | host_port_ = it->second; |
| 154 | } |
| 155 | host_port_ += ":" + std::to_string(bound_port_); |
| 156 | |
| 157 | auto& index_manager = IndexManager::Instance(); |
nothing calls this directly
no test coverage detected