| 2169 | } |
| 2170 | |
| 2171 | void NameServerImpl::GetTablePartition(RpcController* controller, const GetTablePartitionRequest* request, |
| 2172 | GetTablePartitionResponse* response, Closure* done) { |
| 2173 | brpc::ClosureGuard done_guard(done); |
| 2174 | if (!running_.load(std::memory_order_acquire)) { |
| 2175 | response->set_code(::fedb::base::ReturnCode::kNameserverIsNotLeader); |
| 2176 | response->set_msg("nameserver is not leader"); |
| 2177 | PDLOG(WARNING, "cur nameserver is not leader"); |
| 2178 | return; |
| 2179 | } |
| 2180 | std::string name = request->name(); |
| 2181 | std::string db = request->db(); |
| 2182 | uint32_t pid = request->pid(); |
| 2183 | std::lock_guard<std::mutex> lock(mu_); |
| 2184 | std::shared_ptr<::fedb::nameserver::TableInfo> table_info; |
| 2185 | if (!GetTableInfoUnlock(name, db, &table_info)) { |
| 2186 | PDLOG(WARNING, "table[%s] is not exist", name.c_str()); |
| 2187 | response->set_code(::fedb::base::ReturnCode::kTableIsNotExist); |
| 2188 | response->set_msg("table is not exist"); |
| 2189 | return; |
| 2190 | } |
| 2191 | for (int idx = 0; idx < table_info->table_partition_size(); idx++) { |
| 2192 | if (table_info->table_partition(idx).pid() != pid) { |
| 2193 | continue; |
| 2194 | } |
| 2195 | ::fedb::nameserver::TablePartition* table_partition = response->mutable_table_partition(); |
| 2196 | table_partition->CopyFrom(table_info->table_partition(idx)); |
| 2197 | break; |
| 2198 | } |
| 2199 | response->set_code(::fedb::base::ReturnCode::kOk); |
| 2200 | response->set_msg("ok"); |
| 2201 | } |
| 2202 | |
| 2203 | void NameServerImpl::SetTablePartition(RpcController* controller, const SetTablePartitionRequest* request, |
| 2204 | GeneralResponse* response, Closure* done) { |
nothing calls this directly
no outgoing calls
no test coverage detected