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

Method state

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

Source from the content-addressed store, hash-verified

956
957
958Future<http::Response> MemoryProfiler::state(
959 const http::Request& request,
960 const Option<http::authentication::Principal>&)
961{
962 bool detected = detectJemalloc();
963
964 JSON::Object state;
965
966 {
967 // State unrelated to jemalloc.
968 JSON::Object profilerState;
969 profilerState.values["jemalloc_detected"] = detected;
970
971 profilerState.values["tmp_dir"] = stringify(
972 temporaryDirectory.getOrElse("Not yet generated"));
973
974 {
975 JSON::Object runInformation;
976 if (currentRun.isSome()) {
977 runInformation.values["id"] = currentRun->id;
978 runInformation.values["remaining_seconds"] =
979 currentRun->timer.timeout().remaining().secs();
980 } else if (rawProfile.isSome()) {
981 runInformation.values["id"] = rawProfile->getId();
982 runInformation.values["remaining_seconds"] = 0;
983 } else {
984 runInformation.values["id"] = JSON::Null();
985 }
986
987 profilerState.values["current_run"] = std::move(runInformation);
988 }
989
990 state.values["memory_profiler"] = std::move(profilerState);
991 }
992
993 if (!detected) {
994 return http::OK(state);
995 }
996
997 {
998 // Holds relevant parts of the current jemalloc state.
999 JSON::Object jemallocState;
1000
1001 {
1002 // Holds malloc configuration from various sources.
1003 JSON::Object mallocConf;
1004
1005 // User-specified malloc configuration that was added via
1006 // the `MALLOC_CONF` environment variable.
1007 mallocConf.values["environment"] =
1008 os::getenv("MALLOC_CONF").getOrElse("");
1009
1010 // Compile-time malloc configuration that was added at build time via
1011 // the `--with-malloc-conf` flag.
1012 Try<const char*> builtinMallocConf = readJemallocSetting<const char*>(
1013 "config.malloc_conf");
1014
1015 if (builtinMallocConf.isError()) {

Callers

nothing calls this directly

Calls 14

detectJemallocFunction · 0.85
OKClass · 0.85
getOrElseMethod · 0.80
getIdMethod · 0.80
errorMethod · 0.65
stringifyClass · 0.50
NullClass · 0.50
getenvFunction · 0.50
isSomeMethod · 0.45
secsMethod · 0.45
remainingMethod · 0.45
timeoutMethod · 0.45

Tested by

no test coverage detected