Skip to content

Commit 8365ba5

Browse files
rock-gitchuandew
authored andcommitted
[feat][mdsv2] Support toml config.
1 parent f31d134 commit 8365ba5

30 files changed

+358
-122
lines changed
File renamed without changes.

conf/dingo-mdsv2.template.toml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
[server]
2+
id = $INSTANCE_ID$
3+
addr = "$SERVER_HOST$:$SERVER_PORT$"
4+
5+
[server.service.meta]
6+
read_worker_num = 128
7+
read_worker_max_pending_num = 1024
8+
read_worker_use_pthread = false
9+
10+
write_worker_num = 128
11+
write_worker_max_pending_num = 1024
12+
write_worker_use_pthread = false
13+
14+
15+
[log]
16+
level = "INFO"
17+
path = "$BASE_PATH$/log"
18+
19+
20+
[crontab]
21+
heartbeat_interval_s = 5
22+
fsinfosync_interval_s = 10
23+
mdsmonitor_interval_s = 5
24+
quota_sync_interval_s = 6
25+
gc_interval_s = 60

conf/mdsv2.conf

Lines changed: 0 additions & 5 deletions
This file was deleted.

conf/mdsv2.template.conf

Lines changed: 0 additions & 5 deletions
This file was deleted.

dev-scripts/deploy.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,18 +66,18 @@ function deploy_server() {
6666

6767
if [ "${FLAGS_replace_conf}" == "0" ]; then
6868
# conf file
69-
dist_conf="${dstpath}/conf/${role}.conf"
70-
cp $srcpath/conf/${role}.template.conf $dist_conf
69+
dist_conf="${dstpath}/conf/${server_name}.toml"
70+
cp $srcpath/conf/${server_name}.template.toml $dist_conf
7171

7272
sed -i 's,\$INSTANCE_ID\$,'"$instance_id"',g' $dist_conf
7373
sed -i 's,\$SERVER_HOST\$,'"$SERVER_HOST"',g' $dist_conf
7474
sed -i 's,\$SERVER_PORT\$,'"$server_port"',g' $dist_conf
7575
sed -i 's,\$BASE_PATH\$,'"$dstpath"',g' $dist_conf
7676

7777
# gflags file
78-
if [ -f $srcpath/conf/${role}.gflags ]
78+
if [ -f $srcpath/conf/${server_name}.gflags ]
7979
then
80-
cp $srcpath/conf/${role}.gflags $dstpath/conf/gflags
80+
cp $srcpath/conf/${server_name}.gflags $dstpath/conf/
8181
fi
8282

8383
# coor_list file

dev-scripts/start.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ function start_server() {
8383
server_name="dingo-${role}"
8484
echo "start server: ${root_dir}/bin/${server_name}"
8585

86-
nohup ${root_dir}/bin/${server_name} 2>&1 >./log/out &
86+
nohup ${root_dir}/bin/${server_name} --conf=${root_dir}/conf/${server_name}.toml 2>&1 >./log/out &
8787
}
8888

8989

dev-scripts/test.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ def threaded_create_structure(base_path, depth, num_threads=5, num_dirs=10, num_
7171
with ThreadPoolExecutor(max_workers=num_threads) as executor:
7272
futures = []
7373
for i in range(num_threads):
74-
thread_base_path = f"{base_path}_thread_{i}"
74+
thread_base_path = f"{base_path}/thread_{i}"
75+
create_directory(thread_base_path) # 确保线程的基础路径存在
7576
futures.append(executor.submit(create_nested_structure, thread_base_path, depth, num_dirs, num_files))
7677

7778
for future in futures:
@@ -83,7 +84,7 @@ def main():
8384
# 解析命令行参数
8485
parser = argparse.ArgumentParser(description="Test script for creating and deleting nested directory structures.")
8586
parser.add_argument('--path', type=str, default='test_structure', help='Base path for the nested structure')
86-
parser.add_argument('--depth', type=int, default=3, help='Depth of the nested structure')
87+
parser.add_argument('--depth', type=int, default=5, help='Depth of the nested structure')
8788
parser.add_argument('--threads', type=int, default=5, help='Number of threads to use for creating structure')
8889
args = parser.parse_args()
8990

@@ -92,9 +93,11 @@ def main():
9293
# 运行各种测试
9394
base_path = args.path
9495
depth = args.depth
96+
num_threads = args.threads
9597
print(f"Creating nested structure at {base_path} with depth {depth}...")
9698

97-
create_nested_structure(base_path, depth, num_dirs=5, num_files=1000)
99+
# create_nested_structure(base_path, depth, num_dirs=5, num_files=1000)
100+
threaded_create_structure(base_path, depth, num_threads, num_dirs=5, num_files=1000)
98101

99102
print("\ntest finish!")
100103

src/mdsv2/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ target_link_libraries(mdsv2_lib
4040
mdsv2_background
4141
mdsv2_statistics
4242

43+
dingofs_options
4344
dingofs_utils
4445

4546
absl::log_internal_message

src/mdsv2/common/crontab.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ namespace mdsv2 {
3131

3232
struct CrontabConfig {
3333
std::string name;
34-
int32_t interval;
34+
uint32_t interval;
3535
bool async;
3636
std::function<void(void*)> funcer;
3737
};

src/mdsv2/common/runnable.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,11 @@ class SimpleWorkerSet : public WorkerSet {
259259
return std::make_shared<SimpleWorkerSet>(name, worker_num, max_pending_task_count, use_pthread, is_inplace_run);
260260
}
261261

262+
static WorkerSetUPtr NewUnique(std::string name, uint32_t worker_num, uint32_t max_pending_task_count,
263+
bool use_pthread, bool is_inplace_run) {
264+
return std::make_unique<SimpleWorkerSet>(name, worker_num, max_pending_task_count, use_pthread, is_inplace_run);
265+
}
266+
262267
bool Init() override;
263268
void Destroy() override;
264269

0 commit comments

Comments
 (0)