summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKefu Chai <tchaikov@gmail.com>2022-01-22 14:30:38 +0800
committerGitHub <noreply@github.com>2022-01-22 14:30:38 +0800
commit67ee1fba6ce3c6bc8a0a3ff767f4148872c04be2 (patch)
tree1ae3fc7fe1cc64b17ca923e524a12a467ec73433
parentdd917a54bc9ce7c7dcf4bf6d330f6179f497060e (diff)
parent636ea2382e83bee182c1aa76a5461cd83d001b5f (diff)
downloadceph-67ee1fba6ce3c6bc8a0a3ff767f4148872c04be2.tar.gz
Merge pull request #44736 from adamemerson/wip-no-using-namespace-std
src: Remove some 'using namespace std' lines that crept back into headers Reviewed-by: Kefu Chai <tchaikov@gmail.com>
-rw-r--r--src/crimson/admin/admin_socket.cc1
-rw-r--r--src/crimson/admin/admin_socket.h2
-rw-r--r--src/crimson/admin/osd_admin.cc1
-rw-r--r--src/crimson/osd/main.cc1
-rw-r--r--src/include/neorados/RADOS.hpp4
-rw-r--r--src/mgr/ActivePyModules.h4
-rw-r--r--src/mgr/TTLCache.h4
-rw-r--r--src/neorados/RADOS.cc2
-rw-r--r--src/osd/scrubber/scrub_machine.h2
-rw-r--r--src/rgw/rgw_object_expirer.cc2
-rw-r--r--src/rgw/rgw_object_expirer_core.h36
-rw-r--r--src/rgw/rgw_rados.cc4
-rw-r--r--src/rgw/rgw_sal_dbstore.cc2
-rw-r--r--src/rgw/rgw_sal_dbstore.h46
-rw-r--r--src/rgw/store/dbstore/common/dbstore.h604
-rw-r--r--src/rgw/store/dbstore/common/dbstore_log.h10
-rw-r--r--src/rgw/store/dbstore/dbstore_main.cc1
-rw-r--r--src/rgw/store/dbstore/dbstore_mgr.cc2
-rw-r--r--src/rgw/store/dbstore/dbstore_mgr.h25
-rw-r--r--src/rgw/store/dbstore/sqlite/sqliteDB.cc2
-rw-r--r--src/rgw/store/dbstore/sqlite/sqliteDB.h77
-rw-r--r--src/test/erasure-code/ErasureCodeExample.h10
-rw-r--r--src/test/erasure-code/TestErasureCodeExample.cc6
-rw-r--r--src/test/erasure-code/ceph_erasure_code_benchmark.cc11
-rw-r--r--src/test/erasure-code/ceph_erasure_code_benchmark.h22
-rw-r--r--src/test/kv_store_bench.h25
-rw-r--r--src/test/librados_test_stub/NeoradosTestStub.cc4
-rw-r--r--src/test/osd/RadosModel.h731
-rw-r--r--src/test/osd/TestOpStat.cc14
29 files changed, 824 insertions, 831 deletions
diff --git a/src/crimson/admin/admin_socket.cc b/src/crimson/admin/admin_socket.cc
index 1593123eb00..de7db209d2e 100644
--- a/src/crimson/admin/admin_socket.cc
+++ b/src/crimson/admin/admin_socket.cc
@@ -21,6 +21,7 @@
#include "crimson/net/Socket.h"
using namespace crimson::common;
+using namespace std::literals;
namespace {
seastar::logger& logger()
diff --git a/src/crimson/admin/admin_socket.h b/src/crimson/admin/admin_socket.h
index a7540a6071f..8bf9fd4d301 100644
--- a/src/crimson/admin/admin_socket.h
+++ b/src/crimson/admin/admin_socket.h
@@ -22,8 +22,6 @@
#include "include/buffer.h"
#include "crimson/net/Fwd.h"
-using namespace std::literals;
-
class MCommand;
namespace crimson::admin {
diff --git a/src/crimson/admin/osd_admin.cc b/src/crimson/admin/osd_admin.cc
index e8320458834..97c7f9a2992 100644
--- a/src/crimson/admin/osd_admin.cc
+++ b/src/crimson/admin/osd_admin.cc
@@ -24,6 +24,7 @@ seastar::logger& logger()
}
} // namespace
+using namespace std::literals;
using std::string_view;
using std::unique_ptr;
using crimson::osd::OSD;
diff --git a/src/crimson/osd/main.cc b/src/crimson/osd/main.cc
index a7afaee66a3..69eaf52097e 100644
--- a/src/crimson/osd/main.cc
+++ b/src/crimson/osd/main.cc
@@ -28,6 +28,7 @@
#include "osd.h"
+using namespace std::literals;
namespace bpo = boost::program_options;
using config_t = crimson::common::ConfigProxy;
using std::string;
diff --git a/src/include/neorados/RADOS.hpp b/src/include/neorados/RADOS.hpp
index 244442bcf60..fa1ac92ae51 100644
--- a/src/include/neorados/RADOS.hpp
+++ b/src/include/neorados/RADOS.hpp
@@ -60,8 +60,6 @@
#include "common/ceph_time.h"
namespace neorados {
-using namespace std::literals;
-
class Object;
class IOContext;
}
@@ -186,7 +184,7 @@ private:
std::aligned_storage_t<impl_size> impl;
};
-inline constexpr std::string_view all_nspaces("\001"sv);
+inline constexpr std::string_view all_nspaces("\001");
enum class cmpxattr_op : std::uint8_t {
eq = 1,
diff --git a/src/mgr/ActivePyModules.h b/src/mgr/ActivePyModules.h
index 2547c256538..0469c4755e9 100644
--- a/src/mgr/ActivePyModules.h
+++ b/src/mgr/ActivePyModules.h
@@ -56,14 +56,14 @@ class ActivePyModules
Objecter &objecter;
Client &client;
Finisher &finisher;
- TTLCache<string, PyObject*> ttl_cache;
+ TTLCache<std::string, PyObject*> ttl_cache;
public:
Finisher cmd_finisher;
private:
DaemonServer &server;
PyModuleRegistry &py_module_registry;
- map<std::string,ProgressEvent> progress_events;
+ std::map<std::string,ProgressEvent> progress_events;
mutable ceph::mutex lock = ceph::make_mutex("ActivePyModules::lock");
diff --git a/src/mgr/TTLCache.h b/src/mgr/TTLCache.h
index a6d5ddf2e2d..d29b787bbf6 100644
--- a/src/mgr/TTLCache.h
+++ b/src/mgr/TTLCache.h
@@ -10,8 +10,6 @@
#include "PyUtil.h"
-using namespace std;
-
template <class Key, class Value> class Cache {
private:
std::atomic<uint64_t> hits, misses;
@@ -20,7 +18,7 @@ template <class Key, class Value> class Cache {
unsigned int capacity;
Cache(unsigned int size = UINT16_MAX) : hits{0}, misses{0}, capacity{size} {};
std::map<Key, Value> content;
- std::vector<string> allowed_keys = {"osd_map", "pg_dump", "pg_stats"};
+ std::vector<std::string> allowed_keys = {"osd_map", "pg_dump", "pg_stats"};
void mark_miss() {
misses++;
diff --git a/src/neorados/RADOS.cc b/src/neorados/RADOS.cc
index 1784a939dac..93f02b1ae70 100644
--- a/src/neorados/RADOS.cc
+++ b/src/neorados/RADOS.cc
@@ -37,6 +37,8 @@
#include "neorados/RADOSImpl.h"
#include "include/neorados/RADOS.hpp"
+using namespace std::literals;
+
namespace bc = boost::container;
namespace bs = boost::system;
namespace ca = ceph::async;
diff --git a/src/osd/scrubber/scrub_machine.h b/src/osd/scrubber/scrub_machine.h
index d9132eedca8..d4fc0f8359a 100644
--- a/src/osd/scrubber/scrub_machine.h
+++ b/src/osd/scrubber/scrub_machine.h
@@ -20,8 +20,6 @@
#include "scrub_machine_lstnr.h"
#include "osd/scrubber_common.h"
-using namespace std::string_literals;
-
class PG; // holding a pointer to that one - just for testing
class PgScrubber;
namespace Scrub {
diff --git a/src/rgw/rgw_object_expirer.cc b/src/rgw/rgw_object_expirer.cc
index e2e82ad58b1..1fd940533c5 100644
--- a/src/rgw/rgw_object_expirer.cc
+++ b/src/rgw/rgw_object_expirer.cc
@@ -55,7 +55,7 @@ int main(const int argc, const char **argv)
{
auto args = argv_to_vec(argc, argv);
if (args.empty()) {
- cerr << argv[0] << ": -h or --help for usage" << std::endl;
+ std::cerr << argv[0] << ": -h or --help for usage" << std::endl;
exit(1);
}
if (ceph_argparse_need_usage(args)) {
diff --git a/src/rgw/rgw_object_expirer_core.h b/src/rgw/rgw_object_expirer_core.h
index 68b65653ba4..c02ca5ea9df 100644
--- a/src/rgw/rgw_object_expirer_core.h
+++ b/src/rgw/rgw_object_expirer_core.h
@@ -32,8 +32,6 @@
#include "rgw_sal.h"
#include "rgw_sal_rados.h"
-using namespace std;
-
class RGWSI_RADOS;
class RGWSI_Zone;
class RGWBucketInfo;
@@ -50,27 +48,27 @@ public:
int objexp_hint_add(const DoutPrefixProvider *dpp,
const ceph::real_time& delete_at,
- const string& tenant_name,
- const string& bucket_name,
- const string& bucket_id,
+ const std::string& tenant_name,
+ const std::string& bucket_name,
+ const std::string& bucket_id,
const rgw_obj_index_key& obj_key);
int objexp_hint_list(const DoutPrefixProvider *dpp,
- const string& oid,
+ const std::string& oid,
const ceph::real_time& start_time,
const ceph::real_time& end_time,
const int max_entries,
- const string& marker,
- list<cls_timeindex_entry>& entries, /* out */
- string *out_marker, /* out */
+ const std::string& marker,
+ std::list<cls_timeindex_entry>& entries, /* out */
+ std::string *out_marker, /* out */
bool *truncated); /* out */
int objexp_hint_trim(const DoutPrefixProvider *dpp,
- const string& oid,
+ const std::string& oid,
const ceph::real_time& start_time,
const ceph::real_time& end_time,
- const string& from_marker,
- const string& to_marker);
+ const std::string& from_marker,
+ const std::string& to_marker);
};
class RGWObjectExpirer {
@@ -95,8 +93,8 @@ protected:
void stop();
CephContext *get_cct() const override;
- unsigned get_subsys() const;
- std::ostream& gen_prefix(std::ostream& out) const;
+ unsigned get_subsys() const override;
+ std::ostream& gen_prefix(std::ostream& out) const override;
};
OEWorker *worker{nullptr};
@@ -114,9 +112,9 @@ public:
int hint_add(const DoutPrefixProvider *dpp,
const ceph::real_time& delete_at,
- const string& tenant_name,
- const string& bucket_name,
- const string& bucket_id,
+ const std::string& tenant_name,
+ const std::string& bucket_name,
+ const std::string& bucket_id,
const rgw_obj_index_key& obj_key) {
return exp_store.objexp_hint_add(dpp, delete_at, tenant_name, bucket_name,
bucket_id, obj_key);
@@ -132,8 +130,8 @@ public:
const std::string& shard,
const utime_t& from,
const utime_t& to,
- const string& from_marker,
- const string& to_marker);
+ const std::string& from_marker,
+ const std::string& to_marker);
bool process_single_shard(const DoutPrefixProvider *dpp,
const std::string& shard,
diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc
index 5fb9e9f3c48..d90b4bcae91 100644
--- a/src/rgw/rgw_rados.cc
+++ b/src/rgw/rgw_rados.cc
@@ -52,8 +52,6 @@
#include "common/Clock.h"
-using namespace librados;
-
#include <string>
#include <iostream>
#include <vector>
@@ -101,6 +99,8 @@ using namespace librados;
#define dout_context g_ceph_context
#define dout_subsys ceph_subsys_rgw
+using namespace std;
+using namespace librados;
static string shadow_ns = "shadow";
static string default_bucket_index_pool_suffix = "rgw.buckets.index";
diff --git a/src/rgw/rgw_sal_dbstore.cc b/src/rgw/rgw_sal_dbstore.cc
index f646d94357d..947ba8909f9 100644
--- a/src/rgw/rgw_sal_dbstore.cc
+++ b/src/rgw/rgw_sal_dbstore.cc
@@ -28,6 +28,8 @@
#define dout_subsys ceph_subsys_rgw
+using namespace std;
+
namespace rgw::sal {
int DBUser::list_buckets(const DoutPrefixProvider *dpp, const string& marker,
diff --git a/src/rgw/rgw_sal_dbstore.h b/src/rgw/rgw_sal_dbstore.h
index 49c1bc4340b..c5b85095041 100644
--- a/src/rgw/rgw_sal_dbstore.h
+++ b/src/rgw/rgw_sal_dbstore.h
@@ -110,7 +110,7 @@ protected:
virtual int complete_flush_stats(const DoutPrefixProvider *dpp, optional_yield y) override;
virtual int read_usage(const DoutPrefixProvider *dpp, uint64_t start_epoch, uint64_t end_epoch, uint32_t max_entries,
bool* is_truncated, RGWUsageIter& usage_iter,
- map<rgw_user_bucket, rgw_usage_log_entry>& usage) override;
+ std::map<rgw_user_bucket, rgw_usage_log_entry>& usage) override;
virtual int trim_usage(const DoutPrefixProvider *dpp, uint64_t start_epoch, uint64_t end_epoch) override;
/* Placeholders */
@@ -205,7 +205,7 @@ protected:
virtual int try_refresh_info(const DoutPrefixProvider *dpp, ceph::real_time *pmtime) override;
virtual int read_usage(const DoutPrefixProvider *dpp, uint64_t start_epoch, uint64_t end_epoch, uint32_t max_entries,
bool *is_truncated, RGWUsageIter& usage_iter,
- map<rgw_user_bucket, rgw_usage_log_entry>& usage) override;
+ std::map<rgw_user_bucket, rgw_usage_log_entry>& usage) override;
virtual int trim_usage(const DoutPrefixProvider *dpp, uint64_t start_epoch, uint64_t end_epoch) override;
virtual int remove_objs_from_index(const DoutPrefixProvider *dpp, std::list<rgw_obj_index_key>& objs_to_unlink) override;
virtual int check_index(const DoutPrefixProvider *dpp, std::map<RGWObjCategory, RGWStorageStats>& existing_stats, std::map<RGWObjCategory, RGWStorageStats>& calculated_stats) override;
@@ -219,12 +219,12 @@ protected:
const std::string& oid, std::optional<std::string> upload_id,
ACLOwner owner={}, ceph::real_time mtime=ceph::real_clock::now()) override;
virtual int list_multiparts(const DoutPrefixProvider *dpp,
- const string& prefix,
- string& marker,
- const string& delim,
+ const std::string& prefix,
+ std::string& marker,
+ const std::string& delim,
const int& max_uploads,
- vector<std::unique_ptr<MultipartUpload>>& uploads,
- map<string, bool> *common_prefixes,
+ std::vector<std::unique_ptr<MultipartUpload>>& uploads,
+ std::map<std::string, bool> *common_prefixes,
bool *is_truncated) override;
virtual int abort_multiparts(const DoutPrefixProvider* dpp,
CephContext* cct) override;
@@ -620,13 +620,13 @@ protected:
const rgw_placement_rule *ptail_placement_rule;
uint64_t olh_epoch;
std::unique_ptr<rgw::sal::Object> head_obj;
- string upload_id;
- string oid; /* object->name() + "." + "upload_id" + "." + part_num */
+ std::string upload_id;
+ std::string oid; /* object->name() + "." + "upload_id" + "." + part_num */
std::unique_ptr<rgw::sal::Object> meta_obj;
DB::Object op_target;
DB::Object::Write parent_op;
int part_num;
- string part_num_str;
+ std::string part_num_str;
uint64_t total_data_size = 0; /* for total data being uploaded */
bufferlist head_data;
bufferlist tail_part_data;
@@ -671,7 +671,7 @@ public:
* multiple db handles (for eg., one for each tenant),
* use dbsm->getDB(tenant) */
DB *db;
- string luarocks_path;
+ std::string luarocks_path;
DBZone zone;
RGWSyncModuleInstanceRef sync_module;
RGWLC* lc;
@@ -728,13 +728,13 @@ public:
virtual RGWLC* get_rgwlc(void) override;
virtual RGWCoroutinesManagerRegistry* get_cr_registry() override { return NULL; }
- virtual int log_usage(const DoutPrefixProvider *dpp, map<rgw_user_bucket, RGWUsageBatch>& usage_info) override;
+ virtual int log_usage(const DoutPrefixProvider *dpp, std::map<rgw_user_bucket, RGWUsageBatch>& usage_info) override;
virtual int log_op(const DoutPrefixProvider *dpp, std::string& oid, bufferlist& bl) override;
- virtual int register_to_service_map(const DoutPrefixProvider *dpp, const string& daemon_type,
- const map<string, string>& meta) override;
+ virtual int register_to_service_map(const DoutPrefixProvider *dpp, const std::string& daemon_type,
+ const std::map<std::string, std::string>& meta) override;
virtual void get_ratelimit(RGWRateLimitInfo& bucket_ratelimit, RGWRateLimitInfo& user_ratelimit, RGWRateLimitInfo& anon_ratelimit) override;
virtual void get_quota(RGWQuotaInfo& bucket_quota, RGWQuotaInfo& user_quota) override;
- virtual int set_buckets_enabled(const DoutPrefixProvider *dpp, vector<rgw_bucket>& buckets, bool enabled) override;
+ virtual int set_buckets_enabled(const DoutPrefixProvider *dpp, std::vector<rgw_bucket>& buckets, bool enabled) override;
virtual uint64_t get_new_req_id() override { return 0; }
virtual int get_sync_policy_handler(const DoutPrefixProvider *dpp,
std::optional<rgw_zone_id> zone,
@@ -742,20 +742,20 @@ public:
RGWBucketSyncPolicyHandlerRef *phandler,
optional_yield y) override;
virtual RGWDataSyncStatusManager* get_data_sync_manager(const rgw_zone_id& source_zone) override;
- virtual void wakeup_meta_sync_shards(set<int>& shard_ids) override { return; }
- virtual void wakeup_data_sync_shards(const DoutPrefixProvider *dpp, const rgw_zone_id& source_zone, map<int, set<string> >& shard_ids) override { return; }
+ virtual void wakeup_meta_sync_shards(std::set<int>& shard_ids) override { return; }
+ virtual void wakeup_data_sync_shards(const DoutPrefixProvider *dpp, const rgw_zone_id& source_zone, std::map<int, std::set<std::string>>& shard_ids) override { return; }
virtual int clear_usage(const DoutPrefixProvider *dpp) override { return 0; }
virtual int read_all_usage(const DoutPrefixProvider *dpp, uint64_t start_epoch, uint64_t end_epoch,
uint32_t max_entries, bool *is_truncated,
RGWUsageIter& usage_iter,
- map<rgw_user_bucket, rgw_usage_log_entry>& usage) override;
+ std::map<rgw_user_bucket, rgw_usage_log_entry>& usage) override;
virtual int trim_all_usage(const DoutPrefixProvider *dpp, uint64_t start_epoch, uint64_t end_epoch) override;
virtual int get_config_key_val(std::string name, bufferlist* bl) override;
virtual int meta_list_keys_init(const DoutPrefixProvider *dpp, const std::string& section, const std::string& marker, void** phandle) override;
- virtual int meta_list_keys_next(const DoutPrefixProvider *dpp, void* handle, int max, list<std::string>& keys, bool* truncated) override;
+ virtual int meta_list_keys_next(const DoutPrefixProvider *dpp, void* handle, int max, std::list<std::string>& keys, bool* truncated) override;
virtual void meta_list_keys_complete(void* handle) override;
virtual std::string meta_get_marker(void *handle) override;
- virtual int meta_remove(const DoutPrefixProvider *dpp, string& metadata_key, optional_yield y) override;
+ virtual int meta_remove(const DoutPrefixProvider *dpp, std::string& metadata_key, optional_yield y) override;
virtual const RGWSyncModuleInstanceRef& get_sync_module() { return sync_module; }
virtual std::string get_host_id() { return ""; }
@@ -772,11 +772,11 @@ public:
optional_yield y,
const std::string& path_prefix,
const std::string& tenant,
- vector<std::unique_ptr<RGWRole>>& roles) override;
+ std::vector<std::unique_ptr<RGWRole>>& roles) override;
virtual std::unique_ptr<RGWOIDCProvider> get_oidc_provider() override;
virtual int get_oidc_providers(const DoutPrefixProvider *dpp,
const std::string& tenant,
- vector<std::unique_ptr<RGWOIDCProvider>>& providers) override;
+ std::vector<std::unique_ptr<RGWOIDCProvider>>& providers) override;
virtual std::unique_ptr<Writer> get_append_writer(const DoutPrefixProvider *dpp,
optional_yield y,
std::unique_ptr<rgw::sal::Object> _head_obj,
@@ -814,7 +814,7 @@ public:
void setDB(DB * st) { db = st; }
DB *getDB(void) { return db; }
- DB *getDB(string tenant) { return dbsm->getDB(tenant, false); }
+ DB *getDB(std::string tenant) { return dbsm->getDB(tenant, false); }
};
} } // namespace rgw::sal
diff --git a/src/rgw/store/dbstore/common/dbstore.h b/src/rgw/store/dbstore/common/dbstore.h
index 9bb61dca7a9..2fe323d75ff 100644
--- a/src/rgw/store/dbstore/common/dbstore.h
+++ b/src/rgw/store/dbstore/common/dbstore.h
@@ -24,8 +24,6 @@
#include "rgw/rgw_obj_manifest.h"
#include "rgw/rgw_multi.h"
-using namespace std;
-
namespace rgw { namespace store {
class DB;
@@ -44,9 +42,9 @@ struct DBOpBucketInfo {
obj_version bucket_version;
ceph::real_time mtime;
// used for list query
- string min_marker;
- string max_marker;
- list<RGWBucketEnt> list_entries;
+ std::string min_marker;
+ std::string max_marker;
+ std::list<RGWBucketEnt> list_entries;
};
struct DBOpObjectInfo {
@@ -67,15 +65,15 @@ struct DBOpObjectInfo {
uint64_t versioned_epoch;
/* from state.manifest (RGWObjManifest) */
- map<uint64_t, RGWObjManifestPart> objs;
+ std::map<uint64_t, RGWObjManifestPart> objs;
uint64_t head_size{0};
rgw_placement_rule head_placement_rule;
uint64_t max_head_size{0};
- string prefix;
+ std::string prefix;
rgw_bucket_placement tail_placement; /* might be different than the original bucket,
as object might have been copied across pools */
- map<uint64_t, RGWObjManifestRule> rules;
- string tail_instance; /* tail object's instance */
+ std::map<uint64_t, RGWObjManifestRule> rules;
+ std::string tail_instance; /* tail object's instance */
/* Obj's omap <key,value> store */
@@ -86,9 +84,9 @@ struct DBOpObjectInfo {
std::list<RGWUploadPartInfo> mp_parts;
bufferlist head_data;
- string min_marker;
- string max_marker;
- list<rgw_bucket_dir_entry> list_entries;
+ std::string min_marker;
+ std::string max_marker;
+ std::list<rgw_bucket_dir_entry> list_entries;
/* Below used to update mp_parts obj name
* from meta object to src object on completion */
rgw_obj_key new_obj_key;
@@ -97,34 +95,34 @@ struct DBOpObjectInfo {
struct DBOpObjectDataInfo {
RGWObjState state;
uint64_t part_num;
- string multipart_part_str;
+ std::string multipart_part_str;
uint64_t offset;
uint64_t size;
bufferlist data{};
};
struct DBOpLCHeadInfo {
- string index;
+ std::string index;
rgw::sal::Lifecycle::LCHead head;
};
struct DBOpLCEntryInfo {
- string index;
+ std::string index;
rgw::sal::Lifecycle::LCEntry entry;
// used for list query
- string min_marker;
- list<rgw::sal::Lifecycle::LCEntry> list_entries;
+ std::string min_marker;
+ std::list<rgw::sal::Lifecycle::LCEntry> list_entries;
};
struct DBOpInfo {
- string name; // Op name
+ std::string name; // Op name
/* Support only single access_key for now. So store
* it separately as primary access_key_id & secret to
* be able to query easily.
*
* XXX: Swift keys and subuser not supported for now */
DBOpUserInfo user;
- string query_str;
+ std::string query_str;
DBOpBucketInfo bucket;
DBOpObjectInfo obj;
DBOpObjectDataInfo obj_data;
@@ -137,19 +135,19 @@ struct DBOpParams {
CephContext *cct;
/* Tables */
- string user_table;
- string bucket_table;
- string object_table;
+ std::string user_table;
+ std::string bucket_table;
+ std::string object_table;
/* Ops*/
DBOpInfo op;
/* Below are subject to change */
- string objectdata_table;
- string quota_table;
- string lc_head_table;
- string lc_entry_table;
- string obj;
+ std::string objectdata_table;
+ std::string quota_table;
+ std::string lc_head_table;
+ std::string lc_entry_table;
+ std::string obj;
};
/* Used for prepared schemas.
@@ -163,11 +161,11 @@ struct DBOpParams {
* to get the right index of each param.
*/
struct DBOpUserPrepareInfo {
- string user_id = ":user_id";
- string tenant = ":tenant";
- string ns = ":ns";
- string display_name = ":display_name";
- string user_email = ":user_email";
+ std::string user_id = ":user_id";
+ std::string tenant = ":tenant";
+ std::string ns = ":ns";
+ std::string display_name = ":display_name";
+ std::string user_email = ":user_email";
/* Support only single access_key for now. So store
* it separately as primary access_key_id & secret to
* be able to query easily.
@@ -175,169 +173,169 @@ struct DBOpUserPrepareInfo {
* In future, when need to support & query from multiple
* access keys, better to maintain them in a separate table.
*/
- string access_keys_id = ":access_keys_id";
- string access_keys_secret = ":access_keys_secret";
- string access_keys = ":access_keys";
- string swift_keys = ":swift_keys";
- string subusers = ":subusers";
- string suspended = ":suspended";
- string max_buckets = ":max_buckets";
- string op_mask = ":op_mask";
- string user_caps = ":user_caps";
- string admin = ":admin";
- string system = ":system";
- string placement_name = ":placement_name";
- string placement_storage_class = ":placement_storage_class";
- string placement_tags = ":placement_tags";
- string bucket_quota = ":bucket_quota";
- string temp_url_keys = ":temp_url_keys";
- string user_quota = ":user_quota";
- string type = ":type";
- string mfa_ids = ":mfa_ids";
- string assumed_role_arn = ":assumed_role_arn";
- string user_attrs = ":user_attrs";
- string user_ver = ":user_vers";
- string user_ver_tag = ":user_ver_tag";
+ std::string access_keys_id = ":access_keys_id";
+ std::string access_keys_secret = ":access_keys_secret";
+ std::string access_keys = ":access_keys";
+ std::string swift_keys = ":swift_keys";
+ std::string subusers = ":subusers";
+ std::string suspended = ":suspended";
+ std::string max_buckets = ":max_buckets";
+ std::string op_mask = ":op_mask";
+ std::string user_caps = ":user_caps";
+ std::string admin = ":admin";
+ std::string system = ":system";
+ std::string placement_name = ":placement_name";
+ std::string placement_storage_class = ":placement_storage_class";
+ std::string placement_tags = ":placement_tags";
+ std::string bucket_quota = ":bucket_quota";
+ std::string temp_url_keys = ":temp_url_keys";
+ std::string user_quota = ":user_quota";
+ std::string type = ":type";
+ std::string mfa_ids = ":mfa_ids";
+ std::string assumed_role_arn = ":assumed_role_arn";
+ std::string user_attrs = ":user_attrs";
+ std::string user_ver = ":user_vers";
+ std::string user_ver_tag = ":user_ver_tag";
};
struct DBOpBucketPrepareInfo {
- string bucket_name = ":bucket_name";
- string tenant = ":tenant";
- string marker = ":marker";
- string bucket_id = ":bucket_id";
- string size = ":size";
- string size_rounded = ":size_rounded";
- string creation_time = ":creation_time";
- string count = ":count";
- string placement_name = ":placement_name";
- string placement_storage_class = ":placement_storage_class";
+ std::string bucket_name = ":bucket_name";
+ std::string tenant = ":tenant";
+ std::string marker = ":marker";
+ std::string bucket_id = ":bucket_id";
+ std::string size = ":size";
+ std::string size_rounded = ":size_rounded";
+ std::string creation_time = ":creation_time";
+ std::string count = ":count";
+ std::string placement_name = ":placement_name";
+ std::string placement_storage_class = ":placement_storage_class";
/* ownerid - maps to DBOpUserPrepareInfo */
- string flags = ":flags";
- string zonegroup = ":zonegroup";
- string has_instance_obj = ":has_instance_obj";
- string quota = ":quota";
- string requester_pays = ":requester_pays";
- string has_website = ":has_website";
- string website_conf = ":website_conf";
- string swift_versioning = ":swift_versioning";
- string swift_ver_location = ":swift_ver_location";
- string mdsearch_config = ":mdsearch_config";
- string new_bucket_instance_id = ":new_bucket_instance_id";
- string obj_lock = ":obj_lock";
- string sync_policy_info_groups = ":sync_policy_info_groups";
- string bucket_attrs = ":bucket_attrs";
- string bucket_ver = ":bucket_vers";
- string bucket_ver_tag = ":bucket_ver_tag";
- string mtime = ":mtime";
- string min_marker = ":min_marker";
- string max_marker = ":max_marker";
+ std::string flags = ":flags";
+ std::string zonegroup = ":zonegroup";
+ std::string has_instance_obj = ":has_instance_obj";
+ std::string quota = ":quota";
+ std::string requester_pays = ":requester_pays";
+ std::string has_website = ":has_website";
+ std::string website_conf = ":website_conf";
+ std::string swift_versioning = ":swift_versioning";
+ std::string swift_ver_location = ":swift_ver_location";
+ std::string mdsearch_config = ":mdsearch_config";
+ std::string new_bucket_instance_id = ":new_bucket_instance_id";
+ std::string obj_lock = ":obj_lock";
+ std::string sync_policy_info_groups = ":sync_policy_info_groups";
+ std::string bucket_attrs = ":bucket_attrs";
+ std::string bucket_ver = ":bucket_vers";
+ std::string bucket_ver_tag = ":bucket_ver_tag";
+ std::string mtime = ":mtime";
+ std::string min_marker = ":min_marker";
+ std::string max_marker = ":max_marker";
};
struct DBOpObjectPrepareInfo {
- string obj_name = ":obj_name";
- string obj_instance = ":obj_instance";
- string obj_ns = ":obj_ns";
- string acls = ":acls";
- string index_ver = ":index_ver";
- string tag = ":tag";
- string flags = ":flags";
- string versioned_epoch = ":versioned_epoch";
- string obj_category = ":obj_category";
- string etag = ":etag";
- string owner = ":owner";
- string owner_display_name = ":owner_display_name";
- string storage_class = ":storage_class";
- string appendable = ":appendable";
- string content_type = ":content_type";
- string index_hash_source = ":index_hash_source";
- string obj_size = ":obj_size";
- string accounted_size = ":accounted_size";
- string mtime = ":mtime";
- string epoch = ":epoch";
- string obj_tag = ":obj_tag";
- string tail_tag = ":tail_tag";
- string write_tag = ":write_tag";
- string fake_tag = ":fake_tag";
- string shadow_obj = ":shadow_obj";
- string has_data = ":has_data";
- string is_olh = ":is_ols";
- string olh_tag = ":olh_tag";
- string pg_ver = ":pg_ver";
- string zone_short_id = ":zone_short_id";
- string obj_version = ":obj_version";
- string obj_version_tag = ":obj_version_tag";
- string obj_attrs = ":obj_attrs";
- string head_size = ":head_size";
- string max_head_size = ":max_head_size";
- string prefix = ":prefix";
- string tail_instance = ":tail_instance";
- string head_placement_rule_name = ":head_placement_rule_name";
- string head_placement_storage_class = ":head_placement_storage_class";
- string tail_placement_rule_name = ":tail_placement_rule_name";
- string tail_placement_storage_class = ":tail_placement_storage_class";
- string manifest_part_objs = ":manifest_part_objs";
- string manifest_part_rules = ":manifest_part_rules";
- string omap = ":omap";
- string is_multipart = ":is_multipart";
- string mp_parts = ":mp_parts";
- string head_data = ":head_data";
- string min_marker = ":min_marker";
- string max_marker = ":max_marker";
+ std::string obj_name = ":obj_name";
+ std::string obj_instance = ":obj_instance";
+ std::string obj_ns = ":obj_ns";
+ std::string acls = ":acls";
+ std::string index_ver = ":index_ver";
+ std::string tag = ":tag";
+ std::string flags = ":flags";
+ std::string versioned_epoch = ":versioned_epoch";
+ std::string obj_category = ":obj_category";
+ std::string etag = ":etag";
+ std::string owner = ":owner";
+ std::string owner_display_name = ":owner_display_name";
+ std::string storage_class = ":storage_class";
+ std::string appendable = ":appendable";
+ std::string content_type = ":content_type";
+ std::string index_hash_source = ":index_hash_source";
+ std::string obj_size = ":obj_size";
+ std::string accounted_size = ":accounted_size";
+ std::string mtime = ":mtime";
+ std::string epoch = ":epoch";
+ std::string obj_tag = ":obj_tag";
+ std::string tail_tag = ":tail_tag";
+ std::string write_tag = ":write_tag";
+ std::string fake_tag = ":fake_tag";
+ std::string shadow_obj = ":shadow_obj";
+ std::string has_data = ":has_data";
+ std::string is_olh = ":is_ols";
+ std::string olh_tag = ":olh_tag";
+ std::string pg_ver = ":pg_ver";
+ std::string zone_short_id = ":zone_short_id";
+ std::string obj_version = ":obj_version";
+ std::string obj_version_tag = ":obj_version_tag";
+ std::string obj_attrs = ":obj_attrs";
+ std::string head_size = ":head_size";
+ std::string max_head_size = ":max_head_size";
+ std::string prefix = ":prefix";
+ std::string tail_instance = ":tail_instance";
+ std::string head_placement_rule_name = ":head_placement_rule_name";
+ std::string head_placement_storage_class = ":head_placement_storage_class";
+ std::string tail_placement_rule_name = ":tail_placement_rule_name";
+ std::string tail_placement_storage_class = ":tail_placement_storage_class";
+ std::string manifest_part_objs = ":manifest_part_objs";
+ std::string manifest_part_rules = ":manifest_part_rules";
+ std::string omap = ":omap";
+ std::string is_multipart = ":is_multipart";
+ std::string mp_parts = ":mp_parts";
+ std::string head_data = ":head_data";
+ std::string min_marker = ":min_marker";
+ std::string max_marker = ":max_marker";
/* Below used to update mp_parts obj name
* from meta object to src object on completion */
- string new_obj_name = ":new_obj_name";
- string new_obj_instance = ":new_obj_instance";
- string new_obj_ns = ":new_obj_ns";
+ std::string new_obj_name = ":new_obj_name";
+ std::string new_obj_instance = ":new_obj_instance";
+ std::string new_obj_ns = ":new_obj_ns";
};
struct DBOpObjectDataPrepareInfo {
- string part_num = ":part_num";
- string offset = ":offset";
- string data = ":data";
- string size = ":size";
- string multipart_part_str = ":multipart_part_str";
+ std::string part_num = ":part_num";
+ std::string offset = ":offset";
+ std::string data = ":data";
+ std::string size = ":size";
+ std::string multipart_part_str = ":multipart_part_str";
};
struct DBOpLCEntryPrepareInfo {
- string index = ":index";
- string bucket_name = ":bucket_name";
- string start_time = ":start_time";
- string status = ":status";
- string min_marker = ":min_marker";
+ std::string index = ":index";
+ std::string bucket_name = ":bucket_name";
+ std::string start_time = ":start_time";
+ std::string status = ":status";
+ std::string min_marker = ":min_marker";
};
struct DBOpLCHeadPrepareInfo {
- string index = ":index";
- string start_date = ":start_date";
- string marker = ":marker";
+ std::string index = ":index";
+ std::string start_date = ":start_date";
+ std::string marker = ":marker";
};
struct DBOpPrepareInfo {
DBOpUserPrepareInfo user;
- string query_str = ":query_str";
+ std::string query_str = ":query_str";
DBOpBucketPrepareInfo bucket;
DBOpObjectPrepareInfo obj;
DBOpObjectDataPrepareInfo obj_data;
DBOpLCHeadPrepareInfo lc_head;
DBOpLCEntryPrepareInfo lc_entry;
- string list_max_count = ":list_max_count";
+ std::string list_max_count = ":list_max_count";
};
struct DBOpPrepareParams {
/* Tables */
- string user_table;
- string bucket_table;
- string object_table;
+ std::string user_table;
+ std::string bucket_table;
+ std::string object_table;
/* Ops */
DBOpPrepareInfo op;
/* below subject to change */
- string objectdata_table;
- string quota_table;
- string lc_head_table;
- string lc_entry_table;
+ std::string objectdata_table;
+ std::string quota_table;
+ std::string lc_head_table;
+ std::string lc_entry_table;
};
struct DBOps {
@@ -374,13 +372,13 @@ class ObjectOp {
class GetObjectDataOp *GetObjectData;
class DeleteObjectDataOp *DeleteObjectData;
- virtual int InitializeObjectOps(string db_name, const DoutPrefixProvider *dpp) { return 0; }
+ virtual int InitializeObjectOps(std::string db_name, const DoutPrefixProvider *dpp) { return 0; }
virtual int FreeObjectOps(const DoutPrefixProvider *dpp) { return 0; }
};
class DBOp {
private:
- const string CreateUserTableQ =
+ const std::string CreateUserTableQ =
/* Corresponds to rgw::sal::User
*
* For now only UserID is made Primary key.
@@ -426,7 +424,7 @@ class DBOp {
UserVersionTag TEXT, \
PRIMARY KEY (UserID) \n);";
- const string CreateBucketTableQ =
+ const std::string CreateBucketTableQ =
/* Corresponds to rgw::sal::Bucket
*
* For now only BucketName is made Primary key.
@@ -481,7 +479,7 @@ class DBOp {
FOREIGN KEY (OwnerID) \
REFERENCES '{}' (UserID) ON DELETE CASCADE ON UPDATE CASCADE \n);";
- const string CreateObjectTableQ =
+ const std::string CreateObjectTableQ =
/* Corresponds to rgw::sal::Object
*
* For now only BucketName, ObjName is made Primary key.
@@ -548,11 +546,11 @@ class DBOp {
ObjAttrs BLOB, \
HeadSize INTEGER, \
MaxHeadSize INTEGER, \
- Prefix String, \
- TailInstance String, \
- HeadPlacementRuleName String, \
+ Prefix std::string, \
+ TailInstance std::string, \
+ HeadPlacementRuleName std::string, \
HeadPlacementRuleStorageClass String, \
- TailPlacementRuleName String, \
+ TailPlacementRuleName std::string, \
TailPlacementStorageClass String, \
ManifestPartObjs BLOB, \
ManifestPartRules BLOB, \
@@ -564,7 +562,7 @@ class DBOp {
FOREIGN KEY (BucketName) \
REFERENCES '{}' (BucketName) ON DELETE CASCADE ON UPDATE CASCADE \n);";
- const string CreateObjectDataTableQ =
+ const std::string CreateObjectDataTableQ =
/* Extra field 'MultipartPartStr' added which signifies multipart
* <uploadid + partnum>. For regular object, it is '0.0'
*
@@ -588,7 +586,7 @@ class DBOp {
FOREIGN KEY (BucketName, ObjName, ObjInstance) \
REFERENCES '{}' (BucketName, ObjName, ObjInstance) ON DELETE CASCADE ON UPDATE CASCADE \n);";
- const string CreateQuotaTableQ =
+ const std::string CreateQuotaTableQ =
"CREATE TABLE IF NOT EXISTS '{}' ( \
QuotaID INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE , \
MaxSizeSoftThreshold INTEGER , \
@@ -598,7 +596,7 @@ class DBOp {
Enabled Boolean , \
CheckOnRaw Boolean \n);";
- const string CreateLCEntryTableQ =
+ const std::string CreateLCEntryTableQ =
"CREATE TABLE IF NOT EXISTS '{}' ( \
LCIndex TEXT NOT NULL , \
BucketName TEXT NOT NULL , \
@@ -608,22 +606,22 @@ class DBOp {
FOREIGN KEY (BucketName) \
REFERENCES '{}' (BucketName) ON DELETE CASCADE ON UPDATE CASCADE \n);";
- const string CreateLCHeadTableQ =
+ const std::string CreateLCHeadTableQ =
"CREATE TABLE IF NOT EXISTS '{}' ( \
LCIndex TEXT NOT NULL , \
Marker TEXT , \
StartDate INTEGER , \
PRIMARY KEY (LCIndex) \n);";
- const string DropQ = "DROP TABLE IF EXISTS '{}'";
- const string ListAllQ = "SELECT * from '{}'";
+ const std::string DropQ = "DROP TABLE IF EXISTS '{}'";
+ const std::string ListAllQ = "SELECT * from '{}'";
public:
DBOp() {}
virtual ~DBOp() {}
std::mutex mtx; // to protect prepared stmt
- string CreateTableSchema(string type, DBOpParams *params) {
+ std::string CreateTableSchema(std::string type, DBOpParams *params) {
if (!type.compare("User"))
return fmt::format(CreateUserTableQ.c_str(),
params->user_table.c_str());
@@ -655,10 +653,10 @@ class DBOp {
return NULL;
}
- string DeleteTableSchema(string table) {
+ std::string DeleteTableSchema(std::string table) {
return fmt::format(DropQ.c_str(), table.c_str());
}
- string ListTableSchema(string table) {
+ std::string ListTableSchema(std::string table) {
return fmt::format(ListAllQ.c_str(), table.c_str());
}
@@ -680,7 +678,7 @@ class InsertUserOp : virtual public DBOp {
* For now using INSERT or REPLACE. If required of updating existing
* record, will use another query.
*/
- const string Query = "INSERT OR REPLACE INTO '{}' \
+ const std::string Query = "INSERT OR REPLACE INTO '{}' \
(UserID, Tenant, NS, DisplayName, UserEmail, \
AccessKeysID, AccessKeysSecret, AccessKeys, SwiftKeys,\
SubUsers, Suspended, MaxBuckets, OpMask, UserCaps, Admin, \
@@ -693,7 +691,7 @@ class InsertUserOp : virtual public DBOp {
public:
virtual ~InsertUserOp() {}
- string Schema(DBOpPrepareParams &params) {
+ std::string Schema(DBOpPrepareParams &params) {
return fmt::format(Query.c_str(), params.user_table.c_str(),
params.op.user.user_id.c_str(), params.op.user.tenant, params.op.user.ns,
params.op.user.display_name, params.op.user.user_email,
@@ -714,13 +712,13 @@ class InsertUserOp : virtual public DBOp {
class RemoveUserOp: virtual public DBOp {
private:
- const string Query =
+ const std::string Query =
"DELETE from '{}' where UserID = {}";
public:
virtual ~RemoveUserOp() {}
- string Schema(DBOpPrepareParams &params) {
+ std::string Schema(DBOpPrepareParams &params) {
return fmt::format(Query.c_str(), params.user_table.c_str(),
params.op.user.user_id.c_str());
}
@@ -730,7 +728,7 @@ class GetUserOp: virtual public DBOp {
private:
/* If below query columns are updated, make sure to update the indexes
* in list_user() cbk in sqliteDB.cc */
- const string Query = "SELECT \
+ const std::string Query = "SELECT \
UserID, Tenant, NS, DisplayName, UserEmail, \
AccessKeysID, AccessKeysSecret, AccessKeys, SwiftKeys,\
SubUsers, Suspended, MaxBuckets, OpMask, UserCaps, Admin, \
@@ -738,7 +736,7 @@ class GetUserOp: virtual public DBOp {
BucketQuota, TempURLKeys, UserQuota, Type, MfaIDs, AssumedRoleARN, \
UserAttrs, UserVersion, UserVersionTag from '{}' where UserID = {}";
- const string QueryByEmail = "SELECT \
+ const std::string QueryByEmail = "SELECT \
UserID, Tenant, NS, DisplayName, UserEmail, \
AccessKeysID, AccessKeysSecret, AccessKeys, SwiftKeys,\
SubUsers, Suspended, MaxBuckets, OpMask, UserCaps, Admin, \
@@ -746,7 +744,7 @@ class GetUserOp: virtual public DBOp {
BucketQuota, TempURLKeys, UserQuota, Type, MfaIDs, AssumedRoleARN, \
UserAttrs, UserVersion, UserVersionTag from '{}' where UserEmail = {}";
- const string QueryByAccessKeys = "SELECT \
+ const std::string QueryByAccessKeys = "SELECT \
UserID, Tenant, NS, DisplayName, UserEmail, \
AccessKeysID, AccessKeysSecret, AccessKeys, SwiftKeys,\
SubUsers, Suspended, MaxBuckets, OpMask, UserCaps, Admin, \
@@ -754,7 +752,7 @@ class GetUserOp: virtual public DBOp {
BucketQuota, TempURLKeys, UserQuota, Type, MfaIDs, AssumedRoleARN, \
UserAttrs, UserVersion, UserVersionTag from '{}' where AccessKeysID = {}";
- const string QueryByUserID = "SELECT \
+ const std::string QueryByUserID = "SELECT \
UserID, Tenant, NS, DisplayName, UserEmail, \
AccessKeysID, AccessKeysSecret, AccessKeys, SwiftKeys,\
SubUsers, Suspended, MaxBuckets, OpMask, UserCaps, Admin, \
@@ -766,7 +764,7 @@ class GetUserOp: virtual public DBOp {
public:
virtual ~GetUserOp() {}
- string Schema(DBOpPrepareParams &params) {
+ std::string Schema(DBOpPrepareParams &params) {
if (params.op.query_str == "email") {
return fmt::format(QueryByEmail.c_str(), params.user_table.c_str(),
params.op.user.user_email.c_str());
@@ -789,7 +787,7 @@ class GetUserOp: virtual public DBOp {
class InsertBucketOp: virtual public DBOp {
private:
- const string Query =
+ const std::string Query =
"INSERT OR REPLACE INTO '{}' \
(BucketName, Tenant, Marker, BucketID, Size, SizeRounded, CreationTime, \
Count, PlacementName, PlacementStorageClass, OwnerID, Flags, Zonegroup, \
@@ -804,7 +802,7 @@ class InsertBucketOp: virtual public DBOp {
public:
virtual ~InsertBucketOp() {}
- string Schema(DBOpPrepareParams &params) {
+ std::string Schema(DBOpPrepareParams &params) {
return fmt::format(Query.c_str(), params.bucket_table.c_str(),
params.op.bucket.bucket_name, params.op.bucket.tenant,
params.op.bucket.marker, params.op.bucket.bucket_id,
@@ -826,7 +824,7 @@ class InsertBucketOp: virtual public DBOp {
class UpdateBucketOp: virtual public DBOp {
private:
// Updates Info, Mtime, Version
- const string InfoQuery =
+ const std::string InfoQuery =
"UPDATE '{}' SET Tenant = {}, Marker = {}, BucketID = {}, CreationTime = {}, \
Count = {}, PlacementName = {}, PlacementStorageClass = {}, OwnerID = {}, Flags = {}, \
Zonegroup = {}, HasInstanceObj = {}, Quota = {}, RequesterPays = {}, HasWebsite = {}, \
@@ -834,17 +832,17 @@ class UpdateBucketOp: virtual public DBOp {
NewBucketInstanceID = {}, ObjectLock = {}, SyncPolicyInfoGroups = {}, \
BucketVersion = {}, Mtime = {} WHERE BucketName = {}";
// Updates Attrs, OwnerID, Mtime, Version
- const string AttrsQuery =
+ const std::string AttrsQuery =
"UPDATE '{}' SET OwnerID = {}, BucketAttrs = {}, Mtime = {}, BucketVersion = {} \
WHERE BucketName = {}";
// Updates OwnerID, CreationTime, Mtime, Version
- const string OwnerQuery =
+ const std::string OwnerQuery =
"UPDATE '{}' SET OwnerID = {}, CreationTime = {}, Mtime = {}, BucketVersion = {} WHERE BucketName = {}";
public:
virtual ~UpdateBucketOp() {}
- string Schema(DBOpPrepareParams &params) {
+ std::string Schema(DBOpPrepareParams &params) {
if (params.op.query_str == "info") {
return fmt::format(InfoQuery.c_str(), params.bucket_table.c_str(),
params.op.bucket.tenant, params.op.bucket.marker, params.op.bucket.bucket_id,
@@ -878,13 +876,13 @@ class UpdateBucketOp: virtual public DBOp {
class RemoveBucketOp: virtual public DBOp {
private:
- const string Query =
+ const std::string Query =
"DELETE from '{}' where BucketName = {}";
public:
virtual ~RemoveBucketOp() {}
- string Schema(DBOpPrepareParams &params) {
+ std::string Schema(DBOpPrepareParams &params) {
return fmt::format(Query.c_str(), params.bucket_table.c_str(),
params.op.bucket.bucket_name.c_str());
}
@@ -892,7 +890,7 @@ class RemoveBucketOp: virtual public DBOp {
class GetBucketOp: virtual public DBOp {
private:
- const string Query = "SELECT \
+ const std::string Query = "SELECT \
BucketName, BucketTable.Tenant, Marker, BucketID, Size, SizeRounded, CreationTime, \
Count, BucketTable.PlacementName, BucketTable.PlacementStorageClass, OwnerID, Flags, Zonegroup, \
HasInstanceObj, Quota, RequesterPays, HasWebsite, WebsiteConf, \
@@ -904,7 +902,7 @@ class GetBucketOp: virtual public DBOp {
public:
virtual ~GetBucketOp() {}
- string Schema(DBOpPrepareParams &params) {
+ std::string Schema(DBOpPrepareParams &params) {
//return fmt::format(Query.c_str(), params.op.bucket.bucket_name.c_str(),
// params.bucket_table.c_str(), params.user_table.c_str());
return fmt::format(Query.c_str(),
@@ -917,7 +915,7 @@ class ListUserBucketsOp: virtual public DBOp {
private:
// once we have stats also stored, may have to update this query to join
// these two tables.
- const string Query = "SELECT \
+ const std::string Query = "SELECT \
BucketName, Tenant, Marker, BucketID, Size, SizeRounded, CreationTime, \
Count, PlacementName, PlacementStorageClass, OwnerID, Flags, Zonegroup, \
HasInstanceObj, Quota, RequesterPays, HasWebsite, WebsiteConf, \
@@ -929,7 +927,7 @@ class ListUserBucketsOp: virtual public DBOp {
public:
virtual ~ListUserBucketsOp() {}
- string Schema(DBOpPrepareParams &params) {
+ std::string Schema(DBOpPrepareParams &params) {
return fmt::format(Query.c_str(), params.bucket_table.c_str(),
params.op.user.user_id.c_str(), params.op.bucket.min_marker.c_str(),
params.op.list_max_count.c_str());
@@ -938,7 +936,7 @@ class ListUserBucketsOp: virtual public DBOp {
class PutObjectOp: virtual public DBOp {
private:
- const string Query =
+ const std::string Query =
"INSERT OR REPLACE INTO '{}' \
(ObjName, ObjInstance, ObjNS, BucketName, ACLs, IndexVer, Tag, \
Flags, VersionedEpoch, ObjCategory, Etag, Owner, OwnerDisplayName, \
@@ -956,7 +954,7 @@ class PutObjectOp: virtual public DBOp {
public:
virtual ~PutObjectOp() {}
- string Schema(DBOpPrepareParams &params) {
+ std::string Schema(DBOpPrepareParams &params) {
return fmt::format(Query.c_str(),
params.object_table.c_str(), params.op.obj.obj_name,
params.op.obj.obj_instance, params.op.obj.obj_ns,
@@ -987,13 +985,13 @@ class PutObjectOp: virtual public DBOp {
class DeleteObjectOp: virtual public DBOp {
private:
- const string Query =
+ const std::string Query =
"DELETE from '{}' where BucketName = {} and ObjName = {} and ObjInstance = {}";
public:
virtual ~DeleteObjectOp() {}
- string Schema(DBOpPrepareParams &params) {
+ std::string Schema(DBOpPrepareParams &params) {
return fmt::format(Query.c_str(), params.object_table.c_str(),
params.op.bucket.bucket_name.c_str(),
params.op.obj.obj_name.c_str(),
@@ -1003,7 +1001,7 @@ class DeleteObjectOp: virtual public DBOp {
class GetObjectOp: virtual public DBOp {
private:
- const string Query =
+ const std::string Query =
"SELECT \
ObjName, ObjInstance, ObjNS, BucketName, ACLs, IndexVer, Tag, \
Flags, VersionedEpoch, ObjCategory, Etag, Owner, OwnerDisplayName, \
@@ -1019,7 +1017,7 @@ class GetObjectOp: virtual public DBOp {
public:
virtual ~GetObjectOp() {}
- string Schema(DBOpPrepareParams &params) {
+ std::string Schema(DBOpPrepareParams &params) {
return fmt::format(Query.c_str(),
params.object_table.c_str(),
params.op.bucket.bucket_name.c_str(),
@@ -1032,7 +1030,7 @@ class ListBucketObjectsOp: virtual public DBOp {
private:
// once we have stats also stored, may have to update this query to join
// these two tables.
- const string Query =
+ const std::string Query =
"SELECT \
ObjName, ObjInstance, ObjNS, BucketName, ACLs, IndexVer, Tag, \
Flags, VersionedEpoch, ObjCategory, Etag, Owner, OwnerDisplayName, \
@@ -1047,7 +1045,7 @@ class ListBucketObjectsOp: virtual public DBOp {
public:
virtual ~ListBucketObjectsOp() {}
- string Schema(DBOpPrepareParams &params) {
+ std::string Schema(DBOpPrepareParams &params) {
/* XXX: Include prefix, delim */
return fmt::format(Query.c_str(),
params.object_table.c_str(),
@@ -1060,16 +1058,16 @@ class ListBucketObjectsOp: virtual public DBOp {
class UpdateObjectOp: virtual public DBOp {
private:
// Updates Omap
- const string OmapQuery =
+ const std::string OmapQuery =
"UPDATE '{}' SET Omap = {}, Mtime = {} \
where BucketName = {} and ObjName = {} and ObjInstance = {}";
- const string AttrsQuery =
+ const std::string AttrsQuery =
"UPDATE '{}' SET ObjAttrs = {}, Mtime = {} \
where BucketName = {} and ObjName = {} and ObjInstance = {}";
- const string MPQuery =
+ const std::string MPQuery =
"UPDATE '{}' SET MPPartsList = {}, Mtime = {} \
where BucketName = {} and ObjName = {} and ObjInstance = {}";
- const string MetaQuery =
+ const std::string MetaQuery =
"UPDATE '{}' SET \
ObjNS = {}, ACLs = {}, IndexVer = {}, Tag = {}, Flags = {}, VersionedEpoch = {}, \
ObjCategory = {}, Etag = {}, Owner = {}, OwnerDisplayName = {}, \
@@ -1088,7 +1086,7 @@ class UpdateObjectOp: virtual public DBOp {
public:
virtual ~UpdateObjectOp() {}
- string Schema(DBOpPrepareParams &params) {
+ std::string Schema(DBOpPrepareParams &params) {
if (params.op.query_str == "omap") {
return fmt::format(OmapQuery.c_str(),
params.object_table.c_str(), params.op.obj.omap.c_str(),
@@ -1147,7 +1145,7 @@ class UpdateObjectOp: virtual public DBOp {
class PutObjectDataOp: virtual public DBOp {
private:
- const string Query =
+ const std::string Query =
"INSERT OR REPLACE INTO '{}' \
(ObjName, ObjInstance, ObjNS, BucketName, MultipartPartStr, PartNum, Offset, Size, Data) \
VALUES ({}, {}, {}, {}, {}, {}, {}, {}, {})";
@@ -1155,7 +1153,7 @@ class PutObjectDataOp: virtual public DBOp {
public:
virtual ~PutObjectDataOp() {}
- string Schema(DBOpPrepareParams &params) {
+ std::string Schema(DBOpPrepareParams &params) {
return fmt::format(Query.c_str(),
params.objectdata_table.c_str(),
params.op.obj.obj_name, params.op.obj.obj_instance,
@@ -1171,7 +1169,7 @@ class PutObjectDataOp: virtual public DBOp {
class UpdateObjectDataOp: virtual public DBOp {
private:
- const string Query =
+ const std::string Query =
"UPDATE '{}' \
SET ObjName = {}, ObjInstance = {}, ObjNS = {} \
WHERE ObjName = {} and ObjInstance = {} and ObjNS = {} and \
@@ -1180,7 +1178,7 @@ class UpdateObjectDataOp: virtual public DBOp {
public:
virtual ~UpdateObjectDataOp() {}
- string Schema(DBOpPrepareParams &params) {
+ std::string Schema(DBOpPrepareParams &params) {
return fmt::format(Query.c_str(),
params.objectdata_table.c_str(),
params.op.obj.new_obj_name, params.op.obj.new_obj_instance,
@@ -1192,7 +1190,7 @@ class UpdateObjectDataOp: virtual public DBOp {
};
class GetObjectDataOp: virtual public DBOp {
private:
- const string Query =
+ const std::string Query =
"SELECT \
ObjName, ObjInstance, ObjNS, BucketName, MultipartPartStr, PartNum, Offset, Size, Data \
from '{}' where BucketName = {} and ObjName = {} and ObjInstance = {} ORDER BY MultipartPartStr, PartNum";
@@ -1200,7 +1198,7 @@ class GetObjectDataOp: virtual public DBOp {
public:
virtual ~GetObjectDataOp() {}
- string Schema(DBOpPrepareParams &params) {
+ std::string Schema(DBOpPrepareParams &params) {
return fmt::format(Query.c_str(),
params.objectdata_table.c_str(),
params.op.bucket.bucket_name.c_str(),
@@ -1211,13 +1209,13 @@ class GetObjectDataOp: virtual public DBOp {
class DeleteObjectDataOp: virtual public DBOp {
private:
- const string Query =
+ const std::string Query =
"DELETE from '{}' where BucketName = {} and ObjName = {} and ObjInstance = {}";
public:
virtual ~DeleteObjectDataOp() {}
- string Schema(DBOpPrepareParams &params) {
+ std::string Schema(DBOpPrepareParams &params) {
return fmt::format(Query.c_str(),
params.objectdata_table.c_str(),
params.op.bucket.bucket_name.c_str(),
@@ -1228,7 +1226,7 @@ class DeleteObjectDataOp: virtual public DBOp {
class InsertLCEntryOp: virtual public DBOp {
private:
- const string Query =
+ const std::string Query =
"INSERT OR REPLACE INTO '{}' \
(LCIndex, BucketName, StartTime, Status) \
VALUES ({}, {}, {}, {})";
@@ -1236,7 +1234,7 @@ class InsertLCEntryOp: virtual public DBOp {
public:
virtual ~InsertLCEntryOp() {}
- string Schema(DBOpPrepareParams &params) {
+ std::string Schema(DBOpPrepareParams &params) {
return fmt::format(Query.c_str(), params.lc_entry_table.c_str(),
params.op.lc_entry.index, params.op.lc_entry.bucket_name,
params.op.lc_entry.start_time, params.op.lc_entry.status);
@@ -1245,13 +1243,13 @@ class InsertLCEntryOp: virtual public DBOp {
class RemoveLCEntryOp: virtual public DBOp {
private:
- const string Query =
+ const std::string Query =
"DELETE from '{}' where LCIndex = {} and BucketName = {}";
public:
virtual ~RemoveLCEntryOp() {}
- string Schema(DBOpPrepareParams &params) {
+ std::string Schema(DBOpPrepareParams &params) {
return fmt::format(Query.c_str(), params.lc_entry_table.c_str(),
params.op.lc_entry.index, params.op.lc_entry.bucket_name);
}
@@ -1259,17 +1257,17 @@ class RemoveLCEntryOp: virtual public DBOp {
class GetLCEntryOp: virtual public DBOp {
private:
- const string Query = "SELECT \
+ const std::string Query = "SELECT \
LCIndex, BucketName, StartTime, Status \
from '{}' where LCIndex = {} and BucketName = {}";
- const string NextQuery = "SELECT \
+ const std::string NextQuery = "SELECT \
LCIndex, BucketName, StartTime, Status \
from '{}' where LCIndex = {} and BucketName > {} ORDER BY BucketName ASC";
public:
virtual ~GetLCEntryOp() {}
- string Schema(DBOpPrepareParams &params) {
+ std::string Schema(DBOpPrepareParams &params) {
if (params.op.query_str == "get_next_entry") {
return fmt::format(NextQuery.c_str(), params.lc_entry_table.c_str(),
params.op.lc_entry.index, params.op.lc_entry.bucket_name);
@@ -1282,14 +1280,14 @@ class GetLCEntryOp: virtual public DBOp {
class ListLCEntriesOp: virtual public DBOp {
private:
- const string Query = "SELECT \
+ const std::string Query = "SELECT \
LCIndex, BucketName, StartTime, Status \
FROM '{}' WHERE LCIndex = {} AND BucketName > {} ORDER BY BucketName ASC LIMIT {}";
public:
virtual ~ListLCEntriesOp() {}
- string Schema(DBOpPrepareParams &params) {
+ std::string Schema(DBOpPrepareParams &params) {
return fmt::format(Query.c_str(), params.lc_entry_table.c_str(),
params.op.lc_entry.index.c_str(), params.op.lc_entry.min_marker.c_str(),
params.op.list_max_count.c_str());
@@ -1298,7 +1296,7 @@ class ListLCEntriesOp: virtual public DBOp {
class InsertLCHeadOp: virtual public DBOp {
private:
- const string Query =
+ const std::string Query =
"INSERT OR REPLACE INTO '{}' \
(LCIndex, Marker, StartDate) \
VALUES ({}, {}, {})";
@@ -1306,7 +1304,7 @@ class InsertLCHeadOp: virtual public DBOp {
public:
virtual ~InsertLCHeadOp() {}
- string Schema(DBOpPrepareParams &params) {
+ std::string Schema(DBOpPrepareParams &params) {
return fmt::format(Query.c_str(), params.lc_head_table.c_str(),
params.op.lc_head.index, params.op.lc_head.marker,
params.op.lc_head.start_date);
@@ -1315,13 +1313,13 @@ class InsertLCHeadOp: virtual public DBOp {
class RemoveLCHeadOp: virtual public DBOp {
private:
- const string Query =
+ const std::string Query =
"DELETE from '{}' where LCIndex = {}";
public:
virtual ~RemoveLCHeadOp() {}
- string Schema(DBOpPrepareParams &params) {
+ std::string Schema(DBOpPrepareParams &params) {
return fmt::format(Query.c_str(), params.lc_head_table.c_str(),
params.op.lc_head.index);
}
@@ -1329,14 +1327,14 @@ class RemoveLCHeadOp: virtual public DBOp {
class GetLCHeadOp: virtual public DBOp {
private:
- const string Query = "SELECT \
+ const std::string Query = "SELECT \
LCIndex, Marker, StartDate \
from '{}' where LCIndex = {}";
public:
virtual ~GetLCHeadOp() {}
- string Schema(DBOpPrepareParams &params) {
+ std::string Schema(DBOpPrepareParams &params) {
return fmt::format(Query.c_str(), params.lc_head_table.c_str(),
params.op.lc_head.index);
}
@@ -1365,14 +1363,14 @@ WRITE_CLASS_ENCODER(DBOLHInfo)
class DB {
private:
- const string db_name;
+ const std::string db_name;
rgw::sal::Store* store;
- const string user_table;
- const string bucket_table;
- const string quota_table;
- const string lc_head_table;
- const string lc_entry_table;
- static map<string, class ObjectOp*> objectmap;
+ const std::string user_table;
+ const std::string bucket_table;
+ const std::string quota_table;
+ const std::string lc_head_table;
+ const std::string lc_entry_table;
+ static std::map<std::string, class ObjectOp*> objectmap;
protected:
void *db;
@@ -1386,8 +1384,8 @@ class DB {
// objects if any.
std::mutex mtx;
- public:
- DB(string db_name, CephContext *_cct) : db_name(db_name),
+ public:
+ DB(std::string db_name, CephContext *_cct) : db_name(db_name),
user_table(db_name+".user.table"),
bucket_table(db_name+".bucket.table"),
quota_table(db_name+".quota.table"),
@@ -1409,19 +1407,19 @@ class DB {
{}
virtual ~DB() {}
- const string getDBname() { return db_name; }
- const string getDBfile() { return db_name + ".db"; }
- const string getUserTable() { return user_table; }
- const string getBucketTable() { return bucket_table; }
- const string getQuotaTable() { return quota_table; }
- const string getLCHeadTable() { return lc_head_table; }
- const string getLCEntryTable() { return lc_entry_table; }
- const string getObjectTable(string bucket) {
+ const std::string getDBname() { return db_name; }
+ const std::string getDBfile() { return db_name + ".db"; }
+ const std::string getUserTable() { return user_table; }
+ const std::string getBucketTable() { return bucket_table; }
+ const std::string getQuotaTable() { return quota_table; }
+ const std::string getLCHeadTable() { return lc_head_table; }
+ const std::string getLCEntryTable() { return lc_entry_table; }
+ const std::string getObjectTable(std::string bucket) {
return db_name+"."+bucket+".object.table"; }
- const string getObjectDataTable(string bucket) {
+ const std::string getObjectDataTable(std::string bucket) {
return db_name+"."+bucket+".objectdata.table"; }
- map<string, class ObjectOp*> getObjectMap();
+ std::map<std::string, class ObjectOp*> getObjectMap();
struct DBOps dbops; // DB operations, make it private?
@@ -1436,18 +1434,18 @@ class DB {
CephContext *ctx() { return cct; }
const DoutPrefixProvider *get_def_dpp() { return &dp; }
- int Initialize(string logfile, int loglevel);
+ int Initialize(std::string logfile, int loglevel);
int Destroy(const DoutPrefixProvider *dpp);
int LockInit(const DoutPrefixProvider *dpp);
int LockDestroy(const DoutPrefixProvider *dpp);
int Lock(const DoutPrefixProvider *dpp);
int Unlock(const DoutPrefixProvider *dpp);
- int InitializeParams(const DoutPrefixProvider *dpp, string Op, DBOpParams *params);
- int ProcessOp(const DoutPrefixProvider *dpp, string Op, DBOpParams *params);
- DBOp* getDBOp(const DoutPrefixProvider *dpp, string Op, struct DBOpParams *params);
- int objectmapInsert(const DoutPrefixProvider *dpp, string bucket, class ObjectOp* ptr);
- int objectmapDelete(const DoutPrefixProvider *dpp, string bucket);
+ int InitializeParams(const DoutPrefixProvider *dpp, std::string Op, DBOpParams *params);
+ int ProcessOp(const DoutPrefixProvider *dpp, std::string Op, DBOpParams *params);
+ DBOp* getDBOp(const DoutPrefixProvider *dpp, std::string Op, struct DBOpParams *params);
+ int objectmapInsert(const DoutPrefixProvider *dpp, std::string bucket, class ObjectOp* ptr);
+ int objectmapDelete(const DoutPrefixProvider *dpp, std::string bucket);
virtual uint64_t get_blob_limit() { return 0; };
virtual void *openDB(const DoutPrefixProvider *dpp) { return NULL; }
@@ -1464,10 +1462,10 @@ class DB {
int get_user(const DoutPrefixProvider *dpp,
const std::string& query_str, const std::string& query_str_val,
- RGWUserInfo& uinfo, map<string, bufferlist> *pattrs,
+ RGWUserInfo& uinfo, std::map<std::string, bufferlist> *pattrs,
RGWObjVersionTracker *pobjv_tracker);
int store_user(const DoutPrefixProvider *dpp,
- RGWUserInfo& uinfo, bool exclusive, map<string, bufferlist> *pattrs,
+ RGWUserInfo& uinfo, bool exclusive, std::map<std::string, bufferlist> *pattrs,
RGWObjVersionTracker *pobjv_tracker, RGWUserInfo* pold_info);
int remove_user(const DoutPrefixProvider *dpp,
RGWUserInfo& uinfo, RGWObjVersionTracker *pobjv_tracker);
@@ -1477,11 +1475,11 @@ class DB {
obj_version* pbucket_version);
int create_bucket(const DoutPrefixProvider *dpp,
const RGWUserInfo& owner, rgw_bucket& bucket,
- const string& zonegroup_id,
+ const std::string& zonegroup_id,
const rgw_placement_rule& placement_rule,
- const string& swift_ver_location,
+ const std::string& swift_ver_location,
const RGWQuotaInfo * pquota_info,
- map<std::string, bufferlist>& attrs,
+ std::map<std::string, bufferlist>& attrs,
RGWBucketInfo& info,
obj_version *pobjv,
obj_version *pep_objv,
@@ -1495,15 +1493,15 @@ class DB {
int remove_bucket(const DoutPrefixProvider *dpp, const RGWBucketInfo info);
int list_buckets(const DoutPrefixProvider *dpp, const rgw_user& user,
- const string& marker,
- const string& end_marker,
+ const std::string& marker,
+ const std::string& end_marker,
uint64_t max,
bool need_stats,
RGWUserBuckets *buckets,
bool *is_truncated);
int update_bucket(const DoutPrefixProvider *dpp, const std::string& query_str,
RGWBucketInfo& info, bool exclusive,
- const rgw_user* powner_id, map<std::string, bufferlist>* pattrs,
+ const rgw_user* powner_id, std::map<std::string, bufferlist>* pattrs,
ceph::real_time* pmtime, RGWObjVersionTracker* pobjv);
uint64_t get_max_head_size() { return ObjHeadSize; }
@@ -1512,17 +1510,17 @@ class DB {
// db raw obj string is of format -
// "<bucketname>_<objname>_<objinstance>_<multipart-part-str>_<partnum>"
- const string raw_obj_oid = "{0}_{1}_{2}_{3}_{4}";
+ const std::string raw_obj_oid = "{0}_{1}_{2}_{3}_{4}";
- inline string to_oid(const string& bucket, const string& obj_name, const string& obj_instance,
- string mp_str, uint64_t partnum) {
- string s = fmt::format(raw_obj_oid.c_str(), bucket, obj_name, obj_instance, mp_str, partnum);
+ inline std::string to_oid(const std::string& bucket, const std::string& obj_name, const std::string& obj_instance,
+ std::string mp_str, uint64_t partnum) {
+ std::string s = fmt::format(raw_obj_oid.c_str(), bucket, obj_name, obj_instance, mp_str, partnum);
return s;
}
- inline int from_oid(const string& oid, string& bucket, string& obj_name,
- string& obj_instance,
- string& mp_str, uint64_t& partnum) {
- vector<std::string> result;
+ inline int from_oid(const std::string& oid, std::string& bucket, std::string& obj_name,
+ std::string& obj_instance,
+ std::string& mp_str, uint64_t& partnum) {
+ std::vector<std::string> result;
boost::split(result, oid, boost::is_any_of("_"));
bucket = result[0];
obj_name = result[1];
@@ -1536,22 +1534,22 @@ class DB {
struct raw_obj {
DB* db;
- string bucket_name;
- string obj_name;
- string obj_instance;
- string obj_ns;
- string multipart_part_str;
+ std::string bucket_name;
+ std::string obj_name;
+ std::string obj_instance;
+ std::string obj_ns;
+ std::string multipart_part_str;
uint64_t part_num;
- string obj_table;
- string obj_data_table;
+ std::string obj_table;
+ std::string obj_data_table;
raw_obj(DB* _db) {
db = _db;
}
- raw_obj(DB* _db, string& _bname, string& _obj_name, string& _obj_instance,
- string& _obj_ns, string _mp_part_str, int _part_num) {
+ raw_obj(DB* _db, std::string& _bname, std::string& _obj_name, std::string& _obj_instance,
+ std::string& _obj_ns, std::string _mp_part_str, int _part_num) {
db = _db;
bucket_name = _bname;
obj_name = _obj_name;
@@ -1564,7 +1562,7 @@ class DB {
obj_data_table = bucket_name+".objectdata.table";
}
- raw_obj(DB* _db, string& oid) {
+ raw_obj(DB* _db, std::string& oid) {
int r;
db = _db;
@@ -1609,11 +1607,11 @@ class DB {
public:
struct Params {
- string prefix;
- string delim;
+ std::string prefix;
+ std::string delim;
rgw_obj_key marker;
rgw_obj_key end_marker;
- string ns;
+ std::string ns;
bool enforce_ns;
RGWAccessListFilter* access_list_filter;
RGWBucketListNameFilter force_check_filter;
@@ -1633,8 +1631,8 @@ class DB {
/* XXX: Handle ordered and unordered separately.
* For now returning only ordered entries */
int list_objects(const DoutPrefixProvider *dpp, int64_t max,
- vector<rgw_bucket_dir_entry> *result,
- map<string, bool> *common_prefixes, bool *is_truncated);
+ std::vector<rgw_bucket_dir_entry> *result,
+ std::map<std::string, bool> *common_prefixes, bool *is_truncated);
rgw_obj_key& get_next_marker() {
return next_marker;
}
@@ -1678,7 +1676,7 @@ class DB {
const char *if_match;
const char *if_nomatch;
- ConditionParams() :
+ ConditionParams() :
mod_ptr(NULL), unmod_ptr(NULL), high_precision_time(false), mod_zone_id(0), mod_pg_ver(0),
if_match(NULL), if_nomatch(NULL) {}
} conds;
@@ -1686,7 +1684,7 @@ class DB {
struct Params {
ceph::real_time *lastmod;
uint64_t *obj_size;
- map<string, bufferlist> *attrs;
+ std::map<std::string, bufferlist> *attrs;
rgw_obj *target_obj;
Params() : lastmod(nullptr), obj_size(nullptr), attrs(nullptr),
@@ -1705,15 +1703,15 @@ class DB {
struct Write {
DB::Object *target;
RGWObjState obj_state;
- string mp_part_str = "0.0"; // multipart num
+ std::string mp_part_str = "0.0"; // multipart num
struct MetaParams {
ceph::real_time *mtime;
- map<std::string, bufferlist>* rmattrs;
+ std::map<std::string, bufferlist>* rmattrs;
const bufferlist *data;
RGWObjManifest *manifest;
- const string *ptag;
- list<rgw_obj_index_key> *remove_objs;
+ const std::string *ptag;
+ std::list<rgw_obj_index_key> *remove_objs;
ceph::real_time set_mtime;
rgw_user owner;
RGWObjCategory category;
@@ -1723,7 +1721,7 @@ class DB {
std::optional<uint64_t> olh_epoch;
ceph::real_time delete_at;
bool canceled;
- const string *user_data;
+ const std::string *user_data;
rgw_zone_set *zones_trace;
bool modify_tail;
bool completeMultipart;
@@ -1737,16 +1735,16 @@ class DB {
explicit Write(DB::Object *_target) : target(_target) {}
- void set_mp_part_str(string _mp_part_str) { mp_part_str = _mp_part_str;}
+ void set_mp_part_str(std::string _mp_part_str) { mp_part_str = _mp_part_str;}
int prepare(const DoutPrefixProvider* dpp);
int write_data(const DoutPrefixProvider* dpp,
bufferlist& data, uint64_t ofs);
int _do_write_meta(const DoutPrefixProvider *dpp,
uint64_t size, uint64_t accounted_size,
- map<string, bufferlist>& attrs,
+ std::map<std::string, bufferlist>& attrs,
bool assume_noent, bool modify_tail);
int write_meta(const DoutPrefixProvider *dpp, uint64_t size,
- uint64_t accounted_size, map<string, bufferlist>& attrs);
+ uint64_t accounted_size, std::map<std::string, bufferlist>& attrs);
/* Below are used to update mp data rows object name
* from meta to src object name on multipart upload
* completion
@@ -1762,9 +1760,9 @@ class DB {
int versioning_status;
ACLOwner obj_owner; /* needed for creation of deletion marker */
uint64_t olh_epoch;
- string marker_version_id;
+ std::string marker_version_id;
uint32_t bilog_flags;
- list<rgw_obj_index_key> *remove_objs;
+ std::list<rgw_obj_index_key> *remove_objs;
ceph::real_time expiration_time;
ceph::real_time unmod_since;
ceph::real_time mtime; /* for setting delete marker mtime */
@@ -1778,7 +1776,7 @@ class DB {
struct DeleteResult {
bool delete_marker;
- string version_id;
+ std::string version_id;
DeleteResult() : delete_marker(false) {}
} result;
@@ -1806,8 +1804,8 @@ class DB {
RGWBucketInfo& get_bucket_info() { return bucket_info; }
int InitializeParamsfromObject(const DoutPrefixProvider *dpp, DBOpParams* params);
- int set_attrs(const DoutPrefixProvider *dpp, map<string, bufferlist>& setattrs,
- map<string, bufferlist>* rmattrs);
+ int set_attrs(const DoutPrefixProvider *dpp, std::map<std::string, bufferlist>& setattrs,
+ std::map<std::string, bufferlist>* rmattrs);
int obj_omap_set_val_by_key(const DoutPrefixProvider *dpp, const std::string& key, bufferlist& val, bool must_exist);
int obj_omap_get_vals_by_keys(const DoutPrefixProvider *dpp, const std::string& oid,
const std::set<std::string>& keys,
diff --git a/src/rgw/store/dbstore/common/dbstore_log.h b/src/rgw/store/dbstore/common/dbstore_log.h
index 9bd4a227480..4b1373bfccb 100644
--- a/src/rgw/store/dbstore/common/dbstore_log.h
+++ b/src/rgw/store/dbstore/common/dbstore_log.h
@@ -4,15 +4,13 @@
#ifndef DB_STORE_LOG_H
#define DB_STORE_LOG_H
-#include <errno.h>
-#include <stdlib.h>
+#include <cerrno>
+#include <cstdlib>
#include <string>
-#include <stdio.h>
+#include <cstdio>
#include <iostream>
#include <fstream>
-#include "common/dout.h"
-
-using namespace std;
+#include "common/dout.h"
#define dout_subsys ceph_subsys_rgw
#undef dout_prefix
diff --git a/src/rgw/store/dbstore/dbstore_main.cc b/src/rgw/store/dbstore/dbstore_main.cc
index 0055191908b..34762b52d90 100644
--- a/src/rgw/store/dbstore/dbstore_main.cc
+++ b/src/rgw/store/dbstore/dbstore_main.cc
@@ -8,6 +8,7 @@
#include <dbstore.h>
#include <dbstore_log.h>
+using namespace std;
using namespace rgw::store;
using DB = rgw::store::DB;
diff --git a/src/rgw/store/dbstore/dbstore_mgr.cc b/src/rgw/store/dbstore/dbstore_mgr.cc
index 61e11d99637..9da98a487dc 100644
--- a/src/rgw/store/dbstore/dbstore_mgr.cc
+++ b/src/rgw/store/dbstore/dbstore_mgr.cc
@@ -4,6 +4,8 @@
#include "dbstore_mgr.h"
#include "common/dbstore_log.h"
+using namespace std;
+
/* Given a tenant, find and return the DBStore handle.
* If not found and 'create' set to true, create one
* and return
diff --git a/src/rgw/store/dbstore/dbstore_mgr.h b/src/rgw/store/dbstore/dbstore_mgr.h
index d3053e6ac7c..850f97a42e2 100644
--- a/src/rgw/store/dbstore/dbstore_mgr.h
+++ b/src/rgw/store/dbstore/dbstore_mgr.h
@@ -4,27 +4,26 @@
#pragma once
#include <map>
-#include <errno.h>
-#include <stdlib.h>
+#include <cerrno>
+#include <cstdlib>
#include <string>
-#include <stdio.h>
+#include <cstdio>
#include <iostream>
+#include <vector>
+
#include "common/ceph_context.h"
#include "common/dbstore.h"
#include "sqlite/sqliteDB.h"
-using namespace std;
using namespace rgw::store;
using DB = rgw::store::DB;
/* XXX: Should be a dbstore config option */
-const static string default_tenant = "default_ns";
-
-using namespace std;
+const static std::string default_tenant = "default_ns";
class DBStoreManager {
private:
- map<string, DB*> DBStoreHandles;
+ std::map<std::string, DB*> DBStoreHandles;
DB *default_db = NULL;
CephContext *cct;
@@ -33,9 +32,9 @@ public:
cct = _cct;
default_db = createDB(default_tenant);
};
- DBStoreManager(string logfile, int loglevel): DBStoreHandles() {
+ DBStoreManager(std::string logfile, int loglevel): DBStoreHandles() {
/* No ceph context. Create one with log args provided */
- vector<const char*> args;
+ std::vector<const char*> args;
cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT,
CODE_ENVIRONMENT_DAEMON, CINIT_FLAG_NO_MON_CONFIG, 1)->get();
cct->_log->set_log_file(logfile);
@@ -50,9 +49,9 @@ public:
* being deleted while using it.
*/
DB* getDB () { return default_db; };
- DB* getDB (string tenant, bool create);
- DB* createDB (string tenant);
- void deleteDB (string tenant);
+ DB* getDB (std::string tenant, bool create);
+ DB* createDB (std::string tenant);
+ void deleteDB (std::string tenant);
void deleteDB (DB* db);
void destroyAllHandles();
};
diff --git a/src/rgw/store/dbstore/sqlite/sqliteDB.cc b/src/rgw/store/dbstore/sqlite/sqliteDB.cc
index f24eb68b2e2..6675af2922e 100644
--- a/src/rgw/store/dbstore/sqlite/sqliteDB.cc
+++ b/src/rgw/store/dbstore/sqlite/sqliteDB.cc
@@ -3,6 +3,8 @@
#include "sqliteDB.h"
+using namespace std;
+
#define SQL_PREPARE(dpp, params, sdb, stmt, ret, Op) \
do { \
string schema; \
diff --git a/src/rgw/store/dbstore/sqlite/sqliteDB.h b/src/rgw/store/dbstore/sqlite/sqliteDB.h
index 5bf7dfdd16f..dd56ab1f9ec 100644
--- a/src/rgw/store/dbstore/sqlite/sqliteDB.h
+++ b/src/rgw/store/dbstore/sqlite/sqliteDB.h
@@ -10,7 +10,6 @@
#include <sqlite3.h>
#include "rgw/store/dbstore/common/dbstore.h"
-using namespace std;
using namespace rgw::store;
class SQLiteDB : public DB, virtual public DBOp {
@@ -20,15 +19,15 @@ class SQLiteDB : public DB, virtual public DBOp {
protected:
CephContext *cct;
- public:
+ public:
sqlite3_stmt *stmt = NULL;
DBOpPrepareParams PrepareParams;
- SQLiteDB(sqlite3 *dbi, string db_name, CephContext *_cct) : DB(db_name, _cct), cct(_cct) {
+ SQLiteDB(sqlite3 *dbi, std::string db_name, CephContext *_cct) : DB(db_name, _cct), cct(_cct) {
db = (void*)dbi;
InitPrepareParams(get_def_dpp(), PrepareParams);
}
- SQLiteDB(string db_name, CephContext *_cct) : DB(db_name, _cct), cct(_cct) {
+ SQLiteDB(std::string db_name, CephContext *_cct) : DB(db_name, _cct), cct(_cct) {
InitPrepareParams(get_def_dpp(), PrepareParams);
}
~SQLiteDB() {}
@@ -48,7 +47,7 @@ class SQLiteDB : public DB, virtual public DBOp {
int Reset(const DoutPrefixProvider *dpp, sqlite3_stmt *stmt);
/* default value matches with sqliteDB style */
- int createTables(const DoutPrefixProvider *dpp);
+ int createTables(const DoutPrefixProvider *dpp) override;
int createBucketTable(const DoutPrefixProvider *dpp, DBOpParams *params);
int createUserTable(const DoutPrefixProvider *dpp, DBOpParams *params);
int createObjectTable(const DoutPrefixProvider *dpp, DBOpParams *params);
@@ -79,7 +78,7 @@ class SQLObjectOp : public ObjectOp {
SQLObjectOp(sqlite3 **sdbi, CephContext *_cct) : sdb(sdbi), cct(_cct) {};
~SQLObjectOp() {}
- int InitializeObjectOps(string db_name, const DoutPrefixProvider *dpp);
+ int InitializeObjectOps(std::string db_name, const DoutPrefixProvider *dpp);
int FreeObjectOps(const DoutPrefixProvider *dpp);
};
@@ -89,7 +88,7 @@ class SQLInsertUser : public SQLiteDB, public InsertUserOp {
sqlite3_stmt *stmt = NULL; // Prepared statement
public:
- SQLInsertUser(void **db, string db_name, CephContext *cct) : SQLiteDB((sqlite3 *)(*db), db_name, cct), sdb((sqlite3 **)db) {}
+ SQLInsertUser(void **db, std::string db_name, CephContext *cct) : SQLiteDB((sqlite3 *)(*db), db_name, cct), sdb((sqlite3 **)db) {}
~SQLInsertUser() {
if (stmt)
sqlite3_finalize(stmt);
@@ -105,7 +104,7 @@ class SQLRemoveUser : public SQLiteDB, public RemoveUserOp {
sqlite3_stmt *stmt = NULL; // Prepared statement
public:
- SQLRemoveUser(void **db, string db_name, CephContext *cct) : SQLiteDB((sqlite3 *)(*db), db_name, cct), sdb((sqlite3 **)db) {}
+ SQLRemoveUser(void **db, std::string db_name, CephContext *cct) : SQLiteDB((sqlite3 *)(*db), db_name, cct), sdb((sqlite3 **)db) {}
~SQLRemoveUser() {
if (stmt)
sqlite3_finalize(stmt);
@@ -124,7 +123,7 @@ class SQLGetUser : public SQLiteDB, public GetUserOp {
sqlite3_stmt *userid_stmt = NULL; // Prepared statement to query by user_id
public:
- SQLGetUser(void **db, string db_name, CephContext *cct) : SQLiteDB((sqlite3 *)(*db), db_name, cct), sdb((sqlite3 **)db) {}
+ SQLGetUser(void **db, std::string db_name, CephContext *cct) : SQLiteDB((sqlite3 *)(*db), db_name, cct), sdb((sqlite3 **)db) {}
~SQLGetUser() {
if (stmt)
sqlite3_finalize(stmt);
@@ -146,7 +145,7 @@ class SQLInsertBucket : public SQLiteDB, public InsertBucketOp {
sqlite3_stmt *stmt = NULL; // Prepared statement
public:
- SQLInsertBucket(void **db, string db_name, CephContext *cct) : SQLiteDB((sqlite3 *)(*db), db_name, cct), sdb((sqlite3 **)db) {}
+ SQLInsertBucket(void **db, std::string db_name, CephContext *cct) : SQLiteDB((sqlite3 *)(*db), db_name, cct), sdb((sqlite3 **)db) {}
~SQLInsertBucket() {
if (stmt)
sqlite3_finalize(stmt);
@@ -164,7 +163,7 @@ class SQLUpdateBucket : public SQLiteDB, public UpdateBucketOp {
sqlite3_stmt *owner_stmt = NULL; // Prepared statement
public:
- SQLUpdateBucket(void **db, string db_name, CephContext *cct) : SQLiteDB((sqlite3 *)(*db), db_name, cct), sdb((sqlite3 **)db) {}
+ SQLUpdateBucket(void **db, std::string db_name, CephContext *cct) : SQLiteDB((sqlite3 *)(*db), db_name, cct), sdb((sqlite3 **)db) {}
~SQLUpdateBucket() {
if (info_stmt)
sqlite3_finalize(info_stmt);
@@ -184,7 +183,7 @@ class SQLRemoveBucket : public SQLiteDB, public RemoveBucketOp {
sqlite3_stmt *stmt = NULL; // Prepared statement
public:
- SQLRemoveBucket(void **db, string db_name, CephContext *cct) : SQLiteDB((sqlite3 *)(*db), db_name, cct), sdb((sqlite3 **)db) {}
+ SQLRemoveBucket(void **db, std::string db_name, CephContext *cct) : SQLiteDB((sqlite3 *)(*db), db_name, cct), sdb((sqlite3 **)db) {}
~SQLRemoveBucket() {
if (stmt)
sqlite3_finalize(stmt);
@@ -200,7 +199,7 @@ class SQLGetBucket : public SQLiteDB, public GetBucketOp {
sqlite3_stmt *stmt = NULL; // Prepared statement
public:
- SQLGetBucket(void **db, string db_name, CephContext *cct) : SQLiteDB((sqlite3 *)(*db), db_name, cct), sdb((sqlite3 **)db) {}
+ SQLGetBucket(void **db, std::string db_name, CephContext *cct) : SQLiteDB((sqlite3 *)(*db), db_name, cct), sdb((sqlite3 **)db) {}
~SQLGetBucket() {
if (stmt)
sqlite3_finalize(stmt);
@@ -216,7 +215,7 @@ class SQLListUserBuckets : public SQLiteDB, public ListUserBucketsOp {
sqlite3_stmt *stmt = NULL; // Prepared statement
public:
- SQLListUserBuckets(void **db, string db_name, CephContext *cct) : SQLiteDB((sqlite3 *)(*db), db_name, cct), sdb((sqlite3 **)db) {}
+ SQLListUserBuckets(void **db, std::string db_name, CephContext *cct) : SQLiteDB((sqlite3 *)(*db), db_name, cct), sdb((sqlite3 **)db) {}
~SQLListUserBuckets() {
if (stmt)
sqlite3_finalize(stmt);
@@ -232,8 +231,8 @@ class SQLPutObject : public SQLiteDB, public PutObjectOp {
sqlite3_stmt *stmt = NULL; // Prepared statement
public:
- SQLPutObject(void **db, string db_name, CephContext *cct) : SQLiteDB((sqlite3 *)(*db), db_name, cct), sdb((sqlite3 **)db) {}
- SQLPutObject(sqlite3 **sdbi, string db_name, CephContext *cct) : SQLiteDB(*sdbi, db_name, cct), sdb(sdbi) {}
+ SQLPutObject(void **db, std::string db_name, CephContext *cct) : SQLiteDB((sqlite3 *)(*db), db_name, cct), sdb((sqlite3 **)db) {}
+ SQLPutObject(sqlite3 **sdbi, std::string db_name, CephContext *cct) : SQLiteDB(*sdbi, db_name, cct), sdb(sdbi) {}
~SQLPutObject() {
if (stmt)
@@ -250,8 +249,8 @@ class SQLDeleteObject : public SQLiteDB, public DeleteObjectOp {
sqlite3_stmt *stmt = NULL; // Prepared statement
public:
- SQLDeleteObject(void **db, string db_name, CephContext *cct) : SQLiteDB((sqlite3 *)(*db), db_name, cct), sdb((sqlite3 **)db) {}
- SQLDeleteObject(sqlite3 **sdbi, string db_name, CephContext *cct) : SQLiteDB(*sdbi, db_name, cct), sdb(sdbi) {}
+ SQLDeleteObject(void **db, std::string db_name, CephContext *cct) : SQLiteDB((sqlite3 *)(*db), db_name, cct), sdb((sqlite3 **)db) {}
+ SQLDeleteObject(sqlite3 **sdbi, std::string db_name, CephContext *cct) : SQLiteDB(*sdbi, db_name, cct), sdb(sdbi) {}
~SQLDeleteObject() {
if (stmt)
@@ -268,8 +267,8 @@ class SQLGetObject : public SQLiteDB, public GetObjectOp {
sqlite3_stmt *stmt = NULL; // Prepared statement
public:
- SQLGetObject(void **db, string db_name, CephContext *cct) : SQLiteDB((sqlite3 *)(*db), db_name, cct), sdb((sqlite3 **)db) {}
- SQLGetObject(sqlite3 **sdbi, string db_name, CephContext *cct) : SQLiteDB(*sdbi, db_name, cct), sdb(sdbi) {}
+ SQLGetObject(void **db, std::string db_name, CephContext *cct) : SQLiteDB((sqlite3 *)(*db), db_name, cct), sdb((sqlite3 **)db) {}
+ SQLGetObject(sqlite3 **sdbi, std::string db_name, CephContext *cct) : SQLiteDB(*sdbi, db_name, cct), sdb(sdbi) {}
~SQLGetObject() {
if (stmt)
@@ -289,8 +288,8 @@ class SQLUpdateObject : public SQLiteDB, public UpdateObjectOp {
sqlite3_stmt *mp_stmt = NULL; // Prepared statement
public:
- SQLUpdateObject(void **db, string db_name, CephContext *cct) : SQLiteDB((sqlite3 *)(*db), db_name, cct), sdb((sqlite3 **)db) {}
- SQLUpdateObject(sqlite3 **sdbi, string db_name, CephContext *cct) : SQLiteDB(*sdbi, db_name, cct), sdb(sdbi) {}
+ SQLUpdateObject(void **db, std::string db_name, CephContext *cct) : SQLiteDB((sqlite3 *)(*db), db_name, cct), sdb((sqlite3 **)db) {}
+ SQLUpdateObject(sqlite3 **sdbi, std::string db_name, CephContext *cct) : SQLiteDB(*sdbi, db_name, cct), sdb(sdbi) {}
~SQLUpdateObject() {
if (omap_stmt)
@@ -312,8 +311,8 @@ class SQLListBucketObjects : public SQLiteDB, public ListBucketObjectsOp {
sqlite3_stmt *stmt = NULL; // Prepared statement
public:
- SQLListBucketObjects(void **db, string db_name, CephContext *cct) : SQLiteDB((sqlite3 *)(*db), db_name, cct), sdb((sqlite3 **)db) {}
- SQLListBucketObjects(sqlite3 **sdbi, string db_name, CephContext *cct) : SQLiteDB(*sdbi, db_name, cct), sdb(sdbi) {}
+ SQLListBucketObjects(void **db, std::string db_name, CephContext *cct) : SQLiteDB((sqlite3 *)(*db), db_name, cct), sdb((sqlite3 **)db) {}
+ SQLListBucketObjects(sqlite3 **sdbi, std::string db_name, CephContext *cct) : SQLiteDB(*sdbi, db_name, cct), sdb(sdbi) {}
~SQLListBucketObjects() {
if (stmt)
@@ -330,8 +329,8 @@ class SQLPutObjectData : public SQLiteDB, public PutObjectDataOp {
sqlite3_stmt *stmt = NULL; // Prepared statement
public:
- SQLPutObjectData(void **db, string db_name, CephContext *cct) : SQLiteDB((sqlite3 *)(*db), db_name, cct), sdb((sqlite3 **)db) {}
- SQLPutObjectData(sqlite3 **sdbi, string db_name, CephContext *cct) : SQLiteDB(*sdbi, db_name, cct), sdb(sdbi) {}
+ SQLPutObjectData(void **db, std::string db_name, CephContext *cct) : SQLiteDB((sqlite3 *)(*db), db_name, cct), sdb((sqlite3 **)db) {}
+ SQLPutObjectData(sqlite3 **sdbi, std::string db_name, CephContext *cct) : SQLiteDB(*sdbi, db_name, cct), sdb(sdbi) {}
~SQLPutObjectData() {
if (stmt)
@@ -348,8 +347,8 @@ class SQLUpdateObjectData : public SQLiteDB, public UpdateObjectDataOp {
sqlite3_stmt *stmt = NULL; // Prepared statement
public:
- SQLUpdateObjectData(void **db, string db_name, CephContext *cct) : SQLiteDB((sqlite3 *)(*db), db_name, cct), sdb((sqlite3 **)db) {}
- SQLUpdateObjectData(sqlite3 **sdbi, string db_name, CephContext *cct) : SQLiteDB(*sdbi, db_name, cct), sdb(sdbi) {}
+ SQLUpdateObjectData(void **db, std::string db_name, CephContext *cct) : SQLiteDB((sqlite3 *)(*db), db_name, cct), sdb((sqlite3 **)db) {}
+ SQLUpdateObjectData(sqlite3 **sdbi, std::string db_name, CephContext *cct) : SQLiteDB(*sdbi, db_name, cct), sdb(sdbi) {}
~SQLUpdateObjectData() {
if (stmt)
@@ -366,8 +365,8 @@ class SQLGetObjectData : public SQLiteDB, public GetObjectDataOp {
sqlite3_stmt *stmt = NULL; // Prepared statement
public:
- SQLGetObjectData(void **db, string db_name, CephContext *cct) : SQLiteDB((sqlite3 *)(*db), db_name, cct), sdb((sqlite3 **)db) {}
- SQLGetObjectData(sqlite3 **sdbi, string db_name, CephContext *cct) : SQLiteDB(*sdbi, db_name, cct), sdb(sdbi) {}
+ SQLGetObjectData(void **db, std::string db_name, CephContext *cct) : SQLiteDB((sqlite3 *)(*db), db_name, cct), sdb((sqlite3 **)db) {}
+ SQLGetObjectData(sqlite3 **sdbi, std::string db_name, CephContext *cct) : SQLiteDB(*sdbi, db_name, cct), sdb(sdbi) {}
~SQLGetObjectData() {
if (stmt)
@@ -384,8 +383,8 @@ class SQLDeleteObjectData : public SQLiteDB, public DeleteObjectDataOp {
sqlite3_stmt *stmt = NULL; // Prepared statement
public:
- SQLDeleteObjectData(void **db, string db_name, CephContext *cct) : SQLiteDB((sqlite3 *)(*db), db_name, cct), sdb((sqlite3 **)db) {}
- SQLDeleteObjectData(sqlite3 **sdbi, string db_name, CephContext *cct) : SQLiteDB(*sdbi, db_name, cct), sdb(sdbi) {}
+ SQLDeleteObjectData(void **db, std::string db_name, CephContext *cct) : SQLiteDB((sqlite3 *)(*db), db_name, cct), sdb((sqlite3 **)db) {}
+ SQLDeleteObjectData(sqlite3 **sdbi, std::string db_name, CephContext *cct) : SQLiteDB(*sdbi, db_name, cct), sdb(sdbi) {}
~SQLDeleteObjectData() {
if (stmt)
@@ -402,7 +401,7 @@ class SQLInsertLCEntry : public SQLiteDB, public InsertLCEntryOp {
sqlite3_stmt *stmt = NULL; // Prepared statement
public:
- SQLInsertLCEntry(void **db, string db_name, CephContext *cct) : SQLiteDB((sqlite3 *)(*db), db_name, cct), sdb((sqlite3 **)db) {}
+ SQLInsertLCEntry(void **db, std::string db_name, CephContext *cct) : SQLiteDB((sqlite3 *)(*db), db_name, cct), sdb((sqlite3 **)db) {}
~SQLInsertLCEntry() {
if (stmt)
sqlite3_finalize(stmt);
@@ -418,7 +417,7 @@ class SQLRemoveLCEntry : public SQLiteDB, public RemoveLCEntryOp {
sqlite3_stmt *stmt = NULL; // Prepared statement
public:
- SQLRemoveLCEntry(void **db, string db_name, CephContext *cct) : SQLiteDB((sqlite3 *)(*db), db_name, cct), sdb((sqlite3 **)db) {}
+ SQLRemoveLCEntry(void **db, std::string db_name, CephContext *cct) : SQLiteDB((sqlite3 *)(*db), db_name, cct), sdb((sqlite3 **)db) {}
~SQLRemoveLCEntry() {
if (stmt)
sqlite3_finalize(stmt);
@@ -435,7 +434,7 @@ class SQLGetLCEntry : public SQLiteDB, public GetLCEntryOp {
sqlite3_stmt *next_stmt = NULL; // Prepared statement
public:
- SQLGetLCEntry(void **db, string db_name, CephContext *cct) : SQLiteDB((sqlite3 *)(*db), db_name, cct), sdb((sqlite3 **)db) {}
+ SQLGetLCEntry(void **db, std::string db_name, CephContext *cct) : SQLiteDB((sqlite3 *)(*db), db_name, cct), sdb((sqlite3 **)db) {}
~SQLGetLCEntry() {
if (stmt)
sqlite3_finalize(stmt);
@@ -453,7 +452,7 @@ class SQLListLCEntries : public SQLiteDB, public ListLCEntriesOp {
sqlite3_stmt *stmt = NULL; // Prepared statement
public:
- SQLListLCEntries(void **db, string db_name, CephContext *cct) : SQLiteDB((sqlite3 *)(*db), db_name, cct), sdb((sqlite3 **)db) {}
+ SQLListLCEntries(void **db, std::string db_name, CephContext *cct) : SQLiteDB((sqlite3 *)(*db), db_name, cct), sdb((sqlite3 **)db) {}
~SQLListLCEntries() {
if (stmt)
sqlite3_finalize(stmt);
@@ -469,7 +468,7 @@ class SQLInsertLCHead : public SQLiteDB, public InsertLCHeadOp {
sqlite3_stmt *stmt = NULL; // Prepared statement
public:
- SQLInsertLCHead(void **db, string db_name, CephContext *cct) : SQLiteDB((sqlite3 *)(*db), db_name, cct), sdb((sqlite3 **)db) {}
+ SQLInsertLCHead(void **db, std::string db_name, CephContext *cct) : SQLiteDB((sqlite3 *)(*db), db_name, cct), sdb((sqlite3 **)db) {}
~SQLInsertLCHead() {
if (stmt)
sqlite3_finalize(stmt);
@@ -485,7 +484,7 @@ class SQLRemoveLCHead : public SQLiteDB, public RemoveLCHeadOp {
sqlite3_stmt *stmt = NULL; // Prepared statement
public:
- SQLRemoveLCHead(void **db, string db_name, CephContext *cct) : SQLiteDB((sqlite3 *)(*db), db_name, cct), sdb((sqlite3 **)db) {}
+ SQLRemoveLCHead(void **db, std::string db_name, CephContext *cct) : SQLiteDB((sqlite3 *)(*db), db_name, cct), sdb((sqlite3 **)db) {}
~SQLRemoveLCHead() {
if (stmt)
sqlite3_finalize(stmt);
@@ -501,7 +500,7 @@ class SQLGetLCHead : public SQLiteDB, public GetLCHeadOp {
sqlite3_stmt *stmt = NULL; // Prepared statement
public:
- SQLGetLCHead(void **db, string db_name, CephContext *cct) : SQLiteDB((sqlite3 *)(*db), db_name, cct), sdb((sqlite3 **)db) {}
+ SQLGetLCHead(void **db, std::string db_name, CephContext *cct) : SQLiteDB((sqlite3 *)(*db), db_name, cct), sdb((sqlite3 **)db) {}
~SQLGetLCHead() {
if (stmt)
sqlite3_finalize(stmt);
diff --git a/src/test/erasure-code/ErasureCodeExample.h b/src/test/erasure-code/ErasureCodeExample.h
index 1185b38d736..4226361c47e 100644
--- a/src/test/erasure-code/ErasureCodeExample.h
+++ b/src/test/erasure-code/ErasureCodeExample.h
@@ -35,15 +35,13 @@
#define MINIMUM_TO_RECOVER 2u
-using namespace std;
-
class ErasureCodeExample final : public ErasureCode {
public:
~ErasureCodeExample() override {}
int create_rule(const std::string &name,
CrushWrapper &crush,
- ostream *ss) const override {
+ std::ostream *ss) const override {
return crush.add_simple_rule(name, "default", "host", "",
"indep", pg_pool_t::TYPE_ERASURE, ss);
}
@@ -70,7 +68,7 @@ public:
c2c[CODING_CHUNK] > c2c[SECOND_DATA_CHUNK])
c2c.erase(CODING_CHUNK);
}
- set <int> available_chunks;
+ std::set <int> available_chunks;
for (std::map<int, int>::const_iterator i = c2c.begin();
i != c2c.end();
++i)
@@ -116,7 +114,7 @@ public:
// to chunk boundaries
//
const bufferptr &ptr = out.front();
- for (set<int>::iterator j = want_to_encode.begin();
+ for (auto j = want_to_encode.begin();
j != want_to_encode.end();
++j) {
bufferlist tmp;
@@ -136,7 +134,7 @@ public:
int _decode(const std::set<int> &want_to_read,
const std::map<int, bufferlist> &chunks,
- std::map<int, bufferlist> *decoded) {
+ std::map<int, bufferlist> *decoded) override {
//
// All chunks have the same size
//
diff --git a/src/test/erasure-code/TestErasureCodeExample.cc b/src/test/erasure-code/TestErasureCodeExample.cc
index 826f3bef177..b488a604b61 100644
--- a/src/test/erasure-code/TestErasureCodeExample.cc
+++ b/src/test/erasure-code/TestErasureCodeExample.cc
@@ -1,4 +1,4 @@
-// -*- mode:C; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph distributed storage system
@@ -11,7 +11,7 @@
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
- *
+ *
*/
#include <stdlib.h>
@@ -20,6 +20,8 @@
#include "global/global_context.h"
#include "gtest/gtest.h"
+using namespace std;
+
TEST(ErasureCodeExample, chunk_size)
{
ErasureCodeExample example;
diff --git a/src/test/erasure-code/ceph_erasure_code_benchmark.cc b/src/test/erasure-code/ceph_erasure_code_benchmark.cc
index 2bcb5f3cd3b..c86e58697c0 100644
--- a/src/test/erasure-code/ceph_erasure_code_benchmark.cc
+++ b/src/test/erasure-code/ceph_erasure_code_benchmark.cc
@@ -35,6 +35,15 @@
#include "erasure-code/ErasureCode.h"
#include "ceph_erasure_code_benchmark.h"
+using std::endl;
+using std::cerr;
+using std::cout;
+using std::map;
+using std::set;
+using std::string;
+using std::stringstream;
+using std::vector;
+
namespace po = boost::program_options;
int ErasureCodeBench::setup(int argc, char** argv) {
@@ -175,7 +184,7 @@ int ErasureCodeBench::encode()
}
utime_t begin_time = ceph_clock_now();
for (int i = 0; i < max_iterations; i++) {
- map<int,bufferlist> encoded;
+ std::map<int,bufferlist> encoded;
code = erasure_code->encode(want_to_encode, in, &encoded);
if (code)
return code;
diff --git a/src/test/erasure-code/ceph_erasure_code_benchmark.h b/src/test/erasure-code/ceph_erasure_code_benchmark.h
index c65f716b1e1..59149a74c16 100644
--- a/src/test/erasure-code/ceph_erasure_code_benchmark.h
+++ b/src/test/erasure-code/ceph_erasure_code_benchmark.h
@@ -19,8 +19,16 @@
#define CEPH_ERASURE_CODE_BENCHMARK_H
#include <string>
+#include <map>
+#include <vector>
-using namespace std;
+#include <boost/intrusive_ptr.hpp>
+
+#include "include/buffer.h"
+
+#include "common/ceph_context.h"
+
+#include "erasure-code/ErasureCodeInterface.h"
class ErasureCodeBench {
int in_size;
@@ -29,21 +37,21 @@ class ErasureCodeBench {
int k;
int m;
- string plugin;
+ std::string plugin;
bool exhaustive_erasures;
- vector<int> erased;
- string workload;
+ std::vector<int> erased;
+ std::string workload;
- ErasureCodeProfile profile;
+ ceph::ErasureCodeProfile profile;
bool verbose;
boost::intrusive_ptr<CephContext> cct;
public:
int setup(int argc, char** argv);
int run();
- int decode_erasures(const map<int,bufferlist> &all_chunks,
- const map<int,bufferlist> &chunks,
+ int decode_erasures(const std::map<int, ceph::buffer::list> &all_chunks,
+ const std::map<int, ceph::buffer::list> &chunks,
unsigned i,
unsigned want_erasures,
ErasureCodeInterfaceRef erasure_code);
diff --git a/src/test/kv_store_bench.h b/src/test/kv_store_bench.h
index 733594b70c5..689c769ce52 100644
--- a/src/test/kv_store_bench.h
+++ b/src/test/kv_store_bench.h
@@ -25,9 +25,6 @@
#include <cfloat>
#include <iostream>
-using namespace std;
-using ceph::bufferlist;
-
/**
* stores pairings from op type to time taken for that op (for latency), and to
* time that op completed to the nearest second (for throughput).
@@ -69,7 +66,7 @@ struct timed_args {
StopWatch sw;
//kv_bench_data data;
KvStoreBench * kvsb;
- bufferlist val;
+ ceph::buffer::list val;
int err;
char op;
@@ -86,7 +83,7 @@ struct timed_args {
{}
};
-typedef pair<string, bufferlist> (KvStoreBench::*next_gen_t)(bool new_elem);
+typedef std::pair<std::string, ceph::buffer::list> (KvStoreBench::*next_gen_t)(bool new_elem);
class KvStoreBench {
@@ -107,13 +104,13 @@ protected:
int cache_size; //number of index entries to store in cache
double cache_refresh; //cache_size / cache_refresh entries are read each time
//the index is read
- string client_name;
+ std::string client_name;
bool verbose;//if true, display debug output
//internal
- map<int, char> probs;//map of numbers from 1 to 100 to chars representing
+ std::map<int, char> probs;//map of numbers from 1 to 100 to chars representing
//operation types - used to generate random operations
- set<string> key_set;//set of keys already in the data set
+ std::set<std::string> key_set;//set of keys already in the data set
KeyValueStructure * kvs;
kv_bench_data data;//stores throughput and latency from completed tests
ceph::mutex data_lock = ceph::make_mutex("data lock");
@@ -123,8 +120,8 @@ protected:
ceph::make_mutex("KvStoreBench::ops_in_flight_lock");
//these are used for cleanup and setup purposes - they are NOT passed to kvs!
librados::Rados rados;
- string rados_id;
- string pool_name;
+ std::string rados_id;
+ std::string pool_name;
bool io_ctx_ready;
librados::IoCtx io_ctx;
@@ -153,7 +150,7 @@ public:
/**
* Returns a string of random characters of length len
*/
- string random_string(int len);
+ std::string random_string(int len);
/**
* Inserts entries random keys and values asynchronously.
@@ -164,20 +161,20 @@ public:
* calls test_random_insertions, then does ops randomly chosen operations
* asynchronously, with max_ops_in_flight operations at a time.
*/
- int test_teuthology_aio(next_gen_t distr, const map<int, char> &probs);
+ int test_teuthology_aio(next_gen_t distr, const std::map<int, char> &probs);
/**
* calls test_random_insertions, then does ops randomly chosen operations
* synchronously.
*/
- int test_teuthology_sync(next_gen_t distr, const map<int, char> &probs);
+ int test_teuthology_sync(next_gen_t distr, const std::map<int, char> &probs);
/**
* returns a key-value pair. If new_elem is true, the key is randomly
* generated. If it is false, the key is selected from the keys currently in
* the key set.
*/
- pair<string, bufferlist> rand_distr(bool new_elem);
+ std::pair<std::string, ceph::buffer::list> rand_distr(bool new_elem);
/**
* Called when aio operations complete. Updates data.
diff --git a/src/test/librados_test_stub/NeoradosTestStub.cc b/src/test/librados_test_stub/NeoradosTestStub.cc
index 882e80820c7..c46660c6cd1 100644
--- a/src/test/librados_test_stub/NeoradosTestStub.cc
+++ b/src/test/librados_test_stub/NeoradosTestStub.cc
@@ -22,12 +22,14 @@
#include <boost/system/system_error.hpp>
namespace bs = boost::system;
+using namespace std::literals;
using namespace std::placeholders;
namespace neorados {
namespace detail {
-struct Client {
+class Client {
+public:
ceph::mutex mutex = ceph::make_mutex("NeoradosTestStub::Client");
librados::TestRadosClient* test_rados_client;
diff --git a/src/test/osd/RadosModel.h b/src/test/osd/RadosModel.h
index a429476749d..7f4de6162fe 100644
--- a/src/test/osd/RadosModel.h
+++ b/src/test/osd/RadosModel.h
@@ -30,8 +30,6 @@
#ifndef RADOSMODEL_H
#define RADOSMODEL_H
-using namespace std;
-
class RadosTestContext;
class TestOpStat;
@@ -90,7 +88,7 @@ public:
}
void handle_error(uint64_t cookie, int err) override {
std::lock_guard l{lock};
- cout << "watch handle_error " << err << std::endl;
+ std::cout << "watch handle_error " << err << std::endl;
}
void start() {
std::lock_guard l{lock};
@@ -143,7 +141,7 @@ public:
{
return;
}
- virtual string getType() = 0;
+ virtual std::string getType() = 0;
virtual bool finished()
{
return true;
@@ -165,29 +163,29 @@ public:
ceph::mutex state_lock = ceph::make_mutex("Context Lock");
ceph::condition_variable wait_cond;
// snap => {oid => desc}
- map<int, map<string,ObjectDesc> > pool_obj_cont;
- set<string> oid_in_use;
- set<string> oid_not_in_use;
- set<string> oid_flushing;
- set<string> oid_not_flushing;
- set<string> oid_redirect_not_in_use;
- set<string> oid_redirect_in_use;
- set<string> oid_set_chunk_tgt_pool;
+ std::map<int, std::map<std::string,ObjectDesc> > pool_obj_cont;
+ std::set<std::string> oid_in_use;
+ std::set<std::string> oid_not_in_use;
+ std::set<std::string> oid_flushing;
+ std::set<std::string> oid_not_flushing;
+ std::set<std::string> oid_redirect_not_in_use;
+ std::set<std::string> oid_redirect_in_use;
+ std::set<std::string> oid_set_chunk_tgt_pool;
SharedPtrRegistry<int, int> snaps_in_use;
int current_snap;
- string pool_name;
+ std::string pool_name;
librados::IoCtx io_ctx;
librados::Rados rados;
int next_oid;
- string prefix;
+ std::string prefix;
int errors;
int max_in_flight;
int seq_num;
- map<int,uint64_t> snaps;
+ std::map<int,uint64_t> snaps;
uint64_t seq;
const char *rados_id;
bool initialized;
- map<string, TestWatchContext*> watches;
+ std::map<std::string, TestWatchContext*> watches;
const uint64_t max_size;
const uint64_t min_stride_size;
const uint64_t max_stride_size;
@@ -196,15 +194,15 @@ public:
const bool no_sparse;
bool pool_snaps;
bool write_fadvise_dontneed;
- string low_tier_pool_name;
+ std::string low_tier_pool_name;
librados::IoCtx low_tier_io_ctx;
int snapname_num;
- map<string,string > redirect_objs;
+ std::map<std::string, std::string> redirect_objs;
bool enable_dedup;
- string chunk_algo;
- string chunk_size;
+ std::string chunk_algo;
+ std::string chunk_size;
- RadosTestContext(const string &pool_name,
+ RadosTestContext(const std::string &pool_name,
int max_in_flight,
uint64_t max_size,
uint64_t min_stride_size,
@@ -213,10 +211,10 @@ public:
bool no_sparse,
bool pool_snaps,
bool write_fadvise_dontneed,
- const string &low_tier_pool_name,
+ const std::string &low_tier_pool_name,
bool enable_dedup,
- string chunk_algo,
- string chunk_size,
+ std::string chunk_algo,
+ std::string chunk_size,
const char *id = 0) :
pool_obj_cont(),
current_snap(0),
@@ -313,7 +311,7 @@ public:
char hostname_cstr[100];
gethostname(hostname_cstr, 100);
- stringstream hostpid;
+ std::stringstream hostpid;
hostpid << hostname_cstr << getpid() << "-";
prefix = hostpid.str();
ceph_assert(!initialized);
@@ -331,7 +329,7 @@ public:
void loop(TestOpGenerator *gen)
{
ceph_assert(initialized);
- list<TestOp*> inflight;
+ std::list<TestOp*> inflight;
std::unique_lock state_locker{state_lock};
TestOp *next = gen->next(*this);
@@ -351,19 +349,19 @@ public:
}
state_lock.lock();
while (1) {
- for (list<TestOp*>::iterator i = inflight.begin();
+ for (auto i = inflight.begin();
i != inflight.end();) {
if ((*i)->finished()) {
- cout << (*i)->num << ": done (" << (inflight.size()-1) << " left)" << std::endl;
+ std::cout << (*i)->num << ": done (" << (inflight.size()-1) << " left)" << std::endl;
delete *i;
inflight.erase(i++);
} else {
++i;
}
}
-
+
if (inflight.size() >= (unsigned) max_in_flight || (!next && !inflight.empty())) {
- cout << " waiting on " << inflight.size() << std::endl;
+ std::cout << " waiting on " << inflight.size() << std::endl;
wait_cond.wait(state_locker);
} else {
break;
@@ -383,28 +381,27 @@ public:
wait_cond.notify_all();
}
- TestWatchContext *get_watch_context(const string &oid) {
+ TestWatchContext *get_watch_context(const std::string &oid) {
return watches.count(oid) ? watches[oid] : 0;
}
- TestWatchContext *watch(const string &oid) {
+ TestWatchContext *watch(const std::string &oid) {
ceph_assert(!watches.count(oid));
return (watches[oid] = new TestWatchContext);
}
- void unwatch(const string &oid) {
+ void unwatch(const std::string &oid) {
ceph_assert(watches.count(oid));
delete watches[oid];
watches.erase(oid);
}
- ObjectDesc get_most_recent(const string &oid) {
+ ObjectDesc get_most_recent(const std::string &oid) {
ObjectDesc new_obj;
- for (map<int, map<string,ObjectDesc> >::reverse_iterator i =
- pool_obj_cont.rbegin();
+ for (auto i = pool_obj_cont.rbegin();
i != pool_obj_cont.rend();
++i) {
- map<string,ObjectDesc>::iterator j = i->second.find(oid);
+ std::map<std::string,ObjectDesc>::iterator j = i->second.find(oid);
if (j != i->second.end()) {
new_obj = j->second;
break;
@@ -413,10 +410,10 @@ public:
return new_obj;
}
- void rm_object_attrs(const string &oid, const set<string> &attrs)
+ void rm_object_attrs(const std::string &oid, const std::set<std::string> &attrs)
{
ObjectDesc new_obj = get_most_recent(oid);
- for (set<string>::const_iterator i = attrs.begin();
+ for (std::set<std::string>::const_iterator i = attrs.begin();
i != attrs.end();
++i) {
new_obj.attrs.erase(*i);
@@ -426,7 +423,7 @@ public:
pool_obj_cont[current_snap].insert_or_assign(oid, new_obj);
}
- void remove_object_header(const string &oid)
+ void remove_object_header(const std::string &oid)
{
ObjectDesc new_obj = get_most_recent(oid);
new_obj.header = bufferlist();
@@ -436,7 +433,7 @@ public:
}
- void update_object_header(const string &oid, const bufferlist &bl)
+ void update_object_header(const std::string &oid, const bufferlist &bl)
{
ObjectDesc new_obj = get_most_recent(oid);
new_obj.header = bl;
@@ -446,11 +443,11 @@ public:
pool_obj_cont[current_snap].insert_or_assign(oid, new_obj);
}
- void update_object_attrs(const string &oid, const map<string, ContDesc> &attrs)
+ void update_object_attrs(const std::string &oid, const std::map<std::string, ContDesc> &attrs)
{
ObjectDesc new_obj = get_most_recent(oid);
- for (map<string, ContDesc>::const_iterator i = attrs.begin();
- i != attrs.end();
+ for (auto i = attrs.cbegin();
+ i != attrs.cend();
++i) {
new_obj.attrs[i->first] = i->second;
}
@@ -461,7 +458,7 @@ public:
}
void update_object(ContentsGenerator *cont_gen,
- const string &oid, const ContDesc &contents)
+ const std::string &oid, const ContDesc &contents)
{
ObjectDesc new_obj = get_most_recent(oid);
new_obj.exists = true;
@@ -472,54 +469,52 @@ public:
pool_obj_cont[current_snap].insert_or_assign(oid, new_obj);
}
- void update_object_full(const string &oid, const ObjectDesc &contents)
+ void update_object_full(const std::string &oid, const ObjectDesc &contents)
{
pool_obj_cont[current_snap].insert_or_assign(oid, contents);
pool_obj_cont[current_snap][oid].dirty = true;
}
- void update_object_undirty(const string &oid)
+ void update_object_undirty(const std::string &oid)
{
ObjectDesc new_obj = get_most_recent(oid);
new_obj.dirty = false;
pool_obj_cont[current_snap].insert_or_assign(oid, new_obj);
}
- void update_object_version(const string &oid, uint64_t version,
+ void update_object_version(const std::string &oid, uint64_t version,
int snap = -1)
{
- for (map<int, map<string,ObjectDesc> >::reverse_iterator i =
- pool_obj_cont.rbegin();
+ for (auto i = pool_obj_cont.rbegin();
i != pool_obj_cont.rend();
++i) {
if (snap != -1 && snap < i->first)
continue;
- map<string,ObjectDesc>::iterator j = i->second.find(oid);
+ std::map<std::string,ObjectDesc>::iterator j = i->second.find(oid);
if (j != i->second.end()) {
if (version)
j->second.version = version;
- cout << __func__ << " oid " << oid
- << " v " << version << " " << j->second.most_recent()
- << " " << (j->second.dirty ? "dirty" : "clean")
- << " " << (j->second.exists ? "exists" : "dne")
- << std::endl;
+ std::cout << __func__ << " oid " << oid
+ << " v " << version << " " << j->second.most_recent()
+ << " " << (j->second.dirty ? "dirty" : "clean")
+ << " " << (j->second.exists ? "exists" : "dne")
+ << std::endl;
break;
}
}
}
- void remove_object(const string &oid)
+ void remove_object(const std::string &oid)
{
ceph_assert(!get_watch_context(oid));
ObjectDesc new_obj;
pool_obj_cont[current_snap].insert_or_assign(oid, new_obj);
}
- bool find_object(const string &oid, ObjectDesc *contents, int snap = -1) const
+ bool find_object(const std::string &oid, ObjectDesc *contents, int snap = -1) const
{
- for (map<int, map<string,ObjectDesc> >::const_reverse_iterator i =
- pool_obj_cont.rbegin();
- i != pool_obj_cont.rend();
+ for (auto i = pool_obj_cont.crbegin();
+ i != pool_obj_cont.crend();
++i) {
if (snap != -1 && snap < i->first) continue;
if (i->second.count(oid) != 0) {
@@ -530,16 +525,15 @@ public:
return false;
}
- void update_object_redirect_target(const string &oid, const string &target)
+ void update_object_redirect_target(const std::string &oid, const std::string &target)
{
redirect_objs[oid] = target;
}
- void update_object_chunk_target(const string &oid, uint64_t offset, const ChunkDesc &info)
+ void update_object_chunk_target(const std::string &oid, uint64_t offset, const ChunkDesc &info)
{
- for (map<int, map<string,ObjectDesc> >::const_reverse_iterator i =
- pool_obj_cont.rbegin();
- i != pool_obj_cont.rend();
+ for (auto i = pool_obj_cont.crbegin();
+ i != pool_obj_cont.crend();
++i) {
if (i->second.count(oid) != 0) {
ObjectDesc obj_desc = i->second.find(oid)->second;
@@ -551,7 +545,7 @@ public:
return;
}
- bool object_existed_at(const string &oid, int snap = -1) const
+ bool object_existed_at(const std::string &oid, int snap = -1) const
{
ObjectDesc contents;
bool found = find_object(oid, &contents, snap);
@@ -560,17 +554,15 @@ public:
void remove_snap(int snap)
{
- map<int, map<string,ObjectDesc> >::iterator next_iter = pool_obj_cont.find(snap);
+ std::map<int, std::map<std::string,ObjectDesc> >::iterator next_iter = pool_obj_cont.find(snap);
ceph_assert(next_iter != pool_obj_cont.end());
- map<int, map<string,ObjectDesc> >::iterator current_iter = next_iter++;
+ std::map<int, std::map<std::string,ObjectDesc> >::iterator current_iter = next_iter++;
ceph_assert(current_iter != pool_obj_cont.end());
- map<string,ObjectDesc> &current = current_iter->second;
- map<string,ObjectDesc> &next = next_iter->second;
- for (map<string,ObjectDesc>::iterator i = current.begin();
- i != current.end();
- ++i) {
+ std::map<std::string,ObjectDesc> &current = current_iter->second;
+ std::map<std::string,ObjectDesc> &next = next_iter->second;
+ for (auto i = current.begin(); i != current.end(); ++i) {
if (next.count(i->first) == 0) {
- next.insert(pair<string,ObjectDesc>(i->first, i->second));
+ next.insert(std::pair<std::string,ObjectDesc>(i->first, i->second));
}
}
pool_obj_cont.erase(current_iter);
@@ -585,7 +577,7 @@ public:
seq = snap;
}
- void roll_back(const string &oid, int snap)
+ void roll_back(const std::string &oid, int snap)
{
ceph_assert(!get_watch_context(oid));
ObjectDesc contents;
@@ -595,15 +587,14 @@ public:
pool_obj_cont.rbegin()->second.insert_or_assign(oid, contents);
}
- void update_object_tier_flushed(const string &oid, int snap)
+ void update_object_tier_flushed(const std::string &oid, int snap)
{
- for (map<int, map<string,ObjectDesc> >::reverse_iterator i =
- pool_obj_cont.rbegin();
+ for (auto i = pool_obj_cont.rbegin();
i != pool_obj_cont.rend();
++i) {
if (snap != -1 && snap < i->first)
continue;
- map<string,ObjectDesc>::iterator j = i->second.find(oid);
+ std::map<std::string,ObjectDesc>::iterator j = i->second.find(oid);
if (j != i->second.end()) {
j->second.flushed = true;
break;
@@ -611,20 +602,19 @@ public:
}
}
- bool check_oldest_snap_flushed(const string &oid, int snap)
+ bool check_oldest_snap_flushed(const std::string &oid, int snap)
{
- for (map<int, map<string,ObjectDesc> >::reverse_iterator i =
- pool_obj_cont.rbegin();
+ for (auto i = pool_obj_cont.rbegin();
i != pool_obj_cont.rend();
++i) {
if (snap != -1 && snap < i->first)
continue;
- map<string,ObjectDesc>::iterator j = i->second.find(oid);
+ std::map<std::string,ObjectDesc>::iterator j = i->second.find(oid);
if (j != i->second.end() && !j->second.flushed) {
- cout << __func__ << " oid " << oid
- << " v " << j->second.version << " " << j->second.most_recent()
- << " " << (j->second.flushed ? "flushed" : "unflushed")
- << " " << i->first << std::endl;
+ std::cout << __func__ << " oid " << oid
+ << " v " << j->second.version << " " << j->second.most_recent()
+ << " " << (j->second.flushed ? "flushed" : "unflushed")
+ << " " << i->first << std::endl;
return false;
}
}
@@ -654,7 +644,7 @@ public:
std::vector<librados::ObjectItem> result;
int r = chunk_pool_ctx.object_list(c, shard_end, 12, {}, &result, &c);
if (r < 0) {
- cerr << "error object_list : " << cpp_strerror(r) << std::endl;
+ std::cerr << "error object_list : " << cpp_strerror(r) << std::endl;
return false;
}
@@ -691,7 +681,7 @@ public:
break;
}
if (src_refcount > dst_refcount) {
- cerr << " src_object " << pp
+ std::cerr << " src_object " << pp
<< ": src_refcount " << src_refcount
<< ", dst_object " << oid
<< ": dst_refcount " << dst_refcount
@@ -712,11 +702,11 @@ void write_callback(librados::completion_t comp, void *arg);
/// entries if @c no_omap is not specified in context
class RemoveAttrsOp : public TestOp {
public:
- string oid;
+ std::string oid;
librados::ObjectWriteOperation op;
librados::AioCompletion *comp;
RemoveAttrsOp(int n, RadosTestContext *context,
- const string &oid,
+ const std::string &oid,
TestOpStat *stat)
: TestOp(n, context, stat), oid(oid), comp(NULL)
{}
@@ -724,7 +714,7 @@ public:
void _begin() override
{
ContDesc cont;
- set<string> to_remove;
+ std::set<std::string> to_remove;
{
std::lock_guard l{context->state_lock};
ObjectDesc obj;
@@ -740,7 +730,7 @@ public:
if (rand() % 30) {
ContentsGenerator::iterator iter = context->attr_gen.get_iterator(cont);
- for (map<string, ContDesc>::iterator i = obj.attrs.begin();
+ for (auto i = obj.attrs.begin();
i != obj.attrs.end();
++i, ++iter) {
if (!(*iter % 3)) {
@@ -762,7 +752,7 @@ public:
if (!context->no_omap) {
op.omap_clear();
}
- for (map<string, ContDesc>::iterator i = obj.attrs.begin();
+ for (auto i = obj.attrs.begin();
i != obj.attrs.end();
++i) {
op.rmxattr(i->first.c_str());
@@ -773,8 +763,8 @@ public:
context->rm_object_attrs(oid, to_remove);
}
- pair<TestOp*, TestOp::CallbackInfo*> *cb_arg =
- new pair<TestOp*, TestOp::CallbackInfo*>(this,
+ std::pair<TestOp*, TestOp::CallbackInfo*> *cb_arg =
+ new std::pair<TestOp*, TestOp::CallbackInfo*>(this,
new TestOp::CallbackInfo(0));
comp = context->rados.aio_create_completion((void*) cb_arg,
&write_callback);
@@ -796,7 +786,7 @@ public:
return done;
}
- string getType() override
+ std::string getType() override
{
return "RemoveAttrsOp";
}
@@ -806,12 +796,12 @@ public:
/// entries if @c no_omap is not specified in context
class SetAttrsOp : public TestOp {
public:
- string oid;
+ std::string oid;
librados::ObjectWriteOperation op;
librados::AioCompletion *comp;
SetAttrsOp(int n,
RadosTestContext *context,
- const string &oid,
+ const std::string &oid,
TestOpStat *stat)
: TestOp(n, context, stat),
oid(oid), comp(NULL)
@@ -828,8 +818,8 @@ public:
context->oid_not_in_use.erase(oid);
}
- map<string, bufferlist> omap_contents;
- map<string, ContDesc> omap;
+ std::map<std::string, bufferlist> omap_contents;
+ std::map<std::string, ContDesc> omap;
bufferlist header;
ContentsGenerator::iterator keygen = context->attr_gen.get_iterator(cont);
op.create(false);
@@ -840,7 +830,7 @@ public:
++keygen;
}
for (int i = 0; i < 20; ++i) {
- string key;
+ std::string key;
while (!*keygen) ++keygen;
while (*keygen && key.size() < 40) {
key.push_back((*keygen % 20) + 'a');
@@ -865,8 +855,8 @@ public:
context->update_object_attrs(oid, omap);
}
- pair<TestOp*, TestOp::CallbackInfo*> *cb_arg =
- new pair<TestOp*, TestOp::CallbackInfo*>(this,
+ std::pair<TestOp*, TestOp::CallbackInfo*> *cb_arg =
+ new std::pair<TestOp*, TestOp::CallbackInfo*>(this,
new TestOp::CallbackInfo(0));
comp = context->rados.aio_create_completion((void*) cb_arg, &write_callback);
context->io_ctx.aio_operate(context->prefix+oid, comp, &op);
@@ -877,7 +867,7 @@ public:
std::lock_guard l{context->state_lock};
int r;
if ((r = comp->get_return_value())) {
- cerr << "err " << r << std::endl;
+ std::cerr << "err " << r << std::endl;
ceph_abort();
}
done = true;
@@ -892,7 +882,7 @@ public:
return done;
}
- string getType() override
+ std::string getType() override
{
return "SetAttrsOp";
}
@@ -900,9 +890,9 @@ public:
class WriteOp : public TestOp {
public:
- const string oid;
+ const std::string oid;
ContDesc cont;
- set<librados::AioCompletion *> waiting;
+ std::set<librados::AioCompletion *> waiting;
librados::AioCompletion *rcompletion = nullptr;
// numbers of async ops submitted
uint64_t waiting_on = 0;
@@ -917,7 +907,7 @@ public:
WriteOp(int n,
RadosTestContext *context,
- const string &oid,
+ const std::string &oid,
bool do_append,
bool do_excl,
TestOpStat *stat = 0)
@@ -930,10 +920,10 @@ public:
void _begin() override
{
assert(!done);
- stringstream acc;
+ std::stringstream acc;
std::lock_guard state_locker{context->state_lock};
acc << context->prefix << "OID: " << oid << " snap " << context->current_snap << std::endl;
- string prefix = acc.str();
+ std::string prefix = acc.str();
cont = ContDesc(context->seq_num, context->current_snap, context->seq_num, prefix);
@@ -968,7 +958,7 @@ public:
context->oid_in_use.insert(oid);
context->oid_not_in_use.erase(oid);
- map<uint64_t, uint64_t> ranges;
+ std::map<uint64_t, uint64_t> ranges;
cont_gen->get_ranges_map(cont, ranges);
std::cout << num << ": seq_num " << context->seq_num << " ranges " << ranges << std::endl;
@@ -987,7 +977,7 @@ public:
<< " from " << offset
<< " to " << len + offset << " tid " << tid << std::endl;
auto cb_arg =
- new pair<TestOp*, TestOp::CallbackInfo*>(this,
+ new std::pair<TestOp*, TestOp::CallbackInfo*>(this,
new TestOp::CallbackInfo(tid++));
librados::AioCompletion *completion =
context->rados.aio_create_completion((void*) cb_arg, &write_callback);
@@ -1007,8 +997,8 @@ public:
bufferlist contbl;
encode(cont, contbl);
- pair<TestOp*, TestOp::CallbackInfo*> *cb_arg =
- new pair<TestOp*, TestOp::CallbackInfo*>(
+ std::pair<TestOp*, TestOp::CallbackInfo*> *cb_arg =
+ new std::pair<TestOp*, TestOp::CallbackInfo*>(
this,
new TestOp::CallbackInfo(tid++));
librados::AioCompletion *completion = context->rados.aio_create_completion(
@@ -1023,7 +1013,7 @@ public:
context->prefix+oid, completion, &write_op);
cb_arg =
- new pair<TestOp*, TestOp::CallbackInfo*>(
+ new std::pair<TestOp*, TestOp::CallbackInfo*>(
this,
new TestOp::CallbackInfo(tid++));
rcompletion = context->rados.aio_create_completion(
@@ -1043,10 +1033,10 @@ public:
std::lock_guard state_locker{context->state_lock};
uint64_t tid = info->id;
- cout << num << ": finishing write tid " << tid << " to " << context->prefix + oid << std::endl;
+ std::cout << num << ": finishing write tid " << tid << " to " << context->prefix + oid << std::endl;
if (tid <= last_acked_tid) {
- cerr << "Error: finished tid " << tid
+ std::cerr << "Error: finished tid " << tid
<< " when last_acked_tid was " << last_acked_tid << std::endl;
ceph_abort();
}
@@ -1056,25 +1046,23 @@ public:
waiting_on--;
if (waiting_on == 0) {
uint64_t version = 0;
- for (set<librados::AioCompletion *>::iterator i = waiting.begin();
- i != waiting.end();
- ) {
+ for (auto i = waiting.begin(); i != waiting.end();) {
ceph_assert((*i)->is_complete());
if (int err = (*i)->get_return_value()) {
- cerr << "Error: oid " << oid << " write returned error code "
- << err << std::endl;
+ std::cerr << "Error: oid " << oid << " write returned error code "
+ << err << std::endl;
}
if ((*i)->get_version64() > version)
version = (*i)->get_version64();
(*i)->release();
waiting.erase(i++);
}
-
+
context->update_object_version(oid, version);
if (rcompletion->get_version64() != version) {
- cerr << "Error: racing read on " << oid << " returned version "
- << rcompletion->get_version64() << " rather than version "
- << version << std::endl;
+ std::cerr << "Error: racing read on " << oid << " returned version "
+ << rcompletion->get_version64() << " rather than version "
+ << version << std::endl;
ceph_abort_msg("racing read got wrong version");
}
@@ -1101,7 +1089,7 @@ public:
return done;
}
- string getType() override
+ std::string getType() override
{
return "WriteOp";
}
@@ -1109,9 +1097,9 @@ public:
class WriteSameOp : public TestOp {
public:
- string oid;
+ std::string oid;
ContDesc cont;
- set<librados::AioCompletion *> waiting;
+ std::set<librados::AioCompletion *> waiting;
librados::AioCompletion *rcompletion;
uint64_t waiting_on;
uint64_t last_acked_tid;
@@ -1122,7 +1110,7 @@ public:
WriteSameOp(int n,
RadosTestContext *context,
- const string &oid,
+ const std::string &oid,
TestOpStat *stat = 0)
: TestOp(n, context, stat),
oid(oid), rcompletion(NULL), waiting_on(0),
@@ -1133,9 +1121,9 @@ public:
{
std::lock_guard state_locker{context->state_lock};
done = 0;
- stringstream acc;
+ std::stringstream acc;
acc << context->prefix << "OID: " << oid << " snap " << context->current_snap << std::endl;
- string prefix = acc.str();
+ std::string prefix = acc.str();
cont = ContDesc(context->seq_num, context->current_snap, context->seq_num, prefix);
@@ -1147,7 +1135,7 @@ public:
context->oid_in_use.insert(oid);
context->oid_not_in_use.erase(oid);
- map<uint64_t, uint64_t> ranges;
+ std::map<uint64_t, uint64_t> ranges;
cont_gen->get_ranges_map(cont, ranges);
std::cout << num << ": seq_num " << context->seq_num << " ranges " << ranges << std::endl;
@@ -1166,7 +1154,7 @@ public:
<< " from " << offset
<< " to " << offset + len << " tid " << tid << std::endl;
auto cb_arg =
- new pair<TestOp*, TestOp::CallbackInfo*>(this,
+ new std::pair<TestOp*, TestOp::CallbackInfo*>(this,
new TestOp::CallbackInfo(tid++));
librados::AioCompletion *completion =
context->rados.aio_create_completion((void*) cb_arg,
@@ -1183,8 +1171,8 @@ public:
bufferlist contbl;
encode(cont, contbl);
- pair<TestOp*, TestOp::CallbackInfo*> *cb_arg =
- new pair<TestOp*, TestOp::CallbackInfo*>(
+ std::pair<TestOp*, TestOp::CallbackInfo*> *cb_arg =
+ new std::pair<TestOp*, TestOp::CallbackInfo*>(
this,
new TestOp::CallbackInfo(tid++));
librados::AioCompletion *completion = context->rados.aio_create_completion(
@@ -1197,7 +1185,7 @@ public:
context->prefix+oid, completion, &write_op);
cb_arg =
- new pair<TestOp*, TestOp::CallbackInfo*>(
+ new std::pair<TestOp*, TestOp::CallbackInfo*>(
this,
new TestOp::CallbackInfo(tid++));
rcompletion = context->rados.aio_create_completion(
@@ -1217,10 +1205,10 @@ public:
std::lock_guard state_locker{context->state_lock};
uint64_t tid = info->id;
- cout << num << ": finishing writesame tid " << tid << " to " << context->prefix + oid << std::endl;
+ std::cout << num << ": finishing writesame tid " << tid << " to " << context->prefix + oid << std::endl;
if (tid <= last_acked_tid) {
- cerr << "Error: finished tid " << tid
+ std::cerr << "Error: finished tid " << tid
<< " when last_acked_tid was " << last_acked_tid << std::endl;
ceph_abort();
}
@@ -1230,12 +1218,10 @@ public:
waiting_on--;
if (waiting_on == 0) {
uint64_t version = 0;
- for (set<librados::AioCompletion *>::iterator i = waiting.begin();
- i != waiting.end();
- ) {
+ for (auto i = waiting.begin(); i != waiting.end();) {
ceph_assert((*i)->is_complete());
if (int err = (*i)->get_return_value()) {
- cerr << "Error: oid " << oid << " writesame returned error code "
+ std::cerr << "Error: oid " << oid << " writesame returned error code "
<< err << std::endl;
}
if ((*i)->get_version64() > version)
@@ -1248,9 +1234,9 @@ public:
ceph_assert(rcompletion->is_complete());
ceph_assert(rcompletion->get_return_value() == 1);
if (rcompletion->get_version64() != version) {
- cerr << "Error: racing read on " << oid << " returned version "
- << rcompletion->get_version64() << " rather than version "
- << version << std::endl;
+ std::cerr << "Error: racing read on " << oid << " returned version "
+ << rcompletion->get_version64() << " rather than version "
+ << version << std::endl;
ceph_abort_msg("racing read got wrong version");
}
rcompletion->release();
@@ -1277,7 +1263,7 @@ public:
return done;
}
- string getType() override
+ std::string getType() override
{
return "WriteSameOp";
}
@@ -1285,11 +1271,11 @@ public:
class DeleteOp : public TestOp {
public:
- string oid;
+ std::string oid;
DeleteOp(int n,
RadosTestContext *context,
- const string &oid,
+ const std::string &oid,
TestOpStat *stat = 0)
: TestOp(n, context, stat), oid(oid)
{}
@@ -1325,7 +1311,7 @@ public:
r = context->io_ctx.remove(context->prefix+oid);
}
if (r && !(r == -ENOENT && !present)) {
- cerr << "r is " << r << " while deleting " << oid << " and present is " << present << std::endl;
+ std::cerr << "r is " << r << " while deleting " << oid << " and present is " << present << std::endl;
ceph_abort();
}
@@ -1335,7 +1321,7 @@ public:
context->kick();
}
- string getType() override
+ std::string getType() override
{
return "DeleteOp";
}
@@ -1343,9 +1329,9 @@ public:
class ReadOp : public TestOp {
public:
- vector<librados::AioCompletion *> completions;
+ std::vector<librados::AioCompletion *> completions;
librados::ObjectReadOperation op;
- string oid;
+ std::string oid;
ObjectDesc old_value;
int snap;
bool balance_reads;
@@ -1353,28 +1339,28 @@ public:
std::shared_ptr<int> in_use;
- vector<bufferlist> results;
- vector<int> retvals;
- vector<std::map<uint64_t, uint64_t>> extent_results;
- vector<bool> is_sparse_read;
+ std::vector<bufferlist> results;
+ std::vector<int> retvals;
+ std::vector<std::map<uint64_t, uint64_t>> extent_results;
+ std::vector<bool> is_sparse_read;
uint64_t waiting_on;
- vector<bufferlist> checksums;
- vector<int> checksum_retvals;
+ std::vector<bufferlist> checksums;
+ std::vector<int> checksum_retvals;
- map<string, bufferlist> attrs;
+ std::map<std::string, bufferlist> attrs;
int attrretval;
- set<string> omap_requested_keys;
- map<string, bufferlist> omap_returned_values;
- set<string> omap_keys;
- map<string, bufferlist> omap;
+ std::set<std::string> omap_requested_keys;
+ std::map<std::string, bufferlist> omap_returned_values;
+ std::set<std::string> omap_keys;
+ std::map<std::string, bufferlist> omap;
bufferlist header;
- map<string, bufferlist> xattrs;
+ std::map<std::string, bufferlist> xattrs;
ReadOp(int n,
RadosTestContext *context,
- const string &oid,
+ const std::string &oid,
bool balance_reads,
bool localize_reads,
TestOpStat *stat = 0)
@@ -1464,11 +1450,9 @@ public:
context->io_ctx.snap_set_read(context->snaps[snap]);
}
_do_read(op, 0);
- for (map<string, ContDesc>::iterator i = old_value.attrs.begin();
- i != old_value.attrs.end();
- ++i) {
+ for (auto i = old_value.attrs.begin(); i != old_value.attrs.end(); ++i) {
if (rand() % 2) {
- string key = i->first;
+ std::string key = i->first;
if (rand() % 2)
key.push_back((rand() % 26) + 'a');
omap_requested_keys.insert(key);
@@ -1520,34 +1504,34 @@ public:
context->oid_in_use.erase(oid);
context->oid_not_in_use.insert(oid);
int retval = completions[0]->get_return_value();
- for (vector<librados::AioCompletion *>::iterator it = completions.begin();
+ for (auto it = completions.begin();
it != completions.end(); ++it) {
ceph_assert((*it)->is_complete());
uint64_t version = (*it)->get_version64();
int err = (*it)->get_return_value();
if (err != retval) {
- cerr << num << ": Error: oid " << oid << " read returned different error codes: "
+ std::cerr << num << ": Error: oid " << oid << " read returned different error codes: "
<< retval << " and " << err << std::endl;
ceph_abort();
}
if (err) {
if (!(err == -ENOENT && old_value.deleted())) {
- cerr << num << ": Error: oid " << oid << " read returned error code "
+ std::cerr << num << ": Error: oid " << oid << " read returned error code "
<< err << std::endl;
ceph_abort();
}
} else if (version != old_value.version) {
- cerr << num << ": oid " << oid << " version is " << version
- << " and expected " << old_value.version << std::endl;
+ std::cerr << num << ": oid " << oid << " version is " << version
+ << " and expected " << old_value.version << std::endl;
ceph_assert(version == old_value.version);
}
}
if (!retval) {
- map<string, bufferlist>::iterator iter = xattrs.find("_header");
+ std::map<std::string, bufferlist>::iterator iter = xattrs.find("_header");
bufferlist headerbl;
if (iter == xattrs.end()) {
if (old_value.has_contents()) {
- cerr << num << ": Error: did not find header attr, has_contents: "
+ std::cerr << num << ": Error: did not find header attr, has_contents: "
<< old_value.has_contents()
<< std::endl;
ceph_assert(!old_value.has_contents());
@@ -1567,19 +1551,19 @@ public:
auto p = headerbl.cbegin();
decode(to_check, p);
if (to_check != old_value.most_recent()) {
- cerr << num << ": oid " << oid << " found incorrect object contents " << to_check
+ std::cerr << num << ": oid " << oid << " found incorrect object contents " << to_check
<< ", expected " << old_value.most_recent() << std::endl;
context->errors++;
}
for (unsigned i = 0; i < results.size(); i++) {
if (is_sparse_read[i]) {
if (!old_value.check_sparse(extent_results[i], results[i])) {
- cerr << num << ": oid " << oid << " contents " << to_check << " corrupt" << std::endl;
+ std::cerr << num << ": oid " << oid << " contents " << to_check << " corrupt" << std::endl;
context->errors++;
}
} else {
if (!old_value.check(results[i])) {
- cerr << num << ": oid " << oid << " contents " << to_check << " corrupt" << std::endl;
+ std::cerr << num << ": oid " << oid << " contents " << to_check << " corrupt" << std::endl;
context->errors++;
}
@@ -1595,7 +1579,7 @@ public:
}
}
if (checksum_retvals[i] != 0 || checksum != results[i].crc32c(-1)) {
- cerr << num << ": oid " << oid << " checksum " << checksums[i]
+ std::cerr << num << ": oid " << oid << " checksum " << checksums[i]
<< " incorrect, expecting " << results[i].crc32c(-1)
<< std::endl;
context->errors++;
@@ -1608,34 +1592,34 @@ public:
// Attributes
if (!context->no_omap) {
if (!(old_value.header == header)) {
- cerr << num << ": oid " << oid << " header does not match, old size: "
+ std::cerr << num << ": oid " << oid << " header does not match, old size: "
<< old_value.header.length() << " new size " << header.length()
<< std::endl;
ceph_assert(old_value.header == header);
}
if (omap.size() != old_value.attrs.size()) {
- cerr << num << ": oid " << oid << " omap.size() is " << omap.size()
+ std::cerr << num << ": oid " << oid << " omap.size() is " << omap.size()
<< " and old is " << old_value.attrs.size() << std::endl;
ceph_assert(omap.size() == old_value.attrs.size());
}
if (omap_keys.size() != old_value.attrs.size()) {
- cerr << num << ": oid " << oid << " omap.size() is " << omap_keys.size()
+ std::cerr << num << ": oid " << oid << " omap.size() is " << omap_keys.size()
<< " and old is " << old_value.attrs.size() << std::endl;
ceph_assert(omap_keys.size() == old_value.attrs.size());
}
}
if (xattrs.size() != old_value.attrs.size()) {
- cerr << num << ": oid " << oid << " xattrs.size() is " << xattrs.size()
- << " and old is " << old_value.attrs.size() << std::endl;
+ std::cerr << num << ": oid " << oid << " xattrs.size() is " << xattrs.size()
+ << " and old is " << old_value.attrs.size() << std::endl;
ceph_assert(xattrs.size() == old_value.attrs.size());
}
- for (map<string, ContDesc>::iterator iter = old_value.attrs.begin();
+ for (auto iter = old_value.attrs.begin();
iter != old_value.attrs.end();
++iter) {
bufferlist bl = context->attr_gen.gen_bl(
iter->second);
if (!context->no_omap) {
- map<string, bufferlist>::iterator omap_iter = omap.find(iter->first);
+ std::map<std::string, bufferlist>::iterator omap_iter = omap.find(iter->first);
ceph_assert(omap_iter != omap.end());
ceph_assert(bl.length() == omap_iter->second.length());
bufferlist::iterator k = bl.begin();
@@ -1645,7 +1629,7 @@ public:
ceph_assert(*l == *k);
}
}
- map<string, bufferlist>::iterator xattr_iter = xattrs.find(iter->first);
+ auto xattr_iter = xattrs.find(iter->first);
ceph_assert(xattr_iter != xattrs.end());
ceph_assert(bl.length() == xattr_iter->second.length());
bufferlist::iterator k = bl.begin();
@@ -1656,7 +1640,7 @@ public:
}
}
if (!context->no_omap) {
- for (set<string>::iterator i = omap_requested_keys.begin();
+ for (std::set<std::string>::iterator i = omap_requested_keys.begin();
i != omap_requested_keys.end();
++i) {
if (!omap_returned_values.count(*i))
@@ -1664,7 +1648,7 @@ public:
if (!old_value.attrs.count(*i))
ceph_assert(!omap_returned_values.count(*i));
}
- for (map<string, bufferlist>::iterator i = omap_returned_values.begin();
+ for (auto i = omap_returned_values.begin();
i != omap_returned_values.end();
++i) {
ceph_assert(omap_requested_keys.count(i->first));
@@ -1674,8 +1658,7 @@ public:
}
}
}
- for (vector<librados::AioCompletion *>::iterator it = completions.begin();
- it != completions.end(); ++it) {
+ for (auto it = completions.begin(); it != completions.end(); ++it) {
(*it)->release();
}
context->kick();
@@ -1687,7 +1670,7 @@ public:
return done;
}
- string getType() override
+ std::string getType() override
{
return "ReadOp";
}
@@ -1704,17 +1687,17 @@ public:
void _begin() override
{
uint64_t snap;
- string snapname;
+ std::string snapname;
if (context->pool_snaps) {
- stringstream ss;
+ std::stringstream ss;
ss << context->prefix << "snap" << ++context->snapname_num;
snapname = ss.str();
int ret = context->io_ctx.snap_create(snapname.c_str());
if (ret) {
- cerr << "snap_create returned " << ret << std::endl;
+ std::cerr << "snap_create returned " << ret << std::endl;
ceph_abort();
}
ceph_assert(!context->io_ctx.snap_lookup(snapname.c_str(), &snap));
@@ -1727,10 +1710,10 @@ public:
context->add_snap(snap);
if (!context->pool_snaps) {
- vector<uint64_t> snapset(context->snaps.size());
+ std::vector<uint64_t> snapset(context->snaps.size());
int j = 0;
- for (map<int,uint64_t>::reverse_iterator i = context->snaps.rbegin();
+ for (auto i = context->snaps.rbegin();
i != context->snaps.rend();
++i, ++j) {
snapset[j] = i->second;
@@ -1740,13 +1723,13 @@ public:
int r = context->io_ctx.selfmanaged_snap_set_write_ctx(context->seq, snapset);
if (r) {
- cerr << "r is " << r << " snapset is " << snapset << " seq is " << context->seq << std::endl;
+ std::cerr << "r is " << r << " snapset is " << snapset << " seq is " << context->seq << std::endl;
ceph_abort();
}
}
}
- string getType() override
+ std::string getType() override
{
return "SnapCreateOp";
}
@@ -1770,16 +1753,16 @@ public:
context->remove_snap(to_remove);
if (context->pool_snaps) {
- string snapname;
+ std::string snapname;
ceph_assert(!context->io_ctx.snap_get_name(snap, &snapname));
ceph_assert(!context->io_ctx.snap_remove(snapname.c_str()));
} else {
ceph_assert(!context->io_ctx.selfmanaged_snap_remove(snap));
- vector<uint64_t> snapset(context->snaps.size());
+ std::vector<uint64_t> snapset(context->snaps.size());
int j = 0;
- for (map<int,uint64_t>::reverse_iterator i = context->snaps.rbegin();
+ for (auto i = context->snaps.rbegin();
i != context->snaps.rend();
++i, ++j) {
snapset[j] = i->second;
@@ -1787,24 +1770,24 @@ public:
int r = context->io_ctx.selfmanaged_snap_set_write_ctx(context->seq, snapset);
if (r) {
- cerr << "r is " << r << " snapset is " << snapset << " seq is " << context->seq << std::endl;
+ std::cerr << "r is " << r << " snapset is " << snapset << " seq is " << context->seq << std::endl;
ceph_abort();
}
}
}
- string getType() override
+ std::string getType() override
{
return "SnapRemoveOp";
}
};
class WatchOp : public TestOp {
- string oid;
+ std::string oid;
public:
WatchOp(int n,
RadosTestContext *context,
- const string &_oid,
+ const std::string &_oid,
TestOpStat *stat = 0)
: TestOp(n, context, stat),
oid(_oid)
@@ -1843,7 +1826,7 @@ public:
}
if (r) {
- cerr << "r is " << r << std::endl;
+ std::cerr << "r is " << r << std::endl;
ceph_abort();
}
@@ -1854,7 +1837,7 @@ public:
}
}
- string getType() override
+ std::string getType() override
{
return "WatchOp";
}
@@ -1862,19 +1845,19 @@ public:
class RollbackOp : public TestOp {
public:
- string oid;
+ std::string oid;
int roll_back_to;
librados::ObjectWriteOperation zero_write_op1;
librados::ObjectWriteOperation zero_write_op2;
librados::ObjectWriteOperation op;
- vector<librados::AioCompletion *> comps;
+ std::vector<librados::AioCompletion *> comps;
std::shared_ptr<int> in_use;
int last_finished;
int outstanding;
RollbackOp(int n,
RadosTestContext *context,
- const string &_oid,
+ const std::string &_oid,
TestOpStat *stat = 0)
: TestOp(n, context, stat),
oid(_oid), roll_back_to(-1),
@@ -1907,7 +1890,7 @@ public:
roll_back_to);
- cout << "rollback oid " << oid << " to " << roll_back_to << std::endl;
+ std::cout << "rollback oid " << oid << " to " << roll_back_to << std::endl;
bool existed_before = context->object_existed_at(oid);
bool existed_after = context->object_existed_at(oid, roll_back_to);
@@ -1930,8 +1913,8 @@ public:
}
if (existed_before) {
- pair<TestOp*, TestOp::CallbackInfo*> *cb_arg =
- new pair<TestOp*, TestOp::CallbackInfo*>(this,
+ std::pair<TestOp*, TestOp::CallbackInfo*> *cb_arg =
+ new std::pair<TestOp*, TestOp::CallbackInfo*>(this,
new TestOp::CallbackInfo(0));
comps[0] =
context->rados.aio_create_completion((void*) cb_arg,
@@ -1940,8 +1923,8 @@ public:
context->prefix+oid, comps[0], &zero_write_op1);
}
{
- pair<TestOp*, TestOp::CallbackInfo*> *cb_arg =
- new pair<TestOp*, TestOp::CallbackInfo*>(this,
+ std::pair<TestOp*, TestOp::CallbackInfo*> *cb_arg =
+ new std::pair<TestOp*, TestOp::CallbackInfo*>(this,
new TestOp::CallbackInfo(1));
comps[1] =
context->rados.aio_create_completion((void*) cb_arg,
@@ -1950,8 +1933,8 @@ public:
context->prefix+oid, comps[1], &op);
}
if (existed_after) {
- pair<TestOp*, TestOp::CallbackInfo*> *cb_arg =
- new pair<TestOp*, TestOp::CallbackInfo*>(this,
+ std::pair<TestOp*, TestOp::CallbackInfo*> *cb_arg =
+ new std::pair<TestOp*, TestOp::CallbackInfo*>(this,
new TestOp::CallbackInfo(2));
comps[2] =
context->rados.aio_create_completion((void*) cb_arg,
@@ -1965,14 +1948,14 @@ public:
{
std::lock_guard l{context->state_lock};
uint64_t tid = info->id;
- cout << num << ": finishing rollback tid " << tid
+ std::cout << num << ": finishing rollback tid " << tid
<< " to " << context->prefix + oid << std::endl;
ceph_assert((int)(info->id) > last_finished);
last_finished = info->id;
int r;
if ((r = comps[last_finished]->get_return_value()) != 0) {
- cerr << "err " << r << std::endl;
+ std::cerr << "err " << r << std::endl;
ceph_abort();
}
if (--outstanding == 0) {
@@ -1990,7 +1973,7 @@ public:
return done;
}
- string getType() override
+ std::string getType() override
{
return "RollBackOp";
}
@@ -1998,7 +1981,7 @@ public:
class CopyFromOp : public TestOp {
public:
- string oid, oid_src;
+ std::string oid, oid_src;
ObjectDesc src_value;
librados::ObjectWriteOperation op;
librados::ObjectReadOperation rd_op;
@@ -2011,8 +1994,8 @@ public:
int r;
CopyFromOp(int n,
RadosTestContext *context,
- const string &oid,
- const string &oid_src,
+ const std::string &oid,
+ const std::string &oid_src,
TestOpStat *stat)
: TestOp(n, context, stat),
oid(oid), oid_src(oid_src),
@@ -2044,19 +2027,19 @@ public:
context->update_object_full(oid, src_value);
}
- string src = context->prefix+oid_src;
+ std::string src = context->prefix+oid_src;
op.copy_from(src.c_str(), context->io_ctx, src_value.version, 0);
- pair<TestOp*, TestOp::CallbackInfo*> *cb_arg =
- new pair<TestOp*, TestOp::CallbackInfo*>(this,
+ std::pair<TestOp*, TestOp::CallbackInfo*> *cb_arg =
+ new std::pair<TestOp*, TestOp::CallbackInfo*>(this,
new TestOp::CallbackInfo(0));
comp = context->rados.aio_create_completion((void*) cb_arg,
&write_callback);
context->io_ctx.aio_operate(context->prefix+oid, comp, &op);
// queue up a racing read, too.
- pair<TestOp*, TestOp::CallbackInfo*> *read_cb_arg =
- new pair<TestOp*, TestOp::CallbackInfo*>(this,
+ std::pair<TestOp*, TestOp::CallbackInfo*> *read_cb_arg =
+ new std::pair<TestOp*, TestOp::CallbackInfo*>(this,
new TestOp::CallbackInfo(1));
comp_racing_read = context->rados.aio_create_completion((void*) read_cb_arg, &write_callback);
rd_op.stat(NULL, NULL, NULL);
@@ -2077,12 +2060,12 @@ public:
if (info->id == 0) {
// copy_from
ceph_assert(comp->is_complete());
- cout << num << ": finishing copy_from to " << context->prefix + oid << std::endl;
+ std::cout << num << ": finishing copy_from to " << context->prefix + oid << std::endl;
if ((r = comp->get_return_value())) {
if (r == -ENOENT && src_value.deleted()) {
- cout << num << ": got expected ENOENT (src dne)" << std::endl;
+ std::cout << num << ": got expected ENOENT (src dne)" << std::endl;
} else {
- cerr << "Error: oid " << oid << " copy_from " << oid_src << " returned error code "
+ std::cerr << "Error: oid " << oid << " copy_from " << oid_src << " returned error code "
<< r << std::endl;
ceph_abort();
}
@@ -2094,10 +2077,10 @@ public:
} else if (info->id == 1) {
// racing read
ceph_assert(comp_racing_read->is_complete());
- cout << num << ": finishing copy_from racing read to " << context->prefix + oid << std::endl;
+ std::cout << num << ": finishing copy_from racing read to " << context->prefix + oid << std::endl;
if ((r = comp_racing_read->get_return_value())) {
if (!(r == -ENOENT && src_value.deleted())) {
- cerr << "Error: oid " << oid << " copy_from " << oid_src << " returned error code "
+ std::cerr << "Error: oid " << oid << " copy_from " << oid_src << " returned error code "
<< r << std::endl;
}
} else {
@@ -2120,7 +2103,7 @@ public:
return done == 2;
}
- string getType() override
+ std::string getType() override
{
return "CopyFromOp";
}
@@ -2128,9 +2111,9 @@ public:
class ChunkReadOp : public TestOp {
public:
- vector<librados::AioCompletion *> completions;
+ std::vector<librados::AioCompletion *> completions;
librados::ObjectReadOperation op;
- string oid;
+ std::string oid;
ObjectDesc old_value;
ObjectDesc tgt_value;
int snap;
@@ -2139,23 +2122,23 @@ public:
std::shared_ptr<int> in_use;
- vector<bufferlist> results;
- vector<int> retvals;
- vector<bool> is_sparse_read;
+ std::vector<bufferlist> results;
+ std::vector<int> retvals;
+ std::vector<bool> is_sparse_read;
uint64_t waiting_on;
- vector<bufferlist> checksums;
- vector<int> checksum_retvals;
+ std::vector<bufferlist> checksums;
+ std::vector<int> checksum_retvals;
uint32_t offset = 0;
uint32_t length = 0;
- string tgt_oid;
- string tgt_pool_name;
+ std::string tgt_oid;
+ std::string tgt_pool_name;
uint32_t tgt_offset = 0;
ChunkReadOp(int n,
RadosTestContext *context,
- const string &oid,
- const string &tgt_pool_name,
+ const std::string &oid,
+ const std::string &tgt_pool_name,
bool balance_reads,
bool localize_reads,
TestOpStat *stat = 0)
@@ -2292,13 +2275,13 @@ public:
ceph_assert(completions[i]->is_complete());
int err = completions[i]->get_return_value();
if (err != retval) {
- cerr << num << ": Error: oid " << oid << " read returned different error codes: "
+ std::cerr << num << ": Error: oid " << oid << " read returned different error codes: "
<< retval << " and " << err << std::endl;
ceph_abort();
}
if (err) {
if (!(err == -ENOENT && old_value.deleted())) {
- cerr << num << ": Error: oid " << oid << " read returned error code "
+ std::cerr << num << ": Error: oid " << oid << " read returned error code "
<< err << std::endl;
ceph_abort();
}
@@ -2326,7 +2309,7 @@ public:
}
if (checksum_retvals[1] != 0) {
- cerr << num << ": oid " << oid << " checksum retvals " << checksums[0]
+ std::cerr << num << ": oid " << oid << " checksum retvals " << checksums[0]
<< " error " << std::endl;
context->errors++;
}
@@ -2334,7 +2317,7 @@ public:
checksum[0] = results[0].crc32c(-1);
if (checksum[0] != checksum[1]) {
- cerr << num << ": oid " << oid << " checksum src " << checksum[0]
+ std::cerr << num << ": oid " << oid << " checksum src " << checksum[0]
<< " chunksum tgt " << checksum[1] << " incorrect, expecting "
<< results[0].crc32c(-1)
<< std::endl;
@@ -2343,8 +2326,7 @@ public:
if (context->errors) ceph_abort();
}
}
- for (vector<librados::AioCompletion *>::iterator it = completions.begin();
- it != completions.end(); ++it) {
+ for (auto it = completions.begin(); it != completions.end(); ++it) {
(*it)->release();
}
context->kick();
@@ -2356,7 +2338,7 @@ public:
return done;
}
- string getType() override
+ std::string getType() override
{
return "ChunkReadOp";
}
@@ -2364,7 +2346,7 @@ public:
class CopyOp : public TestOp {
public:
- string oid, oid_src, tgt_pool_name;
+ std::string oid, oid_src, tgt_pool_name;
librados::ObjectWriteOperation op;
librados::ObjectReadOperation rd_op;
librados::AioCompletion *comp;
@@ -2373,9 +2355,9 @@ public:
int r;
CopyOp(int n,
RadosTestContext *context,
- const string &oid_src,
- const string &oid,
- const string &tgt_pool_name,
+ const std::string &oid_src,
+ const std::string &oid,
+ const std::string &tgt_pool_name,
TestOpStat *stat = 0)
: TestOp(n, context, stat),
oid(oid), oid_src(oid_src), tgt_pool_name(tgt_pool_name),
@@ -2388,14 +2370,14 @@ public:
context->oid_in_use.insert(oid_src);
context->oid_not_in_use.erase(oid_src);
- string src = context->prefix+oid_src;
+ std::string src = context->prefix+oid_src;
context->find_object(oid_src, &src_value);
op.copy_from(src.c_str(), context->io_ctx, src_value.version, 0);
- cout << "copy op oid " << oid_src << " to " << oid << " tgt_pool_name " << tgt_pool_name << std::endl;
+ std::cout << "copy op oid " << oid_src << " to " << oid << " tgt_pool_name " << tgt_pool_name << std::endl;
- pair<TestOp*, TestOp::CallbackInfo*> *cb_arg =
- new pair<TestOp*, TestOp::CallbackInfo*>(this,
+ std::pair<TestOp*, TestOp::CallbackInfo*> *cb_arg =
+ new std::pair<TestOp*, TestOp::CallbackInfo*>(this,
new TestOp::CallbackInfo(0));
comp = context->rados.aio_create_completion((void*) cb_arg, &write_callback);
if (tgt_pool_name == context->low_tier_pool_name) {
@@ -2411,10 +2393,10 @@ public:
if (info->id == 0) {
ceph_assert(comp->is_complete());
- cout << num << ": finishing copy op to oid " << oid << std::endl;
+ std::cout << num << ": finishing copy op to oid " << oid << std::endl;
if ((r = comp->get_return_value())) {
- cerr << "Error: oid " << oid << " write returned error code "
- << r << std::endl;
+ std::cerr << "Error: oid " << oid << " write returned error code "
+ << r << std::endl;
ceph_abort();
}
}
@@ -2431,7 +2413,7 @@ public:
return done == 1;
}
- string getType() override
+ std::string getType() override
{
return "CopyOp";
}
@@ -2439,7 +2421,7 @@ public:
class SetChunkOp : public TestOp {
public:
- string oid, oid_tgt;
+ std::string oid, oid_tgt;
ObjectDesc src_value, tgt_value;
librados::ObjectReadOperation op;
librados::AioCompletion *comp;
@@ -2452,8 +2434,8 @@ public:
std::shared_ptr<int> in_use;
SetChunkOp(int n,
RadosTestContext *context,
- const string &oid,
- const string &oid_tgt,
+ const std::string &oid,
+ const std::string &oid_tgt,
TestOpStat *stat = 0)
: TestOp(n, context, stat),
oid(oid), oid_tgt(oid_tgt),
@@ -2463,8 +2445,8 @@ public:
snap(0)
{}
- pair<uint64_t, uint64_t> get_rand_off_len(uint32_t max_len) {
- pair<uint64_t, uint64_t> r (0, 0);
+ std::pair<uint64_t, uint64_t> get_rand_off_len(uint32_t max_len) {
+ std::pair<uint64_t, uint64_t> r (0, 0);
r.first = rand() % max_len;
r.second = rand() % max_len;
r.first = r.first - (r.first % 512);
@@ -2501,7 +2483,7 @@ public:
} else {
max_len = src_value.most_recent_gen()->get_length(src_value.most_recent());
}
- pair<uint64_t, uint64_t> off_len; // first: offset, second: length
+ std::pair<uint64_t, uint64_t> off_len; // first: offset, second: length
if (snap >= 0) {
context->io_ctx.snap_set_read(context->snaps[snap]);
off_len = get_rand_off_len(max_len);
@@ -2516,12 +2498,12 @@ public:
length = off_len.second;
tgt_offset = offset;
- string target_oid;
+ std::string target_oid;
if (!src_value.deleted() && oid_tgt.empty()) {
bufferlist bl;
int r = context->io_ctx.read(context->prefix+oid, bl, length, offset);
ceph_assert(r > 0);
- string fp_oid = ceph::crypto::digest<ceph::crypto::SHA256>(bl).to_str();
+ std::string fp_oid = ceph::crypto::digest<ceph::crypto::SHA256>(bl).to_str();
r = context->low_tier_io_ctx.write(fp_oid, bl, bl.length(), 0);
ceph_assert(r == 0);
target_oid = fp_oid;
@@ -2530,15 +2512,15 @@ public:
target_oid = context->prefix+oid_tgt;
}
- cout << num << ": " << "set_chunk oid " << oid << " offset: " << offset
+ std::cout << num << ": " << "set_chunk oid " << oid << " offset: " << offset
<< " length: " << length << " target oid " << target_oid
<< " offset: " << tgt_offset << " snap " << snap << std::endl;
op.set_chunk(offset, length, context->low_tier_io_ctx,
target_oid, tgt_offset, CEPH_OSD_OP_FLAG_WITH_REFERENCE);
- pair<TestOp*, TestOp::CallbackInfo*> *cb_arg =
- new pair<TestOp*, TestOp::CallbackInfo*>(this,
+ std::pair<TestOp*, TestOp::CallbackInfo*> *cb_arg =
+ new std::pair<TestOp*, TestOp::CallbackInfo*>(this,
new TestOp::CallbackInfo(0));
comp = context->rados.aio_create_completion((void*) cb_arg,
&write_callback);
@@ -2555,21 +2537,21 @@ public:
if (info->id == 0) {
ceph_assert(comp->is_complete());
- cout << num << ": finishing set_chunk to oid " << oid << std::endl;
+ std::cout << num << ": finishing set_chunk to oid " << oid << std::endl;
if ((r = comp->get_return_value())) {
if (r == -ENOENT && src_value.deleted()) {
- cout << num << ": got expected ENOENT (src dne)" << std::endl;
+ std::cout << num << ": got expected ENOENT (src dne)" << std::endl;
} else if (r == -ENOENT && context->oid_set_chunk_tgt_pool.find(oid_tgt) !=
context->oid_set_chunk_tgt_pool.end()) {
- cout << num << ": get expected ENOENT tgt oid " << oid_tgt << std::endl;
+ std::cout << num << ": get expected ENOENT tgt oid " << oid_tgt << std::endl;
} else if (r == -ERANGE && src_value.deleted()) {
- cout << num << ": got expected ERANGE (src dne)" << std::endl;
+ std::cout << num << ": got expected ERANGE (src dne)" << std::endl;
} else if (r == -EOPNOTSUPP) {
- cout << "Range is overlapped: oid " << oid << " set_chunk " << oid_tgt << " returned error code "
+ std::cout << "Range is overlapped: oid " << oid << " set_chunk " << oid_tgt << " returned error code "
<< r << " offset: " << offset << " length: " << length << std::endl;
context->update_object_version(oid, comp->get_version64());
} else {
- cerr << "Error: oid " << oid << " set_chunk " << oid_tgt << " returned error code "
+ std::cerr << "Error: oid " << oid << " set_chunk " << oid_tgt << " returned error code "
<< r << std::endl;
ceph_abort();
}
@@ -2595,7 +2577,7 @@ public:
return done == 1;
}
- string getType() override
+ std::string getType() override
{
return "SetChunkOp";
}
@@ -2603,7 +2585,7 @@ public:
class SetRedirectOp : public TestOp {
public:
- string oid, oid_tgt, tgt_pool_name;
+ std::string oid, oid_tgt, tgt_pool_name;
ObjectDesc src_value, tgt_value;
librados::ObjectWriteOperation op;
librados::ObjectReadOperation rd_op;
@@ -2613,9 +2595,9 @@ public:
int r;
SetRedirectOp(int n,
RadosTestContext *context,
- const string &oid,
- const string &oid_tgt,
- const string &tgt_pool_name,
+ const std::string &oid,
+ const std::string &oid_tgt,
+ const std::string &tgt_pool_name,
TestOpStat *stat = 0)
: TestOp(n, context, stat),
oid(oid), oid_tgt(oid_tgt), tgt_pool_name(tgt_pool_name),
@@ -2637,14 +2619,14 @@ public:
if(!context->redirect_objs[oid].empty()) {
/* copy_from oid --> oid_tgt */
comp = context->rados.aio_create_completion();
- string src = context->prefix+oid;
+ std::string src = context->prefix+oid;
op.copy_from(src.c_str(), context->io_ctx, src_value.version, 0);
context->low_tier_io_ctx.aio_operate(context->prefix+oid_tgt, comp, &op,
librados::OPERATION_ORDER_READS_WRITES);
comp->wait_for_complete();
if ((r = comp->get_return_value())) {
- cerr << "Error: oid " << oid << " copy_from " << oid_tgt << " returned error code "
- << r << std::endl;
+ std::cerr << "Error: oid " << oid << " copy_from " << oid_tgt << " returned error code "
+ << r << std::endl;
ceph_abort();
}
comp->release();
@@ -2659,7 +2641,7 @@ public:
comp->wait_for_complete();
if ((r = comp->get_return_value())) {
if (!(r == -ENOENT && !present) && r != -EOPNOTSUPP) {
- cerr << "r is " << r << " while deleting " << oid << " and present is " << present << std::endl;
+ std::cerr << "r is " << r << " while deleting " << oid << " and present is " << present << std::endl;
ceph_abort();
}
}
@@ -2677,7 +2659,7 @@ public:
NULL);
comp->wait_for_complete();
if ((r = comp->get_return_value()) && !src_value.deleted()) {
- cerr << "Error: oid " << oid << " stat returned error code "
+ std::cerr << "Error: oid " << oid << " stat returned error code "
<< r << std::endl;
ceph_abort();
}
@@ -2692,7 +2674,7 @@ public:
NULL);
comp->wait_for_complete();
if ((r = comp->get_return_value())) {
- cerr << "Error: oid " << oid_tgt << " stat returned error code "
+ std::cerr << "Error: oid " << oid_tgt << " stat returned error code "
<< r << std::endl;
ceph_abort();
}
@@ -2706,8 +2688,8 @@ public:
op.assert_version(src_value.version);
op.set_redirect(context->prefix+oid_tgt, context->low_tier_io_ctx, tgt_version);
- pair<TestOp*, TestOp::CallbackInfo*> *cb_arg =
- new pair<TestOp*, TestOp::CallbackInfo*>(this,
+ std::pair<TestOp*, TestOp::CallbackInfo*> *cb_arg =
+ new std::pair<TestOp*, TestOp::CallbackInfo*>(this,
new TestOp::CallbackInfo(0));
comp = context->rados.aio_create_completion((void*) cb_arg, &write_callback);
context->io_ctx.aio_operate(context->prefix+oid, comp, &op,
@@ -2720,12 +2702,12 @@ public:
if (info->id == 0) {
ceph_assert(comp->is_complete());
- cout << num << ": finishing set_redirect to oid " << oid << std::endl;
+ std::cout << num << ": finishing set_redirect to oid " << oid << std::endl;
if ((r = comp->get_return_value())) {
if (r == -ENOENT && src_value.deleted()) {
- cout << num << ": got expected ENOENT (src dne)" << std::endl;
+ std::cout << num << ": got expected ENOENT (src dne)" << std::endl;
} else {
- cerr << "Error: oid " << oid << " set_redirect " << oid_tgt << " returned error code "
+ std::cerr << "Error: oid " << oid << " set_redirect " << oid_tgt << " returned error code "
<< r << std::endl;
ceph_abort();
}
@@ -2747,7 +2729,7 @@ public:
return done == 1;
}
- string getType() override
+ std::string getType() override
{
return "SetRedirectOp";
}
@@ -2755,13 +2737,13 @@ public:
class UnsetRedirectOp : public TestOp {
public:
- string oid;
+ std::string oid;
librados::ObjectWriteOperation op;
librados::AioCompletion *comp = nullptr;
UnsetRedirectOp(int n,
RadosTestContext *context,
- const string &oid,
+ const std::string &oid,
TestOpStat *stat = 0)
: TestOp(n, context, stat), oid(oid)
{}
@@ -2794,7 +2776,7 @@ public:
comp->wait_for_complete();
int r = comp->get_return_value();
if (r && !(r == -ENOENT && !present)) {
- cerr << "r is " << r << " while deleting " << oid << " and present is " << present << std::endl;
+ std::cerr << "r is " << r << " while deleting " << oid << " and present is " << present << std::endl;
ceph_abort();
}
state_locker.lock();
@@ -2803,12 +2785,12 @@ public:
if(!context->redirect_objs[oid].empty()) {
context->oid_redirect_not_in_use.insert(context->redirect_objs[oid]);
context->oid_redirect_in_use.erase(context->redirect_objs[oid]);
- context->update_object_redirect_target(oid, string());
+ context->update_object_redirect_target(oid, {});
}
context->kick();
}
- string getType() override
+ std::string getType() override
{
return "UnsetRedirectOp";
}
@@ -2818,13 +2800,13 @@ class TierPromoteOp : public TestOp {
public:
librados::AioCompletion *completion;
librados::ObjectWriteOperation op;
- string oid;
+ std::string oid;
std::shared_ptr<int> in_use;
ObjectDesc src_value;
TierPromoteOp(int n,
RadosTestContext *context,
- const string &oid,
+ const std::string &oid,
TestOpStat *stat)
: TestOp(n, context, stat),
completion(NULL),
@@ -2840,8 +2822,8 @@ public:
context->find_object(oid, &src_value);
- pair<TestOp*, TestOp::CallbackInfo*> *cb_arg =
- new pair<TestOp*, TestOp::CallbackInfo*>(this,
+ std::pair<TestOp*, TestOp::CallbackInfo*> *cb_arg =
+ new std::pair<TestOp*, TestOp::CallbackInfo*>(this,
new TestOp::CallbackInfo(0));
completion = context->rados.aio_create_completion((void *) cb_arg,
&write_callback);
@@ -2862,11 +2844,11 @@ public:
ObjectDesc oid_value;
context->find_object(oid, &oid_value);
int r = completion->get_return_value();
- cout << num << ": got " << cpp_strerror(r) << std::endl;
+ std::cout << num << ": got " << cpp_strerror(r) << std::endl;
if (r == 0) {
// sucess
} else if (r == -ENOENT && src_value.deleted()) {
- cout << num << ": got expected ENOENT (src dne)" << std::endl;
+ std::cout << num << ": got expected ENOENT (src dne)" << std::endl;
} else {
ceph_abort_msg("shouldn't happen");
}
@@ -2883,7 +2865,7 @@ public:
return done;
}
- string getType() override
+ std::string getType() override
{
return "TierPromoteOp";
}
@@ -2893,7 +2875,7 @@ class TierFlushOp : public TestOp {
public:
librados::AioCompletion *completion;
librados::ObjectReadOperation op;
- string oid;
+ std::string oid;
std::shared_ptr<int> in_use;
int snap;
ObjectDesc src_value;
@@ -2901,7 +2883,7 @@ public:
TierFlushOp(int n,
RadosTestContext *context,
- const string &oid,
+ const std::string &oid,
TestOpStat *stat)
: TestOp(n, context, stat),
completion(NULL),
@@ -2923,7 +2905,7 @@ public:
snap = -1;
}
- cout << num << ": tier_flush oid " << oid << " snap " << snap << std::endl;
+ std::cout << num << ": tier_flush oid " << oid << " snap " << snap << std::endl;
if (snap >= 0) {
context->io_ctx.snap_set_read(context->snaps[snap]);
@@ -2931,8 +2913,8 @@ public:
context->find_object(oid, &src_value, snap);
- pair<TestOp*, TestOp::CallbackInfo*> *cb_arg =
- new pair<TestOp*, TestOp::CallbackInfo*>(this,
+ std::pair<TestOp*, TestOp::CallbackInfo*> *cb_arg =
+ new std::pair<TestOp*, TestOp::CallbackInfo*>(this,
new TestOp::CallbackInfo(0));
completion = context->rados.aio_create_completion((void *) cb_arg,
&write_callback);
@@ -2956,7 +2938,7 @@ public:
ceph_assert(completion->is_complete());
int r = completion->get_return_value();
- cout << num << ": got " << cpp_strerror(r) << std::endl;
+ std::cout << num << ": got " << cpp_strerror(r) << std::endl;
if (r == 0) {
// sucess
context->update_object_tier_flushed(oid, snap);
@@ -2967,15 +2949,15 @@ public:
} else if (r == -ENOENT) {
// could fail if object is removed
if (src_value.deleted()) {
- cout << num << ": got expected ENOENT (src dne)" << std::endl;
+ std::cout << num << ": got expected ENOENT (src dne)" << std::endl;
} else {
- cerr << num << ": got unexpected ENOENT" << std::endl;
+ std::cerr << num << ": got unexpected ENOENT" << std::endl;
ceph_abort();
}
} else {
if (r != -ENOENT && src_value.deleted()) {
- cerr << num << ": src dne, but r is not ENOENT" << std::endl;
- }
+ std::cerr << num << ": src dne, but r is not ENOENT" << std::endl;
+ }
ceph_abort_msg("shouldn't happen");
}
context->oid_in_use.erase(oid);
@@ -2990,7 +2972,7 @@ public:
return done;
}
- string getType() override
+ std::string getType() override
{
return "TierFlushOp";
}
@@ -3000,14 +2982,14 @@ class TierEvictOp : public TestOp {
public:
librados::AioCompletion *completion;
librados::ObjectReadOperation op;
- string oid;
+ std::string oid;
std::shared_ptr<int> in_use;
int snap;
ObjectDesc src_value;
TierEvictOp(int n,
RadosTestContext *context,
- const string &oid,
+ const std::string &oid,
TestOpStat *stat)
: TestOp(n, context, stat),
completion(NULL),
@@ -3029,7 +3011,7 @@ public:
snap = -1;
}
- cout << num << ": tier_evict oid " << oid << " snap " << snap << std::endl;
+ std::cout << num << ": tier_evict oid " << oid << " snap " << snap << std::endl;
if (snap >= 0) {
context->io_ctx.snap_set_read(context->snaps[snap]);
@@ -3037,8 +3019,8 @@ public:
context->find_object(oid, &src_value, snap);
- pair<TestOp*, TestOp::CallbackInfo*> *cb_arg =
- new pair<TestOp*, TestOp::CallbackInfo*>(this,
+ std::pair<TestOp*, TestOp::CallbackInfo*> *cb_arg =
+ new std::pair<TestOp*, TestOp::CallbackInfo*>(this,
new TestOp::CallbackInfo(0));
completion = context->rados.aio_create_completion((void *) cb_arg,
&write_callback);
@@ -3062,7 +3044,7 @@ public:
ceph_assert(completion->is_complete());
int r = completion->get_return_value();
- cout << num << ": got " << cpp_strerror(r) << std::endl;
+ std::cout << num << ": got " << cpp_strerror(r) << std::endl;
if (r == 0) {
// ok
} else if (r == -EINVAL) {
@@ -3072,15 +3054,15 @@ public:
} else if (r == -ENOENT) {
// could fail if object is removed
if (src_value.deleted()) {
- cout << num << ": got expected ENOENT (src dne)" << std::endl;
+ std::cout << num << ": got expected ENOENT (src dne)" << std::endl;
} else {
- cerr << num << ": got unexpected ENOENT" << std::endl;
+ std::cerr << num << ": got unexpected ENOENT" << std::endl;
ceph_abort();
}
} else {
if (r != -ENOENT && src_value.deleted()) {
- cerr << num << ": src dne, but r is not ENOENT" << std::endl;
- }
+ std::cerr << num << ": src dne, but r is not ENOENT" << std::endl;
+ }
ceph_abort_msg("shouldn't happen");
}
context->oid_in_use.erase(oid);
@@ -3094,7 +3076,7 @@ public:
return done;
}
- string getType() override
+ std::string getType() override
{
return "TierEvictOp";
}
@@ -3118,8 +3100,8 @@ public:
void _begin() override
{
- pair<TestOp*, TestOp::CallbackInfo*> *cb_arg =
- new pair<TestOp*, TestOp::CallbackInfo*>(this,
+ std::pair<TestOp*, TestOp::CallbackInfo*> *cb_arg =
+ new std::pair<TestOp*, TestOp::CallbackInfo*>(this,
new TestOp::CallbackInfo(0));
comp1 = context->rados.aio_create_completion((void*) cb_arg,
&write_callback);
@@ -3131,17 +3113,16 @@ public:
std::lock_guard l{context->state_lock};
if (!comp2) {
if (ls.empty()) {
- cerr << num << ": no hitsets" << std::endl;
+ std::cerr << num << ": no hitsets" << std::endl;
done = true;
} else {
- cerr << num << ": hitsets are " << ls << std::endl;
+ std::cerr << num << ": hitsets are " << ls << std::endl;
int r = rand() % ls.size();
- std::list<pair<time_t,time_t> >::iterator p = ls.begin();
+ auto p = ls.begin();
while (r--)
++p;
- pair<TestOp*, TestOp::CallbackInfo*> *cb_arg =
- new pair<TestOp*, TestOp::CallbackInfo*>(this,
- new TestOp::CallbackInfo(0));
+ auto cb_arg = new std::pair<TestOp*, TestOp::CallbackInfo*>(
+ this, new TestOp::CallbackInfo(0));
comp2 = context->rados.aio_create_completion((void*) cb_arg, &write_callback);
r = context->io_ctx.hit_set_get(hash, comp2, p->second, &bl);
ceph_assert(r == 0);
@@ -3152,9 +3133,9 @@ public:
HitSet hitset;
auto p = bl.cbegin();
decode(hitset, p);
- cout << num << ": got hitset of type " << hitset.get_type_name()
- << " size " << bl.length()
- << std::endl;
+ std::cout << num << ": got hitset of type " << hitset.get_type_name()
+ << " size " << bl.length()
+ << std::endl;
} else {
// FIXME: we could verify that we did in fact race with a trim...
ceph_assert(r == -ENOENT);
@@ -3169,7 +3150,7 @@ public:
return done;
}
- string getType() override {
+ std::string getType() override {
return "HitSetListOp";
}
};
@@ -3178,11 +3159,11 @@ class UndirtyOp : public TestOp {
public:
librados::AioCompletion *completion;
librados::ObjectWriteOperation op;
- string oid;
+ std::string oid;
UndirtyOp(int n,
RadosTestContext *context,
- const string &oid,
+ const std::string &oid,
TestOpStat *stat = 0)
: TestOp(n, context, stat),
completion(NULL),
@@ -3192,8 +3173,8 @@ public:
void _begin() override
{
context->state_lock.lock();
- pair<TestOp*, TestOp::CallbackInfo*> *cb_arg =
- new pair<TestOp*, TestOp::CallbackInfo*>(this,
+ std::pair<TestOp*, TestOp::CallbackInfo*> *cb_arg =
+ new std::pair<TestOp*, TestOp::CallbackInfo*>(this,
new TestOp::CallbackInfo(0));
completion = context->rados.aio_create_completion((void *) cb_arg,
&write_callback);
@@ -3226,7 +3207,7 @@ public:
return done;
}
- string getType() override
+ std::string getType() override
{
return "UndirtyOp";
}
@@ -3236,7 +3217,7 @@ class IsDirtyOp : public TestOp {
public:
librados::AioCompletion *completion;
librados::ObjectReadOperation op;
- string oid;
+ std::string oid;
bool dirty;
ObjectDesc old_value;
int snap = 0;
@@ -3244,7 +3225,7 @@ public:
IsDirtyOp(int n,
RadosTestContext *context,
- const string &oid,
+ const std::string &oid,
TestOpStat *stat = 0)
: TestOp(n, context, stat),
completion(NULL),
@@ -3265,8 +3246,8 @@ public:
std::cout << num << ": is_dirty oid " << oid << " snap " << snap
<< std::endl;
- pair<TestOp*, TestOp::CallbackInfo*> *cb_arg =
- new pair<TestOp*, TestOp::CallbackInfo*>(this,
+ std::pair<TestOp*, TestOp::CallbackInfo*> *cb_arg =
+ new std::pair<TestOp*, TestOp::CallbackInfo*>(this,
new TestOp::CallbackInfo(0));
completion = context->rados.aio_create_completion((void *) cb_arg,
&write_callback);
@@ -3301,11 +3282,11 @@ public:
int r = completion->get_return_value();
if (r == 0) {
- cout << num << ": " << (dirty ? "dirty" : "clean") << std::endl;
+ std::cout << num << ": " << (dirty ? "dirty" : "clean") << std::endl;
ceph_assert(!old_value.deleted());
ceph_assert(dirty == old_value.dirty);
} else {
- cout << num << ": got " << r << std::endl;
+ std::cout << num << ": got " << r << std::endl;
ceph_assert(r == -ENOENT);
ceph_assert(old_value.deleted());
}
@@ -3318,7 +3299,7 @@ public:
return done;
}
- string getType() override
+ std::string getType() override
{
return "IsDirtyOp";
}
@@ -3330,7 +3311,7 @@ class CacheFlushOp : public TestOp {
public:
librados::AioCompletion *completion;
librados::ObjectReadOperation op;
- string oid;
+ std::string oid;
bool blocking;
int snap;
bool can_fail;
@@ -3338,7 +3319,7 @@ public:
CacheFlushOp(int n,
RadosTestContext *context,
- const string &oid,
+ const std::string &oid,
TestOpStat *stat,
bool b)
: TestOp(n, context, stat),
@@ -3365,15 +3346,15 @@ public:
// FIXME: we could fail if we've ever removed a snap due to
// the async snap trimming.
can_fail = true;
- cout << num << ": " << (blocking ? "cache_flush" : "cache_try_flush")
+ std::cout << num << ": " << (blocking ? "cache_flush" : "cache_try_flush")
<< " oid " << oid << " snap " << snap << std::endl;
if (snap >= 0) {
context->io_ctx.snap_set_read(context->snaps[snap]);
}
- pair<TestOp*, TestOp::CallbackInfo*> *cb_arg =
- new pair<TestOp*, TestOp::CallbackInfo*>(this,
+ std::pair<TestOp*, TestOp::CallbackInfo*> *cb_arg =
+ new std::pair<TestOp*, TestOp::CallbackInfo*>(this,
new TestOp::CallbackInfo(0));
completion = context->rados.aio_create_completion((void *) cb_arg,
&write_callback);
@@ -3405,7 +3386,7 @@ public:
context->oid_flushing.erase(oid);
context->oid_not_flushing.insert(oid);
int r = completion->get_return_value();
- cout << num << ": got " << cpp_strerror(r) << std::endl;
+ std::cout << num << ": got " << cpp_strerror(r) << std::endl;
if (r == 0) {
context->update_object_version(oid, 0, snap);
} else if (r == -EBUSY) {
@@ -3426,7 +3407,7 @@ public:
return done;
}
- string getType() override
+ std::string getType() override
{
return "CacheFlushOp";
}
@@ -3436,12 +3417,12 @@ class CacheEvictOp : public TestOp {
public:
librados::AioCompletion *completion;
librados::ObjectReadOperation op;
- string oid;
+ std::string oid;
std::shared_ptr<int> in_use;
CacheEvictOp(int n,
RadosTestContext *context,
- const string &oid,
+ const std::string &oid,
TestOpStat *stat)
: TestOp(n, context, stat),
completion(NULL),
@@ -3459,14 +3440,14 @@ public:
} else {
snap = -1;
}
- cout << num << ": cache_evict oid " << oid << " snap " << snap << std::endl;
+ std::cout << num << ": cache_evict oid " << oid << " snap " << snap << std::endl;
if (snap >= 0) {
context->io_ctx.snap_set_read(context->snaps[snap]);
}
- pair<TestOp*, TestOp::CallbackInfo*> *cb_arg =
- new pair<TestOp*, TestOp::CallbackInfo*>(this,
+ std::pair<TestOp*, TestOp::CallbackInfo*> *cb_arg =
+ new std::pair<TestOp*, TestOp::CallbackInfo*>(this,
new TestOp::CallbackInfo(0));
completion = context->rados.aio_create_completion((void *) cb_arg,
&write_callback);
@@ -3490,7 +3471,7 @@ public:
ceph_assert(completion->is_complete());
int r = completion->get_return_value();
- cout << num << ": got " << cpp_strerror(r) << std::endl;
+ std::cout << num << ": got " << cpp_strerror(r) << std::endl;
if (r == 0) {
// yay!
} else if (r == -EBUSY) {
@@ -3511,7 +3492,7 @@ public:
return done;
}
- string getType() override
+ std::string getType() override
{
return "CacheEvictOp";
}
diff --git a/src/test/osd/TestOpStat.cc b/src/test/osd/TestOpStat.cc
index 48b87b885b0..eb13e1d55e0 100644
--- a/src/test/osd/TestOpStat.cc
+++ b/src/test/osd/TestOpStat.cc
@@ -17,10 +17,10 @@ void TestOpStat::end(TestOp *in) {
stats[in->getType()].end(in);
}
-void TestOpStat::TypeStatus::export_latencies(map<double,uint64_t> &in) const
+void TestOpStat::TypeStatus::export_latencies(std::map<double,uint64_t> &in) const
{
- map<double,uint64_t>::iterator i = in.begin();
- multiset<uint64_t>::iterator j = latencies.begin();
+ auto i = in.begin();
+ auto j = latencies.begin();
int count = 0;
while (j != latencies.end() && i != in.end()) {
count++;
@@ -31,22 +31,22 @@ void TestOpStat::TypeStatus::export_latencies(map<double,uint64_t> &in) const
++j;
}
}
-
+
std::ostream & operator<<(std::ostream &out, const TestOpStat &rhs)
{
std::lock_guard l{rhs.stat_lock};
for (auto i = rhs.stats.begin();
i != rhs.stats.end();
++i) {
- map<double,uint64_t> latency;
+ std::map<double,uint64_t> latency;
latency[10] = 0;
latency[50] = 0;
latency[90] = 0;
latency[99] = 0;
i->second.export_latencies(latency);
-
+
out << i->first << " latency: " << std::endl;
- for (map<double,uint64_t>::iterator j = latency.begin();
+ for (auto j = latency.begin();
j != latency.end();
++j) {
if (j->second == 0) break;