| 2159 | |
| 2160 | |
| 2161 | Future<Response> Master::Http::weights( |
| 2162 | const Request& request, |
| 2163 | const Option<Principal>& principal) const |
| 2164 | { |
| 2165 | // TODO(greggomann): Remove this check once the `Principal` type is used in |
| 2166 | // `ReservationInfo`, `DiskInfo`, and within the master's `principals` map. |
| 2167 | // See MESOS-7202. |
| 2168 | if (principal.isSome() && principal->value.isNone()) { |
| 2169 | return Forbidden( |
| 2170 | "The request's authenticated principal contains claims, but no value " |
| 2171 | "string. The master currently requires that principals have a value"); |
| 2172 | } |
| 2173 | |
| 2174 | // When current master is not the leader, redirect to the leading master. |
| 2175 | if (!master->elected()) { |
| 2176 | return redirect(request); |
| 2177 | } |
| 2178 | |
| 2179 | if (request.method == "GET") { |
| 2180 | return weightsHandler.get(request, principal); |
| 2181 | } |
| 2182 | |
| 2183 | // Dispatch based on HTTP method to separate `WeightsHandler`. |
| 2184 | if (request.method == "PUT") { |
| 2185 | return weightsHandler.update(request, principal); |
| 2186 | } |
| 2187 | |
| 2188 | return MethodNotAllowed({"GET", "PUT"}, request.method); |
| 2189 | } |
| 2190 | |
| 2191 | |
| 2192 | string Master::Http::STATE_HELP() |