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

Method readFile

src/slave/http.cpp:3196–3245  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3194
3195
3196Future<Response> Http::readFile(
3197 const mesos::agent::Call& call,
3198 ContentType acceptType,
3199 const Option<Principal>& principal) const
3200{
3201 CHECK_EQ(mesos::agent::Call::READ_FILE, call.type());
3202
3203 const size_t offset = call.read_file().offset();
3204 const string& path = call.read_file().path();
3205
3206 LOG(INFO) << "Processing READ_FILE call for path '" << path << "'";
3207
3208 Option<size_t> length;
3209 if (call.read_file().has_length()) {
3210 length = call.read_file().length();
3211 }
3212
3213 return slave->files->read(offset, length, path, principal)
3214 .then([acceptType](const Try<tuple<size_t, string>, FilesError>& result)
3215 -> Future<Response> {
3216 if (result.isError()) {
3217 const FilesError& error = result.error();
3218
3219 switch (error.type) {
3220 case FilesError::Type::INVALID:
3221 return BadRequest(error.message);
3222
3223 case FilesError::Type::UNAUTHORIZED:
3224 return Forbidden(error.message);
3225
3226 case FilesError::Type::NOT_FOUND:
3227 return NotFound(error.message);
3228
3229 case FilesError::Type::UNKNOWN:
3230 return InternalServerError(error.message);
3231 }
3232
3233 UNREACHABLE();
3234 }
3235
3236 mesos::agent::Response response;
3237 response.set_type(mesos::agent::Response::READ_FILE);
3238
3239 response.mutable_read_file()->set_size(std::get<0>(result.get()));
3240 response.mutable_read_file()->set_data(std::get<1>(result.get()));
3241
3242 return OK(serialize(acceptType, evolve(response)),
3243 stringify(acceptType));
3244 });
3245}
3246
3247
3248Future<Response> Http::launchNestedContainer(

Callers

nothing calls this directly

Calls 15

BadRequestClass · 0.85
ForbiddenClass · 0.85
NotFoundClass · 0.85
InternalServerErrorClass · 0.85
OKClass · 0.85
typeMethod · 0.80
errorMethod · 0.65
serializeFunction · 0.50
evolveFunction · 0.50
stringifyFunction · 0.50
pathMethod · 0.45
thenMethod · 0.45

Tested by

no test coverage detected