| 547 | |
| 548 | |
| 549 | Future<bool> LogStorageProcess::___set( |
| 550 | const Entry& entry, |
| 551 | size_t diffs, |
| 552 | Option<Log::Position> position) |
| 553 | { |
| 554 | if (position.isNone()) { |
| 555 | starting = None(); // Reset 'starting' so we try again. |
| 556 | return false; |
| 557 | } |
| 558 | |
| 559 | // Update index so we don't bother reading anything before this |
| 560 | // position again (if we don't have to). |
| 561 | index = max(index, position); |
| 562 | |
| 563 | // Determine the position that represents the snapshot: if we just |
| 564 | // wrote a diff then we want to use the existing position of the |
| 565 | // snapshot, otherwise we just overwrote the snapshot so we should |
| 566 | // use the returned position (i.e., do nothing). |
| 567 | if (diffs > 0) { |
| 568 | CHECK(snapshots.contains(entry.name())); |
| 569 | position = snapshots.at(entry.name()).position; |
| 570 | } |
| 571 | |
| 572 | Snapshot snapshot(position.get(), entry, diffs); |
| 573 | snapshots.put(snapshot.entry.name(), snapshot); |
| 574 | |
| 575 | // And truncate the log if necessary. |
| 576 | truncate(); |
| 577 | |
| 578 | return true; |
| 579 | } |
| 580 | |
| 581 | |
| 582 | Future<bool> LogStorageProcess::expunge(const Entry& entry) |