Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
dataroaring committed Sep 5, 2024
1 parent 0661341 commit 2cf29c3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
20 changes: 10 additions & 10 deletions tools/fdb/fdb_ctl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ calculate_process_numbers() {
local data_dir_count

# Convert comma-separated DATA_DIRS into an array
IFS=',' read -r -a DATA_DIR_ARRAY <<< "${DATA_DIRS}"
IFS=',' read -r -a DATA_DIR_ARRAY <<<"${DATA_DIRS}"
data_dir_count=${#DATA_DIR_ARRAY[@]}

# Stateless processes (at least 1, up to 1/4 of CPU cores)
Expand All @@ -152,13 +152,13 @@ calculate_process_numbers() {
# Storage processes (must be a multiple of the number of data directories)
local storage_processes=$((cpu_cores / 4))
[[ ${storage_processes} -lt ${data_dir_count} ]] && storage_processes=${data_dir_count}
storage_processes=$(( (storage_processes / data_dir_count) * data_dir_count ))
storage_processes=$(((storage_processes / data_dir_count) * data_dir_count ))

# Transaction processes (must be a multiple of the number of data directories)
local transaction_processes=$((cpu_cores / 8))
[[ ${transaction_processes} -lt ${min_processes} ]] && transaction_processes=${min_processes}
[[ ${transaction_processes} -lt ${data_dir_count} ]] && transaction_processes=${data_dir_count}
transaction_processes=$(( (transaction_processes / data_dir_count) * data_dir_count ))
transaction_processes=$(((transaction_processes / data_dir_count) * data_dir_count ))

# Return the values
echo "${stateless_processes} ${storage_processes} ${transaction_processes}"
Expand All @@ -175,9 +175,9 @@ function deploy_fdb() {
CLUSTER_DESC="${FDB_CLUSTER_DESC:-${FDB_CLUSTER_ID}}"

# Convert comma-separated DATA_DIRS into an array
IFS=',' read -r -a DATA_DIR_ARRAY <<< "${DATA_DIRS}"
IFS=',' read -r -a DATA_DIR_ARRAY <<<"${DATA_DIRS}"
for DIR in "${DATA_DIR_ARRAY[@]}"; do
mkdir -p "${DIR}" || handle_error "Failed to create data directory ${DIR}"
mkdir -p "${DIR}" || handle_error "Failed to create data directory ${DIR}"
done

echo -e "\tCreate fdb.cluster, coordinator: $(get_coordinators)"
Expand Down Expand Up @@ -210,13 +210,13 @@ EOF
CPU_CORES_LIMIT=${CPU_CORES_LIMIT:-1}

# Calculate number of processes based on resources and data directories
read -r stateless_processes storage_processes transaction_processes <<< "$(calculate_process_numbers "${MEMORY_LIMIT_GB}" "${CPU_CORES_LIMIT}")"
read -r stateless_processes storage_processes transaction_processes <<<"$(calculate_process_numbers "${MEMORY_LIMIT_GB}" "${CPU_CORES_LIMIT}")"

# Add stateless processes
for ((i = 0; i < stateless_processes; i++)); do
PORT=$((FDB_PORT + i))
echo "[fdbserver.${PORT}]
class = stateless" >> "${FDB_HOME}/conf/fdb.conf"
class = stateless" >>"${FDB_HOME}/conf/fdb.conf"
done

FDB_PORT=$((FDB_PORT + stateless_processes))
Expand All @@ -228,7 +228,7 @@ class = stateless" >> "${FDB_HOME}/conf/fdb.conf"
DIR_INDEX=$((i % STORAGE_DIR_COUNT))
echo "[fdbserver.${PORT}]
class = storage
datadir = ${DATA_DIR_ARRAY[${DIR_INDEX}]}/${PORT}" | tee -a "${FDB_HOME}/conf/fdb.conf" > /dev/null
datadir = ${DATA_DIR_ARRAY[${DIR_INDEX}]}/${PORT}" | tee -a "${FDB_HOME}/conf/fdb.conf" >/dev/null
done

FDB_PORT=$((FDB_PORT + storage_processes))
Expand All @@ -239,12 +239,12 @@ datadir = ${DATA_DIR_ARRAY[${DIR_INDEX}]}/${PORT}" | tee -a "${FDB_HOME}/conf/f
DIR_INDEX=$((i % STORAGE_DIR_COUNT))
echo "[fdbserver.${PORT}]
class = transaction
datadir = ${DATA_DIR_ARRAY[${DIR_INDEX}]}/${PORT}" | tee -a "${FDB_HOME}/conf/fdb.conf" > /dev/null
datadir = ${DATA_DIR_ARRAY[${DIR_INDEX}]}/${PORT}" | tee -a "${FDB_HOME}/conf/fdb.conf" >/dev/null
done

echo "[backup_agent]
command = ${FDB_HOME}/backup_agent
logdir = ${LOG_DIR}" >> "${FDB_HOME}/conf/fdb.conf"
logdir = ${LOG_DIR}" >>"${FDB_HOME}/conf/fdb.conf"

echo "Deploy FDB to: ${FDB_HOME}"
}
Expand Down
3 changes: 1 addition & 2 deletions tools/fdb/fdb_vars.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,13 @@ DATA_DIRS="/mnt/foundationdb/data1,/mnt/foundationdb/data2,/mnt/foundationdb/dat

FDB_CLUSTER_IPS="172.200.0.2,172.200.0.3,172.200.0.4"


# Define the FoundationDB home directory, which contains the fdb binaries and logs.
# default is /fdbhome and have to be absolute path.
FDB_HOME="/fdbhome"

# Define the cluster id, shoule be generated random like mktemp -u XXXXXXXX,
# have to be different for each cluster.
FDB_CLUSTER_ID=`mktemp -u XXXXXXXX`
FDB_CLUSTER_ID=$(mktemp -u XXXXXXXX)

# Define the cluster description, you 'd better to change it.
FDB_CLUSTER_DESC="mycluster"
Expand Down

0 comments on commit 2cf29c3

Please sign in to comment.