| 556 | } |
| 557 | |
| 558 | Status AddWorker(ServerContext*, const AddWorkerRequest* request, |
| 559 | EmptyResponse* response) override { |
| 560 | std::lock_guard<std::recursive_mutex> lock(mutex_); |
| 561 | |
| 562 | uint64_t wid = request->wid(); |
| 563 | if (wid >= Worker::kMaxWorkers) { |
| 564 | return return_with_error(response, EINVAL, "Invalid worker id"); |
| 565 | } |
| 566 | uint64_t core = request->core(); |
| 567 | if (!is_cpu_present(core)) { |
| 568 | return return_with_error(response, EINVAL, "Invalid core %d", core); |
| 569 | } |
| 570 | if (is_worker_active(wid)) { |
| 571 | return return_with_error(response, EEXIST, "worker:%d is already active", |
| 572 | wid); |
| 573 | } |
| 574 | const std::string& scheduler = request->scheduler(); |
| 575 | if (scheduler != "" && scheduler != "experimental") { |
| 576 | return return_with_error(response, EINVAL, "Invalid scheduler %s", |
| 577 | scheduler.c_str()); |
| 578 | } |
| 579 | |
| 580 | launch_worker(wid, core, scheduler); |
| 581 | return Status::OK; |
| 582 | } |
| 583 | |
| 584 | Status DestroyWorker(ServerContext*, const DestroyWorkerRequest* request, |
| 585 | EmptyResponse* response) override { |
nothing calls this directly
no test coverage detected