-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MB-16181: Transfer the collection name over DCP
The DCP mutation/deletion callbacks now take a collection_len field, the data in this field will be sent over DCP streams when a client has signalled they want collection-aware DCP. For example "dairy::cheese" will set a collection length of 5, default collection documents, set a collection length of 0. Change-Id: I303d9b18bc5d0fd0968708d84e461ee59577c003 Reviewed-on: http://review.couchbase.org/78135 Reviewed-by: Dave Rigby <daver@couchbase.com> Tested-by: Build Bot <build@couchbase.com>
- Loading branch information
1 parent
126ed5a
commit e708fe3
Showing
6 changed files
with
99 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */ | ||
/* | ||
* Copyright 2017 Couchbase, Inc | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#include "stats.h" | ||
|
||
void EPStats::memAllocated(size_t sz) { | ||
if (isShutdown) { | ||
return; | ||
} | ||
|
||
if (localMemCounter.get() == nullptr) { | ||
// this HAS to be a non-bucket allocation | ||
// or else the callbacks would try to call this | ||
// function again & it would become an infinite loop | ||
SystemAllocationGuard system_alloc_guard; | ||
localMemCounter.set(new TLMemCounter()); | ||
} | ||
|
||
if (0 == sz) { | ||
return; | ||
} | ||
|
||
localMemCounter.get()->used += sz; | ||
mergeMemCounter(); | ||
} | ||
|
||
void EPStats::memDeallocated(size_t sz) { | ||
if (isShutdown) { | ||
return; | ||
} | ||
|
||
if (localMemCounter.get() == nullptr) { | ||
// this HAS to be a non-bucket allocation | ||
// or else the callbacks would try to call this | ||
// function again & it would become an infinite loop | ||
SystemAllocationGuard system_alloc_guard; | ||
localMemCounter.set(new TLMemCounter()); | ||
} | ||
|
||
if (0 == sz) { | ||
return; | ||
} | ||
|
||
localMemCounter.get()->used -= sz; | ||
mergeMemCounter(); | ||
} | ||
|
||
void EPStats::mergeMemCounter(bool force) { | ||
auto& counter = *(localMemCounter.get()); | ||
counter.count++; | ||
if (force || counter.count % mem_merge_count_threshold == 0 || | ||
std::abs(counter.used) > (long)mem_merge_bytes_threshold) { | ||
totalMemory->fetch_add(counter.used); | ||
counter.used = 0; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters