|
| 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_ep_bucket.h" |
| 19 | +#include "ep_engine.h" |
| 20 | +#include "executorpool.h" |
| 21 | +#include "failover-table.h" |
| 22 | +#include "mock_checkpoint_manager.h" |
| 23 | +#include "mock_item_freq_decayer.h" |
| 24 | + |
| 25 | +void MockEPBucket::createItemFreqDecayerTask() { |
| 26 | + Configuration& config = engine.getConfiguration(); |
| 27 | + itemFreqDecayerTask = std::make_shared<MockItemFreqDecayerTask>( |
| 28 | + &engine, config.getItemFreqDecayerPercent()); |
| 29 | +} |
| 30 | + |
| 31 | +void MockEPBucket::disableItemFreqDecayerTask() { |
| 32 | + ExecutorPool::get()->cancel(itemFreqDecayerTask->getId()); |
| 33 | +} |
| 34 | + |
| 35 | +MockItemFreqDecayerTask* MockEPBucket::getMockItemFreqDecayerTask() { |
| 36 | + return dynamic_cast<MockItemFreqDecayerTask*>(itemFreqDecayerTask.get()); |
| 37 | +} |
| 38 | + |
| 39 | +VBucketPtr MockEPBucket::makeVBucket( |
| 40 | + Vbid id, |
| 41 | + vbucket_state_t state, |
| 42 | + KVShard* shard, |
| 43 | + std::unique_ptr<FailoverTable> table, |
| 44 | + NewSeqnoCallback newSeqnoCb, |
| 45 | + std::unique_ptr<Collections::VB::Manifest> manifest, |
| 46 | + vbucket_state_t initState, |
| 47 | + int64_t lastSeqno, |
| 48 | + uint64_t lastSnapStart, |
| 49 | + uint64_t lastSnapEnd, |
| 50 | + uint64_t purgeSeqno, |
| 51 | + uint64_t maxCas, |
| 52 | + int64_t hlcEpochSeqno, |
| 53 | + bool mightContainXattrs, |
| 54 | + const nlohmann::json& replicationTopology) { |
| 55 | + auto vptr = EPBucket::makeVBucket(id, |
| 56 | + state, |
| 57 | + shard, |
| 58 | + std::move(table), |
| 59 | + std::move(newSeqnoCb), |
| 60 | + std::move(manifest), |
| 61 | + initState, |
| 62 | + lastSeqno, |
| 63 | + lastSnapStart, |
| 64 | + lastSnapEnd, |
| 65 | + purgeSeqno, |
| 66 | + maxCas, |
| 67 | + hlcEpochSeqno, |
| 68 | + mightContainXattrs, |
| 69 | + replicationTopology); |
| 70 | + // Create a MockCheckpointManager. |
| 71 | + vptr->checkpointManager = std::make_unique<MockCheckpointManager>( |
| 72 | + stats, |
| 73 | + id, |
| 74 | + engine.getCheckpointConfig(), |
| 75 | + lastSeqno, |
| 76 | + lastSnapStart, |
| 77 | + lastSnapEnd, |
| 78 | + /*flusher callback*/ nullptr); |
| 79 | + return vptr; |
| 80 | +} |
0 commit comments