MCPcopy Create free account
hub / github.com/apache/mesos / getState

Method getState

src/slave/http.cpp:2488–2561  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2486
2487
2488Future<Response> Http::getState(
2489 const mesos::agent::Call& call,
2490 ContentType contentType,
2491 const Option<Principal>& principal) const
2492{
2493 CHECK_EQ(mesos::agent::Call::GET_STATE, call.type());
2494
2495 LOG(INFO) << "Processing GET_STATE call";
2496
2497 return ObjectApprovers::create(
2498 slave->authorizer,
2499 principal,
2500 {VIEW_FRAMEWORK, VIEW_TASK, VIEW_EXECUTOR})
2501 .then(defer(
2502 slave->self(),
2503 [=](const Owned<ObjectApprovers>& approvers) -> Response {
2504 // Serialize the following message:
2505 //
2506 // v1::agent::Response response;
2507 // response.set_type(mesos::agent::Response::GET_STATE);
2508 // *response.mutable_get_state() = _...;
2509
2510 switch (contentType) {
2511 case ContentType::PROTOBUF: {
2512 string output;
2513 google::protobuf::io::StringOutputStream stream(&output);
2514 google::protobuf::io::CodedOutputStream writer(&stream);
2515
2516 WireFormatLite::WriteEnum(
2517 v1::agent::Response::kTypeFieldNumber,
2518 v1::agent::Response::GET_STATE,
2519 &writer);
2520
2521 WireFormatLite::WriteBytes(
2522 v1::agent::Response::kGetStateFieldNumber,
2523 serializeGetState(approvers),
2524 &writer);
2525
2526 // We must manually trim the unused buffer space since
2527 // we use the string before the coded output stream is
2528 // destructed.
2529 writer.Trim();
2530
2531 return OK(std::move(output), stringify(contentType));
2532 }
2533
2534 case ContentType::JSON: {
2535 string body = jsonify([&](JSON::ObjectWriter* writer) {
2536 const google::protobuf::Descriptor* descriptor =
2537 v1::agent::Response::descriptor();
2538
2539 int field;
2540
2541 field = v1::agent::Response::kTypeFieldNumber;
2542 writer->field(
2543 descriptor->FindFieldByNumber(field)->name(),
2544 v1::agent::Response::Type_Name(
2545 v1::agent::Response::GET_STATE));

Callers 7

doNamesMethod · 0.45
doGetMethod · 0.45
doSetMethod · 0.45
doExpungeMethod · 0.45
statusUpdateMethod · 0.45
statusUpdateMethod · 0.45
updateMethod · 0.45

Calls 11

deferFunction · 0.85
OKClass · 0.85
jsonifyFunction · 0.85
NotAcceptableClass · 0.85
typeMethod · 0.80
fieldMethod · 0.80
createFunction · 0.50
stringifyFunction · 0.50
thenMethod · 0.45
selfMethod · 0.45
nameMethod · 0.45

Tested by 3

statusUpdateMethod · 0.36
statusUpdateMethod · 0.36
updateMethod · 0.36