Skip to content

Commit e550190

Browse files
paolococchidaverigby
authored andcommitted
Refactor [SR]: Remove the MockDurabilityMonitor class
The mock class was exposing mostly const-methods. We can just expose those to the DM public interface. Also, a DM instance is owned by VBucket. Given that in all DM tests we already have access to VBucket, then there is no much gain in hiding the DM's services. Change-Id: I806b18717b715c8d66092f7d0fa955ab165c5c0c Reviewed-on: http://review.couchbase.org/107933 Tested-by: Build Bot <[email protected]> Reviewed-by: Dave Rigby <[email protected]>
1 parent a489e4a commit e550190

File tree

10 files changed

+117
-140
lines changed

10 files changed

+117
-140
lines changed

engines/ep/src/durability/active_durability_monitor.h

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,8 @@ class ActiveDurabilityMonitor : public DurabilityMonitor {
110110
*/
111111
void addStats(const AddStatFn& addStat, const void* cookie) const override;
112112

113-
protected:
114113
size_t getNumTracked() const override;
115114

116-
void toOStream(std::ostream& os) const override;
117-
118115
/**
119116
* @return the size of FirstChain
120117
*/
@@ -149,6 +146,16 @@ class ActiveDurabilityMonitor : public DurabilityMonitor {
149146
*/
150147
int64_t getNodeAckSeqno(const std::string& node) const;
151148

149+
/**
150+
* Test only.
151+
*
152+
* @return the set of seqnos tracked by this DurabilityMonitor
153+
*/
154+
std::unordered_set<int64_t> getTrackedSeqnos() const;
155+
156+
protected:
157+
void toOStream(std::ostream& os) const override;
158+
152159
/**
153160
* Commit the given SyncWrite.
154161
*
@@ -163,13 +170,6 @@ class ActiveDurabilityMonitor : public DurabilityMonitor {
163170
*/
164171
void abort(const SyncWrite& sw);
165172

166-
/**
167-
* Test only.
168-
*
169-
* @return the set of seqnos tracked by this DurabilityMonitor
170-
*/
171-
std::unordered_set<int64_t> getTrackedSeqnos() const;
172-
173173
/**
174174
* Test only (for now; shortly this will be probably needed at rollback).
175175
* Removes all SyncWrites from the tracked container. Replication chain
@@ -271,4 +271,7 @@ class ActiveDurabilityMonitor : public DurabilityMonitor {
271271
folly::Synchronized<State> state;
272272

273273
const size_t maxReplicas = 3;
274+
275+
// @todo: Try to remove this, currenlty necessary for testing wipeTracked()
276+
friend class ActiveDurabilityMonitorTest;
274277
};

engines/ep/src/durability/durability_monitor.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,18 @@ class DurabilityMonitor {
3838
/// @return the high_prepared_seqno.
3939
virtual int64_t getHighPreparedSeqno() const = 0;
4040

41+
/**
42+
* @return the number of pending SyncWrite(s) currently tracked
43+
*/
44+
virtual size_t getNumTracked() const = 0;
45+
4146
protected:
4247
class SyncWrite;
4348
struct ReplicationChain;
4449
struct Position;
4550

4651
using Container = std::list<SyncWrite>;
4752

48-
/**
49-
* @return the number of pending SyncWrite(s) currently tracked
50-
*/
51-
virtual size_t getNumTracked() const = 0;
52-
5353
virtual void toOStream(std::ostream& os) const = 0;
5454

5555
friend std::ostream& operator<<(std::ostream& os,

engines/ep/src/vbucket.cc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -577,11 +577,16 @@ void VBucket::setReplicationTopology(const nlohmann::json& topology) {
577577
}
578578
}
579579

580-
ActiveDurabilityMonitor& VBucket::getActiveDM() const {
580+
ActiveDurabilityMonitor& VBucket::getActiveDM() {
581581
Expects(state == vbucket_state_active);
582582
return dynamic_cast<ActiveDurabilityMonitor&>(*durabilityMonitor);
583583
}
584584

585+
PassiveDurabilityMonitor& VBucket::getPassiveDM() {
586+
Expects(state == vbucket_state_replica);
587+
return dynamic_cast<PassiveDurabilityMonitor&>(*durabilityMonitor);
588+
}
589+
585590
std::unique_ptr<DurabilityMonitor> VBucket::makeDurabilityMonitor() {
586591
if (state == vbucket_state_active) {
587592
return std::make_unique<ActiveDurabilityMonitor>(*this);

engines/ep/src/vbucket.h

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,16 @@
3838
#include <queue>
3939

4040
class ActiveDurabilityMonitor;
41-
class EPStats;
4241
class CheckpointManager;
4342
class ConflictResolution;
4443
class Configuration;
44+
class DCPBackfill;
4545
class DurabilityMonitor;
46+
class EPStats;
47+
class EventuallyPersistentEngine;
4648
class ItemMetaData;
49+
class PassiveDurabilityMonitor;
4750
class PreLinkDocumentContext;
48-
class EventuallyPersistentEngine;
49-
class DCPBackfill;
5051
class RollbackResult;
5152
class VBucketBGFetchItem;
5253
struct vbucket_state;
@@ -1844,7 +1845,12 @@ class VBucket : public std::enable_shared_from_this<VBucket> {
18441845
/**
18451846
* @return a reference (if valid, i.e. vbstate=active) to the Active DM
18461847
*/
1847-
ActiveDurabilityMonitor& getActiveDM() const;
1848+
ActiveDurabilityMonitor& getActiveDM();
1849+
1850+
/**
1851+
* @return a reference (if valid, i.e. vbstate=replica) to the Passive DM
1852+
*/
1853+
PassiveDurabilityMonitor& getPassiveDM();
18481854

18491855
/**
18501856
* @return a new instance of DurabilityMonitor, Active or Passive depending
@@ -2185,11 +2191,10 @@ class VBucket : public std::enable_shared_from_this<VBucket> {
21852191

21862192
static double mutationMemThreshold;
21872193

2188-
friend class ActiveDurabilityMonitorTest;
21892194
friend class DurabilityMonitorTest;
2190-
friend class PassiveDurabilityMonitorTest;
21912195
friend class SingleThreadedActiveStreamTest;
21922196
friend class VBucketTestBase;
2197+
friend class VBucketTestIntrospector;
21932198
friend class VBucketDurabilityTest;
21942199

21952200
DISALLOW_COPY_AND_ASSIGN(VBucket);

engines/ep/tests/mock/mock_durability_monitor.h

Lines changed: 0 additions & 61 deletions
This file was deleted.

0 commit comments

Comments
 (0)