Skip to content

Commit 2fd42b9

Browse files
committed
fix clang-tidy
1 parent 510dc78 commit 2fd42b9

File tree

5 files changed

+53
-46
lines changed

5 files changed

+53
-46
lines changed

src/meta/meta_service.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include <boost/lexical_cast.hpp>
3030
#include <algorithm> // for std::remove_if
3131
#include <chrono>
32+
#include <cstdint>
3233
#include <functional>
3334
#include <ostream>
3435
#include <string_view>

src/replica/replica_stub.cpp

Lines changed: 49 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
// IWYU pragma: no_include <ext/alloc_traits.h>
3030
#include <fmt/core.h>
3131
#include <fmt/format.h>
32+
#include <nlohmann/json.hpp>
3233
#include <rapidjson/ostreamwrapper.h>
3334
#include <stdio.h>
3435
#include <stdlib.h>
@@ -413,30 +414,33 @@ namespace {
413414
void register_flags_ctrl_command()
414415
{
415416
static std::once_flag flag;
416-
static std::vector<std::unique_ptr<dsn::command_deregister>> cmds;
417417
std::call_once(flag, []() mutable {
418-
cmds.emplace_back(dsn::command_manager::instance().register_int_command(
419-
FLAGS_max_replicas_on_load_for_each_disk,
420-
FLAGS_max_replicas_on_load_for_each_disk,
421-
"replica.max-replicas-on-load-for-each-disk",
422-
kMaxReplicasOnLoadForEachDiskDesc));
423-
424-
cmds.emplace_back(dsn::command_manager::instance().register_int_command(
425-
FLAGS_load_replica_max_wait_time_ms,
426-
FLAGS_load_replica_max_wait_time_ms,
427-
"replica.load-replica-max-wait-time-ms",
428-
kLoadReplicaMaxWaitTimeMsDesc));
429-
430-
cmds.emplace_back(dsn::command_manager::instance().register_bool_command(
431-
FLAGS_empty_write_disabled,
432-
"replica.disable-empty-write",
433-
"whether to disable empty writes"));
434-
435-
cmds.emplace_back(::dsn::command_manager::instance().register_int_command(
436-
FLAGS_max_concurrent_bulk_load_downloading_count,
437-
FLAGS_max_concurrent_bulk_load_downloading_count,
438-
"replica.max-concurrent-bulk-load-downloading-count",
439-
kMaxConcurrentBulkLoadDownloadingCountDesc));
418+
dsn::command_manager::instance().add_global_cmd(
419+
dsn::command_manager::instance().register_int_command(
420+
FLAGS_max_replicas_on_load_for_each_disk,
421+
FLAGS_max_replicas_on_load_for_each_disk,
422+
"replica.max-replicas-on-load-for-each-disk",
423+
kMaxReplicasOnLoadForEachDiskDesc));
424+
425+
dsn::command_manager::instance().add_global_cmd(
426+
dsn::command_manager::instance().register_int_command(
427+
FLAGS_load_replica_max_wait_time_ms,
428+
FLAGS_load_replica_max_wait_time_ms,
429+
"replica.load-replica-max-wait-time-ms",
430+
kLoadReplicaMaxWaitTimeMsDesc));
431+
432+
dsn::command_manager::instance().add_global_cmd(
433+
dsn::command_manager::instance().register_bool_command(
434+
FLAGS_empty_write_disabled,
435+
"replica.disable-empty-write",
436+
"whether to disable empty writes"));
437+
438+
dsn::command_manager::instance().add_global_cmd(
439+
dsn::command_manager::instance().register_int_command(
440+
FLAGS_max_concurrent_bulk_load_downloading_count,
441+
FLAGS_max_concurrent_bulk_load_downloading_count,
442+
"replica.max-concurrent-bulk-load-downloading-count",
443+
kMaxConcurrentBulkLoadDownloadingCountDesc));
440444
});
441445
}
442446

@@ -445,6 +449,9 @@ void register_flags_ctrl_command()
445449
replica_stub::replica_stub(replica_state_subscriber subscriber /*= nullptr*/,
446450
bool is_long_subscriber /* = true*/)
447451
: serverlet("replica_stub"),
452+
_state(NS_Disconnected),
453+
_replica_state_subscriber(subscriber),
454+
_is_long_subscriber(is_long_subscriber),
448455
_deny_client(false),
449456
_verbose_client_log(false),
450457
_verbose_commit_log(false),
@@ -454,6 +461,9 @@ replica_stub::replica_stub(replica_state_subscriber subscriber /*= nullptr*/,
454461
_bulk_load_downloading_count(0),
455462
_manual_emergency_checkpointing_count(0),
456463
_is_running(false),
464+
#ifdef DSN_ENABLE_GPERF
465+
_is_releasing_memory(false),
466+
#endif
457467
METRIC_VAR_INIT_server(total_replicas),
458468
METRIC_VAR_INIT_server(opening_replicas),
459469
METRIC_VAR_INIT_server(closing_replicas),
@@ -486,18 +496,10 @@ replica_stub::replica_stub(replica_state_subscriber subscriber /*= nullptr*/,
486496
METRIC_VAR_INIT_server(splitting_replicas_async_learn_max_duration_ms),
487497
METRIC_VAR_INIT_server(splitting_replicas_max_copy_file_bytes)
488498
{
489-
#ifdef DSN_ENABLE_GPERF
490-
_is_releasing_memory = false;
491-
#endif
492-
_replica_state_subscriber = subscriber;
493-
_is_long_subscriber = is_long_subscriber;
494-
_failure_detector = nullptr;
495-
_state = NS_Disconnected;
496-
497499
register_flags_ctrl_command();
498500
}
499501

500-
replica_stub::~replica_stub(void) { close(); }
502+
replica_stub::~replica_stub() { close(); }
501503

502504
void replica_stub::initialize(bool clear /* = false*/)
503505
{
@@ -2680,7 +2682,7 @@ void replica_stub::register_ctrl_command()
26802682
std::string
26812683
replica_stub::exec_command_on_replica(const std::vector<std::string> &arg_str_list,
26822684
bool allow_empty_args,
2683-
std::function<std::string(const replica_ptr &rep)> func)
2685+
std::function<std::string(const replica_ptr &)> func)
26842686
{
26852687
static const std::string kInvalidArguments("invalid arguments");
26862688

@@ -2710,25 +2712,29 @@ replica_stub::exec_command_on_replica(const std::vector<std::string> &arg_str_li
27102712
}
27112713

27122714
gpid id;
2713-
int pid;
27142715
if (id.parse_from(arg.c_str())) {
27152716
// app_id.partition_index
27162717
required_ids.insert(id);
27172718
auto find = rs.find(id);
27182719
if (find != rs.end()) {
27192720
choosed_rs[id] = find->second;
27202721
}
2721-
} else if (sscanf(arg.c_str(), "%d", &pid) == 1) {
2722-
// app_id
2723-
for (auto kv : rs) {
2724-
id = kv.second->get_gpid();
2725-
if (id.get_app_id() == pid) {
2726-
choosed_rs[id] = kv.second;
2727-
}
2728-
}
2729-
} else {
2722+
2723+
continue;
2724+
}
2725+
2726+
int pid = 0;
2727+
if (sscanf(arg.c_str(), "%d", &pid) != 1) {
27302728
return kInvalidArguments;
27312729
}
2730+
2731+
// app_id
2732+
for (const auto &[_, rep] : rs) {
2733+
id = rep->get_gpid();
2734+
if (id.get_app_id() == pid) {
2735+
choosed_rs[id] = rep;
2736+
}
2737+
}
27322738
}
27332739
}
27342740
} else {

src/replica/replica_stub.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,9 +229,9 @@ class replica_stub : public serverlet<replica_stub>, public ref_counter
229229
// - if allow_empty_args = false, you should specify at least one argument.
230230
// each argument should be in format of:
231231
// id1,id2... (where id is 'app_id' or 'app_id.partition_id')
232-
std::string exec_command_on_replica(const std::vector<std::string> &args,
232+
std::string exec_command_on_replica(const std::vector<std::string> &arg_str_list,
233233
bool allow_empty_args,
234-
std::function<std::string(const replica_ptr &rep)> func);
234+
std::function<std::string(const replica_ptr &)> func);
235235

236236
//
237237
// partition split

src/server/result_writer.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121

2222
#include <pegasus/error.h>
2323
#include <chrono>
24-
#include <type_traits>
2524
#include <utility>
2625

2726
#include "pegasus/client.h"

src/utils/command_manager.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
#include <map>
3737
#include <memory>
3838
#include <string>
39+
#include <type_traits>
3940
#include <vector>
4041

4142
#include "utils/fmt_logging.h"

0 commit comments

Comments
 (0)