Skip to content

Commit

Permalink
refactor(configs): Move configs defination and declearation to global…
Browse files Browse the repository at this point in the history
… namespace (#1876)

Move the uses of DSN_DECLARE_* and DSN_DEFINE_* to global namespace because they
are all global variables, we can access them without any namespace scopes.
  • Loading branch information
acelyc111 authored Feb 7, 2024
1 parent 07c3985 commit a9cfa5c
Show file tree
Hide file tree
Showing 142 changed files with 568 additions and 575 deletions.
24 changes: 12 additions & 12 deletions src/block_service/hdfs/hdfs_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,6 @@
#include "utils/safe_strerror_posix.h"
#include "utils/strings.h"

DSN_DECLARE_bool(enable_direct_io);

struct hdfsBuilder;

namespace dsn {
class task_tracker;

namespace dist {
namespace block_service {

DEFINE_TASK_CODE(LPC_HDFS_SERVICE_CALL, TASK_PRIORITY_COMMON, THREAD_POOL_BLOCK_SERVICE)

DSN_DEFINE_uint64(replication,
hdfs_read_batch_size_bytes,
64 << 20,
Expand All @@ -69,6 +57,18 @@ DSN_DEFINE_uint64(replication,
"hdfs write batch size, the default value is 64MB");
DSN_TAG_VARIABLE(hdfs_write_batch_size_bytes, FT_MUTABLE);

DSN_DECLARE_bool(enable_direct_io);

struct hdfsBuilder;

namespace dsn {
class task_tracker;

namespace dist {
namespace block_service {

DEFINE_TASK_CODE(LPC_HDFS_SERVICE_CALL, TASK_PRIORITY_COMMON, THREAD_POOL_BLOCK_SERVICE)

hdfs_service::hdfs_service()
{
_read_token_bucket.reset(new folly::DynamicTokenBucket());
Expand Down
6 changes: 3 additions & 3 deletions src/block_service/test/hdfs_service_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,6 @@
#include "utils/test_macros.h"
#include "utils/threadpool_code.h"

using namespace dsn;
using namespace dsn::dist::block_service;

DSN_DEFINE_string(hdfs_test, test_name_node, "", "hdfs name node");
DSN_DEFINE_string(hdfs_test, test_backup_path, "", "path for uploading and downloading test files");

Expand All @@ -60,6 +57,9 @@ DSN_DEFINE_uint32(hdfs_test,
64,
"number of total files for hdfs concurrent test");

using namespace dsn;
using namespace dsn::dist::block_service;

DEFINE_TASK_CODE(LPC_TEST_HDFS, TASK_PRIORITY_HIGH, dsn::THREAD_POOL_DEFAULT)

class HDFSClientTest : public pegasus::encrypt_data_test_base
Expand Down
3 changes: 2 additions & 1 deletion src/common/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@
#include "utils/fmt_logging.h"
#include "utils/strings.h"

namespace dsn {
DSN_DEFINE_string(replication, cluster_name, "", "name of this cluster");

namespace dsn {

/*extern*/ const char *get_current_cluster_name()
{
CHECK(!utils::is_empty(FLAGS_cluster_name), "cluster_name is not set");
Expand Down
6 changes: 3 additions & 3 deletions src/common/duplication_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@
#include "utils/singleton.h"
#include "utils/time_utils.h"

namespace dsn {
namespace replication {

DSN_DEFINE_uint32(replication,
duplicate_log_batch_bytes,
4096,
"send mutation log batch bytes size per rpc");
DSN_TAG_VARIABLE(duplicate_log_batch_bytes, FT_MUTABLE);

namespace dsn {
namespace replication {

const std::string duplication_constants::kDuplicationCheckpointRootDir /*NOLINT*/ = "duplication";
const std::string duplication_constants::kClustersSectionName /*NOLINT*/ = "pegasus.clusters";
const std::string duplication_constants::kDuplicationEnvMasterClusterKey /*NOLINT*/ =
Expand Down
4 changes: 2 additions & 2 deletions src/common/duplication_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@
#include "utils/flags.h"
#include "utils/fmt_utils.h"

DSN_DECLARE_uint32(duplicate_log_batch_bytes);

namespace dsn {
namespace replication {

DSN_DECLARE_uint32(duplicate_log_batch_bytes);

typedef rpc_holder<duplication_modify_request, duplication_modify_response> duplication_modify_rpc;
typedef rpc_holder<duplication_add_request, duplication_add_response> duplication_add_rpc;
typedef rpc_holder<duplication_query_request, duplication_query_response> duplication_query_rpc;
Expand Down
28 changes: 14 additions & 14 deletions src/common/fs_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,20 @@
#include "utils/math.h"
#include "utils/ports.h"

DSN_DEFINE_int32(replication,
disk_min_available_space_ratio,
10,
"if disk available space ratio "
"is below this value, this "
"disk will be considered as "
"space insufficient");
DSN_TAG_VARIABLE(disk_min_available_space_ratio, FT_MUTABLE);

DSN_DEFINE_bool(replication,
ignore_broken_disk,
true,
"true means ignore broken data disk when initialize");

METRIC_DEFINE_entity(disk);

METRIC_DEFINE_gauge_int64(disk,
Expand All @@ -58,20 +72,6 @@ METRIC_DEFINE_gauge_int64(disk,
namespace dsn {
namespace replication {

DSN_DEFINE_int32(replication,
disk_min_available_space_ratio,
10,
"if disk available space ratio "
"is below this value, this "
"disk will be considered as "
"space insufficient");
DSN_TAG_VARIABLE(disk_min_available_space_ratio, FT_MUTABLE);

DSN_DEFINE_bool(replication,
ignore_broken_disk,
true,
"true means ignore broken data disk when initialize");

error_code disk_status_to_error_code(disk_status::type ds)
{
switch (ds) {
Expand Down
4 changes: 2 additions & 2 deletions src/common/fs_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@
#include "utils/ports.h"
#include "utils/zlocks.h"

DSN_DECLARE_int32(disk_min_available_space_ratio);

namespace dsn {
class gpid;

namespace replication {
class disk_info;

DSN_DECLARE_int32(disk_min_available_space_ratio);

error_code disk_status_to_error_code(disk_status::type ds);

class disk_capacity_metrics
Expand Down
6 changes: 3 additions & 3 deletions src/common/replication_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,6 @@
#include "utils/string_conv.h"
#include "utils/strings.h"

namespace dsn {
namespace replication {

DSN_DEFINE_bool(replication, duplication_enabled, true, "is duplication enabled");

DSN_DEFINE_int32(replication,
Expand Down Expand Up @@ -104,6 +101,9 @@ DSN_DEFINE_string(replication,
"",
"The prefix of cold backup data path on remote storage");

namespace dsn {
namespace replication {

replication_options::~replication_options() {}

void replication_options::initialize()
Expand Down
3 changes: 1 addition & 2 deletions src/failure_detector/test/failure_detector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,11 @@
#include "utils/zlocks.h"

DSN_DECLARE_int32(max_succssive_unstable_restart);
DSN_DECLARE_uint64(stable_rs_min_running_seconds);

using namespace dsn;
using namespace dsn::fd;

DSN_DECLARE_uint64(stable_rs_min_running_seconds);

#define MPORT_START 30001
#define WPORT 40001
#define MCOUNT 3
Expand Down
5 changes: 3 additions & 2 deletions src/geo/lib/geo_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@
#include "utils/fmt_logging.h"
#include "utils/synchronize.h"

namespace pegasus {
namespace geo {
DSN_DEFINE_int32(geo_client.lib,
min_level,
12,
Expand Down Expand Up @@ -79,6 +77,9 @@ DSN_DEFINE_group_validator(min_max_level, [](std::string &message) -> bool {
DSN_DEFINE_uint32(geo_client.lib, latitude_index, 5, "latitude index in value");
DSN_DEFINE_uint32(geo_client.lib, longitude_index, 4, "longitude index in value");

namespace pegasus {
namespace geo {

struct SearchResultNearer
{
inline bool operator()(const SearchResult &l, const SearchResult &r)
Expand Down
4 changes: 2 additions & 2 deletions src/geo/test/geo_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@
#include "utils/fmt_logging.h"
#include "utils/string_conv.h"

DSN_DECLARE_int32(min_level);

namespace pegasus {
namespace geo {

DSN_DECLARE_int32(min_level);

// TODO(yingchun): it doesn't make sense to derive from pegasus::encrypt_data_test_base to test
// encryption or non-encryption senarios, because the Pegasus cluster has been started with a
// fixed value of FLAGS_encrypt_data_at_rest.
Expand Down
4 changes: 2 additions & 2 deletions src/http/http_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@
#include "utils/flags.h"
#include "utils/fmt_logging.h"

namespace dsn {

DSN_DEFINE_uint32(http,
curl_timeout_ms,
10000,
"The maximum time in milliseconds that you allow the libcurl transfer operation "
"to complete");

namespace dsn {

#define RETURN_IF_CURL_NOT_OK(expr, ok, ...) \
do { \
const auto &code = (expr); \
Expand Down
4 changes: 2 additions & 2 deletions src/http/http_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@
#include "utils/output_utils.h"
#include "utils/strings.h"

namespace dsn {

DSN_DEFINE_bool(http, enable_http_server, true, "whether to enable the embedded HTTP server");

namespace dsn {

namespace {
error_s update_config(const http_request &req)
{
Expand Down
4 changes: 2 additions & 2 deletions src/http/http_server.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@
#include "utils/flags.h"
#include "utils/threadpool_code.h"

namespace dsn {

DSN_DECLARE_bool(enable_http_server);

namespace dsn {

/// The rpc code for all the HTTP RPCs.
DEFINE_TASK_CODE_RPC(RPC_HTTP_SERVICE, TASK_PRIORITY_COMMON, THREAD_POOL_DEFAULT);

Expand Down
9 changes: 5 additions & 4 deletions src/meta/app_balance_policy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,17 @@
#include "utils/flags.h"
#include "utils/fmt_logging.h"

namespace dsn {
class rpc_address;

namespace replication {
DSN_DEFINE_bool(meta_server, balancer_in_turn, false, "balance the apps one-by-one/concurrently");
DSN_DEFINE_bool(meta_server, only_primary_balancer, false, "only try to make the primary balanced");
DSN_DEFINE_bool(meta_server,
only_move_primary,
false,
"only try to make the primary balanced by move");

namespace dsn {
class rpc_address;

namespace replication {
app_balance_policy::app_balance_policy(meta_service *svc) : load_balance_policy(svc)
{
if (_svc != nullptr) {
Expand Down
8 changes: 4 additions & 4 deletions src/meta/cluster_balance_policy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,16 @@
#include "utils/fmt_logging.h"
#include "utils/utils.h"

namespace dsn {
namespace replication {
class meta_service;

DSN_DEFINE_uint32(meta_server,
balance_op_count_per_round,
10,
"balance operation count per round for cluster balancer");
DSN_TAG_VARIABLE(balance_op_count_per_round, FT_MUTABLE);

namespace dsn {
namespace replication {
class meta_service;

uint32_t get_partition_count(const node_state &ns, balance_type type, int32_t app_id)
{
unsigned count = 0;
Expand Down
10 changes: 5 additions & 5 deletions src/meta/greedy_load_balancer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,16 @@
#include "utils/math.h"
#include "utils/metrics.h"

namespace dsn {
class gpid;

namespace replication {

DSN_DEFINE_bool(meta_server, balance_cluster, false, "whether to enable cluster balancer");
DSN_TAG_VARIABLE(balance_cluster, FT_MUTABLE);

DSN_DECLARE_uint64(min_live_node_count_for_unfreeze);

namespace dsn {
class gpid;

namespace replication {

greedy_load_balancer::greedy_load_balancer(meta_service *_svc) : server_load_balancer(_svc)
{
_app_balance_policy = std::make_unique<app_balance_policy>(_svc);
Expand Down
3 changes: 2 additions & 1 deletion src/meta/load_balance_policy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,10 @@
#include "absl/strings/string_view.h"
#include "utils/strings.h"

DSN_DECLARE_uint64(min_live_node_count_for_unfreeze);

namespace dsn {
namespace replication {
DSN_DECLARE_uint64(min_live_node_count_for_unfreeze);

void dump_disk_load(app_id id, const rpc_address &node, bool only_primary, const disk_load &load)
{
Expand Down
7 changes: 3 additions & 4 deletions src/meta/meta_backup_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,10 @@
#include "utils/fmt_logging.h"
#include "utils/time_utils.h"

METRIC_DEFINE_entity(backup_policy);
DSN_DECLARE_int32(cold_backup_checkpoint_reserve_minutes);
DSN_DECLARE_int32(fd_lease_seconds);

METRIC_DEFINE_entity(backup_policy);
METRIC_DEFINE_gauge_int64(backup_policy,
backup_recent_duration_ms,
dsn::metric_unit::kMilliSeconds,
Expand All @@ -63,9 +65,6 @@ METRIC_DEFINE_gauge_int64(backup_policy,
namespace dsn {
namespace replication {

DSN_DECLARE_int32(cold_backup_checkpoint_reserve_minutes);
DSN_DECLARE_int32(fd_lease_seconds);

namespace {

metric_entity_ptr instantiate_backup_policy_metric_entity(const std::string &policy_name)
Expand Down
6 changes: 3 additions & 3 deletions src/meta/meta_bulk_load_ingestion_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@
#include "utils/string_conv.h"
#include "absl/strings/string_view.h"

namespace dsn {
namespace replication {

DSN_DEFINE_uint32(meta_server,
bulk_load_node_max_ingesting_count,
4,
Expand All @@ -40,6 +37,9 @@ DSN_TAG_VARIABLE(bulk_load_node_max_ingesting_count, FT_MUTABLE);
DSN_DEFINE_uint32(meta_server, bulk_load_node_min_disk_count, 1, "min disk count of one node");
DSN_TAG_VARIABLE(bulk_load_node_min_disk_count, FT_MUTABLE);

namespace dsn {
namespace replication {

ingestion_context::ingestion_context() { reset_all(); }

ingestion_context::~ingestion_context() { reset_all(); }
Expand Down
Loading

0 comments on commit a9cfa5c

Please sign in to comment.