1 /* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2 /*
3  *     Copyright 2019 Couchbase, Inc
4  *
5  *   Licensed under the Apache License, Version 2.0 (the "License");
6  *   you may not use this file except in compliance with the License.
7  *   You may obtain a copy of the License at
8  *
9  *       http://www.apache.org/licenses/LICENSE-2.0
10  *
11  *   Unless required by applicable law or agreed to in writing, software
12  *   distributed under the License is distributed on an "AS IS" BASIS,
13  *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  *   See the License for the specific language governing permissions and
15  *   limitations under the License.
16  */
17 
18 #include "mock_ephemeral_bucket.h"
19 #include "ep_engine.h"
20 #include "executorpool.h"
21 #include "failover-table.h"
22 #include "mock_checkpoint_manager.h"
23 
makeVBucket( Vbid id, vbucket_state_t state, KVShard* shard, std::unique_ptr<FailoverTable> table, NewSeqnoCallback newSeqnoCb, std::unique_ptr<Collections::VB::Manifest> manifest, vbucket_state_t initState, int64_t lastSeqno, uint64_t lastSnapStart, uint64_t lastSnapEnd, uint64_t purgeSeqno, uint64_t maxCas, int64_t hlcEpochSeqno, bool mightContainXattrs, const nlohmann::json& replicationTopology, uint64_t maxVisibleSeqno)24 VBucketPtr MockEphemeralBucket::makeVBucket(
25         Vbid id,
26         vbucket_state_t state,
27         KVShard* shard,
28         std::unique_ptr<FailoverTable> table,
29         NewSeqnoCallback newSeqnoCb,
30         std::unique_ptr<Collections::VB::Manifest> manifest,
31         vbucket_state_t initState,
32         int64_t lastSeqno,
33         uint64_t lastSnapStart,
34         uint64_t lastSnapEnd,
35         uint64_t purgeSeqno,
36         uint64_t maxCas,
37         int64_t hlcEpochSeqno,
38         bool mightContainXattrs,
39         const nlohmann::json& replicationTopology,
40         uint64_t maxVisibleSeqno) {
41     auto vptr = EphemeralBucket::makeVBucket(id,
42                                              state,
43                                              shard,
44                                              std::move(table),
45                                              std::move(newSeqnoCb),
46                                              std::move(manifest),
47                                              initState,
48                                              lastSeqno,
49                                              lastSnapStart,
50                                              lastSnapEnd,
51                                              purgeSeqno,
52                                              maxCas,
53                                              hlcEpochSeqno,
54                                              mightContainXattrs,
55                                              replicationTopology,
56                                              maxVisibleSeqno);
57 
58     vptr->checkpointManager = std::make_unique<MockCheckpointManager>(
59             stats,
60             id,
61             engine.getCheckpointConfig(),
62             lastSeqno,
63             lastSnapStart,
64             lastSnapEnd,
65             maxVisibleSeqno,
66             /*flusher callback*/ nullptr);
67     return vptr;
68 }
69 
setDurabilityCompletionTask( std::shared_ptr<DurabilityCompletionTask> task)70 void MockEphemeralBucket::setDurabilityCompletionTask(
71         std::shared_ptr<DurabilityCompletionTask> task) {
72     durabilityCompletionTask = task;
73 }
74