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

Method recover

src/slave/state.cpp:141–280  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

139
140
141Try<SlaveState> SlaveState::recover(
142 const string& rootDir,
143 const SlaveID& slaveId,
144 bool strict,
145 bool rebooted)
146{
147 SlaveState state;
148 state.id = slaveId;
149
150 // Read the slave info.
151 const string path = paths::getSlaveInfoPath(rootDir, slaveId);
152 if (!os::exists(path)) {
153 // This could happen if the slave died before it registered with
154 // the master.
155 LOG(WARNING) << "Failed to find agent info file '" << path << "'";
156 return state;
157 }
158
159 Result<SlaveInfo> slaveInfo = state::read<SlaveInfo>(path);
160
161 if (slaveInfo.isError()) {
162 const string message = "Failed to read agent info from '" + path + "': " +
163 slaveInfo.error();
164 if (strict) {
165 return Error(message);
166 } else {
167 LOG(WARNING) << message;
168 state.errors++;
169 return state;
170 }
171 }
172
173 if (slaveInfo.isNone()) {
174 // This could happen if the slave is hard rebooted after the file is created
175 // but before the data is synced on disk.
176 LOG(WARNING) << "Found empty agent info file '" << path << "'";
177 return state;
178 }
179
180 state.info = slaveInfo.get();
181
182 // Find the frameworks.
183 Try<list<string>> frameworks = paths::getFrameworkPaths(rootDir, slaveId);
184
185 if (frameworks.isError()) {
186 return Error("Failed to find frameworks for agent " + slaveId.value() +
187 ": " + frameworks.error());
188 }
189
190 // Recover each of the frameworks.
191 foreach (const string& path, frameworks.get()) {
192 FrameworkID frameworkId;
193 frameworkId.set_value(Path(path).basename());
194
195 Try<FrameworkState> framework =
196 FrameworkState::recover(rootDir, slaveId, frameworkId, strict, rebooted);
197
198 if (framework.isError()) {

Callers 2

callMethod · 0.45
foreachpairFunction · 0.45

Calls 15

getSlaveInfoPathFunction · 0.85
getFrameworkPathsFunction · 0.85
getDrainConfigPathFunction · 0.85
getResourceStatePathFunction · 0.85
getFrameworkInfoPathFunction · 0.85
getFrameworkPidPathFunction · 0.85
getExecutorPathsFunction · 0.85
getExecutorRunPathsFunction · 0.85
getExecutorInfoPathFunction · 0.85
endsWithFunction · 0.85

Tested by

no test coverage detected