summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZheng Chao <[email protected]>2024-04-08 16:10:18 +0800
committer郑超 <[email protected]>2024-05-28 02:40:48 +0000
commitdedc8317c36c88b585a0ea1d8cebd757aa1ddf0b (patch)
tree9da487e707cc367f0159bc58d8520e6079db0965
parentadbf82d087f5aeac880c6b618300dd7172c78d86 (diff)
Update cli.md
-rw-r--r--docs/cli.md151
-rw-r--r--docs/commands/cluster.md20
-rw-r--r--docs/commands/trouble_shooting.md106
-rw-r--r--readme.md30
-rw-r--r--src/t_cms.c2
-rw-r--r--test/swarmkv_gtest.cpp8
6 files changed, 153 insertions, 164 deletions
diff --git a/docs/cli.md b/docs/cli.md
index 32de3d9..4f42cd9 100644
--- a/docs/cli.md
+++ b/docs/cli.md
@@ -1,4 +1,4 @@
-## CLI
+# CLI
The SwarmKV command line interface (swarmkv-cli) is a terminal program used to send commands to and read replies from the SwarmKV Cluster. It has two main modes: an interactive Read Eval Print Loop (REPL) mode where the user types SwarmKV commands and receives replies, and a command mode where swarmkv-cli is executed with additional arguments and the reply is printed to the standard output.
@@ -9,7 +9,7 @@ $ ./swarmkv-cli -n cluster-name
```
The `--exec` option is used to execute a command in a non-interactive fashion.
-### Running the same command N times
+## Running the same command N times
In interactive mode, you can prefixing the command name by a number to run it N times.
@@ -31,27 +31,101 @@ Prefixing by two number are repeat times and interval (unit: second, default: 0
(integer) 8
```
-### Attach/Detach
+## Attach/Detach
Low-level commands don't have auto-route ability. If you execute low-level command via `swarmkv-cli`, you should execute `ATTACH IP:port` first. The `DETACH` command exits attaching model.
Another use case is the ability to attach to a node and execute commands on it. For example, you can connect to a node and execute the DEBUG command to debug the node.
-### CLUSTER CREATE
+## Trouble Shooting
+### INFO
+
Syntax
```
-CLUSTER CREATE cluster-name IP:port [IP:port ...]
+INFO [section]
```
-The `CLUSTER CREATE` command creates a new cluster with the specified name and adds the specified nodes to it.
-### CLUSTER NODES
+The `INFO` command returns information and statistics about the node in a format that is simple to parse by computers and easy to read by humans.
+
+The optional parameter can be used to select a specific section of information:
+
+- Node
+- Store
+- Keyspace
+- Network
+
+Return
+
+- Bulk string reply: as a collection of text lines. Lines can contain a section name (starting with a # character) or a property. All the properties are in the form of **field: value** terminated by \r\n.
+
+Example
+
+```
+swarmkv-sync> info
+# Node
+version: 4.3.0-2-ga8acac2
+address: 127.0.0.1:40619
+uuid: 922eab5d-2634-47f6-934a-1504379a12a3
+worker_threads: 1
+server_time_usec: 1668444667564448
+up_time_in_seconds: 302
+up_time_in_days: 0
+
+# Store
+shards: 8
+keys: 0
+to_sync: 0
+synced: 0
+sync_ok: 0
+sync_err: 0
+sync_interval_in_usec:500
+
+# Keyspace
+health_check_port: 0
+slots: 0
+keys: 0
+expires: 0
+
+# Network
+timeout_in_msec: 500.00
+connections: 2
+pending_rpcs: 0
+timed_out_rpcs: 0
+input_bytes: 4197
+output_bytes: 3481
+input_cmds: 0
+output_cmds: 45
+input_replies: 45
+output_replies: 0
+input_msgs: 45
+output_msgs: 45
+input_buffer: 333
+output_buffer: 0
+unknown_sequence: 0
+instantaneous_input_kbps: 0.00
+instantaneous_output_kbps: 0.00
+instantaneous_input_cps: 0.00
+instantaneous_output_cps: 0.00
+```
+
+### LATENCY
Syntax
```
-CLUSTER NODES
+LATENCY <subcommand> [<arg> [value] [opt] ...]
```
-List active nodes by communicate with Consul.
+
+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.
### MONITOR
Syntax
@@ -60,11 +134,10 @@ Syntax
MONITOR [pattern]
```
-`MONITOR` is a debugging command to see all the command executed by a specific node. It is implemented by registering the client at the attached node with the `MONREG` command, after which the attached node streams back every executed command using the `PRINT` command.
-
+`MONITOR` is a debugging command to see all the command executed by a specific node.
The optional `pattern` argument is a glob-style pattern that is matched against the command name and arguments. If the pattern is specified, only commands that match the pattern are streamed.
```
-1711950111.894233 [1 R 127.0.0.1:43385 KRT] "get" "key" "value"
+1711950111.894233 [1 R 127.0.0.1:43385 KRT] "get" "key"
1711950111.894324 [1 L 127.0.0.1:5212 RDR] "keyspace" "xradd" "key" "127.0.0.1:5212"
```
The abbreviations are listed before:
@@ -74,6 +147,59 @@ The abbreviations are listed before:
- `RDR` for redirect
- `FIN` for finished
+It is implemented by registering the client at the attached node with the `MONREG` command, after which the attached node streams back every executed command using the `PRINT` command.
+
+### DEBUG
+
+Syntax
+
+```
+DEBUG <subcommand> [<arg> [value] [opt] ...]
+```
+
+Subcommands are:
+* SLEEP <seconds>
+ - Stop the server for <seconds>. Decimals allowed.
+* ASSERT
+ - Crash by assertion failed.
+
+## Cluster Managment
+
+### CLUSTER CREATE
+Syntax
+
+```
+CLUSTER CREATE cluster-name IP:port [IP:port ...]
+```
+The `CLUSTER CREATE` command creates a new cluster with the specified name and adds the specified nodes to it.
+
+### CLUSTER NODES
+
+Syntax
+
+```
+CLUSTER NODES
+```
+List active nodes by communicate with Consul.
+
+### CLUSTER KEYS
+
+Syntax
+
+```
+CLUSTER KEYS pattern
+```
+Supported glob-style patterns:
+
+- `h?llo` matches `hello`, `hallo` and `hxllo`
+- `h*llo` matches `hllo` and `heeeello`
+- `h[ae]llo` matches `hello` and `hallo,` but not `hillo`
+- `h[^e]llo` matches `hallo`, `hbllo`, ... but not `hello`
+- `h[a-b]llo` matches `hallo` and `hbllo`
+
+Use `\` to escape special characters if you want to match them verbatim.
+The pattern is exactly same as Redis https://redis.io/commands/keys/ .
+
### CLUSTER SANITY
Syntax
@@ -92,5 +218,6 @@ CLUSTER ADDSLOTOWNER IP:Port [IP:Port ...]
The `CLUSTER ADDSLOTOWNER` command assigns the slots to new nodes.
+
### Known Issues
If a swarmkv-cli instance attempts to connect to itself using an address other than 127.0.0.1:port, it will result in a crash. \ No newline at end of file
diff --git a/docs/commands/cluster.md b/docs/commands/cluster.md
deleted file mode 100644
index 38b7d8e..0000000
--- a/docs/commands/cluster.md
+++ /dev/null
@@ -1,20 +0,0 @@
-## Cluster Management
-
-### CLUSTER KEYS
-
-Syntax
-
-```
-CLUSTER KEYS pattern
-```
-Supported glob-style patterns:
-
-- `h?llo` matches `hello`, `hallo` and `hxllo`
-- `h*llo` matches `hllo` and `heeeello`
-- `h[ae]llo` matches `hello` and `hallo,` but not `hillo`
-- `h[^e]llo` matches `hallo`, `hbllo`, ... but not `hello`
-- `h[a-b]llo` matches `hallo` and `hbllo`
-
-Use `\` to escape special characters if you want to match them verbatim.
-The pattern is exactly same as Redis https://redis.io/commands/keys/ .
-
diff --git a/docs/commands/trouble_shooting.md b/docs/commands/trouble_shooting.md
deleted file mode 100644
index 5af3b32..0000000
--- a/docs/commands/trouble_shooting.md
+++ /dev/null
@@ -1,106 +0,0 @@
-## Debug
-
-### INFO
-
-Syntax
-
-```
-INFO [section]
-```
-
-The `INFO` command returns information and statistics about the node in a format that is simple to parse by computers and easy to read by humans.
-
-The optional parameter can be used to select a specific section of information:
-
-- Node
-- Store
-- Keyspace
-- Network
-
-Return
-
-- Bulk string reply: as a collection of text lines. Lines can contain a section name (starting with a # character) or a property. All the properties are in the form of **field: value** terminated by \r\n.
-
-Example
-
-```
-swarmkv-sync> info
-# Node
-swarmkv_version: 3.0.0
-address: 127.0.0.1:40619
-uuid: 922eab5d-2634-47f6-934a-1504379a12a3
-worker_threads: 1
-server_time_usec: 1668444667564448
-up_time_in_seconds: 302
-up_time_in_days: 0
-
-# Store
-shards: 8
-keys: 0
-to_sync: 0
-synced: 0
-sync_ok: 0
-sync_err: 0
-sync_interval_in_usec:500
-
-# Keyspace
-health_check_port: 0
-slots: 0
-keys: 0
-expires: 0
-
-# Network
-timeout_in_msec: 500.00
-connections: 2
-pending_rpcs: 0
-timed_out_rpcs: 0
-input_bytes: 4197
-output_bytes: 3481
-input_cmds: 0
-output_cmds: 45
-input_replies: 45
-output_replies: 0
-input_msgs: 45
-output_msgs: 45
-input_buffer: 333
-output_buffer: 0
-unknown_sequence: 0
-instantaneous_input_kbps: 0.00
-instantaneous_output_kbps: 0.00
-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. \ No newline at end of file
diff --git a/readme.md b/readme.md
index 0d67e4c..4b06b80 100644
--- a/readme.md
+++ b/readme.md
@@ -23,20 +23,16 @@ Main Features
<img src="./docs/imgs/cluster.png" alt="swamrkv-cluster" />
SwarmKV Data Types
-
-- String
-- Integer
-- Set
-- Hash Table
-- Token Buckets
+- [String and Integer](./docs/commands/string_and_integer.md) by Last-Write-Wins (LWW) Register and Positive-Negative Counter.
+- [Set](./docs/commands/set.md) by Observed-Remove Set (OR-Set).
+- [Hash](./docs/commands/hash.md) embed string and integer by OR-Set.
+- [Token Buckets](./docs/commands/token_bucket.md)
- Generic Token Buckets
- Fair Token Bucket: Implements stochastic fairness allocation to ensure equitable resource distribution.
- Bulk Token Bucket: Optimized for scenarios requiring a large number of token buckets with identical configurations.
-- Bloom Filter with the ability to expire.
-- Count-min Sketch
-- HyperLogLog
-
-
+- [Bloom Filter](./docs/commands/bloom_filter.md) by age-partitioned bloom filter with the ability to expire.
+- [Count-Min Sketch](./docs/commands/count_min_sketch.md).
+- [HyperLogLog](./docs/commands/hyperloglog.md) by staggered HyperLogLog with the ability to expire.
# Getting started
@@ -154,13 +150,5 @@ Here are some specific details about the SwarmKV.
* [Command-line interface (CLI)](./docs/cli.md)
* [Conflict-free Replicated Data Type (CRDT)](./docs/crdt.md)
* [Commands](./docs/command_toc.md)
- * [Generic Type](./docs/commands/generic.md)
- * [String and Integer Types](./docs/commands/string_and_integer.md)
- * [Set Type](./docs/commands/set.md)
- * [Hash Type](./docs/commands/hash.md)
- * [Token Bucket Types](./docs/commands/token_bucket.md)
- * [Bloom Filter Type](./docs/commands/bloom_filter.md)
- * [Count-Min Sketch Type](./docs/commands/count_min_sketch.md)
- * [HyperLogLog Type](./docs/commands/hyperloglog.md)
- * [Cluster Management](./docs/commands/cluster.md)
- * [Trouble Shooting](./docs/commands/trouble_shooting.md) \ No newline at end of file
+* [Cluster Management](./docs/commands/cluster.md)
+* [Trouble Shooting](./docs/commands/trouble_shooting.md) \ No newline at end of file
diff --git a/src/t_cms.c b/src/t_cms.c
index 587d3e2..cb0f8dd 100644
--- a/src/t_cms.c
+++ b/src/t_cms.c
@@ -277,7 +277,7 @@ enum cmd_exec_result cmsrlist_command(struct swarmkv_module *mod_store, const st
{
char uuid_str[37];
uuid_unparse(replicas[i], uuid_str);
- (*reply)->elements[i]=swarmkv_reply_new_string(uuid_str, strlen(uuid_str)+1);
+ (*reply)->elements[i]=swarmkv_reply_new_string(uuid_str, strlen(uuid_str));
}
return FINISHED;
}
diff --git a/test/swarmkv_gtest.cpp b/test/swarmkv_gtest.cpp
index 39c27e3..175853b 100644
--- a/test/swarmkv_gtest.cpp
+++ b/test/swarmkv_gtest.cpp
@@ -970,7 +970,7 @@ protected:
char ip_list[1024]={0};
snprintf(ip_list, sizeof(ip_list), "127.0.0.1:%d 127.0.0.1:%d", TWO_NODES_TEST_CLUSTER_PORT, TWO_NODES_TEST_CLUSTER_PORT+1);
swarmkv_cli_create_cluster(cluster_name, ip_list);
- unsigned int very_long_timeout_us=600*1000*1000;
+ //unsigned int very_long_timeout_us=600*1000*1000;
logger=log_handle_create(log_path, 0);
struct swarmkv_options *opts[2];
struct swarmkv *tmp_db[2];
@@ -981,7 +981,7 @@ protected:
swarmkv_options_set_health_check_port(opts[i], TWO_NODES_TEST_HEALTH_PORT+i);
swarmkv_options_set_logger(opts[i], logger);
swarmkv_options_set_sync_interval_us(opts[i], 10000);
- swarmkv_options_set_cluster_timeout_us(opts[i], very_long_timeout_us);
+ swarmkv_options_set_cluster_timeout_us(opts[i], 500*1000);
swarmkv_options_set_worker_thread_number(opts[i], 2);
swarmkv_options_set_caller_thread_number(opts[i], 1);
swarmkv_options_set_batch_sync_enabled(opts[i], 1);
@@ -2029,8 +2029,8 @@ TEST_F(SwarmkvTwoNodes, Monitor)
}
TEST_F(SwarmkvTwoNodes, Wait)
{
- //return;
- sleep(3600*2);
+ return;
+ //sleep(3600*2);
}
TEST(CloudNative, AnnounceIPPort)
{