Refactor: Replace RCPtr<VBucket> with VBucketPtr 56/76556/3
authorJim Walker <jim@couchbase.com>
Mon, 10 Apr 2017 14:03:34 +0000 (15:03 +0100)
committerDave Rigby <daver@couchbase.com>
Tue, 11 Apr 2017 09:44:17 +0000 (09:44 +0000)
Declare a named type for shared pointers to VBuckets.

Change-Id: I93e121f86199617c1651c5896efc7df7cd99ea83
Reviewed-on: http://review.couchbase.org/76556
Reviewed-by: Dave Rigby <daver@couchbase.com>
Tested-by: Build Bot <build@couchbase.com>
45 files changed:
src/access_scanner.cc
src/backfill.cc
src/backfill.h
src/bgfetcher.cc
src/checkpoint_remover.cc
src/dcp/backfill-manager.cc
src/dcp/backfill_disk.cc
src/dcp/consumer.cc
src/dcp/producer.cc
src/dcp/stream.cc
src/dcp/stream.h
src/ep_bucket.cc
src/ep_bucket.h
src/ep_engine.cc
src/ep_engine.h
src/ephemeral_bucket.cc
src/ephemeral_bucket.h
src/ephemeral_vb_count_visitor.cc
src/ephemeral_vb_count_visitor.h
src/flusher.cc
src/htresizer.cc
src/item_pager.cc
src/kv_bucket.cc
src/kv_bucket.h
src/kv_bucket_iface.h
src/kvshard.cc
src/kvshard.h
src/mutation_log.cc
src/tapconnection.cc
src/tapconnmap.cc
src/vb_count_visitor.cc
src/vb_count_visitor.h
src/vbucket.h
src/vbucketmap.cc
src/vbucketmap.h
src/vbucketmemorydeletiontask.cc
src/vbucketmemorydeletiontask.h
src/warmup.cc
tests/mock/mock_stream.h
tests/module_tests/UNUSED_vbucket_test.cc
tests/module_tests/collections/evp_store_collections_test.cc
tests/module_tests/dcp_test.cc
tests/module_tests/evp_store_rollback_test.cc
tests/module_tests/evp_store_single_threaded_test.cc
tests/module_tests/evp_store_test.cc

index 8d4bca9..415797b 100644 (file)
@@ -91,7 +91,7 @@ public:
         accessed.clear();
     }
 
-    void visitBucket(RCPtr<VBucket> &vb) override {
+    void visitBucket(VBucketPtr &vb) override {
         currentBucket = vb;
         update();
 
@@ -208,7 +208,7 @@ private:
     // The number of items to scan before we pause
     const uint64_t items_to_scan;
 
-    RCPtr<VBucket> currentBucket;
+    VBucketPtr currentBucket;
 };
 
 AccessScanner::AccessScanner(KVBucket& _store,
index cf52429..750c633 100644 (file)
@@ -50,7 +50,7 @@ private:
 };
 
 void ItemResidentCallback::callback(CacheLookup &lookup) {
-    RCPtr<VBucket> vb = engine->getKVBucket()->getVBucket(
+    VBucketPtr vb = engine->getKVBucket()->getVBucket(
                                                         lookup.getVBucketId());
     if (!vb) {
         setStatus(ENGINE_SUCCESS);
@@ -208,7 +208,7 @@ BackFillVisitor::BackFillVisitor(EventuallyPersistentEngine* e,
       valid(true) {
 }
 
-void BackFillVisitor::visitBucket(RCPtr<VBucket> &vb) {
+void BackFillVisitor::visitBucket(VBucketPtr &vb) {
     if (vBucketFilter(vb->getId())) {
         double num_items = static_cast<double>(vb->getNumItems());
 
index ed8c6c7..c264283 100644 (file)
@@ -80,7 +80,7 @@ public:
 
     virtual ~BackFillVisitor() {}
 
-    void visitBucket(RCPtr<VBucket> &vb) override;
+    void visitBucket(VBucketPtr &vb) override;
 
     void complete(void) override;
 
index 0ce8220..7b503fc 100644 (file)
@@ -116,7 +116,7 @@ bool BgFetcher::run(GlobalTask *task) {
     }
 
     for (const uint16_t vbId : bg_vbs) {
-        RCPtr<VBucket> vb = shard->getBucket(vbId);
+        VBucketPtr vb = shard->getBucket(vbId);
         if (vb) {
             // Requeue the bg fetch task if vbucket DB file is not created yet.
             if (vb->isBucketCreation()) {
@@ -154,7 +154,7 @@ bool BgFetcher::run(GlobalTask *task) {
 
 bool BgFetcher::pendingJob() const {
     for (const auto vbid : shard->getVBuckets()) {
-        RCPtr<VBucket> vb = shard->getBucket(vbid);
+        VBucketPtr vb = shard->getBucket(vbid);
         if (vb && vb->hasPendingBGFetchItems()) {
             return true;
         }
index 2a92e1b..8690435 100644 (file)
@@ -42,7 +42,7 @@ public:
         : store(s), stats(st), removed(0), taskStart(gethrtime()),
           wasHighMemoryUsage(s->isMemoryUsageTooHigh()), stateFinalizer(sfin) {}
 
-    void visitBucket(RCPtr<VBucket> &vb) override {
+    void visitBucket(VBucketPtr &vb) override {
         bool newCheckpointCreated = false;
         removed = vb->checkpointManager.removeClosedUnrefCheckpoints(
                 *vb, newCheckpointCreated);
@@ -108,7 +108,7 @@ void ClosedUnrefCheckpointRemoverTask::cursorDroppingIfNeeded(void) {
         for (const auto& it: vbuckets) {
             if (memoryCleared < amountOfMemoryToClear) {
                 uint16_t vbid = it.first;
-                RCPtr<VBucket> vb = kvBucket->getVBucket(vbid);
+                VBucketPtr vb = kvBucket->getVBucket(vbid);
                 if (vb) {
                     // Get a list of cursors that can be dropped from the
                     // vbucket's checkpoint manager, so as to unreference
index b945bc9..1cf66e8 100644 (file)
@@ -282,7 +282,7 @@ backfill_status_t BackfillManager::backfill() {
             break;
         case backfill_snooze: {
             uint16_t vbid = backfill->getVBucketId();
-            RCPtr<VBucket> vb = engine.getVBucket(vbid);
+            VBucketPtr vb = engine.getVBucket(vbid);
             if (vb) {
                 snoozingBackfills.push_back(
                         std::make_pair(ep_current_time(), std::move(backfill)));
index 588041e..3379ac8 100644 (file)
@@ -49,7 +49,7 @@ CacheCallback::CacheCallback(EventuallyPersistentEngine& e, active_stream_t& s)
 }
 
 void CacheCallback::callback(CacheLookup& lookup) {
-    RCPtr<VBucket> vb =
+    VBucketPtr vb =
             engine_.getKVBucket()->getVBucket(lookup.getVBucketId());
     if (!vb) {
         setStatus(ENGINE_SUCCESS);
index af25bcc..ce529c1 100644 (file)
@@ -159,7 +159,7 @@ ENGINE_ERROR_CODE DcpConsumer::addStream(uint32_t opaque, uint16_t vbucket,
         return ENGINE_DISCONNECT;
     }
 
-    RCPtr<VBucket> vb = engine_.getVBucket(vbucket);
+    VBucketPtr vb = engine_.getVBucket(vbucket);
     if (!vb) {
         logger.log(EXTENSION_LOG_WARNING,
             "(vb %d) Add stream failed because this vbucket doesn't exist",
@@ -763,7 +763,7 @@ bool DcpConsumer::doRollback(uint32_t opaque, uint16_t vbid,
                 "code from EpStore::rollback: " + std::to_string(err));
     }
 
-    RCPtr<VBucket> vb = engine_.getVBucket(vbid);
+    VBucketPtr vb = engine_.getVBucket(vbid);
     auto stream = findStream(vbid);
     if (stream) {
         stream->reconnectStream(vb, opaque, vb->getHighSeqno());
@@ -959,7 +959,7 @@ void DcpConsumer::streamAccepted(uint32_t opaque, uint16_t status, uint8_t* body
         auto stream = findStream(vbucket);
         if (stream && stream->getOpaque() == opaque && stream->isPending()) {
             if (status == ENGINE_SUCCESS) {
-                RCPtr<VBucket> vb = engine_.getVBucket(vbucket);
+                VBucketPtr vb = engine_.getVBucket(vbucket);
                 vb->failovers->replaceFailoverLog(body, bodylen);
                 KVBucketIface* kvBucket = engine_.getKVBucket();
                 kvBucket->scheduleVBStatePersist(vbucket);
index 322c214..e2b54a5 100644 (file)
@@ -226,7 +226,7 @@ ENGINE_ERROR_CODE DcpProducer::streamRequest(uint32_t flags,
         return ENGINE_DISCONNECT;
     }
 
-    RCPtr<VBucket> vb = engine_.getVBucket(vbucket);
+    VBucketPtr vb = engine_.getVBucket(vbucket);
     if (!vb) {
         LOG(EXTENSION_LOG_WARNING, "%s (vb %d) Stream request failed because "
             "this vbucket doesn't exist", logHeader(), vbucket);
@@ -408,7 +408,7 @@ ENGINE_ERROR_CODE DcpProducer::getFailoverLog(uint32_t opaque, uint16_t vbucket,
         return ENGINE_DISCONNECT;
     }
 
-    RCPtr<VBucket> vb = engine_.getVBucket(vbucket);
+    VBucketPtr vb = engine_.getVBucket(vbucket);
     if (!vb) {
         LOG(EXTENSION_LOG_WARNING, "%s (vb %d) Get Failover Log failed "
             "because this vbucket doesn't exist", logHeader(), vbucket);
index 7a621d4..7bce4dd 100644 (file)
@@ -263,7 +263,7 @@ ActiveStream::ActiveStream(EventuallyPersistentEngine* e,
         end_seqno_ = dcpMaxSeqno;
     }
 
-    RCPtr<VBucket> vbucket = engine->getVBucket(vb);
+    VBucketPtr vbucket = engine->getVBucket(vb);
     if (vbucket) {
         ReaderLockHolder rlh(vbucket->getStateLock());
         if (vbucket->getState() == vbucket_state_replica) {
@@ -358,7 +358,7 @@ void ActiveStream::markDiskSnapshot(uint64_t startSeqno, uint64_t endSeqno) {
         startSeqno = std::min(snap_start_seqno_, startSeqno);
         firstMarkerSent = true;
 
-        RCPtr<VBucket> vb = engine->getVBucket(vb_);
+        VBucketPtr vb = engine->getVBucket(vb_);
         if (!vb) {
             producer->getLogger().log(EXTENSION_LOG_WARNING,"(vb %" PRIu16 ") "
                                       "ActiveStream::markDiskSnapshot, vbucket "
@@ -504,7 +504,7 @@ void ActiveStream::setVBucketStateAckRecieved() {
 
             engine->getKVBucket()->setVBucketState(vb_, vbucket_state_dead,
                                                    false, false);
-            RCPtr<VBucket> vbucket = engine->getVBucket(vb_);
+            VBucketPtr vbucket = engine->getVBucket(vb_);
             producer->getLogger().log(EXTENSION_LOG_NOTICE,
                 "(vb %" PRIu16 ") Vbucket marked as dead, last sent seqno: %"
                 PRIu64 ", high seqno: %" PRIu64,
@@ -593,7 +593,7 @@ DcpResponse* ActiveStream::inMemoryPhase() {
 
 DcpResponse* ActiveStream::takeoverSendPhase() {
 
-    RCPtr<VBucket> vb = engine->getVBucket(vb_);
+    VBucketPtr vb = engine->getVBucket(vb_);
     if (vb && takeoverStart != 0 &&
         !vb->isTakeoverBackedUp() &&
         (ep_current_time() - takeoverStart) > takeoverSendMaxTime) {
@@ -786,7 +786,7 @@ DcpResponse* ActiveStream::nextQueuedItem() {
 }
 
 bool ActiveStream::nextCheckpointItem() {
-    RCPtr<VBucket> vbucket = engine->getVBucket(vb_);
+    VBucketPtr vbucket = engine->getVBucket(vb_);
     if (vbucket && vbucket->checkpointManager.getNumItemsForCursor(name_) > 0) {
         // schedule this stream to build the next checkpoint
         producer->scheduleCheckpointProcessorTask(this);
@@ -855,7 +855,7 @@ void ActiveStreamCheckpointProcessorTask::clearQueues() {
 }
 
 void ActiveStream::nextCheckpointItemTask() {
-    RCPtr<VBucket> vbucket = engine->getVBucket(vb_);
+    VBucketPtr vbucket = engine->getVBucket(vb_);
     if (vbucket) {
         std::vector<queued_item> items;
         getOutstandingItems(vbucket, items);
@@ -869,7 +869,7 @@ void ActiveStream::nextCheckpointItemTask() {
     }
 }
 
-void ActiveStream::getOutstandingItems(RCPtr<VBucket> &vb,
+void ActiveStream::getOutstandingItems(VBucketPtr &vb,
                                        std::vector<queued_item> &items) {
     // Commencing item processing - set guard flag.
     chkptItemsExtractionInProgress.store(true);
@@ -1063,7 +1063,7 @@ void ActiveStream::scheduleBackfill_UNLOCKED(bool reschedule) {
         return;
     }
 
-    RCPtr<VBucket> vbucket = engine->getVBucket(vb_);
+    VBucketPtr vbucket = engine->getVBucket(vb_);
     if (!vbucket) {
         producer->getLogger().log(EXTENSION_LOG_WARNING,
                                   "(vb %" PRIu16 ") Failed to schedule "
@@ -1367,7 +1367,7 @@ void ActiveStream::transitionState(StreamState newState) {
             break;
         case StreamState::Dead:
             {
-                RCPtr<VBucket> vb = engine->getVBucket(vb_);
+                VBucketPtr vb = engine->getVBucket(vb_);
                 if (vb) {
                     vb->checkpointManager.removeCursor(name_);
                 }
@@ -1384,7 +1384,7 @@ void ActiveStream::transitionState(StreamState newState) {
 }
 
 size_t ActiveStream::getItemsRemaining() {
-    RCPtr<VBucket> vbucket = engine->getVBucket(vb_);
+    VBucketPtr vbucket = engine->getVBucket(vb_);
 
     if (!vbucket || !isActive()) {
         return 0;
@@ -1412,7 +1412,7 @@ const Logger& ActiveStream::getLogger() const
 
 bool ActiveStream::isCurrentSnapshotCompleted() const
 {
-    RCPtr<VBucket> vbucket = engine->getVBucket(vb_);
+    VBucketPtr vbucket = engine->getVBucket(vb_);
     // An atomic read of vbucket state without acquiring the
     // reader lock for state should suffice here.
     if (vbucket && vbucket->getState() == vbucket_state_replica) {
@@ -1426,7 +1426,7 @@ bool ActiveStream::isCurrentSnapshotCompleted() const
 
 void ActiveStream::dropCheckpointCursor_UNLOCKED()
 {
-    RCPtr<VBucket> vbucket = engine->getVBucket(vb_);
+    VBucketPtr vbucket = engine->getVBucket(vb_);
     if (!vbucket) {
         endStream(END_STREAM_STATE);
         bool inverse = false;
@@ -1448,7 +1448,7 @@ NotifierStream::NotifierStream(EventuallyPersistentEngine* e, dcp_producer_t p,
              snap_start_seqno, snap_end_seqno, Type::Notifier),
       producer(p) {
     LockHolder lh(streamMutex);
-    RCPtr<VBucket> vbucket = e->getVBucket(vb_);
+    VBucketPtr vbucket = e->getVBucket(vb_);
     if (vbucket && static_cast<uint64_t>(vbucket->getHighSeqno()) > st_seqno) {
         pushToReadyQ(new StreamEndResponse(opaque_, END_STREAM_OK, vb_));
         transitionState(StreamState::Dead);
@@ -1653,7 +1653,7 @@ void PassiveStream::acceptStream(uint16_t status, uint32_t add_opaque) {
     }
 }
 
-void PassiveStream::reconnectStream(RCPtr<VBucket> &vb,
+void PassiveStream::reconnectStream(VBucketPtr &vb,
                                     uint32_t new_opaque,
                                     uint64_t start_seqno) {
     vb_uuid_ = vb->failovers->getLatestEntry().vb_uuid;
@@ -1863,7 +1863,7 @@ process_items_error_t PassiveStream::processBufferedMessages(uint32_t& processed
 }
 
 ENGINE_ERROR_CODE PassiveStream::processMutation(MutationResponse* mutation) {
-    RCPtr<VBucket> vb = engine->getVBucket(vb_);
+    VBucketPtr vb = engine->getVBucket(vb_);
     if (!vb) {
         return ENGINE_NOT_MY_VBUCKET;
     }
@@ -1922,7 +1922,7 @@ ENGINE_ERROR_CODE PassiveStream::processMutation(MutationResponse* mutation) {
 }
 
 ENGINE_ERROR_CODE PassiveStream::processDeletion(MutationResponse* deletion) {
-    RCPtr<VBucket> vb = engine->getVBucket(vb_);
+    VBucketPtr vb = engine->getVBucket(vb_);
     if (!vb) {
         return ENGINE_NOT_MY_VBUCKET;
     }
@@ -1981,7 +1981,7 @@ ENGINE_ERROR_CODE PassiveStream::processDeletion(MutationResponse* deletion) {
 
 ENGINE_ERROR_CODE PassiveStream::processSystemEvent(
         const SystemEventMessage& event) {
-    RCPtr<VBucket> vb = engine->getVBucket(vb_);
+    VBucketPtr vb = engine->getVBucket(vb_);
 
     if (!vb) {
         return ENGINE_NOT_MY_VBUCKET;
@@ -2065,7 +2065,7 @@ ENGINE_ERROR_CODE PassiveStream::processSeparatorChanged(
 }
 
 void PassiveStream::processMarker(SnapshotMarker* marker) {
-    RCPtr<VBucket> vb = engine->getVBucket(vb_);
+    VBucketPtr vb = engine->getVBucket(vb_);
 
     cur_snapshot_start.store(marker->getStartSeqno());
     cur_snapshot_end.store(marker->getEndSeqno());
@@ -2116,7 +2116,7 @@ void PassiveStream::processSetVBucketState(SetVBucketState* state) {
     }
 }
 
-void PassiveStream::handleSnapshotEnd(RCPtr<VBucket>& vb, uint64_t byseqno) {
+void PassiveStream::handleSnapshotEnd(VBucketPtr& vb, uint64_t byseqno) {
     if (byseqno == cur_snapshot_end.load()) {
         if (cur_snapshot_type.load() == Snapshot::Disk &&
                 vb->isBackfillPhase()) {
index d326bae..79b7906 100644 (file)
@@ -278,7 +278,7 @@ public:
 
 protected:
     // Returns the outstanding items for the stream's checkpoint cursor.
-    void getOutstandingItems(RCPtr<VBucket> &vb, std::vector<queued_item> &items);
+    void getOutstandingItems(VBucketPtr &vb, std::vector<queued_item> &items);
 
     // Given a set of queued items, create mutation responses for each item,
     // and pass onto the producer associated with this stream.
@@ -520,7 +520,7 @@ public:
 
     void acceptStream(uint16_t status, uint32_t add_opaque);
 
-    void reconnectStream(RCPtr<VBucket> &vb, uint32_t new_opaque,
+    void reconnectStream(VBucketPtr &vb, uint32_t new_opaque,
                          uint64_t start_seqno);
 
     ENGINE_ERROR_CODE messageReceived(std::unique_ptr<DcpResponse> response);
@@ -571,7 +571,7 @@ protected:
     ENGINE_ERROR_CODE processSeparatorChanged(VBucket& vb,
                                               const CollectionsEvent& event);
 
-    void handleSnapshotEnd(RCPtr<VBucket>& vb, uint64_t byseqno);
+    void handleSnapshotEnd(VBucketPtr& vb, uint64_t byseqno);
 
     void processMarker(SnapshotMarker* marker);
 
index 0b0fa86..33ff843 100644 (file)
@@ -190,7 +190,7 @@ ENGINE_ERROR_CODE EPBucket::getPerVBucketDiskStats(const void* cookie,
         DiskStatVisitor(const void* c, ADD_STAT a) : cookie(c), add_stat(a) {
         }
 
-        void visitBucket(RCPtr<VBucket>& vb) override {
+        void visitBucket(VBucketPtr& vb) override {
             char buf[32];
             uint16_t vbid = vb->getId();
             DBFileInfo dbInfo =
@@ -218,7 +218,7 @@ ENGINE_ERROR_CODE EPBucket::getPerVBucketDiskStats(const void* cookie,
     return ENGINE_SUCCESS;
 }
 
-RCPtr<VBucket> EPBucket::makeVBucket(VBucket::id_type id,
+VBucketPtr EPBucket::makeVBucket(VBucket::id_type id,
                                      vbucket_state_t state,
                                      KVShard* shard,
                                      std::unique_ptr<FailoverTable> table,
@@ -231,7 +231,7 @@ RCPtr<VBucket> EPBucket::makeVBucket(VBucket::id_type id,
                                      uint64_t maxCas,
                                      const std::string& collectionsManifest) {
     auto flusherCb = std::make_shared<NotifyFlusherCB>(shard);
-    return RCPtr<VBucket>(new EPVBucket(id,
+    return VBucketPtr(new EPVBucket(id,
                                         state,
                                         stats,
                                         engine.getCheckpointConfig(),
@@ -253,7 +253,7 @@ RCPtr<VBucket> EPBucket::makeVBucket(VBucket::id_type id,
 ENGINE_ERROR_CODE EPBucket::statsVKey(const DocKey& key,
                                       uint16_t vbucket,
                                       const void* cookie) {
-    RCPtr<VBucket> vb = getVBucket(vbucket);
+    VBucketPtr vb = getVBucket(vbucket);
     if (!vb) {
         return ENGINE_NOT_MY_VBUCKET;
     }
@@ -271,7 +271,7 @@ void EPBucket::completeStatsVKey(const void* cookie,
     gcb.waitForValue();
 
     if (eviction_policy == FULL_EVICTION) {
-        RCPtr<VBucket> vb = getVBucket(vbid);
+        VBucketPtr vb = getVBucket(vbid);
         if (vb) {
             vb->completeStatsVKey(key, gcb);
         }
@@ -303,7 +303,7 @@ public:
                     "EPDiskRollbackCB::callback: dbHandle is NULL");
         }
         UniqueItemPtr itm(val.getValue());
-        RCPtr<VBucket> vb = engine.getVBucket(itm->getVBucketId());
+        VBucketPtr vb = engine.getVBucket(itm->getVBucketId());
         RememberingCallback<GetValue> gcb;
         engine.getKVBucket()
                 ->getROUnderlying(itm->getVBucketId())
index 00d963f..abab214 100644 (file)
@@ -69,7 +69,7 @@ public:
     /**
      * Creates a VBucket object.
      */
-    RCPtr<VBucket> makeVBucket(VBucket::id_type id,
+    VBucketPtr makeVBucket(VBucket::id_type id,
                                vbucket_state_t state,
                                KVShard* shard,
                                std::unique_ptr<FailoverTable> table,
index 500722c..e59a5b9 100644 (file)
@@ -809,7 +809,7 @@ static ENGINE_ERROR_CODE getVBucket(EventuallyPersistentEngine* e,
     }
 
     uint16_t vbucket = ntohs(req->message.header.request.vbucket);
-    RCPtr<VBucket> vb = e->getVBucket(vbucket);
+    VBucketPtr vb = e->getVBucket(vbucket);
     if (!vb) {
         return e->sendNotMyVBucketResponse(response, cookie, 0);
     } else {
@@ -1764,7 +1764,7 @@ static bool EvpGetItemInfo(ENGINE_HANDLE* handle, const void*,
                            const item* itm, item_info* itm_info) {
     const Item* it = reinterpret_cast<const Item*>(itm);
     auto engine = acquireEngine(handle);
-    RCPtr<VBucket> vb = engine->getKVBucket()->getVBucket(it->getVBucketId());
+    VBucketPtr vb = engine->getKVBucket()->getVBucket(it->getVBucketId());
     uint64_t vb_uuid = vb ? vb->failovers->getLatestUUID() : 0;
     *itm_info = it->toItemInfo(vb_uuid);
     return true;
@@ -2189,7 +2189,7 @@ cb::EngineErrorItemPair EventuallyPersistentEngine::get_if(const void* cookie,
         auto* item = gv.getValue();
         cb::unique_item_ptr ret{item, cb::ItemDeleter{handle}};
 
-        const RCPtr<VBucket> vb = getKVBucket()->getVBucket(vbucket);
+        const VBucketPtr vb = getKVBucket()->getVBucket(vbucket);
         const uint64_t vb_uuid = vb ? vb->failovers->getLatestUUID() : 0;
 
         // Currently
@@ -2421,7 +2421,7 @@ inline uint16_t EventuallyPersistentEngine::doWalkTapQueue(const void *cookie,
             *es = connection->specificData;
         } else if (ret == TAP_CHECKPOINT_START) {
             // Send the current value of the max deleted seqno
-            RCPtr<VBucket> vb = getVBucket(*vbucket);
+            VBucketPtr vb = getVBucket(*vbucket);
             if (!vb) {
                 retry = true;
                 return TAP_NOOP;
@@ -2700,7 +2700,7 @@ ENGINE_ERROR_CODE EventuallyPersistentEngine::tapNotify(const void *cookie,
                 if (tap_event == TAP_CHECKPOINT_START &&
                     nengine == TapEngineSpecific::sizeRevSeqno) {
                     // Set the current value for the max deleted seqno
-                    RCPtr<VBucket> vb = getVBucket(vbucket);
+                    VBucketPtr vb = getVBucket(vbucket);
                     if (!vb) {
                         return ENGINE_TMPFAIL;
                     }
@@ -3001,7 +3001,7 @@ void EventuallyPersistentEngine::queueBackfill(const VBucketFilter
                          1);
 }
 
-void VBucketCountAggregator::visitBucket(RCPtr<VBucket> &vb) {
+void VBucketCountAggregator::visitBucket(VBucketPtr &vb) {
     std::map<vbucket_state_t, VBucketCountVisitor*>::iterator it;
     it = visitorMap.find(vb->getState());
     if ( it != visitorMap.end() ) {
@@ -3399,13 +3399,13 @@ ENGINE_ERROR_CODE EventuallyPersistentEngine::doVBucketStats(
             isPrevState(isPrevStateRequested),
             isDetailsRequested(detailsRequested) {}
 
-        void visitBucket(RCPtr<VBucket> &vb) override {
+        void visitBucket(VBucketPtr &vb) override {
             addVBStats(cookie, add_stat, vb, eps, isPrevState,
                        isDetailsRequested);
         }
 
         static void addVBStats(const void *cookie, ADD_STAT add_stat,
-                               RCPtr<VBucket> &vb,
+                               VBucketPtr &vb,
                                KVBucketIface* store,
                                bool isPrevStateRequested,
                                bool detailsRequested) {
@@ -3443,7 +3443,7 @@ ENGINE_ERROR_CODE EventuallyPersistentEngine::doVBucketStats(
         if (!parseUint16(vbid.c_str(), &vbucket_id)) {
             return ENGINE_EINVAL;
         }
-        RCPtr<VBucket> vb = getVBucket(vbucket_id);
+        VBucketPtr vb = getVBucket(vbucket_id);
         if (!vb) {
             return ENGINE_NOT_MY_VBUCKET;
         }
@@ -3467,7 +3467,7 @@ ENGINE_ERROR_CODE EventuallyPersistentEngine::doHashStats(const void *cookie,
         StatVBucketVisitor(const void *c, ADD_STAT a) : cookie(c),
                                                         add_stat(a) {}
 
-        void visitBucket(RCPtr<VBucket> &vb) override {
+        void visitBucket(VBucketPtr &vb) override {
             uint16_t vbid = vb->getId();
             char buf[32];
             try {
@@ -3531,13 +3531,13 @@ public:
                           ADD_STAT a) : kvBucket(kvs), cookie(c),
                                         add_stat(a) {}
 
-    void visitBucket(RCPtr<VBucket> &vb) override {
+    void visitBucket(VBucketPtr &vb) override {
         addCheckpointStat(cookie, add_stat, kvBucket, vb);
     }
 
     static void addCheckpointStat(const void *cookie, ADD_STAT add_stat,
                                   KVBucketIface* eps,
-                                  RCPtr<VBucket> &vb) {
+                                  VBucketPtr &vb) {
         if (!vb) {
             return;
         }
@@ -3618,7 +3618,7 @@ ENGINE_ERROR_CODE EventuallyPersistentEngine::doCheckpointStats(
         if (!parseUint16(vbid.c_str(), &vbucket_id)) {
             return ENGINE_EINVAL;
         }
-        RCPtr<VBucket> vb = getVBucket(vbucket_id);
+        VBucketPtr vb = getVBucket(vbucket_id);
 
         StatCheckpointVisitor::addCheckpointStat(cookie, add_stat,
                                                  kvBucket.get(), vb);
@@ -3986,7 +3986,7 @@ ENGINE_ERROR_CODE EventuallyPersistentEngine::doVbIdFailoverLogStats(
                                                             const void *cookie,
                                                             ADD_STAT add_stat,
                                                             uint16_t vbid) {
-    RCPtr<VBucket> vb = getVBucket(vbid);
+    VBucketPtr vb = getVBucket(vbid);
     if(!vb) {
         return ENGINE_NOT_MY_VBUCKET;
     }
@@ -4004,7 +4004,7 @@ ENGINE_ERROR_CODE EventuallyPersistentEngine::doAllFailoverLogStats(
         StatVBucketVisitor(const void *c, ADD_STAT a) :
             cookie(c), add_stat(a) {}
 
-        void visitBucket(RCPtr<VBucket> &vb) override {
+        void visitBucket(VBucketPtr &vb) override {
             vb->failovers->addStats(cookie, vb->getId(), add_stat);
         }
 
@@ -4187,7 +4187,7 @@ ENGINE_ERROR_CODE EventuallyPersistentEngine::doWorkloadStats(const void
 
 void EventuallyPersistentEngine::addSeqnoVbStats(const void *cookie,
                                                  ADD_STAT add_stat,
-                                                 const RCPtr<VBucket> &vb) {
+                                                 const VBucketPtr &vb) {
     // MB-19359: An atomic read of vbucket state without acquiring the
     // reader lock for state should suffice here.
     uint64_t relHighSeqno = vb->getHighSeqno();
@@ -4242,7 +4242,7 @@ ENGINE_ERROR_CODE EventuallyPersistentEngine::doSeqnoStats(const void *cookie,
         }
 
         int vbucket = atoi(value.c_str());
-        RCPtr<VBucket> vb = getVBucket(vbucket);
+        VBucketPtr vb = getVBucket(vbucket);
         if (!vb || vb->getState() == vbucket_state_dead) {
             return ENGINE_NOT_MY_VBUCKET;
         }
@@ -4254,7 +4254,7 @@ ENGINE_ERROR_CODE EventuallyPersistentEngine::doSeqnoStats(const void *cookie,
 
     auto vbuckets = kvBucket->getVBuckets().getBuckets();
     for (auto vbid : vbuckets) {
-        RCPtr<VBucket> vb = getVBucket(vbid);
+        VBucketPtr vb = getVBucket(vbid);
         if (vb) {
             addSeqnoVbStats(cookie, add_stat, vb);
         }
@@ -4568,7 +4568,7 @@ ENGINE_ERROR_CODE EventuallyPersistentEngine::observe_seqno(
     LOG(EXTENSION_LOG_DEBUG, "Observing vbucket: %d with uuid: %" PRIu64,
                              vb_id, vb_uuid);
 
-    RCPtr<VBucket> vb = kvBucket->getVBucket(vb_id);
+    VBucketPtr vb = kvBucket->getVBucket(vb_id);
 
     if (!vb) {
         return sendNotMyVBucketResponse(response, cookie, 0);
@@ -4734,7 +4734,7 @@ ENGINE_ERROR_CODE EventuallyPersistentEngine::deregisterTapClient(
         /// its checkpoint cursors.
         const VBucketMap &vbuckets = getKVBucket()->getVBuckets();
         for (VBucketMap::id_type vbid = 0; vbid < vbuckets.getSize(); ++vbid) {
-            RCPtr<VBucket> vb = vbuckets.getBucket(vbid);
+            VBucketPtr vb = vbuckets.getBucket(vbid);
             if (!vb) {
                 continue;
             }
@@ -4754,7 +4754,7 @@ EventuallyPersistentEngine::handleCheckpointCmds(const void *cookie,
 {
     std::stringstream msg;
     uint16_t vbucket = ntohs(req->request.vbucket);
-    RCPtr<VBucket> vb = getVBucket(vbucket);
+    VBucketPtr vb = getVBucket(vbucket);
 
     if (!vb) {
         return sendNotMyVBucketResponse(response, cookie, 0);
@@ -4885,7 +4885,7 @@ EventuallyPersistentEngine::handleSeqnoCmds(const void *cookie,
 {
     std::stringstream msg;
     uint16_t vbucket = ntohs(req->request.vbucket);
-    RCPtr<VBucket> vb = getVBucket(vbucket);
+    VBucketPtr vb = getVBucket(vbucket);
 
     if (!vb) {
         return sendNotMyVBucketResponse(response, cookie, 0);
@@ -5624,7 +5624,7 @@ EventuallyPersistentEngine::doDcpVbTakeoverStats(const void *cookie,
                                                  ADD_STAT add_stat,
                                                  std::string &key,
                                                  uint16_t vbid) {
-    RCPtr<VBucket> vb = getVBucket(vbid);
+    VBucketPtr vb = getVBucket(vbid);
     if (!vb) {
         return ENGINE_NOT_MY_VBUCKET;
     }
@@ -5684,7 +5684,7 @@ EventuallyPersistentEngine::doTapVbTakeoverStats(const void *cookie,
                                                  ADD_STAT add_stat,
                                                  std::string &key,
                                                  uint16_t vbid) {
-    RCPtr<VBucket> vb = getVBucket(vbid);
+    VBucketPtr vb = getVBucket(vbid);
     if (!vb) {
         return ENGINE_NOT_MY_VBUCKET;
     }
@@ -6021,7 +6021,7 @@ EventuallyPersistentEngine::getAllKeys(const void* cookie,
     }
 
     uint16_t vbucket = ntohs(request->message.header.request.vbucket);
-    RCPtr<VBucket> vb = getVBucket(vbucket);
+    VBucketPtr vb = getVBucket(vbucket);
 
     if (!vb) {
         return ENGINE_NOT_MY_VBUCKET;
@@ -6211,7 +6211,7 @@ ENGINE_ERROR_CODE EventuallyPersistentEngine::getAllVBucketSequenceNumbers(
     }
 
     for (auto id : vbuckets) {
-        RCPtr<VBucket> vb = getVBucket(id);
+        VBucketPtr vb = getVBucket(id);
         if (vb) {
             auto state = vb->getState();
             bool getSeqnoForThisVb = false;
@@ -6310,7 +6310,7 @@ ENGINE_ERROR_CODE EventuallyPersistentEngine::sendMutationExtras(
         protocol_binary_response_status status,
         uint64_t cas,
         const void* cookie) {
-    RCPtr<VBucket> vb = kvBucket->getVBucket(vbucket);
+    VBucketPtr vb = kvBucket->getVBucket(vbucket);
     if (!vb) {
         return sendErrorResponse(
                 response, PROTOCOL_BINARY_RESPONSE_NOT_MY_VBUCKET, cas, cookie);
index 7efde97..112769e 100644 (file)
@@ -95,7 +95,7 @@ private:
  */
 class VBucketCountAggregator : public VBucketVisitor  {
 public:
-    void visitBucket(RCPtr<VBucket> &vb) override;
+    void visitBucket(VBucketPtr &vb) override;
 
     void addVisitor(VBucketCountVisitor* visitor);
 private:
@@ -474,7 +474,7 @@ public:
                                     protocol_binary_request_header *request,
                                     ADD_RESPONSE response);
 
-    RCPtr<VBucket> getVBucket(uint16_t vbucket) {
+    VBucketPtr getVBucket(uint16_t vbucket) {
         return kvBucket->getVBucket(vbucket);
     }
 
@@ -728,7 +728,7 @@ protected:
     ENGINE_ERROR_CODE doSeqnoStats(const void *cookie, ADD_STAT add_stat,
                                    const char* stat_key, int nkey);
     void addSeqnoVbStats(const void *cookie, ADD_STAT add_stat,
-                                  const RCPtr<VBucket> &vb);
+                                  const VBucketPtr &vb);
 
     void addLookupResult(const void *cookie, Item *result) {
         LockHolder lh(lookupMutex);
index cd45cbc..e699bdc 100644 (file)
@@ -102,7 +102,7 @@ bool EphemeralBucket::initialize() {
     return true;
 }
 
-RCPtr<VBucket> EphemeralBucket::makeVBucket(
+VBucketPtr EphemeralBucket::makeVBucket(
         VBucket::id_type id,
         vbucket_state_t state,
         KVShard* shard,
@@ -186,7 +186,7 @@ size_t EphemeralBucket::getNumPersistedDeletes(uint16_t vbid) {
     /* the name is getNumPersistedDeletes, in ephemeral buckets the equivalent
        meaning is the number of deletes seen by the vbucket.
        This is needed by ns-server during vb-takeover */
-    RCPtr<VBucket> vb = getVBucket(vbid);
+    VBucketPtr vb = getVBucket(vbid);
     return vb->getNumInMemoryDeletes();
 }
 
@@ -201,7 +201,7 @@ void EphemeralBucket::notifyNewSeqno(const uint16_t vbid,
 
     /* In ephemeral buckets we must notify high priority requests as well.
        We do not wait for persistence to notify high priority requests */
-    RCPtr<VBucket> vb = getVBucket(vbid);
+    VBucketPtr vb = getVBucket(vbid);
     vb->notifyHighPriorityRequests(
             engine, notifyCtx.bySeqno, HighPriorityVBNotify::Seqno);
 }
index e1e9d35..48fec35 100644 (file)
@@ -57,7 +57,7 @@ public:
     /**
      * Creates an EphemeralVBucket
      */
-    RCPtr<VBucket> makeVBucket(VBucket::id_type id,
+    VBucketPtr makeVBucket(VBucket::id_type id,
                                vbucket_state_t state,
                                KVShard* shard,
                                std::unique_ptr<FailoverTable> table,
index a5b0c66..b81c2ef 100644 (file)
@@ -20,7 +20,7 @@
 #include "ephemeral_vb.h"
 #include "seqlist.h"
 
-void EphemeralVBucket::CountVisitor::visitBucket(RCPtr<VBucket>& vb) {
+void EphemeralVBucket::CountVisitor::visitBucket(VBucketPtr& vb) {
     // Handle base class counts
     VBucketCountVisitor::visitBucket(vb);
 
index f68409e..6e4877c 100644 (file)
@@ -29,7 +29,7 @@ public:
         : VBucketCountVisitor(state) {
     }
 
-    void visitBucket(RCPtr<VBucket> &vb) override;
+    void visitBucket(VBucketPtr &vb) override;
 
     size_t autoDeleteCount = 0;
     uint64_t seqlistCount = 0;
index d0586ff..3cae9e3 100644 (file)
@@ -251,7 +251,7 @@ void Flusher::flushVB(void) {
 
     if (!doHighPriority && shard->highPriorityCount.load() > 0) {
         for (auto vbid : shard->getVBuckets()) {
-            RCPtr<VBucket> vb = store->getVBucket(vbid);
+            VBucketPtr vb = store->getVBucket(vbid);
             if (vb && vb->getHighPriorityChkSize() > 0) {
                 hpVbs.push(vbid);
             }
index 8316208..34e0dbe 100644 (file)
@@ -35,7 +35,7 @@ class ResizingVisitor : public VBucketVisitor {
 public:
     ResizingVisitor() { }
 
-    void visitBucket(RCPtr<VBucket> &vb) override {
+    void visitBucket(VBucketPtr &vb) override {
         vb->ht.resize();
     }
 };
index 2198e92..d4f2483 100644 (file)
@@ -103,7 +103,7 @@ public:
         }
     }
 
-    void visitBucket(RCPtr<VBucket> &vb) override {
+    void visitBucket(VBucketPtr &vb) override {
         update();
 
         bool newCheckpointCreated = false;
@@ -253,7 +253,7 @@ private:
     bool wasHighMemoryUsage;
     hrtime_t taskStart;
     std::atomic<item_pager_phase>* pager_phase;
-    RCPtr<VBucket> currentBucket;
+    VBucketPtr currentBucket;
 };
 
 ItemPager::ItemPager(EventuallyPersistentEngine *e, EPStats &st) :
index c9a8b79..1d5b34a 100644 (file)
@@ -188,7 +188,7 @@ public:
     }
 
     void callback(uint16_t& vbucketId, const DocKey& key, bool& isDeleted) {
-        RCPtr<VBucket> vb = store.getVBucket(vbucketId);
+        VBucketPtr vb = store.getVBucket(vbucketId);
         if (vb) {
             /* Check if a temporary filter has been initialized. If not,
              * initialize it. If initialization fails, throw an exception
@@ -241,7 +241,7 @@ private:
 
 bool BloomFilterCallback::initTempFilter(uint16_t vbucketId) {
     Configuration& config = store.getEPEngine().getConfiguration();
-    RCPtr<VBucket> vb = store.getVBucket(vbucketId);
+    VBucketPtr vb = store.getVBucket(vbucketId);
     if (!vb) {
         return false;
     }
@@ -319,7 +319,7 @@ class ExpiredItemsCallback : public Callback<uint16_t&, const DocKey&, uint64_t&
 
 class PendingOpsNotification : public GlobalTask {
 public:
-    PendingOpsNotification(EventuallyPersistentEngine& e, RCPtr<VBucket>& vb)
+    PendingOpsNotification(EventuallyPersistentEngine& e, VBucketPtr& vb)
         : GlobalTask(&e, TaskId::PendingOpsNotification, 0, false),
           engine(e),
           vbucket(vb),
@@ -340,7 +340,7 @@ public:
 
 private:
     EventuallyPersistentEngine &engine;
-    RCPtr<VBucket> vbucket;
+    VBucketPtr vbucket;
     const std::string description;
 };
 
@@ -550,7 +550,7 @@ void KVBucket::wakeUpFlusher() {
 protocol_binary_response_status KVBucket::evictKey(const DocKey& key,
                                                    VBucket::id_type vbucket,
                                                    const char** msg) {
-    RCPtr<VBucket> vb = getVBucket(vbucket);
+    VBucketPtr vb = getVBucket(vbucket);
     if (!vb || (vb->getState() != vbucket_state_active)) {
         return PROTOCOL_BINARY_RESPONSE_NOT_MY_VBUCKET;
     }
@@ -563,7 +563,7 @@ void KVBucket::deleteExpiredItem(uint16_t vbid,
                                  time_t startTime,
                                  uint64_t revSeqno,
                                  ExpireBy source) {
-    RCPtr<VBucket> vb = getVBucket(vbid);
+    VBucketPtr vb = getVBucket(vbid);
     if (vb) {
         // Obtain reader access to the VB state change lock so that
         // the VB can't switch state whilst we're processing
@@ -583,7 +583,7 @@ void KVBucket::deleteExpiredItems(
     }
 }
 
-bool KVBucket::isMetaDataResident(RCPtr<VBucket> &vb, const DocKey& key) {
+bool KVBucket::isMetaDataResident(VBucketPtr &vb, const DocKey& key) {
 
     if (!vb) {
         throw std::invalid_argument("EPStore::isMetaDataResident: vb is NULL");
@@ -602,7 +602,7 @@ bool KVBucket::isMetaDataResident(RCPtr<VBucket> &vb, const DocKey& key) {
 
 ENGINE_ERROR_CODE KVBucket::set(Item &itm, const void *cookie) {
 
-    RCPtr<VBucket> vb = getVBucket(itm.getVBucketId());
+    VBucketPtr vb = getVBucket(itm.getVBucketId());
     if (!vb) {
         ++stats.numNotMyVBuckets;
         return ENGINE_NOT_MY_VBUCKET;
@@ -639,7 +639,7 @@ ENGINE_ERROR_CODE KVBucket::set(Item &itm, const void *cookie) {
 
 ENGINE_ERROR_CODE KVBucket::add(Item &itm, const void *cookie)
 {
-    RCPtr<VBucket> vb = getVBucket(itm.getVBucketId());
+    VBucketPtr vb = getVBucket(itm.getVBucketId());
     if (!vb) {
         ++stats.numNotMyVBuckets;
         return ENGINE_NOT_MY_VBUCKET;
@@ -671,7 +671,7 @@ ENGINE_ERROR_CODE KVBucket::add(Item &itm, const void *cookie)
 }
 
 ENGINE_ERROR_CODE KVBucket::replace(Item &itm, const void *cookie) {
-    RCPtr<VBucket> vb = getVBucket(itm.getVBucketId());
+    VBucketPtr vb = getVBucket(itm.getVBucketId());
     if (!vb) {
         ++stats.numNotMyVBuckets;
         return ENGINE_NOT_MY_VBUCKET;
@@ -696,7 +696,7 @@ ENGINE_ERROR_CODE KVBucket::replace(Item &itm, const void *cookie) {
 ENGINE_ERROR_CODE KVBucket::addBackfillItem(Item& itm,
                                             GenerateBySeqno genBySeqno,
                                             ExtendedMetaData* emd) {
-    RCPtr<VBucket> vb = getVBucket(itm.getVBucketId());
+    VBucketPtr vb = getVBucket(itm.getVBucketId());
     if (!vb) {
         ++stats.numNotMyVBuckets;
         return ENGINE_NOT_MY_VBUCKET;
@@ -733,7 +733,7 @@ ENGINE_ERROR_CODE KVBucket::setVBucketState_UNLOCKED(uint16_t vbid,
                                                      bool transfer,
                                                      bool notify_dcp,
                                                      LockHolder& vbset) {
-    RCPtr<VBucket> vb = vbMap.getBucket(vbid);
+    VBucketPtr vb = vbMap.getBucket(vbid);
     if (vb && to == vb->getState()) {
         return ENGINE_SUCCESS;
     }
@@ -786,7 +786,7 @@ ENGINE_ERROR_CODE KVBucket::setVBucketState_UNLOCKED(uint16_t vbid,
                 std::make_unique<FailoverTable>(engine.getMaxFailoverEntries());
         KVShard* shard = vbMap.getShardByVbId(vbid);
 
-        RCPtr<VBucket> newvb =
+        VBucketPtr newvb =
                 makeVBucket(vbid,
                             to,
                             shard,
@@ -824,7 +824,7 @@ void KVBucket::scheduleVBStatePersist() {
 }
 
 void KVBucket::scheduleVBStatePersist(VBucket::id_type vbid) {
-    RCPtr<VBucket> vb = getVBucket(vbid);
+    VBucketPtr vb = getVBucket(vbid);
 
     if (!vb) {
         LOG(EXTENSION_LOG_WARNING,
@@ -841,7 +841,7 @@ bool KVBucket::completeVBucketDeletion(uint16_t vbid, const void* cookie) {
     bool bucketDeleting;
     {
         LockHolder lh(vbsetMutex);
-        RCPtr<VBucket> vb = vbMap.getBucket(vbid);
+        VBucketPtr vb = vbMap.getBucket(vbid);
         bucketDeleting = !vb ||
                 vb->getState() == vbucket_state_dead ||
                 vb->isBucketDeletion();
@@ -873,7 +873,7 @@ bool KVBucket::completeVBucketDeletion(uint16_t vbid, const void* cookie) {
     return true;
 }
 
-void KVBucket::scheduleVBDeletion(RCPtr<VBucket> &vb, const void* cookie,
+void KVBucket::scheduleVBDeletion(VBucketPtr &vb, const void* cookie,
                                   double delay) {
     ExTask delTask = make_STRCPtr<VBucketMemoryDeletionTask>(engine, vb, delay);
     ExecutorPool::get()->schedule(delTask);
@@ -887,7 +887,7 @@ void KVBucket::scheduleVBDeletion(RCPtr<VBucket> &vb, const void* cookie,
 ENGINE_ERROR_CODE KVBucket::deleteVBucket(uint16_t vbid, const void* c) {
     // Lock to prevent a race condition between a failed update and add
     // (and delete).
-    RCPtr<VBucket> vb;
+    VBucketPtr vb;
     {
         LockHolder lh(vbsetMutex);
         vb = vbMap.getBucket(vbid);
@@ -909,7 +909,7 @@ ENGINE_ERROR_CODE KVBucket::deleteVBucket(uint16_t vbid, const void* c) {
 ENGINE_ERROR_CODE KVBucket::checkForDBExistence(DBFileId db_file_id) {
     std::string backend = engine.getConfiguration().getBackend();
     if (backend.compare("couchdb") == 0) {
-        RCPtr<VBucket> vb = vbMap.getBucket(db_file_id);
+        VBucketPtr vb = vbMap.getBucket(db_file_id);
         if (!vb) {
             return ENGINE_NOT_MY_VBUCKET;
         }
@@ -935,7 +935,7 @@ ENGINE_ERROR_CODE KVBucket::scheduleCompaction(uint16_t vbid, compaction_ctx c,
     }
 
     /* Obtain the vbucket so we can get the previous purge seqno */
-    RCPtr<VBucket> vb = vbMap.getBucket(vbid);
+    VBucketPtr vb = vbMap.getBucket(vbid);
     if (!vb) {
         return ENGINE_NOT_MY_VBUCKET;
     }
@@ -991,7 +991,7 @@ void KVBucket::compactInternal(compaction_ctx *ctx) {
      */
     for (auto& it : ctx->max_purged_seq) {
         const uint16_t vbid = it.first;
-        RCPtr<VBucket> vb = getVBucket(vbid);
+        VBucketPtr vb = getVBucket(vbid);
         if (!vb) {
             continue;
         }
@@ -1018,7 +1018,7 @@ bool KVBucket::doCompact(compaction_ctx *ctx, const void *cookie) {
      * the writer and compactor threads
      */
     if (concWriteCompact == false) {
-        RCPtr<VBucket> vb = getVBucket(vbid);
+        VBucketPtr vb = getVBucket(vbid);
         if (!vb) {
             err = ENGINE_NOT_MY_VBUCKET;
             engine.storeEngineSpecific(cookie, NULL);
@@ -1078,7 +1078,7 @@ bool KVBucket::resetVBucket(uint16_t vbid) {
 bool KVBucket::resetVBucket_UNLOCKED(uint16_t vbid, LockHolder& vbset) {
     bool rv(false);
 
-    RCPtr<VBucket> vb = vbMap.getBucket(vbid);
+    VBucketPtr vb = vbMap.getBucket(vbid);
     if (vb) {
         vbucket_state_t vbstate = vb->getState();
 
@@ -1092,7 +1092,7 @@ bool KVBucket::resetVBucket_UNLOCKED(uint16_t vbid, LockHolder& vbset) {
                                  false/*transfer*/, true/*notifyDcp*/, vbset);
 
         // Copy the all cursors from the old vbucket into the new vbucket
-        RCPtr<VBucket> newvb = vbMap.getBucket(vbid);
+        VBucketPtr newvb = vbMap.getBucket(vbid);
         newvb->checkpointManager.resetCursors(cursors);
 
         rv = true;
@@ -1355,7 +1355,7 @@ void KVBucket::completeBGFetch(const DocKey& key,
       // Lock to prevent a race condition between a fetch for restore and delete
         LockHolder lh(vbsetMutex);
 
-        RCPtr<VBucket> vb = getVBucket(vbucket);
+        VBucketPtr vb = getVBucket(vbucket);
         if (vb) {
             VBucketBGFetchItem item{gcb.val, cookie, init, isMeta};
             ENGINE_ERROR_CODE status =
@@ -1377,7 +1377,7 @@ void KVBucket::completeBGFetch(const DocKey& key,
 void KVBucket::completeBGFetchMulti(uint16_t vbId,
                                     std::vector<bgfetched_item_t>& fetchedItems,
                                     ProcessClock::time_point startTime) {
-    RCPtr<VBucket> vb = getVBucket(vbId);
+    VBucketPtr vb = getVBucket(vbId);
     if (vb) {
         for (const auto& item : fetchedItems) {
             auto& key = item.first;
@@ -1409,7 +1409,7 @@ GetValue KVBucket::getInternal(const DocKey& key, uint16_t vbucket,
 
     vbucket_state_t disallowedState = (allowedState == vbucket_state_active) ?
         vbucket_state_replica : vbucket_state_active;
-    RCPtr<VBucket> vb = getVBucket(vbucket);
+    VBucketPtr vb = getVBucket(vbucket);
 
     if (!vb) {
         ++stats.numNotMyVBuckets;
@@ -1453,7 +1453,7 @@ GetValue KVBucket::getRandomKey() {
     std::unique_ptr<Item> itm;
 
     while (itm == NULL) {
-        RCPtr<VBucket> vb = getVBucket(curr++);
+        VBucketPtr vb = getVBucket(curr++);
         while (!vb || vb->getState() != vbucket_state_active) {
             if (curr == start) {
                 return GetValue(NULL, ENGINE_KEY_ENOENT);
@@ -1491,7 +1491,7 @@ ENGINE_ERROR_CODE KVBucket::getMetaData(const DocKey& key,
                                         uint32_t& deleted,
                                         uint8_t& datatype)
 {
-    RCPtr<VBucket> vb = getVBucket(vbucket);
+    VBucketPtr vb = getVBucket(vbucket);
 
     if (!vb) {
         ++stats.numNotMyVBuckets;
@@ -1521,7 +1521,7 @@ ENGINE_ERROR_CODE KVBucket::setWithMeta(Item &itm,
                                         ExtendedMetaData *emd,
                                         bool isReplication)
 {
-    RCPtr<VBucket> vb = getVBucket(itm.getVBucketId());
+    VBucketPtr vb = getVBucket(itm.getVBucketId());
     if (!vb) {
         ++stats.numNotMyVBuckets;
         return ENGINE_NOT_MY_VBUCKET;
@@ -1565,7 +1565,7 @@ ENGINE_ERROR_CODE KVBucket::setWithMeta(Item &itm,
 GetValue KVBucket::getAndUpdateTtl(const DocKey& key, uint16_t vbucket,
                                    const void *cookie, time_t exptime)
 {
-    RCPtr<VBucket> vb = getVBucket(vbucket);
+    VBucketPtr vb = getVBucket(vbucket);
     if (!vb) {
         ++stats.numNotMyVBuckets;
         return GetValue(NULL, ENGINE_NOT_MY_VBUCKET);
@@ -1590,7 +1590,7 @@ GetValue KVBucket::getAndUpdateTtl(const DocKey& key, uint16_t vbucket,
 GetValue KVBucket::getLocked(const DocKey& key, uint16_t vbucket,
                              rel_time_t currentTime, uint32_t lockTimeout,
                              const void *cookie) {
-    RCPtr<VBucket> vb = getVBucket(vbucket);
+    VBucketPtr vb = getVBucket(vbucket);
     if (!vb || vb->getState() != vbucket_state_active) {
         ++stats.numNotMyVBuckets;
         return GetValue(NULL, ENGINE_NOT_MY_VBUCKET);
@@ -1606,7 +1606,7 @@ ENGINE_ERROR_CODE KVBucket::unlockKey(const DocKey& key,
                                       rel_time_t currentTime)
 {
 
-    RCPtr<VBucket> vb = getVBucket(vbucket);
+    VBucketPtr vb = getVBucket(vbucket);
     if (!vb || vb->getState() != vbucket_state_active) {
         ++stats.numNotMyVBuckets;
         return ENGINE_NOT_MY_VBUCKET;
@@ -1651,7 +1651,7 @@ ENGINE_ERROR_CODE KVBucket::getKeyStats(const DocKey& key,
                                         const void* cookie,
                                         struct key_stats& kstats,
                                         WantsDeleted wantsDeleted) {
-    RCPtr<VBucket> vb = getVBucket(vbucket);
+    VBucketPtr vb = getVBucket(vbucket);
     if (!vb) {
         return ENGINE_NOT_MY_VBUCKET;
     }
@@ -1662,7 +1662,7 @@ ENGINE_ERROR_CODE KVBucket::getKeyStats(const DocKey& key,
 
 std::string KVBucket::validateKey(const DocKey& key, uint16_t vbucket,
                                   Item &diskItem) {
-    RCPtr<VBucket> vb = getVBucket(vbucket);
+    VBucketPtr vb = getVBucket(vbucket);
     auto hbl = vb->ht.getLockedBucket(key);
     StoredValue* v = vb->fetchValidValue(
             hbl, key, WantsDeleted::Yes, TrackReference::No, QueueExpired::Yes);
@@ -1695,7 +1695,7 @@ ENGINE_ERROR_CODE KVBucket::deleteItem(const DocKey& key,
                                        Item* itm,
                                        ItemMetaData* itemMeta,
                                        mutation_descr_t* mutInfo) {
-    RCPtr<VBucket> vb = getVBucket(vbucket);
+    VBucketPtr vb = getVBucket(vbucket);
     if (!vb || vb->getState() == vbucket_state_dead) {
         ++stats.numNotMyVBuckets;
         return ENGINE_NOT_MY_VBUCKET;
@@ -1735,7 +1735,7 @@ ENGINE_ERROR_CODE KVBucket::deleteWithMeta(const DocKey& key,
                                            uint64_t bySeqno,
                                            ExtendedMetaData* emd,
                                            bool isReplication) {
-    RCPtr<VBucket> vb = getVBucket(vbucket);
+    VBucketPtr vb = getVBucket(vbucket);
 
     if (!vb) {
         ++stats.numNotMyVBuckets;
@@ -1782,7 +1782,7 @@ ENGINE_ERROR_CODE KVBucket::deleteWithMeta(const DocKey& key,
 void KVBucket::reset() {
     auto buckets = vbMap.getBuckets();
     for (auto vbid : buckets) {
-        RCPtr<VBucket> vb = getVBucket(vbid);
+        VBucketPtr vb = getVBucket(vbid);
         if (vb) {
             LockHolder lh(vb_mutexes[vb->getId()]);
             vb->ht.clear();
@@ -1804,7 +1804,7 @@ class PersistenceCallback : public Callback<mutation_result>,
                             public Callback<int> {
 public:
 
-    PersistenceCallback(const queued_item &qi, RCPtr<VBucket> &vb,
+    PersistenceCallback(const queued_item &qi, VBucketPtr &vb,
                         EPStats& s, uint64_t c)
         : queuedItem(qi), vbucket(vb), stats(s), cas(c) {
         if (!vb) {
@@ -1904,7 +1904,7 @@ public:
         }
     }
 
-    RCPtr<VBucket>& getVBucket() {
+    VBucketPtr& getVBucket() {
         return vbucket;
     }
 
@@ -1926,7 +1926,7 @@ private:
     }
 
     const queued_item queuedItem;
-    RCPtr<VBucket> vbucket;
+    VBucketPtr vbucket;
     EPStats& stats;
     uint64_t cas;
     DISALLOW_COPY_AND_ASSIGN(PersistenceCallback);
@@ -1959,7 +1959,7 @@ void KVBucket::setDeleteAllComplete() {
 
 void KVBucket::flushOneDeleteAll() {
     for (VBucketMap::id_type i = 0; i < vbMap.getSize(); ++i) {
-        RCPtr<VBucket> vb = getVBucket(i);
+        VBucketPtr vb = getVBucket(i);
         // Reset the vBucket if it's non-null and not already in the middle of
         // being created / destroyed.
         if (vb && !(vb->isBucketCreation() || vb->isBucketDeletion())) {
@@ -1986,7 +1986,7 @@ int KVBucket::flushVBucket(uint16_t vbid) {
     int items_flushed = 0;
     const hrtime_t flush_start = gethrtime();
 
-    RCPtr<VBucket> vb = vbMap.getBucket(vbid);
+    VBucketPtr vb = vbMap.getBucket(vbid);
     if (vb) {
         std::unique_lock<std::mutex> lh(vb_mutexes[vbid], std::try_to_lock);
         if (!lh.owns_lock()) { // Try another bucket if this one is locked
@@ -2200,7 +2200,7 @@ void KVBucket::commit(KVStore& kvstore, const Item* collectionsManifest) {
         std::unordered_set<uint16_t> vbSet;
         for (auto pcbIter : pcbs) {
             PersistenceCallback *pcb = pcbIter;
-            RCPtr<VBucket>& vb = pcb->getVBucket();
+            VBucketPtr& vb = pcb->getVBucket();
             uint16_t vbid = vb->getId();
             auto found = vbSet.find(vbid);
             if (found == vbSet.end()) {
@@ -2224,7 +2224,7 @@ void KVBucket::commit(KVStore& kvstore, const Item* collectionsManifest) {
 }
 
 PersistenceCallback* KVBucket::flushOneDelOrSet(const queued_item &qi,
-                                                RCPtr<VBucket> &vb) {
+                                                VBucketPtr &vb) {
 
     if (!vb) {
         --stats.diskQueueSize;
@@ -2514,7 +2514,7 @@ void KVBucket::resetAccessScannerStartTime() {
 
 void KVBucket::setAllBloomFilters(bool to) {
     for (VBucketMap::id_type vbid = 0; vbid < vbMap.getSize(); vbid++) {
-        RCPtr<VBucket> vb = vbMap.getBucket(vbid);
+        VBucketPtr vb = vbMap.getBucket(vbid);
         if (vb) {
             if (to) {
                 vb->setFilterStatus(BFILTER_ENABLED);
@@ -2528,7 +2528,7 @@ void KVBucket::setAllBloomFilters(bool to) {
 void KVBucket::visit(VBucketVisitor &visitor)
 {
     for (VBucketMap::id_type vbid = 0; vbid < vbMap.getSize(); ++vbid) {
-        RCPtr<VBucket> vb = vbMap.getBucket(vbid);
+        VBucketPtr vb = vbMap.getBucket(vbid);
         if (vb) {
             visitor.visitBucket(vb);
         }
@@ -2542,7 +2542,7 @@ KVBucket::Position KVBucket::pauseResumeVisit(
 {
     uint16_t vbid = start_pos.vbucket_id;
     for (; vbid < vbMap.getSize(); ++vbid) {
-        RCPtr<VBucket> vb = vbMap.getBucket(vbid);
+        VBucketPtr vb = vbMap.getBucket(vbid);
         if (vb) {
             bool paused = !visitor.visit(vbid, vb->ht);
             if (paused) {
@@ -2590,7 +2590,7 @@ bool VBCBAdaptor::run(void) {
         TRACE_EVENT("ep-engine/task", "VBCBAdaptor", vbList.front());
         currentvb.store(vbList.front());
         updateDescription();
-        RCPtr<VBucket> vb = store->getVBucket(currentvb);
+        VBucketPtr vb = store->getVBucket(currentvb);
         if (vb) {
             if (visitor->pauseVisitor()) {
                 snooze(sleepTime);
@@ -2695,7 +2695,7 @@ ENGINE_ERROR_CODE KVBucket::rollback(uint16_t vbid, uint64_t rollbackSeqno) {
         return ENGINE_TMPFAIL; // Reschedule a vbucket rollback task.
     }
 
-    RCPtr<VBucket> vb = vbMap.getBucket(vbid);
+    VBucketPtr vb = vbMap.getBucket(vbid);
     if (!vb) {
         return ENGINE_NOT_MY_VBUCKET;
     }
@@ -2720,7 +2720,7 @@ ENGINE_ERROR_CODE KVBucket::rollback(uint16_t vbid, uint64_t rollbackSeqno) {
         }
 
         if (resetVBucket_UNLOCKED(vbid, vbset)) {
-            RCPtr<VBucket> newVb = vbMap.getBucket(vbid);
+            VBucketPtr newVb = vbMap.getBucket(vbid);
             newVb->incrRollbackItemCount(prevHighSeqno);
             return ENGINE_SUCCESS;
         }
@@ -2759,7 +2759,7 @@ size_t KVBucket::getReplicaResidentRatio() const {
 }
 
 ENGINE_ERROR_CODE KVBucket::forceMaxCas(uint16_t vbucket, uint64_t cas) {
-    RCPtr<VBucket> vb = vbMap.getBucket(vbucket);
+    VBucketPtr vb = vbMap.getBucket(vbucket);
     if (vb) {
         vb->forceMaxCas(cas);
         return ENGINE_SUCCESS;
index af6ba69..92a4b1d 100644 (file)
@@ -316,7 +316,7 @@ public:
                               std::vector<bgfetched_item_t>& fetchedItems,
                               ProcessClock::time_point start);
 
-    RCPtr<VBucket> getVBucket(uint16_t vbid) {
+    VBucketPtr getVBucket(uint16_t vbid) {
         return vbMap.getBucket(vbid);
     }
 
@@ -587,7 +587,7 @@ public:
         bfilterResidencyThreshold = to;
     }
 
-    bool isMetaDataResident(RCPtr<VBucket> &vb, const DocKey& key);
+    bool isMetaDataResident(VBucketPtr &vb, const DocKey& key);
 
     void logQTime(TaskId taskType, const ProcessClock::duration enqTime) {
         const auto ns_count = std::chrono::duration_cast
@@ -739,7 +739,7 @@ public:
     /**
      * Create a VBucket object appropriate for this Bucket class.
      */
-    virtual RCPtr<VBucket> makeVBucket(
+    virtual VBucketPtr makeVBucket(
             VBucket::id_type id,
             vbucket_state_t state,
             KVShard* shard,
@@ -772,13 +772,13 @@ protected:
      */
     void compactInternal(compaction_ctx *ctx);
 
-    void scheduleVBDeletion(RCPtr<VBucket> &vb,
+    void scheduleVBDeletion(VBucketPtr &vb,
                             const void* cookie,
                             double delay = 0);
 
     void flushOneDeleteAll(void);
     PersistenceCallback* flushOneDelOrSet(const queued_item &qi,
-                                          RCPtr<VBucket> &vb);
+                                          VBucketPtr &vb);
 
     GetValue getInternal(const DocKey& key, uint16_t vbucket, const void *cookie,
                          vbucket_state_t allowedState,
index 25cf0b7..27585a2 100644 (file)
@@ -55,7 +55,7 @@ public:
      *
      * @param vb the vbucket we are beginning to visit
      */
-    virtual void visitBucket(RCPtr<VBucket> &vb) = 0;
+    virtual void visitBucket(VBucketPtr &vb) = 0;
 
     const VBucketFilter &getVBucketFilter() {
         return vBucketFilter;
@@ -449,7 +449,7 @@ public:
             std::vector<bgfetched_item_t>& fetchedItems,
             ProcessClock::time_point start) = 0;
 
-    virtual RCPtr<VBucket> getVBucket(uint16_t vbid) = 0;
+    virtual VBucketPtr getVBucket(uint16_t vbid) = 0;
 
     /**
      * Returns the last persisted checkpoint Id for the specified vBucket.
@@ -694,7 +694,7 @@ public:
 
     virtual void setBfiltersResidencyThreshold(float to) = 0;
 
-    virtual bool isMetaDataResident(RCPtr<VBucket> &vb,
+    virtual bool isMetaDataResident(VBucketPtr &vb,
                                     const DocKey& key) = 0;
 
     virtual void logQTime(TaskId taskType,
@@ -800,7 +800,7 @@ public:
     /**
      * Create a VBucket object appropriate for this Bucket class.
      */
-    virtual RCPtr<VBucket> makeVBucket(
+    virtual VBucketPtr makeVBucket(
             VBucket::id_type id,
             vbucket_state_t state,
             KVShard* shard,
@@ -850,13 +850,13 @@ protected:
      */
     virtual void compactInternal(compaction_ctx *ctx) = 0;
 
-    virtual void scheduleVBDeletion(RCPtr<VBucket> &vb,
+    virtual void scheduleVBDeletion(VBucketPtr &vb,
                             const void* cookie,
                             double delay = 0) = 0;
 
     virtual void flushOneDeleteAll(void) = 0;
     virtual PersistenceCallback* flushOneDelOrSet(const queued_item &qi,
-                                                  RCPtr<VBucket> &vb) = 0;
+                                                  VBucketPtr &vb) = 0;
 
     virtual GetValue getInternal(const DocKey& key, uint16_t vbucket,
                                  const void *cookie,
index c8ee255..19c2531 100644 (file)
@@ -65,7 +65,7 @@ BgFetcher *KVShard::getBgFetcher() {
     return bgFetcher.get();
 }
 
-RCPtr<VBucket> KVShard::getBucket(uint16_t id) const {
+VBucketPtr KVShard::getBucket(uint16_t id) const {
     if (id < vbuckets.size()) {
         return vbuckets[id];
     } else {
@@ -73,7 +73,7 @@ RCPtr<VBucket> KVShard::getBucket(uint16_t id) const {
     }
 }
 
-void KVShard::setBucket(const RCPtr<VBucket> &vb) {
+void KVShard::setBucket(const VBucketPtr &vb) {
     vbuckets[vb->getId()].reset(vb);
 }
 
@@ -86,7 +86,7 @@ std::vector<VBucket::id_type> KVShard::getVBucketsSortedByState() {
     for (int state = vbucket_state_active;
          state <= vbucket_state_dead;
          ++state) {
-        for (RCPtr<VBucket> b : vbuckets) {
+        for (VBucketPtr b : vbuckets) {
             if (b && b->getState() == state) {
                 rv.push_back(b->getId());
             }
@@ -97,7 +97,7 @@ std::vector<VBucket::id_type> KVShard::getVBucketsSortedByState() {
 
 std::vector<VBucket::id_type> KVShard::getVBuckets() {
     std::vector<VBucket::id_type> rv;
-    for (RCPtr<VBucket> b : vbuckets) {
+    for (VBucketPtr b : vbuckets) {
         if (b) {
             rv.push_back(b->getId());
         }
index a50c1a9..825f5e8 100644 (file)
@@ -77,8 +77,8 @@ public:
     Flusher *getFlusher();
     BgFetcher *getBgFetcher();
 
-    RCPtr<VBucket> getBucket(VBucket::id_type id) const;
-    void setBucket(const RCPtr<VBucket> &b);
+    VBucketPtr getBucket(VBucket::id_type id) const;
+    void setBucket(const VBucketPtr &b);
     void resetBucket(VBucket::id_type id);
 
     KVShard::id_type getId() const {
@@ -90,7 +90,7 @@ public:
 
 private:
     KVStoreConfig kvConfig;
-    std::vector<RCPtr<VBucket>> vbuckets;
+    std::vector<VBucketPtr> vbuckets;
 
     std::unique_ptr<KVStore> rwStore;
     std::unique_ptr<KVStore> roStore;
index 22ce9f3..376193d 100644 (file)
@@ -1039,7 +1039,7 @@ void MutationLogHarvester::apply(void *arg, mlCallbackWithQueue mlc) {
                 "when engine is NULL");
     }
     for (const uint16_t vb : vbid_set) {
-        RCPtr<VBucket> vbucket = engine->getKVBucket()->getVBucket(vb);
+        VBucketPtr vbucket = engine->getKVBucket()->getVBucket(vb);
         if (!vbucket) {
             continue;
         }
index 722a7ee..e4d69c5 100644 (file)
@@ -443,7 +443,7 @@ void TapProducer::setVBucketFilter(const std::vector<uint16_t> &vbuckets,
         // Remove TAP cursors from the vbuckets that don't belong to the new vbucket filter.
         for (std::set<uint16_t>::const_iterator it = vset.begin(); it != vset.end(); ++it) {
             if (vbucketFilter(*it)) {
-                RCPtr<VBucket> vb = vbMap.getBucket(*it);
+                VBucketPtr vb = vbMap.getBucket(*it);
                 if (vb) {
                     vb->checkpointManager.removeCursor(getName());
                 }
@@ -1256,7 +1256,7 @@ queued_item TapProducer::nextFgFetched_UNLOCKED(bool &shouldPause) {
         std::map<uint16_t, CheckpointState>::iterator it = checkpointState_.begin();
         for (; it != checkpointState_.end(); ++it) {
             uint16_t vbid = it->first;
-            RCPtr<VBucket> vb = vbuckets.getBucket(vbid);
+            VBucketPtr vb = vbuckets.getBucket(vbid);
             if (!vb || (vb->getState() == vbucket_state_dead && !doTakeOver)) {
                 logger.log(EXTENSION_LOG_WARNING,
                            "Skip vbucket %d checkpoint queue as it's in invalid state.",
@@ -1361,7 +1361,7 @@ size_t TapProducer::getRemainingOnCheckpoints_UNLOCKED() {
     std::map<uint16_t, CheckpointState>::iterator it = checkpointState_.begin();
     for (; it != checkpointState_.end(); ++it) {
         uint16_t vbid = it->first;
-        RCPtr<VBucket> vb = vbuckets.getBucket(vbid);
+        VBucketPtr vb = vbuckets.getBucket(vbid);
         if (!vb || (vb->getState() == vbucket_state_dead && !doTakeOver)) {
             continue;
         }
@@ -1376,7 +1376,7 @@ bool TapProducer::hasNextFromCheckpoints_UNLOCKED() {
     std::map<uint16_t, CheckpointState>::iterator it = checkpointState_.begin();
     for (; it != checkpointState_.end(); ++it) {
         uint16_t vbid = it->first;
-        RCPtr<VBucket> vb = vbuckets.getBucket(vbid);
+        VBucketPtr vb = vbuckets.getBucket(vbid);
         if (!vb || (vb->getState() == vbucket_state_dead && !doTakeOver)) {
             continue;
         }
@@ -1399,7 +1399,7 @@ void TapProducer::scheduleBackfill_UNLOCKED(const std::vector<uint16_t> &vblist)
     // Skip all the vbuckets that are (1) receiving backfill from their master nodes
     // or (2) already scheduled for backfill.
     for (; vbit != vblist.end(); ++vbit) {
-        RCPtr<VBucket> vb = vbuckets.getBucket(*vbit);
+        VBucketPtr vb = vbuckets.getBucket(*vbit);
         if (!vb || vb->isBackfillPhase() ||
             backfillVBuckets.find(*vbit) != backfillVBuckets.end()) {
             continue;
@@ -1412,7 +1412,7 @@ void TapProducer::scheduleBackfill_UNLOCKED(const std::vector<uint16_t> &vblist)
 
     std::vector<uint16_t>::iterator it = new_vblist.begin();
     for (; it != new_vblist.end(); ++it) {
-        RCPtr<VBucket> vb = vbuckets.getBucket(*it);
+        VBucketPtr vb = vbuckets.getBucket(*it);
         if (!vb) {
             logger.log(EXTENSION_LOG_WARNING,
                        "VBucket %d not exist for backfill. Skip it.", *it);
@@ -1443,7 +1443,7 @@ VBucketEvent TapProducer::checkDumpOrTakeOverCompletion() {
     if (mayCompleteDumpOrTakeover_UNLOCKED()) {
         ev = nextVBucketLowPriority_UNLOCKED();
         if (ev.event != TAP_PAUSE) {
-            RCPtr<VBucket> vb = engine_.getVBucket(ev.vbucket);
+            VBucketPtr vb = engine_.getVBucket(ev.vbucket);
             vbucket_state_t myState(vb ? vb->getState() : vbucket_state_dead);
             if (ev.event != TAP_VBUCKET_SET) {
                 throw std::logic_error("TapProducer::checkDumpOrTakeOverCompletion: "
@@ -1697,7 +1697,7 @@ void TapProducer::registerCursor(const std::map<uint16_t, uint64_t> &lastCheckpo
     const VBucketMap &vbuckets = engine_.getKVBucket()->getVBuckets();
     for (VBucketMap::id_type vbid = 0; vbid < vbuckets.getSize(); ++vbid) {
         if (vbucketFilter(vbid)) {
-            RCPtr<VBucket> vb = vbuckets.getBucket(vbid);
+            VBucketPtr vb = vbuckets.getBucket(vbid);
             if (!vb) {
                 checkpointState_.erase(vbid);
                 logger.log(EXTENSION_LOG_WARNING,
@@ -2013,7 +2013,7 @@ void Consumer::addStats(ADD_STAT add_stat, const void *c) {
 
 void Consumer::setBackfillPhase(bool isBackfill, uint16_t vbucket) {
     const VBucketMap &vbuckets = engine_.getKVBucket()->getVBuckets();
-    RCPtr<VBucket> vb = vbuckets.getBucket(vbucket);
+    VBucketPtr vb = vbuckets.getBucket(vbucket);
     if (!(vb && supportCheckpointSync_)) {
         return;
     }
@@ -2037,7 +2037,7 @@ void Consumer::setBackfillPhase(bool isBackfill, uint16_t vbucket) {
 
 bool Consumer::isBackfillPhase(uint16_t vbucket) {
     const VBucketMap &vbuckets = engine_.getKVBucket()->getVBuckets();
-    RCPtr<VBucket> vb = vbuckets.getBucket(vbucket);
+    VBucketPtr vb = vbuckets.getBucket(vbucket);
     if (vb && vb->isBackfillPhase()) {
         return true;
     }
@@ -2137,7 +2137,7 @@ void Consumer::processedEvent(uint16_t event, ENGINE_ERROR_CODE ret)
 
 void Consumer::checkVBOpenCheckpoint(uint16_t vbucket) {
     const VBucketMap &vbuckets = engine_.getKVBucket()->getVBuckets();
-    RCPtr<VBucket> vb = vbuckets.getBucket(vbucket);
+    VBucketPtr vb = vbuckets.getBucket(vbucket);
     if (!vb || vb->getState() == vbucket_state_active) {
         return;
     }
@@ -2154,7 +2154,7 @@ TapConsumer::TapConsumer(EventuallyPersistentEngine &engine, const void *cookie,
 bool TapConsumer::processCheckpointCommand(uint8_t event, uint16_t vbucket,
                                            uint64_t checkpointId) {
     const VBucketMap &vbuckets = engine_.getKVBucket()->getVBuckets();
-    RCPtr<VBucket> vb = vbuckets.getBucket(vbucket);
+    VBucketPtr vb = vbuckets.getBucket(vbucket);
     if (!vb) {
         return false;
     }
index d569b98..93105dc 100644 (file)
@@ -591,7 +591,7 @@ void TapConnMap::removeTapCursors_UNLOCKED(TapProducer *tp) {
         const VBucketMap &vbuckets = engine.getKVBucket()->getVBuckets();
         // Remove all the cursors belonging to the TAP connection to be purged.
         for (VBucketMap::id_type vbid = 0; vbid < vbuckets.getSize(); ++vbid) {
-            RCPtr<VBucket> vb = vbuckets.getBucket(vbid);
+            VBucketPtr vb = vbuckets.getBucket(vbid);
             if (!vb) {
                 continue;
             }
index e392b47..29eedaa 100644 (file)
@@ -17,7 +17,7 @@
 
 #include "vb_count_visitor.h"
 
-void VBucketCountVisitor::visitBucket(RCPtr<VBucket>& vb) {
+void VBucketCountVisitor::visitBucket(VBucketPtr& vb) {
     ++numVbucket;
     numItems += vb->getNumItems();
     numTempItems += vb->getNumTempItems();
index ad17de5..8508ea7 100644 (file)
@@ -61,7 +61,7 @@ public:
           totalHLCDriftExceptionCounters() {
     }
 
-    void visitBucket(RCPtr<VBucket>& vb) override;
+    void visitBucket(VBucketPtr& vb) override;
 
     vbucket_state_t getVBucketState() {
         return desired_state;
index 4c434a3..1e66784 100644 (file)
@@ -1571,3 +1571,5 @@ private:
 
     DISALLOW_COPY_AND_ASSIGN(VBucket);
 };
+
+using VBucketPtr = RCPtr<VBucket>;
index 2cb260d..28b265c 100644 (file)
@@ -38,8 +38,8 @@ VBucketMap::VBucketMap(Configuration& config, KVBucket& store)
                                     new VBucketConfigChangeListener(*this));
 }
 
-RCPtr<VBucket> VBucketMap::getBucket(id_type id) const {
-    static RCPtr<VBucket> emptyVBucket;
+VBucketPtr VBucketMap::getBucket(id_type id) const {
+    static VBucketPtr emptyVBucket;
     if (id < size) {
         return getShardByVbId(id)->getBucket(id);
     } else {
@@ -47,7 +47,7 @@ RCPtr<VBucket> VBucketMap::getBucket(id_type id) const {
     }
 }
 
-ENGINE_ERROR_CODE VBucketMap::addBucket(const RCPtr<VBucket> &b) {
+ENGINE_ERROR_CODE VBucketMap::addBucket(const VBucketPtr &b) {
     if (b->getId() < size) {
         getShardByVbId(b->getId())->setBucket(b);
         LOG(EXTENSION_LOG_INFO, "Mapped new vbucket %d in state %s",
@@ -71,7 +71,7 @@ void VBucketMap::removeBucket(id_type id) {
 std::vector<VBucketMap::id_type> VBucketMap::getBuckets(void) const {
     std::vector<id_type> rv;
     for (id_type i = 0; i < size; ++i) {
-        RCPtr<VBucket> b(getBucket(i));
+        VBucketPtr b(getBucket(i));
         if (b) {
             rv.push_back(b->getId());
         }
@@ -84,7 +84,7 @@ std::vector<VBucketMap::id_type> VBucketMap::getBucketsSortedByState(void) const
     for (int state = vbucket_state_active;
          state <= vbucket_state_dead; ++state) {
         for (size_t i = 0; i < size; ++i) {
-            RCPtr<VBucket> b = getBucket(i);
+            VBucketPtr b = getBucket(i);
             if (b && b->getState() == state) {
                 rv.push_back(b->getId());
             }
@@ -97,7 +97,7 @@ std::vector<std::pair<VBucketMap::id_type, size_t> >
 VBucketMap::getActiveVBucketsSortedByChkMgrMem(void) const {
     std::vector<std::pair<id_type, size_t> > rv;
     for (id_type i = 0; i < size; ++i) {
-        RCPtr<VBucket> b = getBucket(i);
+        VBucketPtr b = getBucket(i);
         if (b && b->getState() == vbucket_state_active) {
             rv.push_back(std::make_pair(b->getId(), b->getChkMgrMemUsage()));
         }
@@ -118,7 +118,7 @@ VBucketMap::getActiveVBucketsSortedByChkMgrMem(void) const {
 void VBucketMap::addBuckets(const std::vector<VBucket*> &newBuckets) {
     std::vector<VBucket*>::const_iterator it;
     for (it = newBuckets.begin(); it != newBuckets.end(); ++it) {
-        RCPtr<VBucket> v(*it);
+        VBucketPtr v(*it);
         addBucket(v);
     }
 }
index 6c6d0a1..4e694ed 100644 (file)
@@ -56,10 +56,10 @@ public:
 
     VBucketMap(Configuration& config, KVBucket& store);
 
-    ENGINE_ERROR_CODE addBucket(const RCPtr<VBucket> &b);
+    ENGINE_ERROR_CODE addBucket(const VBucketPtr &b);
     void removeBucket(id_type id);
     void addBuckets(const std::vector<VBucket*> &newBuckets);
-    RCPtr<VBucket> getBucket(id_type id) const;
+    VBucketPtr getBucket(id_type id) const;
 
     // Returns the size of the map, i.e. the total number of VBuckets it can
     // contain.
index 9de5fdd..c66ceef 100644 (file)
@@ -22,7 +22,7 @@
 #include <sstream>
 
 VBucketMemoryDeletionTask::VBucketMemoryDeletionTask(
-        EventuallyPersistentEngine& eng, RCPtr<VBucket>& vb, double delay)
+        EventuallyPersistentEngine& eng, VBucketPtr& vb, double delay)
     : GlobalTask(&eng, TaskId::VBucketMemoryDeletionTask, delay, true),
       e(eng),
       vbucket(vb) {
index af96138..b26da60 100644 (file)
@@ -27,7 +27,7 @@
 class VBucketMemoryDeletionTask : public GlobalTask {
 public:
     VBucketMemoryDeletionTask(EventuallyPersistentEngine& eng,
-                              RCPtr<VBucket>& vb,
+                              VBucketPtr& vb,
                               double delay);
 
     cb::const_char_buffer getDescription();
@@ -36,6 +36,6 @@ public:
 
 private:
     EventuallyPersistentEngine& e;
-    RCPtr<VBucket> vbucket;
+    VBucketPtr vbucket;
     std::string description;
 };
index 13146b2..7ae54bb 100644 (file)
@@ -488,7 +488,7 @@ void LoadStorageKVPairCallback::callback(GetValue &val) {
 
     bool stopLoading = false;
     if (i != NULL && !epstore.getWarmup()->isComplete()) {
-        RCPtr<VBucket> vb = vbuckets.getBucket(i->getVBucketId());
+        VBucketPtr vb = vbuckets.getBucket(i->getVBucketId());
         if (!vb) {
             setStatus(ENGINE_NOT_MY_VBUCKET);
             return;
@@ -603,7 +603,7 @@ void LoadStorageKVPairCallback::purge() {
         EmergencyPurgeVisitor(KVBucket& store) :
             epstore(store) {}
 
-        void visitBucket(RCPtr<VBucket> &vb) override {
+        void visitBucket(VBucketPtr &vb) override {
             if (vBucketFilter(vb->getId())) {
                 currentBucket = vb;
                 vb->ht.visit(*this);
@@ -618,13 +618,13 @@ void LoadStorageKVPairCallback::purge() {
 
     private:
         KVBucket& epstore;
-        RCPtr<VBucket> currentBucket;
+        VBucketPtr currentBucket;
     };
 
     auto vbucketIds(vbuckets.getBuckets());
     EmergencyPurgeVisitor epv(epstore);
     for (auto vbid : vbucketIds) {
-        RCPtr<VBucket> vb = vbuckets.getBucket(vbid);
+        VBucketPtr vb = vbuckets.getBucket(vbid);
         if (vb) {
             epv.visitBucket(vb);
         }
@@ -635,7 +635,7 @@ void LoadStorageKVPairCallback::purge() {
 void LoadValueCallback::callback(CacheLookup &lookup)
 {
     if (warmupState == WarmupState::LoadingData) {
-        RCPtr<VBucket> vb = vbuckets.getBucket(lookup.getVBucketId());
+        VBucketPtr vb = vbuckets.getBucket(lookup.getVBucketId());
         if (!vb) {
             return;
         }
@@ -767,7 +767,7 @@ void Warmup::createVBuckets(uint16_t shardId) {
         uint16_t vbid = itr.first;
         vbucket_state vbs = itr.second;
 
-        RCPtr<VBucket> vb = store.getVBucket(vbid);
+        VBucketPtr vb = store.getVBucket(vbid);
         if (!vb) {
             std::unique_ptr<FailoverTable> table;
             if (vbs.failovers.empty()) {
@@ -843,7 +843,7 @@ void Warmup::estimateDatabaseItemCount(uint16_t shardId)
     for (const auto vbid : shardVbIds[shardId]) {
         size_t vbItemCount = store.getROUnderlyingByShard(shardId)->
                                                         getItemCount(vbid);
-        RCPtr<VBucket> vb = store.getVBucket(vbid);
+        VBucketPtr vb = store.getVBucket(vbid);
         if (vb) {
             vb->ht.numTotalItems = vbItemCount;
         }
index 5ba0eaa..07bf592 100644 (file)
@@ -50,7 +50,7 @@ public:
     }
 
     // Expose underlying protected ActiveStream methods as public
-    void public_getOutstandingItems(RCPtr<VBucket>& vb,
+    void public_getOutstandingItems(VBucketPtr& vb,
                                     std::vector<queued_item>& items) {
         getOutstandingItems(vb, items);
     }
index 3d03382..89e05bd 100644 (file)
@@ -60,7 +60,7 @@ private:
 };
 
 static void assertVBucket(const VBucketMap& vbm, int id) {
-    RCPtr<VBucket> v = vbm.getBucket(id);
+    VBucketPtr v = vbm.getBucket(id);
     cb_assert(v);
     cb_assert(v->getId() == id);
 }
@@ -87,7 +87,7 @@ public:
         for (size_t j = 0; j < vbucketsEach; j++) {
             int newId = ++i;
 
-            RCPtr<VBucket> v(new VBucket(newId, vbucket_state_active,
+            VBucketPtr v(new VBucket(newId, vbucket_state_active,
                                          global_stats, checkpoint_config, NULL));
             vbm->addBucket(v);
             cb_assert(vbm->getBucket(newId) == v);
@@ -201,7 +201,7 @@ static void testGetVBucketsByState(void) {
 
     int st = vbucket_state_dead;
     for (int id = 0; id < 4; id++, st--) {
-        RCPtr<VBucket> v(new VBucket(id, (vbucket_state_t)st, global_stats,
+        VBucketPtr v(new VBucket(id, (vbucket_state_t)st, global_stats,
                                      checkpoint_config, NULL));
         vbm.addBucket(v);
         cb_assert(vbm.getBucket(id) == v);
index 7ca0be3..0d92a85 100644 (file)
@@ -49,7 +49,7 @@ TEST_F(CollectionsTest, namespace_separation) {
     store_item(vbid,
                {"$collections::create:meat1", DocNamespace::DefaultCollection},
                "value");
-    RCPtr<VBucket> vb = store->getVBucket(vbid);
+    VBucketPtr vb = store->getVBucket(vbid);
     // Add the meat collection
     vb->updateFromManifest(
             {R"({"revision":1,)"
@@ -97,7 +97,7 @@ TEST_F(CollectionsTest, collections_basic) {
                0,
                {cb::engine_errc::unknown_collection});
 
-    RCPtr<VBucket> vb = store->getVBucket(vbid);
+    VBucketPtr vb = store->getVBucket(vbid);
 
     // Add the meat collection
     vb->updateFromManifest(
@@ -208,7 +208,7 @@ void CollectionsFlushTest::storeItems(const std::string& collection,
 
 std::string CollectionsFlushTest::createCollectionAndFlush(
         const std::string& json, const std::string& collection, int items) {
-    RCPtr<VBucket> vb = store->getVBucket(vbid);
+    VBucketPtr vb = store->getVBucket(vbid);
     vb->updateFromManifest(json);
     storeItems(collection, DocNamespace::Collections, items);
     flush_vbucket_to_disk(vbid, 1 + items); // create event + items
@@ -217,7 +217,7 @@ std::string CollectionsFlushTest::createCollectionAndFlush(
 
 std::string CollectionsFlushTest::deleteCollectionAndFlush(
         const std::string& json, const std::string& collection, int items) {
-    RCPtr<VBucket> vb = store->getVBucket(vbid);
+    VBucketPtr vb = store->getVBucket(vbid);
     storeItems(collection, DocNamespace::Collections, items);
     vb->updateFromManifest(json);
     flush_vbucket_to_disk(vbid, items); // only flush items
@@ -226,7 +226,7 @@ std::string CollectionsFlushTest::deleteCollectionAndFlush(
 
 std::string CollectionsFlushTest::completeDeletionAndFlush(
         const std::string& collection, int revision, int items) {
-    RCPtr<VBucket> vb = store->getVBucket(vbid);
+    VBucketPtr vb = store->getVBucket(vbid);
     vb->completeDeletion(collection, revision);
     storeItems("defaultcollection", DocNamespace::DefaultCollection, items);
     flush_vbucket_to_disk(vbid, 1 + items); // delete event + items
@@ -416,7 +416,7 @@ private:
 // or after a delete.
 //
 TEST_F(CollectionsTest, checkpoint_consistency) {
-    RCPtr<VBucket> vb = store->getVBucket(vbid);
+    VBucketPtr vb = store->getVBucket(vbid);
     CollectionsThreadTest threadTest(*this, *vb, 256, 256);
     threadTest.run();
 
@@ -493,7 +493,7 @@ public:
 // persisted collection state and should have the collection accessible.
 //
 TEST_F(CollectionsWarmupTest, warmup) {
-    RCPtr<VBucket> vb = store->getVBucket(vbid);
+    VBucketPtr vb = store->getVBucket(vbid);
 
     // Add the meat collection
     vb->updateFromManifest(
@@ -573,7 +573,7 @@ TEST_F(CollectionsTest, test_dcp_consumer) {
                                        /*end_seqno*/ 100,
                                        /*flags*/ 0));
 
-    RCPtr<VBucket> vb = store->getVBucket(vbid);
+    VBucketPtr vb = store->getVBucket(vbid);
 
     EXPECT_FALSE(vb->lockCollections().doesKeyContainValidCollection(
             {"meat::bacon", DocNamespace::Collections}));
@@ -723,7 +723,7 @@ SingleThreadedRCPtr<MockDcpConsumer> CollectionsDcpTest::consumer;
  * The test replicates VBn to VBn+1
  */
 TEST_F(CollectionsDcpTest, test_dcp) {
-    RCPtr<VBucket> vb = store->getVBucket(vbid);
+    VBucketPtr vb = store->getVBucket(vbid);
 
     // Add a collection, then remove it. This generated events into the CP which
     // we'll manually replicate with calls to step
@@ -748,7 +748,7 @@ TEST_F(CollectionsDcpTest, test_dcp) {
     // Next step which will process a snapshot marker
     EXPECT_EQ(ENGINE_WANT_MORE, producer->step(producers.get()));
 
-    RCPtr<VBucket> replica = store->getVBucket(replicaVB);
+    VBucketPtr replica = store->getVBucket(replicaVB);
 
     // 1. Replica does not know about meat
     EXPECT_FALSE(vb->lockCollections().doesKeyContainValidCollection(
@@ -773,7 +773,7 @@ TEST_F(CollectionsDcpTest, test_dcp) {
 }
 
 TEST_F(CollectionsDcpTest, test_dcp_separator) {
-    RCPtr<VBucket> vb = store->getVBucket(vbid);
+    VBucketPtr vb = store->getVBucket(vbid);
 
     // Change the separator
     vb->updateFromManifest(
@@ -796,7 +796,7 @@ TEST_F(CollectionsDcpTest, test_dcp_separator) {
     // Next step which should process a snapshot marker
     EXPECT_EQ(ENGINE_WANT_MORE, producer->step(producers.get()));
 
-    RCPtr<VBucket> replica = store->getVBucket(replicaVB);
+    VBucketPtr replica = store->getVBucket(replicaVB);
 
     // Now step the producer to transfer the separator
     EXPECT_EQ(ENGINE_WANT_MORE, producer->step(producers.get()));
index 4988d53..eeeb691 100644 (file)
@@ -131,7 +131,7 @@ protected:
 
     dcp_producer_t producer;
     stream_t stream;
-    RCPtr<VBucket> vb0;
+    VBucketPtr vb0;
 };
 
 /* Regression test for MB-17766 - ensure that when an ActiveStream is preparing
index c1484be..95f71c5 100644 (file)
@@ -472,7 +472,7 @@ public:
     const void* cookie;
     SingleThreadedRCPtr<MockDcpConsumer> consumer;
     std::unique_ptr<dcp_message_producers> producers;
-    RCPtr<VBucket> vb;
+    VBucketPtr vb;
 };
 
 RollbackDcpTest::StreamRequestData RollbackDcpTest::streamRequestData = {};
index 466d2ed..ad5c313 100644 (file)
@@ -812,7 +812,7 @@ TEST_F(MB20054_SingleThreadedEPStoreTest, MB20054_onDeleteItem_during_bucket_del
     store_item(vbid, makeStoredDocKey("key"), "value");
 
     // Force a new checkpoint.
-    RCPtr<VBucket> vb = store->getVBuckets().getBucket(vbid);
+    VBucketPtr vb = store->getVBuckets().getBucket(vbid);
     CheckpointManager& ckpt_mgr = vb->checkpointManager;
     ckpt_mgr.createNewCheckpoint();
     auto lpWriterQ = task_executor->getLpTaskQ()[WRITER_TASK_IDX];
index 6162890..4ebaa42 100644 (file)
@@ -348,7 +348,7 @@ TEST_P(EPStoreEvictionTest, MB_21976) {
     unlock_mock_cookie(cookie);
 
     // Manually run the VBucketMemoryDeletionTask task
-    RCPtr<VBucket> vb = store->getVBucket(vbid);
+    VBucketPtr vb = store->getVBucket(vbid);
     VBucketMemoryDeletionTask deletionTask(*engine, vb, /*delay*/0.0);
     deletionTask.run();