Skip to content

Commit

Permalink
Minor code quality improvements & script fixes (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
josehu07 authored Aug 27, 2024
1 parent 0ce946b commit 855dc5a
Show file tree
Hide file tree
Showing 36 changed files with 260 additions and 654 deletions.
16 changes: 8 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@ authors = ["Guanzhou Hu <me@josehu.com>"]

[dependencies]
async-trait = "0.1"
fixedbitset = { version = "0.4", features = ["serde"] }
rangemap = "1.4"
fixedbitset = { version = "0.5", features = ["serde"] }
rangemap = "1.5"
flashmap = "0.1"
bytes = { version = "1.4", features = ["serde"] }
bytes = { version = "1.7", features = ["serde"] }
futures = "0.3"
tokio = { version = "1.29", features = ["full"] }
tokio = { version = "1.39", features = ["full"] }
rand = "0.8"
lazy_static = "1.4"
rmp-serde = "1.1"
lazy_static = "1.5"
serde = { version = "1.0", features = ["derive"] }
toml = { version = "0.7", features = ["parse"] }
bincode = "1.3"
toml = { version = "0.8", features = ["parse"] }
log = "0.4"
env_logger = "0.10"
env_logger = "0.11"
reed-solomon-erasure = { version = "6.0" }
ctrlc = { version = "3.4", features = ["termination"] }
get-size = { version = "0.1", features = ["derive"] }
Expand Down
15 changes: 2 additions & 13 deletions scripts/distr_clients.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@
TOML_FILENAME = "scripts/remote_hosts.toml"


CLIENT_LOOP_IP = "0.0.0.0"
CLIENT_BIND_BASE_PORT = lambda p, c: 42000 + (p * 100 + c) * 10

MANAGER_CLI_PORT = lambda p: 40001 + p * 10
MANAGER_CLI_PORT = lambda p: 40009 + p * 20 # NOTE: assuming at most 9 servers


CLIENT_OUTPUT_PATH = (
Expand Down Expand Up @@ -91,15 +88,11 @@ def glue_params_str(cli_args, params_list):
return "+".join(params_strs)


def compose_client_cmd(
protocol, bind_base, manager, config, utility, timeout_ms, params, release
):
def compose_client_cmd(protocol, manager, config, utility, timeout_ms, params, release):
cmd = [f"./target/{'release' if release else 'debug'}/summerset_client"]
cmd += [
"-p",
protocol,
"-b",
bind_base,
"-m",
manager,
"--timeout-ms",
Expand Down Expand Up @@ -153,13 +146,9 @@ def run_clients(

client_procs = []
for i in range(num_clients):
client = base_idx + i
bind_base = f"{CLIENT_LOOP_IP}:{CLIENT_BIND_BASE_PORT(partition, client)}"
manager_addr = f"{manager_pub_ip}:{MANAGER_CLI_PORT(partition)}"

cmd = compose_client_cmd(
protocol,
bind_base,
manager_addr,
config,
utility,
Expand Down
29 changes: 10 additions & 19 deletions scripts/distr_cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,12 @@


SERVER_LOOP_IP = "0.0.0.0"
SERVER_API_PORT = lambda p, r: 40100 + (p * 10 + r)
SERVER_P2P_PORT = lambda p, r: 40200 + (p * 10 + r)
SERVER_BIND_BASE_PORT = lambda p, r: 41000 + (p * 10 + r) * 10
SERVER_API_PORT = lambda p, r: 40000 + (p * 20 + r)
SERVER_P2P_PORT = lambda p, r: 40010 + (p * 20 + r)

MANAGER_LOOP_IP = "0.0.0.0"
MANAGER_SRV_PORT = lambda p: 40000 + p * 10
MANAGER_CLI_PORT = lambda p: 40001 + p * 10
MANAGER_CLI_PORT = lambda p: 40009 + p * 20 # NOTE: assuming at most 9 servers
MANAGER_SRV_PORT = lambda p: 40019 + p * 20


PROTOCOL_BACKER_PATH = (
Expand Down Expand Up @@ -127,29 +126,26 @@ def config_dict_to_str(d):
return config_dict_to_str(config_dict)


def compose_manager_cmd(protocol, bind_ip, srv_port, cli_port, num_replicas, release):
def compose_manager_cmd(protocol, srv_port, cli_port, num_replicas, release):
cmd = [f"./target/{'release' if release else 'debug'}/summerset_manager"]
cmd += [
"-p",
protocol,
"-b",
bind_ip,
"-s",
str(srv_port),
MANAGER_LOOP_IP,
"-c",
str(cli_port),
"-s",
str(srv_port),
"-n",
str(num_replicas),
]
return cmd


def launch_manager(protocol, partition, num_replicas, release):
bind_ip = MANAGER_LOOP_IP

cmd = compose_manager_cmd(
protocol,
bind_ip,
MANAGER_SRV_PORT(partition),
MANAGER_CLI_PORT(partition),
num_replicas,
Expand Down Expand Up @@ -177,15 +173,13 @@ def wait_manager_setup(proc):
break


def compose_server_cmd(
protocol, bind_base, api_port, p2p_port, manager, config, release
):
def compose_server_cmd(protocol, api_port, p2p_port, manager, config, release):
cmd = [f"./target/{'release' if release else 'debug'}/summerset_server"]
cmd += [
"-p",
protocol,
"-b",
bind_base,
SERVER_LOOP_IP,
"-a",
str(api_port),
"-i",
Expand Down Expand Up @@ -224,13 +218,10 @@ def launch_servers(
server_procs = []
for replica in range(num_replicas):
host = hosts[replica]

bind_base = f"{SERVER_LOOP_IP}:{SERVER_BIND_BASE_PORT(partition, replica)}"
manager_addr = f"{manager_pub_ip}:{MANAGER_SRV_PORT(partition)}"

cmd = compose_server_cmd(
protocol,
bind_base,
SERVER_API_PORT(partition, replica),
SERVER_P2P_PORT(partition, replica),
manager_addr,
Expand Down
17 changes: 2 additions & 15 deletions scripts/local_clients.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,9 @@
import utils


CLIENT_LOOP_IP = "127.0.0.1"
CLIENT_VETH_IP = lambda c: f"10.0.2.{c}"
CLIENT_BIND_BASE_PORT = lambda c: 32000 + c * 10

MANAGER_LOOP_IP = "127.0.0.1"
MANAGER_VETH_IP = "10.0.0.0"
MANAGER_CLI_PORT = 30001
MANAGER_CLI_PORT = 30009 # NOTE: assuming at most 9 servers


CLIENT_OUTPUT_PATH = (
Expand Down Expand Up @@ -82,15 +78,11 @@ def glue_params_str(cli_args, params_list):
return "+".join(params_strs)


def compose_client_cmd(
protocol, bind_base, manager, config, utility, timeout_ms, params, release
):
def compose_client_cmd(protocol, manager, config, utility, timeout_ms, params, release):
cmd = [f"./target/{'release' if release else 'debug'}/summerset_client"]
cmd += [
"-p",
protocol,
"-b",
bind_base,
"-m",
manager,
"--timeout-ms",
Expand Down Expand Up @@ -128,16 +120,11 @@ def run_clients(

client_procs = []
for i in range(num_clients):
client = base_idx + i
bind_base = f"{CLIENT_LOOP_IP}:{CLIENT_BIND_BASE_PORT(client)}"
manager_addr = f"{MANAGER_LOOP_IP}:{MANAGER_CLI_PORT}"
if use_veth:
bind_base = f"{CLIENT_VETH_IP(client)}:{CLIENT_BIND_BASE_PORT(client)}"
manager_addr = f"{MANAGER_VETH_IP}:{MANAGER_CLI_PORT}"

cmd = compose_client_cmd(
protocol,
bind_base,
manager_addr,
config,
utility,
Expand Down
27 changes: 11 additions & 16 deletions scripts/local_cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,13 @@

SERVER_LOOP_IP = "127.0.0.1"
SERVER_VETH_IP = lambda r: f"10.0.1.{r}"
SERVER_API_PORT = lambda r: 30100 + r
SERVER_P2P_PORT = lambda r: 30200 + r
SERVER_BIND_BASE_PORT = lambda r: 31000 + r * 10
SERVER_API_PORT = lambda r: 30000 + r
SERVER_P2P_PORT = lambda r: 30010 + r

MANAGER_LOOP_IP = "127.0.0.1"
MANAGER_VETH_IP = "10.0.0.0"
MANAGER_SRV_PORT = 30000
MANAGER_CLI_PORT = 30001
MANAGER_CLI_PORT = 30009 # NOTE: assuming at most 9 servers
MANAGER_SRV_PORT = 30019


PROTOCOL_BACKER_PATH = (
Expand Down Expand Up @@ -119,10 +118,10 @@ def compose_manager_cmd(protocol, bind_ip, srv_port, cli_port, num_replicas, rel
protocol,
"-b",
bind_ip,
"-s",
str(srv_port),
"-c",
str(cli_port),
"-s",
str(srv_port),
"-n",
str(num_replicas),
]
Expand All @@ -133,7 +132,6 @@ def launch_manager(protocol, num_replicas, release, use_veth):
bind_ip = MANAGER_LOOP_IP
if use_veth:
bind_ip = MANAGER_VETH_IP

cmd = compose_manager_cmd(
protocol,
bind_ip,
Expand Down Expand Up @@ -164,15 +162,13 @@ def wait_manager_setup(proc):
break


def compose_server_cmd(
protocol, bind_base, api_port, p2p_port, manager, config, release
):
def compose_server_cmd(protocol, bind_ip, api_port, p2p_port, manager, config, release):
cmd = [f"./target/{'release' if release else 'debug'}/summerset_server"]
cmd += [
"-p",
protocol,
"-b",
bind_base,
bind_ip,
"-a",
str(api_port),
"-i",
Expand Down Expand Up @@ -202,15 +198,14 @@ def launch_servers(

server_procs = []
for replica in range(num_replicas):
bind_base = f"{SERVER_LOOP_IP}:{SERVER_BIND_BASE_PORT(replica)}"
bind_ip = SERVER_LOOP_IP
manager_addr = f"{MANAGER_LOOP_IP}:{MANAGER_SRV_PORT}"
if use_veth:
bind_base = f"{SERVER_VETH_IP(replica)}:{SERVER_BIND_BASE_PORT(replica)}"
bind_ip = SERVER_VETH_IP
manager_addr = f"{MANAGER_VETH_IP}:{MANAGER_SRV_PORT}"

cmd = compose_server_cmd(
protocol,
bind_base,
bind_ip,
SERVER_API_PORT(replica),
SERVER_P2P_PORT(replica),
manager_addr,
Expand Down
25 changes: 13 additions & 12 deletions scripts/remote_hosts.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,20 @@ repo_name = "summerset"

# (SET PROPERLY) for each group, its username @ DNS domain names
[1dc]
host0 = "username@domain.com"
host1 = "username@domain.com"
host2 = "username@domain.com"
host3 = "username@domain.com"
host4 = "username@domain.com"
host5 = "username@domain.com"
host6 = "username@domain.com"
host7 = "username@domain.com"
host8 = "username@domain.com"

[wan]
host0 = "username@domain.com"
host1 = "username@domain.com"
host2 = "username@domain.com"
host3 = "username@domain.com"
host4 = "username@domain.com"
# host3 = "username@domain.com"
# host4 = "username@domain.com"
# host5 = "username@domain.com"
# host6 = "username@domain.com"
# host7 = "username@domain.com"
# host8 = "username@domain.com"

# [wan]
# host0 = "username@domain.com"
# host1 = "username@domain.com"
# host2 = "username@domain.com"
# host3 = "username@domain.com"
# host4 = "username@domain.com"
20 changes: 10 additions & 10 deletions scripts/setup/install_devdeps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ sudo apt -y upgrade

echo
echo "Installing necessary apt packages..."
sudo apt -y install htop
sudo apt -y install tree
sudo apt -y install cloc
sudo apt -y install python3-pip
sudo apt -y install iperf3
sudo apt -y install iptables-persistent
sudo apt -y install screen
sudo apt -y install htop \
tree \
cloc \
python3-pip \
iperf3 \
iptables-persistent \
screen


echo
Expand All @@ -38,9 +38,9 @@ sudo chown -R ${USER} /usr/local/cargo

echo
echo "Installing necessary pip packages..."
sudo -H pip3 install numpy
sudo -H pip3 install matplotlib
sudo -H pip3 install toml
sudo -H pip3 install numpy \
matplotlib \
toml


echo
Expand Down
4 changes: 2 additions & 2 deletions scripts/setup/resize_partition.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

TARGET_DEV=/dev/sda
PART_NUMBER=3
PART_SIZE=240G


echo
Expand All @@ -13,8 +14,7 @@ sed -e 's/\s*\([\+0-9a-zA-Z]*\).*/\1/' << EOF | sudo fdisk ${TARGET_DEV}
n # new partition
${PART_NUMBER} # use partition number
# default start sec
+240G # default end sec
N # not removing ext3 signature
+${PART_SIZE} # default end sec
p # print the resulting table
w # sync to disk
q # done, quit
Expand Down
3 changes: 1 addition & 2 deletions src/client/apistub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,9 @@ impl ClientApiStub {
/// Creates a new API connection stub by connecting to the given server.
pub(crate) async fn new_by_connect(
id: ClientId,
bind_addr: SocketAddr,
server: SocketAddr,
) -> Result<Self, SummersetError> {
let mut stream = tcp_connect_with_retry(bind_addr, server, 10).await?;
let mut stream = tcp_connect_with_retry(server, 10).await?;
stream.write_u64(id).await?; // send my client ID
let (read_half, write_half) = stream.into_split();

Expand Down
3 changes: 1 addition & 2 deletions src/client/ctrlstub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,9 @@ pub struct ClientCtrlStub {
impl ClientCtrlStub {
/// Creates a new control API stub and connects to the manager.
pub(crate) async fn new_by_connect(
bind_addr: SocketAddr,
manager: SocketAddr,
) -> Result<Self, SummersetError> {
let mut stream = tcp_connect_with_retry(bind_addr, manager, 10).await?;
let mut stream = tcp_connect_with_retry(manager, 10).await?;
let id = stream.read_u64().await?; // receive my client ID
let (read_half, write_half) = stream.into_split();

Expand Down
Loading

0 comments on commit 855dc5a

Please sign in to comment.