1 /* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2 /*
3  *     Copyright 2018 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 #pragma once
19 
20 #include "item.h"
21 #include "paging_visitor.h"
22 #include <string>
23 
24 /**
25  * Mock PagingVisitor class.  Provide access to ItemEviction data structure.
26  */
27 class MockPagingVisitor : public PagingVisitor {
28 public:
MockPagingVisitor(KVBucket& s, EPStats& st, double pcnt, std::shared_ptr<std::atomic<bool>>& sfin, pager_type_t caller, bool pause, double bias, const VBucketFilter& vbFilter, std::atomic<item_pager_phase>* phase, bool _isEphemeral, size_t agePercentage, size_t freqCounterAgeThreshold)29     MockPagingVisitor(KVBucket& s,
30                       EPStats& st,
31                       double pcnt,
32                       std::shared_ptr<std::atomic<bool>>& sfin,
33                       pager_type_t caller,
34                       bool pause,
35                       double bias,
36                       const VBucketFilter& vbFilter,
37                       std::atomic<item_pager_phase>* phase,
38                       bool _isEphemeral,
39                       size_t agePercentage,
40                       size_t freqCounterAgeThreshold)
41         : PagingVisitor(s,
42                         st,
43                         pcnt,
44                         sfin,
45                         caller,
46                         pause,
47                         bias,
48                         vbFilter,
49                         phase,
50                         _isEphemeral,
51                         agePercentage,
52                         freqCounterAgeThreshold) {
53     }
54 
getItemEviction()55     ItemEviction& getItemEviction() {
56         return itemEviction;
57     }
58 
getEjected() const59     size_t getEjected() const {
60         return ejected;
61     }
62 
setFreqCounterThreshold(uint16_t threshold)63     void setFreqCounterThreshold(uint16_t threshold) {
64         freqCounterThreshold = threshold;
65     }
66 
setCurrentBucket(VBucketPtr _currentBucket)67     void setCurrentBucket(VBucketPtr _currentBucket) {
68         currentBucket = _currentBucket;
69     }
70 };
71