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

Method expunge

src/state/leveldb.cpp:186–224  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

184
185
186Future<bool> LevelDBStorageProcess::expunge(const Entry& entry)
187{
188 if (error.isSome()) {
189 return Failure(error.get());
190 }
191
192 // We do a read first to make sure the version has not changed. This
193 // could be optimized in the future, for now it will probably hit
194 // the cache anyway.
195 Try<Option<Entry>> option = read(entry.name());
196
197 if (option.isError()) {
198 return Failure(option.error());
199 }
200
201 if (option->isNone()) {
202 return false;
203 }
204
205 if (id::UUID::fromBytes(option.get()->uuid()).get() !=
206 id::UUID::fromBytes(entry.uuid()).get()) {
207 return false;
208 }
209
210 // Note that the read (i.e., DB::Get) and DB::Delete are inherently
211 // "atomic" because only one db can be opened at a time, so there
212 // cannot be any writes that occur concurrently.
213
214 leveldb::WriteOptions options;
215 options.sync = true;
216
217 leveldb::Status status = db->Delete(options, entry.name());
218
219 if (!status.ok()) {
220 return Failure(status.ToString());
221 }
222
223 return true;
224}
225
226
227Try<Option<Entry>> LevelDBStorageProcess::read(const string& name)

Callers

nothing calls this directly

Calls 9

FailureClass · 0.85
errorMethod · 0.65
readFunction · 0.50
dispatchFunction · 0.50
isSomeMethod · 0.45
getMethod · 0.45
nameMethod · 0.45
isErrorMethod · 0.45
isNoneMethod · 0.45

Tested by

no test coverage detected