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

Method _truncate

src/state/log.cpp:393–423  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

391
392
393Future<Nothing> LogStorageProcess::_truncate()
394{
395 // Determine the minimum necessary position for all the snapshots.
396 Option<Log::Position> minimum = None();
397
398 foreachvalue (const Snapshot& snapshot, snapshots) {
399 minimum = min(minimum, snapshot.position);
400 }
401
402 // TODO(benh): It's possible that the minimum position we've found
403 // will leave a lot of "unnecessary" entries in the log (e.g., a
404 // snapshot that has been overwritten at a later position). In this
405 // circumstance we should "compact/defrag" the log by writing/moving
406 // snapshots to the end of the log first applying any diffs as
407 // necessary.
408
409 CHECK_SOME(truncated);
410
411 if (minimum.isSome() && minimum.get() > truncated.get()) {
412 return writer.truncate(minimum.get())
413 .then(defer(self(), &Self::__truncate, minimum.get(), lambda::_1));
414
415 // NOTE: Any failure from Log::Writer::truncate doesn't propagate
416 // since the expectation is any subsequent Log::Writer::append
417 // would cause a failure. Furthermore, if the failure was
418 // temporary any subsequent Log::Writer::truncate should rectify a
419 // "missing" truncation.
420 }
421
422 return Nothing();
423}
424
425
426Future<Nothing> LogStorageProcess::__truncate(

Callers

nothing calls this directly

Calls 7

NoneClass · 0.85
deferFunction · 0.85
NothingClass · 0.85
isSomeMethod · 0.45
getMethod · 0.45
thenMethod · 0.45
truncateMethod · 0.45

Tested by

no test coverage detected