Skip to content

Commit

Permalink
support custom config the configure file items
Browse files Browse the repository at this point in the history
  • Loading branch information
cjcchen committed Oct 27, 2023
1 parent c05a9ee commit 21c9df1
Show file tree
Hide file tree
Showing 10 changed files with 48 additions and 12 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
deps/*/
scripts/deploy/config/key.conf
scripts/deploy/config_out/
deploy/kv_server/output/
.idea/
.vscode/
Expand Down
3 changes: 0 additions & 3 deletions platform/config/resdb_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,6 @@ ResDBConfig::ResDBConfig(const ResConfigData& config_data,
if (config_data_.tcp_batch_num() == 0) {
config_data_.set_tcp_batch_num(100);
}
if (!config_data_.has_recovery_enabled()) {
config_data_.set_recovery_enabled(true);
}
}

void ResDBConfig::SetConfigData(const ResConfigData& config_data) {
Expand Down
3 changes: 2 additions & 1 deletion scripts/deploy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ This directory includes deployment scripts that help to deploy ResilientDB on mu

## Deploy KV Service

Add the IP addresses and the SSH key of the machines where you wish to deploy ResilientDB replicas and client proxy in the file [config/kv_server.conf](https://github.com/msadoghi/nexres/blob/master/deploy/config/kv_server.conf).
Add the IP addresses of the machines where you wish to deploy ResilientDB replicas and client proxy in the file [config/kv_server.conf](scripts/deploy/config/kv_server.conf).
Create the ssh key file in the config "config/key.conf" and put your ssh key there (See the [key_example.conf](scripts/deploy/config/key_example.conf) as an example).
We recommend using private IP addresses of each machine.

* If you do not require any SSH key to log in to a machine, then you would need to update the scripts.
Expand Down
2 changes: 2 additions & 0 deletions scripts/deploy/config/key_example.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

key=~/.ssh/junchao.pem
1 change: 0 additions & 1 deletion scripts/deploy/config/kv_performance_server.conf
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,3 @@ iplist=(
172.31.21.196
)

key=~/.ssh/junchao.pem
1 change: 0 additions & 1 deletion scripts/deploy/config/kv_server.conf
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,3 @@ iplist=(
172.31.57.186
)

key=~/.ssh/your_key
6 changes: 6 additions & 0 deletions scripts/deploy/config/template.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"clientBatchNum": 100,
"enable_viewchange": false,
"recovery_enabled":true,
"max_client_complaint_num":10
}
2 changes: 1 addition & 1 deletion scripts/deploy/script/generate_config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,5 @@ do
idx=$(($idx+1))
done

python3 ${CONFIG_TOOLS_BIN} ./server.config ./server.config.json
python3 ${CONFIG_TOOLS_BIN} ./server.config ./server.config.json ../config/template.config
mv server.config.json server.config
8 changes: 7 additions & 1 deletion scripts/deploy/script/load_config.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@

KEY_FILE="config/key.conf"
. $1

if [ ! -f "${KEY_FILE}" ]; then
"please create \"${KEY_FILE}\" and put your ssh key in it"
exit -1
fi
. ${KEY_FILE}
32 changes: 28 additions & 4 deletions tools/generate_region_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@
from google.protobuf.json_format import Parse, ParseDict


def GenerateJsonConfig(file_name, output_file):
def GenerateJsonConfig(file_name, output_file, template_file):
config_data=ResConfigData()
config_data.enable_viewchange = False
config_data.max_client_complaint_num = 10
tmp_config={}
with open(file_name) as f:
for line in f.readlines():
Expand Down Expand Up @@ -39,5 +37,31 @@ def GenerateJsonConfig(file_name, output_file):
with open(output_file,"w") as f:
f.write(json_obj)

if template_file:
old_json = None
with open(output_file) as f:
lines=f.readlines()
for l in lines:
l=l.strip()
s=''.join(lines)
old_json=json.loads(s)

template_json = {}
with open(template_file) as f:
lines=f.readlines()
for l in lines:
l=l.strip()
s=''.join(lines)
template_json=json.loads(s)

for (k,v) in template_json.items():
old_json[k] = v

with open(output_file,"w") as f:
json.dump(old_json, f)

if __name__ == "__main__":
GenerateJsonConfig(sys.argv[1], sys.argv[2])
template_config = None
if len(sys.argv)>3:
template_config = sys.argv[3]
GenerateJsonConfig(sys.argv[1], sys.argv[2], template_config)

0 comments on commit 21c9df1

Please sign in to comment.