diff options
| -rw-r--r-- | docs/commands.md | 49 | ||||
| -rw-r--r-- | src/swarmkv.c | 21 | ||||
| -rw-r--r-- | test/swarmkv_gtest.cpp | 2 |
3 files changed, 70 insertions, 2 deletions
diff --git a/docs/commands.md b/docs/commands.md index 2b45021..f1d9df7 100644 --- a/docs/commands.md +++ b/docs/commands.md @@ -585,7 +585,7 @@ swarmkv-2-nodes> BTINFO bulk user1 12) (integer) 100000 ``` -## Cluster Management +## Debug ### INFO @@ -658,6 +658,53 @@ instantaneous_input_cps: 0.00 instantaneous_output_cps: 0.00 ``` +### LATENCY + +Syntax + +``` +LATENCY <subcommand> [<arg> [value] [opt] ...] +``` + +The `LANTENCY` command returns latency metrics of command execution. +Subcommands are: +* COMMAND [command] + - Return time-latency samples for a specified command name. +* PEER [IP:port] + - Return time-latency samples for the specified peer. +* EVENT [event] + - Return time-latency samples for the specified event. +* RESET [command|event|peer] + - Reset data of a specified catalog or all the data if no catalog provided. + +### DEBUG + +Syntax + +``` +DEBUG <subcommand> [<arg> [value] [opt] ...]. +``` + +Subcommands are: +* SLEEP <seconds> + - Stop the server for <seconds>. Decimals allowed. +* ASSERT + - Crash by assertion failed. + +### COMMAND LIST + +Syntax + +``` +COMMAND LIST +``` + +The `COMMAND LIST` command returns an array of the server's command names. + +Return + +- Array reply: a list of command names. + ## Cluster Management ### CLUSTER KEYS diff --git a/src/swarmkv.c b/src/swarmkv.c index a0d4d18..4adf862 100644 --- a/src/swarmkv.c +++ b/src/swarmkv.c @@ -463,6 +463,21 @@ enum cmd_exec_result config_command(struct swarmkv_module *mod_store, const stru { return FINISHED; } +enum cmd_exec_result command_list_command(struct swarmkv_module *mod_db, const struct swarmkv_cmd *cmd, const node_t *accessing_node, struct swarmkv_reply **reply) +{ + struct swarmkv *db=module2db(mod_db); + size_t cnt=HASH_COUNT(db->command_table); + struct swarmkv_cmd_spec *spec=NULL, *tmp_spec=NULL; + int i=0; + *reply=swarmkv_reply_new_array(cnt); + HASH_ITER(hh, db->command_table, spec, tmp_spec) + { + (*reply)->elements[i]=swarmkv_reply_new_string(spec->name, strlen(spec->name)); + i++; + } + assert(i==cnt); + return FINISHED; +} struct swarmkv_cmd_spec *get_spec_by_argv(struct swarmkv *db, size_t argc, char* const argv[]) { struct swarmkv_cmd_spec *spec=NULL; @@ -1001,6 +1016,9 @@ void command_spec_init(struct swarmkv *db) command_register(&(db->command_table), "PING", "IP:port", 1, -1, CMD_KEY_NA, REPLY_NA, AUTO_ROUTE, ping_command, &db->module); + command_register(&(db->command_table), "COMMAND LIST", "", + 0, -1, CMD_KEY_NA, REPLY_NA, AUTO_ROUTE, + command_list_command, &db->module); command_register(&(db->command_table), "TUNNEL", "IP:port command ...", 2, -1, CMD_KEY_NA, REPLY_NA, AUTO_ROUTE, tunnel_command, &db->module); @@ -1009,6 +1027,9 @@ void command_spec_init(struct swarmkv *db) 1, -1, CMD_KEY_NA, REPLY_NA, NOT_AUTO_ROUTE, latency_command, db->mod_monitor); + + + /* low-level state-based CRDT synchronization commands*/ command_register(&(db->command_table), "CRDT PULL", "key", 1, 2, CMD_KEY_NA, REPLY_NA, NOT_AUTO_ROUTE, diff --git a/test/swarmkv_gtest.cpp b/test/swarmkv_gtest.cpp index 4e04803..8cd8a19 100644 --- a/test/swarmkv_gtest.cpp +++ b/test/swarmkv_gtest.cpp @@ -1496,7 +1496,7 @@ TEST_F(SwarmkvTwoNodes, TypeHash) TEST_F(SwarmkvTwoNodes, Wait) { //return; - //sleep(3600*2); + sleep(3600*2); } TEST(CloudNative, AnnounceIPPort) { |
