-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmemd.c
76 lines (62 loc) · 2.34 KB
/
memd.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/*
* Copyright 2023 Regents of Nanjing University of Aeronautics and Astronautics and
* Hohai University, Miao Cai <[email protected]> and Junru Shen <[email protected]>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* Memory Daemon (memd) Running at Memory Node
*/
#define _GNU_SOURCE
#include <zookeeper/zookeeper.h>
#include <pthread.h>
#include <unistd.h>
#include "ethanefs.h"
#include "ethane.h"
#include "debug.h"
#include "third_party/argparse/argparse.h"
int main(int argc, const char **argv) {
const char *zookeeper_ip = "localhost:2181";
const char *memd_config_path = NULL;
ethanefs_memd_config_t *config;
zhandle_t *zh;
struct argparse_option options[] = {
OPT_HELP(),
OPT_GROUP("Basic options"),
OPT_STRING('z', "zookeeper", &zookeeper_ip, "ZooKeeper server IP address and port"),
OPT_STRING('c', "config", &memd_config_path, "Memory Daemon (memd) config file path"),
OPT_END(),
};
struct argparse argparse;
argparse_init(&argparse, options, NULL, 0);
argparse_describe(&argparse, "\nmemd", "\nMemory Daemon (memd) for ETHANE");
argparse_parse(&argparse, argc, argv);
if (unlikely(!memd_config_path)) {
pr_err("memd config file not specified");
return -1;
}
zoo_set_debug_level(0);
zh = zookeeper_init(zookeeper_ip, NULL, 100000, NULL, NULL, 0);
if (unlikely(!zh)) {
pr_err("failed to connect to ZooKeeper server");
return -1;
}
config = ethanefs_config_parse_memd(memd_config_path);
if (unlikely(IS_ERR(config))) {
pr_err("failed to parse memd config file");
return -1;
}
pthread_setname_np(pthread_self(), "ethane-md");
reg_debug_sig_handler();
ethanefs_mem_daemon(zh, config);
}