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

Method getTasks

src/slave/http.cpp:2061–2135  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2059
2060
2061Future<Response> Http::getTasks(
2062 const mesos::agent::Call& call,
2063 ContentType contentType,
2064 const Option<Principal>& principal) const
2065{
2066 CHECK_EQ(mesos::agent::Call::GET_TASKS, call.type());
2067
2068 LOG(INFO) << "Processing GET_TASKS call";
2069
2070 return ObjectApprovers::create(
2071 slave->authorizer,
2072 principal,
2073 {VIEW_FRAMEWORK, VIEW_TASK, VIEW_EXECUTOR})
2074 .then(defer(
2075 slave->self(),
2076 [this, contentType](
2077 const Owned<ObjectApprovers>& approvers) -> Response {
2078 // Serialize the following message:
2079 //
2080 // v1::agent::Response response;
2081 // response.set_type(mesos::agent::Response::GET_TASKS);
2082 // *response.mutable_get_tasks() = _...;
2083
2084 switch (contentType) {
2085 case ContentType::PROTOBUF: {
2086 string output;
2087 google::protobuf::io::StringOutputStream stream(&output);
2088 google::protobuf::io::CodedOutputStream writer(&stream);
2089
2090 WireFormatLite::WriteEnum(
2091 v1::agent::Response::kTypeFieldNumber,
2092 v1::agent::Response::GET_TASKS,
2093 &writer);
2094
2095 WireFormatLite::WriteBytes(
2096 v1::agent::Response::kGetTasksFieldNumber,
2097 serializeGetTasks(approvers),
2098 &writer);
2099
2100 // We must manually trim the unused buffer space since
2101 // we use the string before the coded output stream is
2102 // destructed.
2103 writer.Trim();
2104
2105 return OK(std::move(output), stringify(contentType));
2106 }
2107
2108 case ContentType::JSON: {
2109 string body = jsonify([&](JSON::ObjectWriter* writer) {
2110 const google::protobuf::Descriptor* descriptor =
2111 v1::agent::Response::descriptor();
2112
2113 int field;
2114
2115 field = v1::agent::Response::kTypeFieldNumber;
2116 writer->field(
2117 descriptor->FindFieldByNumber(field)->name(),
2118 v1::agent::Response::Type_Name(

Callers

nothing calls this directly

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

no test coverage detected