Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
tangyanzhao committed Oct 21, 2020
1 parent 15215ec commit a694db5
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 12 deletions.
69 changes: 69 additions & 0 deletions config-shell.ini.203047
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
[apps..default]
run = true
count = 1
;network.client.RPC_CHANNEL_TCP = dsn::tools::sim_network_provider, 65536
;network.client.RPC_CHANNEL_UDP = dsn::tools::sim_network_provider, 65536
;network.server.0.RPC_CHANNEL_TCP = dsn::tools::sim_network_provider, 65536

[apps.mimic]
type = dsn.app.mimic
arguments =
pools = THREAD_POOL_DEFAULT,THREAD_POOL_META_SERVER
run = true
count = 1

[core]
;tool = simulator
tool = nativerun
;toollets = tracer
;toollets = tracer, profiler, fault_injector
pause_on_start = false

;aio_factory_name = dsn::tools::native_aio_provider

logging_start_level = LOG_LEVEL_DEBUG
logging_factory_name = dsn::tools::simple_logger
;logging_factory_name = dsn::tools::screen_logger
logging_flush_on_exit = false

enable_default_app_mimic = true

data_dir = ./pegasus_shell.data

[tools.simple_logger]
short_header = false
fast_flush = true
max_number_of_log_files_on_disk = 10
stderr_start_level = LOG_LEVEL_FATAL

[tools.simulator]
random_seed = 0

[network]
; how many network threads for network library(used by asio)
io_service_worker_count = 4

; specification for each thread pool
[threadpool..default]
worker_count = 4
partitioned = false
worker_priority = THREAD_xPRIORITY_NORMAL

[threadpool.THREAD_POOL_DEFAULT]
name = default
worker_count = 8

[threadpool.THREAD_POOL_META_SERVER]
name = meta_server

[task..default]
is_trace = false
is_profile = false
allow_inline = false
rpc_call_header_format = NET_HDR_DSN
rpc_call_channel = RPC_CHANNEL_TCP
rpc_timeout_milliseconds = 10000

[pegasus.clusters]
onebox = 127.0.0.1:34601,127.0.0.1:34602,127.0.0.1:34603

21 changes: 10 additions & 11 deletions src/server/hotkey_collector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,9 @@ void hotkey_collector::analyse_data()
{
switch (_state.load()) {
case hotkey_collector_state::COARSE_DETECTING:
terminate_if_timeout();
_internal_collector->analyse_data();
if (terminate_if_timeout()) {
_internal_collector->analyse_data();
}
return;
default:
return;
Expand All @@ -100,9 +101,9 @@ void hotkey_collector::on_start_detect(dsn::replication::detect_hotkey_response
return;
case hotkey_collector_state::FINISHED:
resp.err = dsn::ERR_INVALID_STATE;
hint = fmt::format("{} hotkey result has been found, you can send a stop rpc to "
"restart hotkey detection",
dsn::enum_to_string(_hotkey_type));
hint = fmt::format(
"{} hotkey result has been found, you can send a stop rpc to restart hotkey detection",
dsn::enum_to_string(_hotkey_type));
dwarn_replica(hint);
return;
case hotkey_collector_state::STOPPED:
Expand Down Expand Up @@ -138,17 +139,15 @@ void hotkey_collector::terminate()
_collector_start_time = 0;
}

void hotkey_collector::terminate_if_timeout()
bool hotkey_collector::terminate_if_timeout()
{
if (_collector_start_time == 0) {
return;
}
if (dsn_now_s() >= _collector_start_time + FLAGS_max_seconds_to_detect_hotkey) {
ddebug_replica("hotkey collector work time is exhausted but no hotkey has been found");
terminate();
return;
return false;
}
};
return true;
}

} // namespace server
} // namespace pegasus
2 changes: 1 addition & 1 deletion src/server/hotkey_collector.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class hotkey_collector : public dsn::replication::replica_base
void on_start_detect(dsn::replication::detect_hotkey_response &resp);
void on_stop_detect(dsn::replication::detect_hotkey_response &resp);
void terminate();
void terminate_if_timeout();
bool terminate_if_timeout();

std::atomic<hotkey_collector_state> _state;
const dsn::replication::hotkey_type::type _hotkey_type;
Expand Down

0 comments on commit a694db5

Please sign in to comment.