1#include "mock_ephemeral_vb.h"
2
3#include "ephemeral_tombstone_purger.h"
4#include "failover-table.h"
5
6MockEphemeralVBucket::MockEphemeralVBucket(
7        Vbid i,
8        vbucket_state_t newState,
9        EPStats& st,
10        CheckpointConfig& chkConfig,
11        KVShard* kvshard,
12        int64_t lastSeqno,
13        uint64_t lastSnapStart,
14        uint64_t lastSnapEnd,
15        std::unique_ptr<FailoverTable> table,
16        NewSeqnoCallback newSeqnoCb,
17        SyncWriteResolvedCallback syncWriteResolvedCb,
18        SyncWriteCompleteCallback syncWriteCb,
19        SeqnoAckCallback seqnoAckCb,
20        Configuration& config,
21        EvictionPolicy evictionPolicy)
22    : EphemeralVBucket(i,
23                       newState,
24                       st,
25                       chkConfig,
26                       kvshard,
27                       lastSeqno,
28                       lastSnapStart,
29                       lastSnapEnd,
30                       std::move(table),
31                       std::move(newSeqnoCb),
32                       syncWriteResolvedCb,
33                       syncWriteCb,
34                       seqnoAckCb,
35                       config,
36                       evictionPolicy,
37                       std::make_unique<Collections::VB::Manifest>()) {
38    /* we want MockBasicLinkedList instead to call certain non-public
39       APIs of BasicLinkedList in ephemeral vbucket */
40    this->seqList = std::make_unique<MockBasicLinkedList>(st);
41    mockLL = dynamic_cast<MockBasicLinkedList*>((this->seqList).get());
42}
43
44size_t MockEphemeralVBucket::markOldTombstonesStale(rel_time_t purgeAge) {
45    // Mark all deleted items in the HashTable which can be purged as Stale -
46    // this removes them from the HashTable, transferring ownership to
47    // SequenceList.
48
49    HTTombstonePurger purger(purgeAge);
50    purger.setCurrentVBucket(*this);
51    ht.visit(purger);
52
53    return purger.getNumItemsMarkedStale();
54}
55
56void MockEphemeralVBucket::public_doCollectionsStats(
57        const Collections::VB::Manifest::CachingReadHandle& cHandle,
58        const VBNotifyCtx& notifyCtx) {
59    VBucket::doCollectionsStats(cHandle, notifyCtx);
60}
61