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

Function createSlaveDirectory

src/slave/paths.cpp:904–935  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

902
903
904string createSlaveDirectory(
905 const string& rootDir,
906 const SlaveID& slaveId)
907{
908 // `slaveId` should be valid because it's assigned by the master but
909 // we do a sanity check here before using it to create a directory.
910 CHECK_NONE(common::validation::validateSlaveID(slaveId));
911
912 const string directory = getSlavePath(rootDir, slaveId);
913
914 Try<Nothing> mkdir = os::mkdir(directory);
915
916 CHECK_SOME(mkdir)
917 << "Failed to create agent directory '" << directory << "'";
918
919 // Remove the previous "latest" symlink.
920 const string latest = getLatestSlavePath(rootDir);
921
922 if (os::exists(latest)) {
923 CHECK_SOME(os::rm(latest))
924 << "Failed to remove latest symlink '" << latest << "'";
925 }
926
927 // Symlink the new slave directory to "latest".
928 Try<Nothing> symlink = ::fs::symlink(directory, latest);
929
930 CHECK_SOME(symlink)
931 << "Failed to symlink directory '" << directory
932 << "' to '" << latest << "'";
933
934 return directory;
935}
936
937
938string createResourceProviderDirectory(

Callers 1

registeredMethod · 0.85

Calls 7

getSlavePathFunction · 0.85
getLatestSlavePathFunction · 0.85
validateSlaveIDFunction · 0.50
mkdirFunction · 0.50
existsFunction · 0.50
rmFunction · 0.50
symlinkFunction · 0.50

Tested by

no test coverage detected