treewide: use std::filesystem
Rather than {std::experimental,boost,seastar::compat}::filesystem
On Sat, 2019-03-23 at 01:44 +0200, Avi Kivity wrote:
> The intent for seastar::compat was to allow the application to choose
> the C++ dialect and have seastar follow, rather than have seastar choose
> the types and have the application follow (as in your patch).
Signed-off-by: Benny Halevy <bhalevy@scylladb.com>
This commit is contained in:
@@ -1111,7 +1111,7 @@ for mode in build_modes:
|
||||
args.user_cflags += " " + pkg_config('jsoncpp', '--cflags')
|
||||
args.user_cflags += ' -march=' + args.target
|
||||
libs = ' '.join([maybe_static(args.staticyamlcpp, '-lyaml-cpp'), '-latomic', '-llz4', '-lz', '-lsnappy', pkg_config('jsoncpp', '--libs'),
|
||||
maybe_static(args.staticboost, '-lboost_filesystem'), ' -lstdc++fs', ' -lcrypt', ' -lcryptopp', ' -lpthread',
|
||||
' -lstdc++fs', ' -lcrypt', ' -lcryptopp', ' -lpthread',
|
||||
maybe_static(args.staticboost, '-lboost_date_time'), ])
|
||||
|
||||
xxhash_dir = 'xxHash'
|
||||
|
||||
@@ -134,8 +134,8 @@ db::config::add_options(boost::program_options::options_description_easy_init& i
|
||||
return init;
|
||||
}
|
||||
|
||||
boost::filesystem::path db::config::get_conf_dir() {
|
||||
using namespace boost::filesystem;
|
||||
db::fs::path db::config::get_conf_dir() {
|
||||
using namespace db::fs;
|
||||
|
||||
path confdir;
|
||||
auto* cd = std::getenv("SCYLLA_CONF");
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <boost/program_options.hpp>
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <unordered_map>
|
||||
|
||||
#include <seastar/core/sstring.hh>
|
||||
@@ -39,6 +38,8 @@ namespace seastar { class file; struct logging_settings; }
|
||||
|
||||
namespace db {
|
||||
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
class extensions;
|
||||
|
||||
/*
|
||||
@@ -74,7 +75,7 @@ public:
|
||||
* @return path of the directory where configuration files are located
|
||||
* according the environment variables definitions.
|
||||
*/
|
||||
static boost::filesystem::path get_conf_dir();
|
||||
static fs::path get_conf_dir();
|
||||
|
||||
using string_map = std::unordered_map<sstring, sstring>;
|
||||
//program_options::string_map;
|
||||
|
||||
@@ -798,7 +798,7 @@ void manager::end_point_hints_manager::sender::send_hints_maybe() noexcept {
|
||||
manager_logger.trace("send_hints(): we handled {} segments", replayed_segments_count);
|
||||
}
|
||||
|
||||
static future<> scan_for_hints_dirs(const sstring& hints_directory, std::function<future<> (stdx::filesystem::path dir, directory_entry de, unsigned shard_id)> f) {
|
||||
static future<> scan_for_hints_dirs(const sstring& hints_directory, std::function<future<> (fs::path dir, directory_entry de, unsigned shard_id)> f) {
|
||||
return lister::scan_dir(hints_directory, { directory_entry_type::directory }, [f = std::move(f)] (fs::path dir, directory_entry de) mutable {
|
||||
try {
|
||||
return f(std::move(dir), std::move(de), std::stoi(de.name.c_str()));
|
||||
|
||||
@@ -27,7 +27,6 @@
|
||||
#include "disk-error-handler.hh"
|
||||
#include "seastarx.hh"
|
||||
#include <seastar/core/sleep.hh>
|
||||
#include <boost/filesystem.hpp>
|
||||
|
||||
namespace db {
|
||||
namespace hints {
|
||||
@@ -198,7 +197,7 @@ future<> resource_manager::prepare_per_device_limits() {
|
||||
// Since we possibly deferred, we need to recheck the _per_device_limits_map.
|
||||
if (inserted) {
|
||||
// By default, give each group of managers 10% of the available disk space. Give each shard an equal share of the available space.
|
||||
it->second.max_shard_disk_space_size = boost::filesystem::space(shard_manager.hints_dir().c_str()).capacity / (10 * smp::count);
|
||||
it->second.max_shard_disk_space_size = std::filesystem::space(shard_manager.hints_dir().c_str()).capacity / (10 * smp::count);
|
||||
// If hints directory is a mountpoint, we assume it's on dedicated (i.e. not shared with data/commitlog/etc) storage.
|
||||
// Then, reserve 90% of all space instead of 10% above.
|
||||
if (is_mountpoint) {
|
||||
|
||||
@@ -22,14 +22,14 @@
|
||||
#pragma once
|
||||
|
||||
#include <unordered_set>
|
||||
#include <filesystem>
|
||||
#include <seastar/core/shared_ptr.hh>
|
||||
#include <seastar/core/file.hh>
|
||||
#include <seastar/core/enum.hh>
|
||||
#include <experimental/filesystem>
|
||||
|
||||
#include "seastarx.hh"
|
||||
|
||||
namespace fs = std::experimental::filesystem;
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
class lister final {
|
||||
public:
|
||||
|
||||
@@ -56,7 +56,7 @@ production_snitch_base::production_snitch_base(const sstring& prop_file_name)
|
||||
if (!prop_file_name.empty()) {
|
||||
_prop_file_name = prop_file_name;
|
||||
} else {
|
||||
using namespace boost::filesystem;
|
||||
using namespace db::fs;
|
||||
|
||||
path def_prop_file(db::config::get_conf_dir());
|
||||
def_prop_file /= path(snitch_properties_filename);
|
||||
|
||||
@@ -42,7 +42,6 @@
|
||||
#include <utility>
|
||||
#include <optional>
|
||||
#include <unordered_set>
|
||||
#include <boost/filesystem.hpp>
|
||||
|
||||
#include "gms/endpoint_state.hh"
|
||||
#include "locator/token_metadata.hh"
|
||||
|
||||
9
main.cc
9
main.cc
@@ -70,6 +70,8 @@
|
||||
#include "gms/feature_service.hh"
|
||||
#include "distributed_loader.hh"
|
||||
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
seastar::metrics::metric_groups app_metrics;
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
@@ -91,14 +93,13 @@ V get_or_default(const std::unordered_map<K, V, Args...>& ss, const K2& key, con
|
||||
return def;
|
||||
}
|
||||
|
||||
static boost::filesystem::path relative_conf_dir(boost::filesystem::path path) {
|
||||
static fs::path relative_conf_dir(fs::path path) {
|
||||
static auto conf_dir = db::config::get_conf_dir(); // this is not gonna change in our life time
|
||||
return conf_dir / path;
|
||||
}
|
||||
|
||||
static future<>
|
||||
read_config(bpo::variables_map& opts, db::config& cfg) {
|
||||
using namespace boost::filesystem;
|
||||
sstring file;
|
||||
|
||||
if (opts.count("options-file") > 0) {
|
||||
@@ -568,7 +569,7 @@ int main(int ac, char** av) {
|
||||
|
||||
supervisor::notify("creating hints directories");
|
||||
if (hinted_handoff_enabled) {
|
||||
boost::filesystem::path hints_base_dir(db.local().get_config().hints_directory());
|
||||
fs::path hints_base_dir(db.local().get_config().hints_directory());
|
||||
dirs.touch_and_lock(db.local().get_config().hints_directory()).get();
|
||||
directories.insert(db.local().get_config().hints_directory());
|
||||
for (unsigned i = 0; i < smp::count; ++i) {
|
||||
@@ -577,7 +578,7 @@ int main(int ac, char** av) {
|
||||
directories.insert(std::move(shard_dir));
|
||||
}
|
||||
}
|
||||
boost::filesystem::path view_pending_updates_base_dir = boost::filesystem::path(db.local().get_config().view_hints_directory());
|
||||
fs::path view_pending_updates_base_dir = fs::path(db.local().get_config().view_hints_directory());
|
||||
sstring view_pending_updates_base_dir_str = view_pending_updates_base_dir.native();
|
||||
dirs.touch_and_lock(view_pending_updates_base_dir_str).get();
|
||||
directories.insert(view_pending_updates_base_dir_str);
|
||||
|
||||
@@ -33,7 +33,6 @@
|
||||
#include <seastar/core/distributed.hh>
|
||||
#include <unordered_set>
|
||||
#include <unordered_map>
|
||||
#include <experimental/filesystem>
|
||||
#include "types.hh"
|
||||
#include "clustering_key_filter.hh"
|
||||
#include <seastar/core/enum.hh>
|
||||
@@ -75,7 +74,7 @@ namespace mc {
|
||||
class writer;
|
||||
}
|
||||
|
||||
namespace fs = std::experimental::filesystem;
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
extern logging::logger sstlog;
|
||||
class key;
|
||||
|
||||
@@ -304,6 +304,8 @@ public:
|
||||
}
|
||||
|
||||
static future<> do_with(std::function<future<>(cql_test_env&)> func, cql_test_config cfg_in) {
|
||||
using namespace std::filesystem;
|
||||
|
||||
return seastar::async([cfg_in = std::move(cfg_in), func] {
|
||||
logalloc::prime_segment_pool(memory::stats().total_memory(), memory::min_free_memory()).get();
|
||||
bool old_active = false;
|
||||
@@ -339,13 +341,13 @@ public:
|
||||
cfg->ring_delay_ms() = 500;
|
||||
cfg->experimental() = true;
|
||||
cfg->shutdown_announce_in_ms() = 0;
|
||||
boost::filesystem::create_directories((data_dir_path + "/system").c_str());
|
||||
boost::filesystem::create_directories(cfg->commitlog_directory().c_str());
|
||||
boost::filesystem::create_directories(cfg->hints_directory().c_str());
|
||||
boost::filesystem::create_directories(cfg->view_hints_directory().c_str());
|
||||
create_directories((data_dir_path + "/system").c_str());
|
||||
create_directories(cfg->commitlog_directory().c_str());
|
||||
create_directories(cfg->hints_directory().c_str());
|
||||
create_directories(cfg->view_hints_directory().c_str());
|
||||
for (unsigned i = 0; i < smp::count; ++i) {
|
||||
boost::filesystem::create_directories((cfg->hints_directory() + "/" + std::to_string(i)).c_str());
|
||||
boost::filesystem::create_directories((cfg->view_hints_directory() + "/" + std::to_string(i)).c_str());
|
||||
create_directories((cfg->hints_directory() + "/" + std::to_string(i)).c_str());
|
||||
create_directories((cfg->view_hints_directory() + "/" + std::to_string(i)).c_str());
|
||||
}
|
||||
|
||||
const gms::inet_address listen("127.0.0.1");
|
||||
|
||||
@@ -24,16 +24,18 @@
|
||||
#include "locator/ec2_snitch.hh"
|
||||
#include "utils/fb_utilities.hh"
|
||||
#include <seastar/testing/test_case.hh>
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <seastar/util/std-compat.hh>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <tuple>
|
||||
|
||||
static boost::filesystem::path test_files_subdir("tests/snitch_property_files");
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
static fs::path test_files_subdir("tests/snitch_property_files");
|
||||
|
||||
future<> one_test(const std::string& property_fname, bool exp_result) {
|
||||
using namespace locator;
|
||||
using namespace boost::filesystem;
|
||||
using namespace std::filesystem;
|
||||
|
||||
printf("Testing %s property file: %s\n",
|
||||
(exp_result ? "well-formed" : "ill-formed"),
|
||||
|
||||
@@ -38,8 +38,11 @@
|
||||
#include <seastar/testing/test_case.hh>
|
||||
#include <seastar/http/httpd.hh>
|
||||
#include <seastar/net/inet_address.hh>
|
||||
#include <seastar/util/std-compat.hh>
|
||||
|
||||
static boost::filesystem::path test_files_subdir("tests/snitch_property_files");
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
static fs::path test_files_subdir("tests/snitch_property_files");
|
||||
static constexpr const char* DUMMY_META_SERVER_IP = "DUMMY_META_SERVER_IP";
|
||||
static constexpr const char* USE_GCE_META_SERVER = "USE_GCE_META_SERVER";
|
||||
|
||||
@@ -60,10 +63,9 @@ class gce_meta_get_handler : public seastar::httpd::handler_base {
|
||||
future<> one_test(const std::string& property_fname, bool exp_result) {
|
||||
return seastar::async([property_fname, exp_result] () {
|
||||
using namespace locator;
|
||||
using namespace boost::filesystem;
|
||||
|
||||
path fname(test_files_subdir);
|
||||
fname /= path(property_fname);
|
||||
fs::path fname(test_files_subdir);
|
||||
fname /= fs::path(property_fname);
|
||||
|
||||
utils::fb_utilities::set_broadcast_address(gms::inet_address("localhost"));
|
||||
utils::fb_utilities::set_broadcast_rpc_address(gms::inet_address("localhost"));
|
||||
|
||||
@@ -23,16 +23,18 @@
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include "locator/gossiping_property_file_snitch.hh"
|
||||
#include <seastar/testing/test_case.hh>
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <seastar/util/std-compat.hh>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <tuple>
|
||||
|
||||
static boost::filesystem::path test_files_subdir("tests/snitch_property_files");
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
static fs::path test_files_subdir("tests/snitch_property_files");
|
||||
|
||||
future<> one_test(const std::string& property_fname, bool exp_result) {
|
||||
using namespace locator;
|
||||
using namespace boost::filesystem;
|
||||
using namespace std::filesystem;
|
||||
|
||||
printf("Testing %s property file: %s\n",
|
||||
(exp_result ? "well-formed" : "ill-formed"),
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
#include <boost/range/irange.hpp>
|
||||
#include <boost/range/algorithm_ext.hpp>
|
||||
#include <boost/range/adaptors.hpp>
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <json/json.h>
|
||||
#include "tests/cql_test_env.hh"
|
||||
#include "tests/perf/perf.hh"
|
||||
|
||||
@@ -23,18 +23,20 @@
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include "locator/gossiping_property_file_snitch.hh"
|
||||
#include <seastar/testing/test_case.hh>
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <seastar/util/std-compat.hh>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <tuple>
|
||||
|
||||
static boost::filesystem::path test_files_subdir("tests/snitch_property_files");
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
static fs::path test_files_subdir("tests/snitch_property_files");
|
||||
|
||||
future<> one_test(const std::string& property_fname1,
|
||||
const std::string& property_fname2,
|
||||
bool exp_result) {
|
||||
using namespace locator;
|
||||
using namespace boost::filesystem;
|
||||
using namespace std::filesystem;
|
||||
|
||||
utils::fb_utilities::set_broadcast_address(gms::inet_address("localhost"));
|
||||
utils::fb_utilities::set_broadcast_rpc_address(gms::inet_address("localhost"));
|
||||
|
||||
@@ -3086,7 +3086,7 @@ static sstring get_write_test_path(sstring table_name) {
|
||||
}
|
||||
|
||||
// This method should not be called for compressed sstables because compression is not deterministic
|
||||
static void compare_sstables(const seastar::compat::filesystem::path& result_path, sstring table_name) {
|
||||
static void compare_sstables(const std::filesystem::path& result_path, sstring table_name) {
|
||||
for (auto file_type : {component_type::Data,
|
||||
component_type::Index,
|
||||
component_type::Digest,
|
||||
@@ -3136,7 +3136,7 @@ static tmpdir write_and_compare_sstables(schema_ptr s, lw_shared_ptr<memtable> m
|
||||
return tmp;
|
||||
}
|
||||
|
||||
static sstable_assertions validate_read(schema_ptr s, const seastar::compat::filesystem::path& path, std::vector<mutation> mutations) {
|
||||
static sstable_assertions validate_read(schema_ptr s, const std::filesystem::path& path, std::vector<mutation> mutations) {
|
||||
sstable_assertions sst(s, path.string(), 1);
|
||||
sst.load();
|
||||
|
||||
|
||||
@@ -66,6 +66,8 @@
|
||||
|
||||
#include "sstable_utils.hh"
|
||||
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
using namespace sstables;
|
||||
|
||||
static const sstring some_keyspace("ks");
|
||||
@@ -3633,7 +3635,7 @@ SEASTAR_TEST_CASE(test_partition_skipping) {
|
||||
|
||||
// Must be run in a seastar thread
|
||||
static
|
||||
shared_sstable make_sstable_easy(test_env& env, const seastar::compat::filesystem::path& path, flat_mutation_reader rd, sstable_writer_config cfg, const sstables::sstable::version_types version) {
|
||||
shared_sstable make_sstable_easy(test_env& env, const fs::path& path, flat_mutation_reader rd, sstable_writer_config cfg, const sstables::sstable::version_types version) {
|
||||
auto s = rd.schema();
|
||||
auto sst = env.make_sstable(s, path.string(), 1, version, big);
|
||||
sst->write_components(std::move(rd), 1, s, cfg, encoding_stats{}).get();
|
||||
@@ -3817,8 +3819,7 @@ SEASTAR_TEST_CASE(test_skipping_using_index) {
|
||||
});
|
||||
}
|
||||
|
||||
static void copy_directory(boost::filesystem::path src_dir, boost::filesystem::path dst_dir) {
|
||||
namespace fs = boost::filesystem;
|
||||
static void copy_directory(fs::path src_dir, fs::path dst_dir) {
|
||||
fs::create_directory(dst_dir);
|
||||
auto src_dir_components = std::distance(src_dir.begin(), src_dir.end());
|
||||
using rdi = fs::recursive_directory_iterator;
|
||||
|
||||
@@ -33,7 +33,6 @@
|
||||
#include "tests/test_services.hh"
|
||||
#include "tests/sstable_test_env.hh"
|
||||
#include "tmpdir.hh"
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <array>
|
||||
|
||||
constexpr auto la = sstables::sstable::version_types::la;
|
||||
@@ -689,11 +688,11 @@ public:
|
||||
storage_service_for_tests ssft;
|
||||
auto src_dir = tmpdir();
|
||||
auto dest_dir = tmpdir();
|
||||
for (const auto& entry : seastar::compat::filesystem::directory_iterator(src.c_str())) {
|
||||
seastar::compat::filesystem::copy(entry.path(), src_dir.path() / entry.path().filename());
|
||||
for (const auto& entry : std::filesystem::directory_iterator(src.c_str())) {
|
||||
std::filesystem::copy(entry.path(), src_dir.path() / entry.path().filename());
|
||||
}
|
||||
auto dest_path = dest_dir.path() / src.c_str();
|
||||
seastar::compat::filesystem::create_directories(dest_path);
|
||||
std::filesystem::create_directories(dest_path);
|
||||
test_env env;
|
||||
fut(env, src_dir.path().string(), dest_path.string()).get();
|
||||
});
|
||||
|
||||
@@ -27,23 +27,25 @@
|
||||
|
||||
#include "utils/UUID.hh"
|
||||
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
// Creates a new empty directory with arbitrary name, which will be removed
|
||||
// automatically when tmpdir object goes out of scope.
|
||||
class tmpdir {
|
||||
seastar::compat::filesystem::path _path;
|
||||
fs::path _path;
|
||||
|
||||
private:
|
||||
void remove() {
|
||||
if (!_path.empty()) {
|
||||
seastar::compat::filesystem::remove_all(_path);
|
||||
fs::remove_all(_path);
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
tmpdir()
|
||||
: _path(seastar::compat::filesystem::temp_directory_path() /
|
||||
fmt::format(FMT_STRING("scylla-{}"), utils::make_random_uuid())) {
|
||||
seastar::compat::filesystem::create_directories(_path);
|
||||
: _path(fs::temp_directory_path() /
|
||||
fs::path(fmt::format(FMT_STRING("scylla-{}"), utils::make_random_uuid()))) {
|
||||
fs::create_directories(_path);
|
||||
}
|
||||
|
||||
tmpdir(tmpdir&& other) noexcept : _path(std::exchange(other._path, {})) { }
|
||||
@@ -58,5 +60,5 @@ public:
|
||||
remove();
|
||||
}
|
||||
|
||||
const seastar::compat::filesystem::path& path() const noexcept { return _path; }
|
||||
const fs::path& path() const noexcept { return _path; }
|
||||
};
|
||||
|
||||
@@ -27,7 +27,6 @@
|
||||
#include <string_view>
|
||||
|
||||
#include <boost/program_options.hpp>
|
||||
#include <boost/filesystem.hpp>
|
||||
|
||||
#include <seastar/core/sstring.hh>
|
||||
#include <seastar/core/future.hh>
|
||||
|
||||
Reference in New Issue
Block a user