diff options
| author | 畅晨铭 <[email protected]> | 2022-01-14 16:07:30 +0800 |
|---|---|---|
| committer | 畅晨铭 <[email protected]> | 2022-01-14 16:07:30 +0800 |
| commit | 764790f4e14432f831fa8c12c583cdc8a0d90576 (patch) | |
| tree | eabb7ada237e257a76f285cd082a14760181d30e | |
| parent | 43ee1c3bb824acf61bb8600b37ac7490db08aeb3 (diff) | |
feat(rrpc): 引入rrpc库,在bootstrap中添加通信方式选择
| -rw-r--r-- | .gitignore | 2 | ||||
| -rw-r--r-- | .gitlab-ci.yml | 6 | ||||
| -rw-r--r-- | include/swarmkv.h | 4 | ||||
| -rw-r--r-- | src/swarmkv.c | 169 | ||||
| -rw-r--r-- | test/multi_thread.cpp | 4 | ||||
| -rw-r--r-- | test/multi_thread_1.cpp | 4 | ||||
| -rw-r--r-- | test/multi_thread_get.cpp | 4 | ||||
| -rw-r--r-- | test/multi_thread_put.cpp | 4 | ||||
| -rw-r--r-- | test/nodeA_gtest.cpp | 2 | ||||
| -rw-r--r-- | test/single_thread.cpp | 4 | ||||
| -rw-r--r-- | test/single_thread_1.cpp | 4 | ||||
| -rw-r--r-- | test/single_thread_get.cpp | 4 | ||||
| -rw-r--r-- | test/single_thread_put.cpp | 4 | ||||
| -rw-r--r-- | test/swarmkv_gtest.cpp | 32 | ||||
| -rw-r--r-- | test/swarmkv_nodeA.c | 6 | ||||
| -rw-r--r-- | test/swarmkv_nodeB.c | 12 | ||||
| -rw-r--r-- | test/swarmkv_nodeC.c | 2 | ||||
| -rw-r--r-- | test/swarmkv_rrpc_nodeA.cpp | 2 | ||||
| -rw-r--r-- | test/swarmkv_rrpc_nodeB.cpp | 2 | ||||
| -rw-r--r-- | vendor/CMakeLists.txt | 7 | ||||
| m--------- | vendor/rrpc | 0 |
21 files changed, 151 insertions, 127 deletions
@@ -43,3 +43,5 @@ build/* # Vscode .vscode/* + +.DS_Store diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b05bc05..4882f04 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -12,7 +12,7 @@ stages: .build_by_travis: before_script: - yum makecache - - yum install -y openssl-devel + - yum install -y openssl-devel rdma-core-devel - mkdir build || true tags: - share @@ -33,7 +33,7 @@ run_test: script: - cd build/ - cmake3 -DCMAKE_BUILD_TYPE=Debug .. - - make + - make -j 6 - cd test - ./swarmkv_gtest @@ -44,5 +44,5 @@ branch_build_debug: script: - cd build/ - cmake3 -DCMAKE_BUILD_TYPE=Debug .. - - make + - make -j 6 diff --git a/include/swarmkv.h b/include/swarmkv.h index 89372de..629c936 100644 --- a/include/swarmkv.h +++ b/include/swarmkv.h @@ -18,8 +18,8 @@ struct swarmkv_writeoptions; struct swarmkv_store; // config example: "node_id=1;token=49ffb3ae-8e7e-40ab-bc3f-824567e932fe,db=0"; -// bootstraps example: "self=0.0.0.0:8323;peers=192.168.0.100:8323,192.168.0.101:8323" -// bootstraps example: "self=0.0.0.0:8323;peers=tcp://192.168.0.100:8323,tcp://192.168.0.101:8323" +// bootstraps example: "proto=udp;self=0.0.0.0:8323;peers=192.168.0.100:8323,192.168.0.101:8323" +// bootstraps example: "proto=udp;self=0.0.0.0:8323;peers=tcp://192.168.0.100:8323,tcp://192.168.0.101:8323" struct swarmkv_store *swarmkv_open(const char *bootstraps, const char *config, char **err); void swarmkv_close(struct swarmkv_store *store); int swarmkv_set(struct swarmkv_store *store, const char *table, const struct swarmkv_writeoptions *options, diff --git a/src/swarmkv.c b/src/swarmkv.c index bc531c2..56dcec2 100644 --- a/src/swarmkv.c +++ b/src/swarmkv.c @@ -2382,86 +2382,100 @@ int swarmkv_parse_config_info(struct config_information *config_info, const char } -int swarmkv_parse_bootstrap_info(struct swarmkv_store *store, const char *bootstraps) -{ - // bootstraps example: "self=0.0.0.0:8323;peers=192.168.0.100:8323,192.168.0.101:8323" - int bs_info_len = strlen(bootstraps); - char *bootstrap_info = ALLOC(char, bs_info_len+1); - memcpy(bootstrap_info, bootstraps, bs_info_len); - char* bootstrap_tmp = bootstrap_info; - - char *p = NULL; - strtok_r(bootstrap_info, ";", &p); - //if(bootstrap_info == NULL || p == NULL) - if(bootstrap_info == NULL) - { - free(bootstrap_tmp); - bootstrap_tmp = NULL; - printf("Please set your ip&port and bootstrap_nodes ip&port. Format: self=ip:port;peers=ip0:port0,ip1:port1,...\n"); +/** + * Used to parse the bootstrap string, bind with a device and send meeting request to peer nodes. + * + * @param store The global data of swarmkv. + * @param bootstraps The boostrap string used to setup swarmkv. + * @return + * - Not Negative: Success and return the count of peer node. + * - Negative: Failed. + */ +static int swarmkv_parse_bootstrap_info(struct swarmkv_store *store, const char *bootstraps) { + if (bootstraps == NULL || strlen(bootstraps) == 0) { + printf( + "Please set your ip&port and bootstrap_nodes ip&port. Format: " + "\n\tproto=udp;self=ip:port;peers=ip0:port0,ip1:port1,... or proto=rdma;self=ip;peers=ip0,ip1,... \n"); return -1; } - - //self=0.0.0.0:8323 + // bootstraps example: "proto=udp;self=0.0.0.0:8323;peers=192.168.0.100:8323,192.168.0.101:8323" + uint64_t bs_info_len = strlen(bootstraps); + char *bootstrap_info = ALLOC(char, bs_info_len + 1); + strcpy(bootstrap_info, bootstraps); + + int meet_node_cnt = 0; + /** + * Transport protocol. e.g. proto=udp, proto=rdma. + */ + char *proto = NULL; + /** + * Address used to bind with. e.g. self=192.168.1.1:8323, self=192.168.1.1. + */ char *my_addr = NULL; - strtok_r(bootstrap_info, "=", &my_addr); - //0.0.0.0:8323 + /** + * IP Address use to bind with. + */ char *my_ip = NULL; - char *my_port = NULL; - my_ip = strtok_r(my_addr, ":", &my_port); - int ip_len = strlen(my_ip); - store->my_ip = ALLOC(char, ip_len+1); - memcpy(store->my_ip, my_ip, ip_len); - store->my_port = atoi(my_port); - printf("store->my_ip:%s\n", store->my_ip); - printf("store->my_port:%d\n", store->my_port); - - //create socket - store->sockfd = swarmkv_create_socket(store->my_port); - printf("store->sockfd : %d\n", store->sockfd); - - char *tmp = NULL; - char *pp = strtok_r(p, ";", &tmp); - if(pp != NULL) - { - //printf("** %s\n",p); - //peers=192.168.0.100:8323,192.168.0.101:8323 - char *peer_node_addr = NULL; - strtok_r(p, "=", &peer_node_addr); - //192.168.0.100:8323,192.168.0.101:8323 - int meet_node_cnt = 0; - - peer_node_addr = strtok_r(peer_node_addr, ",", &p); - while(peer_node_addr != NULL) - { - //192.168.0.100:8323 - char *p1 = NULL; - //printf("peer_node_addr: %s\n",peer_node_addr); - char *peer_ip = NULL; - uint16_t peer_port; - peer_ip = strtok_r(peer_node_addr, ":", &p1); - peer_port = atoi(p1); - //send meet msg to each bootstrap peer node - char *meet_req = ALLOC(char, SWARMKV_MAX_MSG_SIZE); - size_t msg_len = swarmkv_msg_pack_meet_req(store, meet_req, SWARMKV_MAX_MSG_SIZE); - assert(msg_len > 0); - swarmkv_msg_send(store->sockfd, meet_req, msg_len, peer_ip, peer_port); - free(meet_req); - meet_req = NULL; - meet_node_cnt++; - peer_node_addr = strtok_r(NULL, ",", &p); - } - if(meet_node_cnt == 0) - { - printf("error: None of the meet messages were sent successfully.\n"); - return -1; + char *next_ptr = NULL; + + // get proto string + proto = strtok_r(bootstrap_info, ";", &next_ptr); + + // get self address + my_addr = strtok_r(NULL, ";", &next_ptr); + strtok_r(my_addr, "=", &my_addr); + + if (strcpy(proto, "proto=udp")) { + char *my_port = NULL; + my_ip = strtok_r(my_addr, ":", &my_port); + uint64_t ip_len = strlen(my_ip); + store->my_ip = ALLOC(char, ip_len + 1); + memcpy(store->my_ip, my_ip, ip_len); + store->my_port = atoi(my_port); + printf("store->my_ip:%s\n", store->my_ip); + printf("store->my_port:%d\n", store->my_port); + + //create socket + store->sockfd = swarmkv_create_socket(store->my_port); + printf("store->sockfd : %d\n", store->sockfd); + + char *pp = strtok_r(NULL, ";", &next_ptr); + if (pp != NULL) { + char *peer_node_addr = NULL; + strtok_r(pp, "=", &peer_node_addr); + + peer_node_addr = strtok_r(peer_node_addr, ",", &next_ptr); + while (peer_node_addr != NULL) { + char *peer_port_str = NULL; + char *peer_ip = NULL; + uint16_t peer_port; + peer_ip = strtok_r(peer_node_addr, ":", &peer_port_str); + peer_port = atoi(peer_port_str); + // send meet msg to each bootstrap peer node + char *meet_req = ALLOC(char, SWARMKV_MAX_MSG_SIZE); + size_t msg_len = swarmkv_msg_pack_meet_req(store, meet_req, SWARMKV_MAX_MSG_SIZE); + assert(msg_len > 0); + swarmkv_msg_send(store->sockfd, meet_req, msg_len, peer_ip, peer_port); + free(meet_req); + meet_req = NULL; + meet_node_cnt++; + peer_node_addr = strtok_r(NULL, ",", &next_ptr); + } + if (meet_node_cnt == 0) { + printf("error: None of the meet messages were sent successfully.\n"); + free(bootstrap_info); + return -2; + } + //store->meet_time = clock(); + store->meet_flag = 1; } - //store->meet_time = clock(); - store->meet_flag = 1; + }else { + printf("error: Not support transport %s", proto); + free(bootstrap_info); + return -3; } - free(bootstrap_tmp); - bootstrap_tmp = NULL; - - return 1; + free(bootstrap_info); + return meet_node_cnt; } @@ -2473,6 +2487,8 @@ struct swarmkv_store *swarmkv_open(const char *bootstraps, const char *config, c uuid_t uuid; uuid_generate(uuid); uuid_unparse(uuid, store->uuid); + + int ret = 0; struct config_information *config_info = ALLOC(struct config_information, 1); if(swarmkv_parse_config_info(config_info, config) < 0) @@ -2486,9 +2502,8 @@ struct swarmkv_store *swarmkv_open(const char *bootstraps, const char *config, c store->my_node_id = config_info->node_id; printf("store->my_node_id: %d\n", store->my_node_id); - if(swarmkv_parse_bootstrap_info(store, bootstraps) < 0) - { - printf("Startup failed, please reconfigure. Format: node_id=id;token=xxxxx,db=0\n"); + if ((ret = swarmkv_parse_bootstrap_info(store, bootstraps)) < 0) { + printf("Startup failed(ret=%d), please reconfigure. Format: node_id=id;token=xxxxx,db=0\n", ret); free(store); return NULL; } diff --git a/test/multi_thread.cpp b/test/multi_thread.cpp index cf507bc..ce1189e 100644 --- a/test/multi_thread.cpp +++ b/test/multi_thread.cpp @@ -250,8 +250,8 @@ int multi_thread() char *local_ip = get_localip("eth0"); //printf("%s\n", local_ip); char *bootstraps = ALLOC(char, 128); - snprintf(bootstraps, 128, "self=%s:8323", local_ip); - //const char *bootstraps = "self=192.168.40.182:8323"; + snprintf(bootstraps, 128, "proto=udp;self=%s:8323", local_ip); + //const char *bootstraps = "proto=udp;self=192.168.40.182:8323"; const char *config = "node_id=0;token=49ffb3ae-8e7e-40ab-bc3f-824567e932fe,db=0"; char *err = NULL; struct swarmkv_store *store = NULL; diff --git a/test/multi_thread_1.cpp b/test/multi_thread_1.cpp index f0af2c9..a9a8dd5 100644 --- a/test/multi_thread_1.cpp +++ b/test/multi_thread_1.cpp @@ -244,8 +244,8 @@ int multi_thread() char *local_ip = get_localip("eth0"); //printf("%s\n", local_ip); char *bootstraps = ALLOC(char, 128); - snprintf(bootstraps, 128, "self=%s:8323", local_ip); - //const char *bootstraps = "self=192.168.40.182:8323"; + snprintf(bootstraps, 128, "proto=udp;self=%s:8323", local_ip); + //const char *bootstraps = "proto=udp;self=192.168.40.182:8323"; const char *config = "node_id=0;token=49ffb3ae-8e7e-40ab-bc3f-824567e932fe,db=0"; char *err = NULL; struct swarmkv_store *store = NULL; diff --git a/test/multi_thread_get.cpp b/test/multi_thread_get.cpp index 2bc6290..3c6379b 100644 --- a/test/multi_thread_get.cpp +++ b/test/multi_thread_get.cpp @@ -365,8 +365,8 @@ int multi_thread() char *local_ip = get_localip("eth0"); //printf("%s\n", local_ip); char *bootstraps = ALLOC(char, 128); - snprintf(bootstraps, 128, "self=%s:8323", local_ip); - //const char *bootstraps = "self=192.168.40.182:8323"; + snprintf(bootstraps, 128, "proto=udp;self=%s:8323", local_ip); + //const char *bootstraps = "proto=udp;self=192.168.40.182:8323"; const char *config = "node_id=0;token=49ffb3ae-8e7e-40ab-bc3f-824567e932fe,db=0"; char *err = NULL; struct swarmkv_store *store = NULL; diff --git a/test/multi_thread_put.cpp b/test/multi_thread_put.cpp index c2faa68..4cec00b 100644 --- a/test/multi_thread_put.cpp +++ b/test/multi_thread_put.cpp @@ -277,8 +277,8 @@ int multi_thread() char *local_ip = get_localip("eth0"); //printf("%s\n", local_ip); char *bootstraps = ALLOC(char, 128); - snprintf(bootstraps, 128, "self=%s:8323", local_ip); - //const char *bootstraps = "self=192.168.40.182:8323"; + snprintf(bootstraps, 128, "proto=udp;self=%s:8323", local_ip); + //const char *bootstraps = "proto=udp;self=192.168.40.182:8323"; const char *config = "node_id=0;token=49ffb3ae-8e7e-40ab-bc3f-824567e932fe,db=0"; char *err = NULL; struct swarmkv_store *store = NULL; diff --git a/test/nodeA_gtest.cpp b/test/nodeA_gtest.cpp index bf143b8..b03bc96 100644 --- a/test/nodeA_gtest.cpp +++ b/test/nodeA_gtest.cpp @@ -157,7 +157,7 @@ protected: virtual void SetUp() { char *bootstraps = ALLOC(char, 128); - snprintf(bootstraps, 128, "self=%s:8323", host_ip); + snprintf(bootstraps, 128, "proto=udp;self=%s:8323", host_ip); const char *config = "node_id=0;token=49ffb3ae-8e7e-40ab-bc3f-824567e932fe,db=0"; char *err = NULL; store_0 = swarmkv_open(bootstraps, config, &err); diff --git a/test/single_thread.cpp b/test/single_thread.cpp index e04d216..8525711 100644 --- a/test/single_thread.cpp +++ b/test/single_thread.cpp @@ -142,8 +142,8 @@ int single_thread() char *local_ip = get_localip("eth0"); //printf("%s\n", local_ip); char *bootstraps = ALLOC(char, 128); - snprintf(bootstraps, 128, "self=%s:8323", local_ip); - //const char *bootstraps = "self=192.168.40.182:8323"; + snprintf(bootstraps, 128, "proto=udp;self=%s:8323", local_ip); + //const char *bootstraps = "proto=udp;self=192.168.40.182:8323"; const char *config = "node_id=0;token=49ffb3ae-8e7e-40ab-bc3f-824567e932fe,db=0"; char *err = NULL; struct swarmkv_store *store = NULL; diff --git a/test/single_thread_1.cpp b/test/single_thread_1.cpp index cb31f6e..84a0fd0 100644 --- a/test/single_thread_1.cpp +++ b/test/single_thread_1.cpp @@ -141,8 +141,8 @@ int single_thread() char *local_ip = get_localip("eth0"); //printf("%s\n", local_ip); char *bootstraps = ALLOC(char, 128); - snprintf(bootstraps, 128, "self=%s:8323", local_ip); - //const char *bootstraps = "self=192.168.40.182:8323"; + snprintf(bootstraps, 128, "proto=udp;self=%s:8323", local_ip); + //const char *bootstraps = "proto=udp;self=192.168.40.182:8323"; const char *config = "node_id=0;token=49ffb3ae-8e7e-40ab-bc3f-824567e932fe,db=0"; char *err = NULL; struct swarmkv_store *store = NULL; diff --git a/test/single_thread_get.cpp b/test/single_thread_get.cpp index 5c56c49..6328cac 100644 --- a/test/single_thread_get.cpp +++ b/test/single_thread_get.cpp @@ -156,8 +156,8 @@ int single_thread() char *local_ip = get_localip("eth0"); //printf("%s\n", local_ip); char *bootstraps = ALLOC(char, 128); - snprintf(bootstraps, 128, "self=%s:8323", local_ip); - //const char *bootstraps = "self=192.168.40.182:8323"; + snprintf(bootstraps, 128, "proto=udp;self=%s:8323", local_ip); + //const char *bootstraps = "proto=udp;self=192.168.40.182:8323"; const char *config = "node_id=0;token=49ffb3ae-8e7e-40ab-bc3f-824567e932fe,db=0"; char *err = NULL; struct swarmkv_store *store = NULL; diff --git a/test/single_thread_put.cpp b/test/single_thread_put.cpp index d96326d..aec6771 100644 --- a/test/single_thread_put.cpp +++ b/test/single_thread_put.cpp @@ -143,8 +143,8 @@ int single_thread() char *local_ip = get_localip("eth0"); //printf("%s\n", local_ip); char *bootstraps = ALLOC(char, 128); - snprintf(bootstraps, 128, "self=%s:8323", local_ip); - //const char *bootstraps = "self=192.168.40.182:8323"; + snprintf(bootstraps, 128, "proto=udp;self=%s:8323", local_ip); + //const char *bootstraps = "proto=udp;self=192.168.40.182:8323"; const char *config = "node_id=0;token=49ffb3ae-8e7e-40ab-bc3f-824567e932fe,db=0"; char *err = NULL; struct swarmkv_store *store = NULL; diff --git a/test/swarmkv_gtest.cpp b/test/swarmkv_gtest.cpp index dd44ff3..8a291ab 100644 --- a/test/swarmkv_gtest.cpp +++ b/test/swarmkv_gtest.cpp @@ -169,7 +169,7 @@ protected: virtual void SetUp() { char *bootstraps = ALLOC(char, 128); - snprintf(bootstraps, 128, "self=%s:8323", host_ip); + snprintf(bootstraps, 128, "proto=udp;self=%s:8323", host_ip); const char *config = "node_id=0;token=49ffb3ae-8e7e-40ab-bc3f-824567e932fe,db=0"; char *err = NULL; store_0 = swarmkv_open(bootstraps, config, &err); @@ -310,7 +310,7 @@ protected: virtual void SetUp() { char *bootstraps = ALLOC(char, 128); - snprintf(bootstraps, 128, "self=%s:8323", host_ip); + snprintf(bootstraps, 128, "proto=udp;self=%s:8323", host_ip); const char *config = "node_id=0;token=49ffb3ae-8e7e-40ab-bc3f-824567e932fe,db=0"; char *err = NULL; store_0 = swarmkv_open(bootstraps, config, &err); @@ -541,7 +541,7 @@ protected: struct swarmkv_store *store[3]; virtual void SetUp() { - const char *bootstraps_0 = "self=192.168.40.182:1323"; + const char *bootstraps_0 = "proto=udp;self=192.168.40.182:1323"; const char *config_0 = "node_id=0;token=49ffb3ae-8e7e-40ab-bc3f-824567e932fe,db=0"; char *err_0 = NULL; store[0] = swarmkv_open(bootstraps_0, config_0, &err_0); @@ -550,7 +550,7 @@ protected: char *bootstraps = ALLOC(char, 128); char *config = ALLOC(char, 128); char *err = NULL; - snprintf(bootstraps, 128, "self=%s:%d323;peers=%s:1323", host_ip, i+1, host_ip); + snprintf(bootstraps, 128, "proto=udp;self=%s:%d323;peers=%s:1323", host_ip, i+1, host_ip); snprintf(config, 128, "node_id=%d;token=49ffb3ae-8e7e-40ab-bc3f-824567e932fe,db=0", i); store[i] = swarmkv_open(bootstraps, config, &err); } @@ -720,7 +720,7 @@ protected: struct swarmkv_store *store[16]; virtual void SetUp() { - const char *bootstraps0 = "self=192.168.40.182:1323"; + const char *bootstraps0 = "proto=udp;self=192.168.40.182:1323"; const char *config0 = "node_id=0;token=49ffb3ae-8e7e-40ab-bc3f-824567e932fe,db=0"; char *err0 = NULL; store[0] = swarmkv_open(bootstraps0, config0, &err0); @@ -729,7 +729,7 @@ protected: char *bootstraps = ALLOC(char, 128); char *config = ALLOC(char, 128); char *err = NULL; - snprintf(bootstraps, 128, "self=%s:%d;peers=%s:1323", host_ip, i+1323, host_ip); + snprintf(bootstraps, 128, "proto=udp;self=%s:%d;peers=%s:1323", host_ip, i+1323, host_ip); snprintf(config, 128, "node_id=%d;token=49ffb3ae-8e7e-40ab-bc3f-824567e932fe,db=0", i); store[i] = swarmkv_open(bootstraps, config, &err); /* @@ -975,7 +975,7 @@ protected: struct swarmkv_store *store[16]; virtual void SetUp() { - const char *bootstraps = "self=192.168.40.182:1323"; + const char *bootstraps = "proto=udp;self=192.168.40.182:1323"; const char *config = "node_id=0;token=49ffb3ae-8e7e-40ab-bc3f-824567e932fe,db=0"; char *err = NULL; store[0] = swarmkv_open(bootstraps, config, &err); @@ -1010,7 +1010,7 @@ protected: char *bootstraps = ALLOC(char, 128); char *config = ALLOC(char, 128); char *err = NULL; - snprintf(bootstraps, 128, "self=%s:%d323;peers=%s:1323", host_ip, i+1, host_ip); + snprintf(bootstraps, 128, "proto=udp;self=%s:%d323;peers=%s:1323", host_ip, i+1, host_ip); snprintf(config, 128, "node_id=%d;token=49ffb3ae-8e7e-40ab-bc3f-824567e932fe,db=0", i); store[i] = swarmkv_open(bootstraps, config, &err); } @@ -1121,11 +1121,11 @@ protected: char *err = NULL; if(i==0) { - snprintf(bootstraps, 128, "self=%s:%d323", host_ip, i+1); + snprintf(bootstraps, 128, "proto=udp;self=%s:%d323", host_ip, i+1); } else { - snprintf(bootstraps, 128, "self=%s:%d323;peers=%s:1323", host_ip, i+1, host_ip); + snprintf(bootstraps, 128, "proto=udp;self=%s:%d323;peers=%s:1323", host_ip, i+1, host_ip); } snprintf(config, 128, "node_id=%d;token=49ffb3ae-8e7e-40ab-bc3f-824567e932fe,db=0", i); store[i] = swarmkv_open(bootstraps, config, &err); @@ -1443,7 +1443,7 @@ TEST_F(SwarmkvClusterTest, PUTafterMigratingTest) //测试update invalidate生效时间 TEST(OneNode, InvalidateSpeedTest) { - const char *bootstraps = "self=192.168.40.182:8323"; + const char *bootstraps = "proto=udp;self=192.168.40.182:8323"; const char *config = "node_id=1;token=49ffb3ae-8e7e-40ab-bc3f-824567e932fe,db=0"; char *err = NULL; struct swarmkv_store *store = swarmkv_open(bootstraps, config, &err); @@ -1484,7 +1484,7 @@ protected: //静态SetUpTestCase()和TearDownTestCase()是TestCase事件,在所有测试中只执行一次,所有的testcase开始前执行SetUpTestCase,结束后执行一次TearDownTestCase static void SetUpTestCase() { - const char *bootstraps = "self=172.16.225.2:8323;peers=172.16.225.2:6323,172.16.225.2:7323,172.16.225.2:18323"; + const char *bootstraps = "proto=udp;self=172.16.225.2:8323;peers=172.16.225.2:6323,172.16.225.2:7323,172.16.225.2:18323"; const char *config = "node_id=0;token=49ffb3ae-8e7e-40ab-bc3f-824567e932fe,db=0"; char *err = NULL; store = swarmkv_open(bootstraps, config, &err); @@ -1500,22 +1500,22 @@ protected: /* TEST(SwarmkvClusterOpenTest, ThreeNode) { - const char *bootstraps_0 = "self=172.16.225.2:8323"; + const char *bootstraps_0 = "proto=udp;self=172.16.225.2:8323"; const char *config_0 = "node_id=0;token=49ffb3ae-8e7e-40ab-bc3f-824567e932fe,db=0"; char *err_0 = NULL; struct swarmkv_store *store_0 = NULL; - const char *bootstraps_1 = "self=172.16.225.2:18323;peers=172.16.225.2:8323"; + const char *bootstraps_1 = "proto=udp;self=172.16.225.2:18323;peers=172.16.225.2:8323"; const char *config_1 = "node_id=1;token=49ffb3ae-8e7e-40ab-bc3f-824567e932fc,db=0"; char *err_1 = NULL; struct swarmkv_store *store_1 = NULL; - const char *bootstraps_2 = "self=172.16.225.2:6323;peers=172.16.225.2:8323"; + const char *bootstraps_2 = "proto=udp;self=172.16.225.2:6323;peers=172.16.225.2:8323"; const char *config_2 = "node_id=2;token=49ffb3ae-8e7e-40ab-bc3f-824567e932fb,db=0"; char *err_2 = NULL; struct swarmkv_store *store_2 = NULL; - const char *bootstraps_3 = "self=172.16.225.2:7323;peers=172.16.225.2:8323"; + const char *bootstraps_3 = "proto=udp;self=172.16.225.2:7323;peers=172.16.225.2:8323"; const char *config_3 = "node_id=3;token=49ffb3ae-8e7e-40ab-bc3f-824567e932fa,db=0"; char *err_3 = NULL; struct swarmkv_store *store_3 = NULL; diff --git a/test/swarmkv_nodeA.c b/test/swarmkv_nodeA.c index 7148ebc..d79ec30 100644 --- a/test/swarmkv_nodeA.c +++ b/test/swarmkv_nodeA.c @@ -137,7 +137,7 @@ void *put_test(void *arg) int multi_thread() { - const char *bootstraps = "self=192.168.40.182:8323"; + const char *bootstraps = "proto=udp;self=192.168.40.182:8323"; const char *config = "node_id=0;token=49ffb3ae-8e7e-40ab-bc3f-824567e932fe,db=0"; char *err = NULL; struct swarmkv_store *store = NULL; @@ -187,7 +187,7 @@ int main(int argc, char **argv) { multi_thread(); /* - const char *bootstraps = "self=192.168.40.182:8323"; + const char *bootstraps = "proto=udp;self=192.168.40.182:8323"; const char *config = "node_id=0;token=49ffb3ae-8e7e-40ab-bc3f-824567e932fe,db=0"; char *err = NULL; struct swarmkv_store *store = NULL; @@ -308,7 +308,7 @@ int main(int argc, char **argv) /* struct init_infomation init_info; - init_info.bootstraps = "self=172.16.225.2:8323;peers=172.16.225.2:6323,172.16.225.2:7323,172.16.225.2:18323"; + init_info.bootstraps = "proto=udp;self=172.16.225.2:8323;peers=172.16.225.2:6323,172.16.225.2:7323,172.16.225.2:18323"; init_info.config = "node_id=0;token=49ffb3ae-8e7e-40ab-bc3f-824567e932fe,db=0"; init_info.err = NULL; */ diff --git a/test/swarmkv_nodeB.c b/test/swarmkv_nodeB.c index 73733ab..eb704d4 100644 --- a/test/swarmkv_nodeB.c +++ b/test/swarmkv_nodeB.c @@ -8,10 +8,10 @@ int main(int argc, char **argv) { //test(); //printf("%d\n",argc); - //const char *bootstraps = "self=172.16.225.2:18323;peers=172.16.225.2:6323,172.16.225.2:7323,172.16.225.2:8323"; + //const char *bootstraps = "proto=udp;self=172.16.225.2:18323;peers=172.16.225.2:6323,172.16.225.2:7323,172.16.225.2:8323"; - const char *bootstraps = "self=172.16.225.2:18323;peers=172.16.225.2:8323"; + const char *bootstraps = "proto=udp;self=172.16.225.2:18323;peers=172.16.225.2:8323"; const char *config = "node_id=1;token=49ffb3ae-8e7e-40ab-bc3f-824567e932fe,db=0"; char *err = NULL; @@ -28,22 +28,22 @@ int main(int argc, char **argv) swarmkv_close(store); /* - const char *bootstraps_0 = "self=172.16.225.2:8323;peers=172.16.225.2:9323"; + const char *bootstraps_0 = "proto=udp;self=172.16.225.2:8323;peers=172.16.225.2:9323"; const char *config_0 = "node_id=0;token=49ffb3ae-8e7e-40ab-bc3f-824567e932fe,db=0"; char *err_0 = NULL; struct swarmkv_store *store_0 = NULL; - const char *bootstraps_1 = "self=172.16.225.2:18323;peers=172.16.225.2:8323"; + const char *bootstraps_1 = "proto=udp;self=172.16.225.2:18323;peers=172.16.225.2:8323"; const char *config_1 = "node_id=1;token=49ffb3ae-8e7e-40ab-bc3f-824567e932fc,db=0"; char *err_1 = NULL; struct swarmkv_store *store_1 = NULL; - const char *bootstraps_2 = "self=172.16.225.2:6323;peers=172.16.225.2:8323"; + const char *bootstraps_2 = "proto=udp;self=172.16.225.2:6323;peers=172.16.225.2:8323"; const char *config_2 = "node_id=2;token=49ffb3ae-8e7e-40ab-bc3f-824567e932fb,db=0"; char *err_2 = NULL; struct swarmkv_store *store_2 = NULL; - const char *bootstraps_3 = "self=172.16.225.2:7323;peers=172.16.225.2:8323"; + const char *bootstraps_3 = "proto=udp;self=172.16.225.2:7323;peers=172.16.225.2:8323"; const char *config_3 = "node_id=3;token=49ffb3ae-8e7e-40ab-bc3f-824567e932fa,db=0"; char *err_3 = NULL; struct swarmkv_store *store_3 = NULL; diff --git a/test/swarmkv_nodeC.c b/test/swarmkv_nodeC.c index 5d4e582..06857e9 100644 --- a/test/swarmkv_nodeC.c +++ b/test/swarmkv_nodeC.c @@ -7,7 +7,7 @@ int main(int argc, char **argv) { //printf("%d\n",argc); - const char *bootstraps = "self=172.16.225.2:9323;peers=172.16.225.2:8323"; + const char *bootstraps = "proto=udp;self=172.16.225.2:9323;peers=172.16.225.2:8323"; const char *config = "node_id=4;token=49ffb3ae-8e7e-40ab-bc3f-824567e932fe,db=0"; char *err = NULL; diff --git a/test/swarmkv_rrpc_nodeA.cpp b/test/swarmkv_rrpc_nodeA.cpp index c17b0a4..ff5977e 100644 --- a/test/swarmkv_rrpc_nodeA.cpp +++ b/test/swarmkv_rrpc_nodeA.cpp @@ -35,7 +35,7 @@ class SwarmkvLocalTest : public testing::Test { struct swarmkv_store *store_0 = NULL; virtual void SetUp() { char *bootstraps = ALLOC(char, 128); - snprintf(bootstraps, 128, "self=%s:8323", host_ip); + snprintf(bootstraps, 128, "proto=udp;self=%s:8323", host_ip); const char *config = "node_id=0;token=49ffb3ae-8e7e-40ab-bc3f-824567e932fe,db=0"; char *err = NULL; store_0 = swarmkv_open(bootstraps, config, &err); diff --git a/test/swarmkv_rrpc_nodeB.cpp b/test/swarmkv_rrpc_nodeB.cpp index 30080d2..00d02a7 100644 --- a/test/swarmkv_rrpc_nodeB.cpp +++ b/test/swarmkv_rrpc_nodeB.cpp @@ -17,7 +17,7 @@ class SwarmkvLocalTest : public testing::Test { struct swarmkv_store *store_0 = NULL; virtual void SetUp() { char *bootstraps = ALLOC(char, 128); - snprintf(bootstraps, 128, "self=%s:8323;peers=10.1.1.1:8323", host_ip); + snprintf(bootstraps, 128, "proto=udp;self=%s:8323;peers=10.1.1.1:8323", host_ip); const char *config = "node_id=1;token=49ffb3ae-8e7e-40ab-bc3f-824567e932fe,db=0"; char *err = NULL; store_0 = swarmkv_open(bootstraps, config, &err); diff --git a/vendor/CMakeLists.txt b/vendor/CMakeLists.txt index 4875661..5653743 100644 --- a/vendor/CMakeLists.txt +++ b/vendor/CMakeLists.txt @@ -81,3 +81,10 @@ add_dependencies(fieldstate-static FieldStat) set_property(TARGET fieldstate-static PROPERTY IMPORTED_LOCATION ${VENDOR_BUILD}/lib/libMESA_field_stat2.a) +#rrpc +ExternalProject_Add(RRPC PREFIX rrpc-build + SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/rrpc + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${VENDOR_BUILD} -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}) +add_library(rrpc-static STATIC IMPORTED GLOBAL) +add_dependencies(rrpc-static RRPC) +set_property(TARGET rrpc-static PROPERTY IMPORTED_LOCATION ${VENDOR_BUILD}/lib/librrpc-lib.a)
\ No newline at end of file diff --git a/vendor/rrpc b/vendor/rrpc new file mode 160000 +Subproject 6505dfcbf3e883f6fbaea6f3c4f24279029821b |
