Commit 7bdcfe04 authored by Mosaical's avatar Mosaical

20210601

parent 1851b81b
No preview for this file type
{ {
"ipv4Addresses": [ "ipv4Addresses": [
"192.168.0.0" "127.0.0.1:6666"
], ],
"nfInstanceId": "duklAMF", "nfInstanceId": "duklAMF",
"nfServices": [ "nfServices": [
......
No preview for this file type
{ {
"ipv4Addresses": [ "ipv4Addresses": [
"192.168.211.67:8080" "127.0.0.1:8080"
], ],
"nfInstanceId": "liuyuSMF", "nfInstanceId": "liuyuSMF",
"nfStatus": "REGISTERED", "nfStatus": "REGISTERED",
......
...@@ -3,6 +3,6 @@ ...@@ -3,6 +3,6 @@
"192.168.211.67:8080" "192.168.211.67:8080"
], ],
"nfInstanceId": "liuyuSMF17", "nfInstanceId": "liuyuSMF17",
"nfStatus": "SUSPENDED", "nfStatus": "REGISTERED",
"nfType": "SMF" "nfType": "SMF"
} }
{
"ipv4Addresses": [
"192.168.211.67:8080"
],
"nfInstanceId": "liuyuSMF18",
"nfStatus": "REGISTERED",
"nfType": "SMF"
}
{
"ipv4Addresses": [
"192.168.211.67:8080"
],
"nfInstanceId": "liuyuSMF19",
"nfStatus": "REGISTERED",
"nfType": "SMF"
}
{ {
"ipv4Addresses": [ "ipv4Addresses": [
"192.168.211.67:8080" "127.0.0.1:8080"
], ],
"nfInstanceId": "liuyuSMF2", "nfInstanceId": "liuyuSMF2",
"nfStatus": "REGISTERED", "nfStatus": "REGISTERED",
......
{
"ipv4Addresses": [
"192.168.211.67:8080"
],
"nfInstanceId": "liuyuSMF20",
"nfStatus": "REGISTERED",
"nfType": "SMF"
}
{
"ipv4Addresses": [
"192.168.211.67:8080"
],
"nfInstanceId": "liuyuSMF21",
"nfStatus": "REGISTERED",
"nfType": "SMF"
}
{
"ipv4Addresses": [
"192.168.211.67:8080"
],
"nfInstanceId": "liuyuSMF22",
"nfStatus": "REGISTERED",
"nfType": "SMF"
}
{
"ipv4Addresses": [
"192.168.211.67:8080"
],
"nfInstanceId": "liuyuSMF23",
"nfStatus": "REGISTERED",
"nfType": "SMF"
}
{
"ipv4Addresses": [
"192.168.211.67:8080"
],
"nfInstanceId": "liuyuSMF24",
"nfStatus": "SUSPENDED",
"nfType": "SMF"
}
{
"ipv4Addresses": [
"192.168.211.67:8080"
],
"nfInstanceId": "liuyuSMF25",
"nfStatus": "SUSPENDED",
"nfType": "SMF"
}
{
"ipv4Addresses": [
"192.168.211.67:8080"
],
"nfInstanceId": "liuyuSMF26",
"nfStatus": "SUSPENDED",
"nfType": "SMF"
}
{
"ipv4Addresses": [
"192.168.211.67:8080"
],
"nfInstanceId": "liuyuSMF27",
"nfStatus": "REGISTERED",
"nfType": "SMF"
}
{
"ipv4Addresses": [
"192.168.211.67:8080"
],
"nfInstanceId": "liuyuSMF28",
"nfStatus": "REGISTERED",
"nfType": "SMF"
}
{
"ipv4Addresses": [
"192.168.211.67:8080"
],
"nfInstanceId": "liuyuSMF29",
"nfStatus": "SUSPENDED",
"nfType": "SMF"
}
{ {
"ipv4Addresses": [ "ipv4Addresses": [
"192.168.211.67:8080" "127.0.0.1:8080"
], ],
"nfInstanceId": "liuyuSMF3", "nfInstanceId": "liuyuSMF3",
"nfStatus": "REGISTERED", "nfStatus": "REGISTERED",
......
...@@ -231,9 +231,14 @@ void NFInstanceIDDocumentApiImpl::register_nf_instance(const std::string &nfInst ...@@ -231,9 +231,14 @@ void NFInstanceIDDocumentApiImpl::register_nf_instance(const std::string &nfInst
} }
threadData[nfInstanceIdLength] = '\0'; threadData[nfInstanceIdLength] = '\0';
for(int i = 0; i <= nfInstanceIdLength; i++ ){
std::cout << "threadData is : " << threadData[i] << std::endl;
}
pthread_t thread_id; pthread_t thread_id;
//pthread_create( &thread_id, NULL, print_message, NULL ); //pthread_create( &thread_id, NULL, print_message, NULL );
pthread_create( &thread_id, NULL, print_message, &threadData );
pthread_create( &thread_id, NULL, print_message, (void*)&nfInstanceId);
pthread_detach(thread_id); pthread_detach(thread_id);
//sleep(1); //sleep(1);
printf("Leave main thread!\n"); printf("Leave main thread!\n");
......
...@@ -69,17 +69,26 @@ static void* print_message( void* data ) ...@@ -69,17 +69,26 @@ static void* print_message( void* data )
// } // }
// pthread_exit(0) ;//pthread_exit时自动会被释放 // pthread_exit(0) ;//pthread_exit时自动会被释放
int flag = 1; int flag = 1;
std::string dataString = (char*)data; std::string dataString = *((std::string*)data);
//std::cout << "data is :" << dataString <<std::endl;(已成功取出) std::cout << "data is :" << *((std::string*)data) <<std::endl;//(已成功取出)
std::string heartBeatString;
zookeeperClient zooK;
bool atest = zooK.connect2ZKServer("192.168.211.128:2181");
utility::zk_cpp* zk;
zk = zooK.getZk();
std::string path = "/HeartBeat";
while (1) while (1)
{ {
utility::zoo_rc ret = zk->get_node(path.c_str(), heartBeatString, nullptr, true);
get2rdNodeMessage *Get2rdNodeMessage = new get2rdNodeMessage; //get2rdNodeMessage *Get2rdNodeMessage = new get2rdNodeMessage;
std::string path = "/HeartBeat"; //std::string path = "/HeartBeat";
std::string heartBeatString = Get2rdNodeMessage->getNodeMessage(path); //std::string heartBeatString = Get2rdNodeMessage->getNodeMessage(path);
free(Get2rdNodeMessage); //free(Get2rdNodeMessage);
if(heartBeatString == dataString){ if(heartBeatString == dataString){
//将心跳zookeeper归零 //将心跳zookeeper归零
std::cout << "进入归零程序!" << std::endl;
zookeeperClient zooK; zookeeperClient zooK;
bool atest = zooK.connect2ZKServer("192.168.211.128:2181"); bool atest = zooK.connect2ZKServer("192.168.211.128:2181");
utility::zk_cpp* zk; utility::zk_cpp* zk;
...@@ -92,15 +101,15 @@ static void* print_message( void* data ) ...@@ -92,15 +101,15 @@ static void* print_message( void* data )
flag = 0; flag = 0;
usleep(1000 * 1000); usleep(100 * 1000);
printf("thread1 running...!\n"); printf("thread1 running...!\n");
}else{ }else{
usleep(1000 * 1000); usleep(100 * 1000);
printf("thread1 running...!\n"); printf("thread1 running...!\n");
flag++; flag++;
if(flag>=6) break; if(flag>=60) break;
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment