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

Function parseExecutorRunPath

src/slave/paths.cpp:88–131  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

86
87
88Try<ExecutorRunPath> parseExecutorRunPath(
89 const string& _rootDir,
90 const string& dir)
91{
92 // TODO(josephw): Consider using `<regex>` here, which requires GCC 4.9+.
93
94 // Make sure there's a separator at the end of the `rootdir` so that
95 // we don't accidentally slice off part of a directory.
96 const string rootDir = path::join(_rootDir, "");
97
98 if (!strings::startsWith(dir, rootDir)) {
99 return Error(
100 "Directory '" + dir + "' does not fall under "
101 "the root directory: " + rootDir);
102 }
103
104 vector<string> tokens = strings::tokenize(
105 dir.substr(rootDir.size()), stringify(os::PATH_SEPARATOR));
106
107 // A complete executor run path consists of at least 8 tokens, which
108 // includes the four named directories and the four IDs.
109 if (tokens.size() < 8) {
110 return Error(
111 "Path after root directory is not long enough to be an "
112 "executor run path: " + path::join(tokens));
113 }
114
115 // All four named directories much match.
116 if (tokens[0] == SLAVES_DIR &&
117 tokens[2] == FRAMEWORKS_DIR &&
118 tokens[4] == EXECUTORS_DIR &&
119 tokens[6] == EXECUTOR_RUNS_DIR) {
120 ExecutorRunPath path;
121
122 path.slaveId.set_value(tokens[1]);
123 path.frameworkId.set_value(tokens[3]);
124 path.executorId.set_value(tokens[5]);
125 path.containerId.set_value(tokens[7]);
126
127 return path;
128 }
129
130 return Error("Could not parse executor run path from directory: " + dir);
131}
132
133
134string getMetaRootDir(const string& rootDir)

Callers 3

TEST_FFunction · 0.85
createMethod · 0.85
foreachFunction · 0.85

Calls 6

startsWithFunction · 0.85
tokenizeFunction · 0.85
joinFunction · 0.50
ErrorFunction · 0.50
stringifyFunction · 0.50
sizeMethod · 0.45

Tested by 1

TEST_FFunction · 0.68