Skip to content

Commit 8431600

Browse files
committed
CBD-6348: Changes required to upgrade boost
Remove use of features no available in the new version of boost Change-Id: I1309e65339b271838e7361bf5d1818e1569df908 Reviewed-on: https://review.couchbase.org/c/kv_engine/+/234654 Tested-by: Trond Norbye <[email protected]> Reviewed-by: Jim Walker <[email protected]> Well-Formed: Restriction Checker
1 parent 2bf70e3 commit 8431600

File tree

3 files changed

+20
-19
lines changed

3 files changed

+20
-19
lines changed

engines/ep/src/ep_engine.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@
8282

8383
#include <chrono>
8484
#include <cstring>
85+
#include <fstream>
8586
#include <iostream>
8687
#include <limits>
8788
#include <memory>
@@ -2009,10 +2010,9 @@ std::optional<size_t> EventuallyPersistentEngine::getShardCountFromDisk() {
20092010
Expects(configuration.getBackend() == "magma");
20102011

20112012
// Look for the file
2012-
const auto shardFile = boost::filesystem::path(
2013-
configuration.getDbname().append(magmaShardFile));
2014-
if (boost::filesystem::exists(shardFile)) {
2015-
boost::filesystem::ifstream ifs(shardFile);
2013+
const auto shardFile = configuration.getDbname().append(magmaShardFile);
2014+
if (cb::io::isFile(shardFile)) {
2015+
std::ifstream ifs(shardFile);
20162016
std::string data;
20172017
std::getline(ifs, data);
20182018
EP_LOG_INFO("Found shard file for magma with {} shards", data);
@@ -7261,4 +7261,4 @@ std::string EventuallyPersistentEngine::getDcpDisconnectWhenStuckNameRegex()
72617261

72627262
bool EventuallyPersistentEngine::isMagmaBlindWriteOptimisationEnabled() const {
72637263
return serverApi->core->isMagmaBlindWriteOptimisationEnabled();
7264-
}
7264+
}

engines/ep/tests/ep_testsuite.cc

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
#include "kvstore/couch-kvstore/couch-kvstore-metadata.h"
2525
#include "kvstore/storage_common/storage_common/local_doc_constants.h"
2626
#include "module_tests/thread_gate.h"
27-
#include <boost/filesystem.hpp>
2827
#include <executor/executorpool.h>
2928
#include <libcouchstore/couch_db.h>
3029
#include <memcached/engine.h>
@@ -43,6 +42,7 @@
4342
#include <cstdio>
4443
#include <cstdlib>
4544
#include <cstring>
45+
#include <filesystem>
4646
#include <iostream>
4747
#include <map>
4848
#include <mutex>
@@ -7790,18 +7790,18 @@ static enum test_result test_mb65737_check_flush_fails(EngineIface* h) {
77907790

77917791
// db file contains persistenceSeqno = 10
77927792
// Rename couchstore file to simulate loss of data
7793-
namespace fs = boost::filesystem;
7794-
std::string dbname = get_dbname(testHarness->get_current_testcase()->cfg);
7795-
std::string oldFileName = dbname + cb::io::DirectorySeparator + "0.couch.1";
7796-
std::string newFileName = dbname + cb::io::DirectorySeparator + "goodbye";
7793+
const std::filesystem::path dbname =
7794+
get_dbname(testHarness->get_current_testcase()->cfg);
7795+
const auto oldFileName = dbname / "0.couch.1";
7796+
const auto newFileName = dbname / "goodbye";
77977797
try {
7798-
if (!fs::exists(oldFileName)) {
7798+
if (!exists(oldFileName)) {
77997799
std::cerr << "Error: Source file does not exist: " << oldFileName
78007800
<< '\n';
78017801
return FAIL;
78027802
}
7803-
fs::rename(oldFileName, newFileName);
7804-
} catch (const fs::filesystem_error& e) {
7803+
rename(oldFileName, newFileName);
7804+
} catch (const std::filesystem::filesystem_error& e) {
78057805
std::cerr << "Error renaming file: " << e.what() << '\n';
78067806
return FAIL;
78077807
}
@@ -7817,10 +7817,10 @@ static enum test_result test_mb65737_check_flush_fails(EngineIface* h) {
78177817
wait_for_warmup_complete(h);
78187818

78197819
// Bring db file back
7820-
if (fs::exists(oldFileName)) {
7821-
fs::remove(oldFileName);
7820+
if (exists(oldFileName)) {
7821+
remove(oldFileName);
78227822
}
7823-
fs::rename(newFileName, oldFileName);
7823+
rename(newFileName, oldFileName);
78247824

78257825
// Store 5 items, highSeqno = 5 and persistenceSeqno=10 (from disk)
78267826
write_items(h, 5, 0, keyBase.c_str(), "value", 0, vb);
@@ -7843,8 +7843,8 @@ static enum test_result test_mb65737_check_flush_fails(EngineIface* h) {
78437843
get_int_stat(h, "vb_0:last_persisted_seqno", "vbucket-seqno"),
78447844
"Unexpected last_persisted_seqno");
78457845

7846-
fs::remove(oldFileName);
7847-
fs::create_directories(dbname);
7846+
remove(oldFileName);
7847+
create_directories(dbname);
78487848
return SUCCESS;
78497849
}
78507850

engines/ep/tests/module_tests/kvstore_test.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#include <executor/workload.h>
3838
#include <folly/portability/GTest.h>
3939
#include <platform/dirutils.h>
40+
#include <fstream>
4041
#include <thread>
4142
#include <unordered_map>
4243
#include <utility>
@@ -1465,7 +1466,7 @@ void KVStoreParamTestSkipRocks::corruptCouchKVStoreDataFile() {
14651466
}
14661467
// manually write nothing to the file as resizing it to 0 using boost
14671468
// fails on windows.
1468-
fs::ofstream osf{dataFile};
1469+
std::ofstream osf{dataFile.string()};
14691470
if (osf.is_open()) {
14701471
osf << "";
14711472
osf.close();

0 commit comments

Comments
 (0)