| 15 | using namespace xsched::protocol; |
| 16 | |
| 17 | Server::Server(const std::string &policy_name, const std::string &port) |
| 18 | { |
| 19 | port_ = std::stoi(port); |
| 20 | |
| 21 | XPolicyType type = GetPolicyType(policy_name); |
| 22 | if (type == kPolicyUnknown) XERRO("invalid policy name %s", policy_name.c_str()); |
| 23 | XASSERT(type > kPolicyUnknown && type < kPolicyMax, "server policy must be a customized policy"); |
| 24 | |
| 25 | scheduler_ = std::make_unique<LocalScheduler>(type); |
| 26 | XINFO("scheduler created with policy %s", policy_name.c_str()); |
| 27 | |
| 28 | http_server_.Get("/xqueue/:handle", std::bind(&Server::GetXQueue, this, |
| 29 | std::placeholders::_1, std::placeholders::_2)); |
| 30 | http_server_.Get("/xqueues", std::bind(&Server::GetXQueues, this, |
| 31 | std::placeholders::_1, std::placeholders::_2)); |
| 32 | http_server_.Post("/config/:handle", std::bind(&Server::PostXQueueConfig, this, |
| 33 | std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)); |
| 34 | http_server_.Get("/policy", std::bind(&Server::GetSchedulerPolicy, this, |
| 35 | std::placeholders::_1, std::placeholders::_2)); |
| 36 | http_server_.Post("/policy", std::bind(&Server::PostSchedulerPolicy, this, |
| 37 | std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)); |
| 38 | http_server_.Post("/hint", std::bind(&Server::PostHint, this, |
| 39 | std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)); |
| 40 | } |
| 41 | |
| 42 | Server::~Server() |
| 43 | { |
nothing calls this directly
no test coverage detected