Skip to content

Commit

Permalink
Change default ports to 9601 and 9701
Browse files Browse the repository at this point in the history
  • Loading branch information
erikgrinaker committed Feb 6, 2025
1 parent 1edd6e4 commit dae2a75
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 15 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ cluster can be built and started as:
```
$ ./cluster/run.sh
Starting 5 nodes on ports 9601-9605 with data under cluster/*/data/.
To connect to node 5, run: cargo run --release --bin toysql
To connect to node 1, run: cargo run --release --bin toysql
toydb4 21:03:55 [INFO] Listening on [::1]:9604 (SQL) and [::1]:9704 (Raft)
toydb1 21:03:55 [INFO] Listening on [::1]:9601 (SQL) and [::1]:9701 (Raft)
Expand All @@ -61,11 +61,11 @@ toydb2 21:03:56 [INFO] Starting new election for term 1
toydb2 21:03:56 [INFO] Won election for term 1, becoming leader
```

A command-line client can be built and used with node 5 on `localhost:9605`:
A command-line client can be built and used with node 1 on `localhost:9601`:

```
$ cargo run --release --bin toysql
Connected to toyDB node n5. Enter !help for instructions.
Connected to toyDB node n1. Enter !help for instructions.
toydb> CREATE TABLE movies (id INTEGER PRIMARY KEY, title VARCHAR NOT NULL);
toydb> INSERT INTO movies VALUES (1, 'Sicario'), (2, 'Stalker'), (3, 'Her');
toydb> SELECT * FROM movies;
Expand Down
4 changes: 2 additions & 2 deletions cluster/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# This script builds and runs a 5-node toyDB cluster listening on ports
# 9601-9605. Config and data is stored under the toydb* directories.
# To connect a toysql client to node 5 on port 9605, run:
# To connect a toysql client to node 1 on port 9601, run:
#
# cargo run --release --bin toysql

Expand All @@ -16,7 +16,7 @@ cargo build --release --bin toydb

# Start nodes 1-5 in the background, prefixing their output with the node ID.
echo "Starting 5 nodes on ports 9601-9605 with data under cluster/*/data/."
echo "To connect to node 5, run: cargo run --release --bin toysql"
echo "To connect to node 1, run: cargo run --release --bin toysql"
echo ""

for ID in 1 2 3 4 5; do
Expand Down
4 changes: 2 additions & 2 deletions config/toydb.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ id: 1
peers: {}

# Addresses to listen for SQL and Raft connections on.
listen_sql: localhost:9605
listen_raft: localhost:9705
listen_sql: localhost:9601
listen_raft: localhost:9701

# The log level. Valid values are DEBUG, INFO, WARN, and ERROR.
log_level: INFO
Expand Down
2 changes: 1 addition & 1 deletion docs/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,7 @@ Finally, the root `ResultSet` is returned to the client.

The toyDB [`Server`](https://github.com/erikgrinaker/toydb/blob/master/src/server.rs) manages
network traffic for the Raft and SQL engines, using the [Tokio](https://tokio.rs) async executor.
It opens TCP listeners on port `9605` for SQL clients and `9705` for Raft peers, both using
It opens TCP listeners on port `9601` for SQL clients and `9701` for Raft peers, both using
length-prefixed [Bincode](https://github.com/servo/bincode)-encoded message passing via
[Serde](https://serde.rs)-encoded Tokio streams as a protocol.

Expand Down
8 changes: 4 additions & 4 deletions src/bin/toydb.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! The toyDB server. Takes configuration from a config file (default
//! config/toydb.yaml) or corresponding TOYDB_ environment variables. Listens
//! for SQL clients (default port 9605) and Raft connections from other toyDB
//! peers (default port 9705). The Raft log and SQL database are stored at
//! for SQL clients (default port 9601) and Raft connections from other toyDB
//! peers (default port 9701). The Raft log and SQL database are stored at
//! data/raft and data/sql by default.
//!
//! Use the toysql command-line client to connect to the server.
Expand Down Expand Up @@ -63,8 +63,8 @@ impl Config {
fn load(file: &str) -> Result<Self> {
Ok(config::Config::builder()
.set_default("id", "1")?
.set_default("listen_sql", "localhost:9605")?
.set_default("listen_raft", "localhost:9705")?
.set_default("listen_sql", "localhost:9601")?
.set_default("listen_raft", "localhost:9701")?
.set_default("log_level", "info")?
.set_default("data_dir", "data")?
.set_default("storage_raft", "bitcask")?
Expand Down
4 changes: 2 additions & 2 deletions src/bin/toysql.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//! toySQL is a command-line client for toyDB. It connects to a toyDB node
//! (default localhost:9605) and executes SQL statements against it via an
//! (default localhost:9601) and executes SQL statements against it via an
//! interactive shell interface. Command history is stored in .toysql.history.
#![warn(clippy::all)]
Expand Down Expand Up @@ -37,7 +37,7 @@ struct Command {
#[arg(short = 'H', long, default_value = "localhost")]
host: String,
/// Port number to connect to.
#[arg(short = 'p', long, default_value = "9605")]
#[arg(short = 'p', long, default_value = "9601")]
port: u16,
}

Expand Down
2 changes: 1 addition & 1 deletion src/bin/workload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ struct Runner {
short = 'H',
long,
value_delimiter = ',',
default_value = "localhost:9605,localhost:9604,localhost:9603,localhost:9602,localhost:9601"
default_value = "localhost:9601,localhost:9602,localhost:9603,localhost:9604,localhost:9605"
)]
hosts: Vec<String>,

Expand Down

0 comments on commit dae2a75

Please sign in to comment.