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

Method downloadSymbolizedProfile

3rdparty/libprocess/src/memory_profiler.cpp:821–875  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

819
820
821Future<http::Response> MemoryProfiler::downloadSymbolizedProfile(
822 const http::Request& request,
823 const Option<http::authentication::Principal>&)
824{
825 Result<time_t> requestedId = extractIdFromRequest(request);
826
827 // Verify that `id` has the correct version if it was explicitly passed.
828 if (requestedId.isError()) {
829 return http::BadRequest(
830 "Invalid parameter 'id': " + requestedId.error() + ".\n");
831 }
832
833 if (currentRun.isSome() && !requestedId.isSome()) {
834 return http::BadRequest(
835 "A profiling run is currently in progress. To download results of the"
836 " previous run, please pass an 'id' explicitly.\n");
837 }
838
839 if (rawProfile.isError()) {
840 return http::BadRequest(
841 "No source profile exists: " + rawProfile.error() + ".\n");
842 }
843
844 const string rawProfilePath = rawProfile->getPath();
845 const time_t rawProfileId = rawProfile->getId();
846
847 // Only requests for the latest available version are allowed.
848 if (requestedId.isSome() && (requestedId.get() != rawProfileId)) {
849 return http::BadRequest(
850 "Cannot serve requested id #" + stringify(requestedId.get()) + ".\n");
851 }
852
853 // Generate the profile for the latest available version
854 // or return the cached file on disk.
855 if (symbolizedProfile.isError() ||
856 (symbolizedProfile->getId() != rawProfileId)) {
857 symbolizedProfile = DiskArtifact::create(
858 SYMBOLIZED_PROFILE_FILENAME,
859 rawProfileId,
860 [rawProfilePath](const string& outputPath) -> Try<Nothing> {
861 return generateJeprofFile(
862 rawProfilePath,
863 "--text",
864 outputPath);
865 });
866 }
867
868 if (symbolizedProfile.isSome()) {
869 return symbolizedProfile->asHttp();
870 } else {
871 const string message = "Cannot generate file: " + symbolizedProfile.error();
872 LOG(WARNING) << message;
873 return http::BadRequest(message + ".\n");
874 }
875}
876
877
878Future<http::Response> MemoryProfiler::downloadGraphProfile(

Callers

nothing calls this directly

Calls 12

extractIdFromRequestFunction · 0.85
BadRequestClass · 0.85
generateJeprofFileFunction · 0.85
getIdMethod · 0.80
asHttpMethod · 0.80
errorMethod · 0.65
stringifyClass · 0.50
createFunction · 0.50
isErrorMethod · 0.45
isSomeMethod · 0.45
getPathMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected