Commit d2c6a887 authored by Mosaical's avatar Mosaical

20201102

parent 93bf8e9f
......@@ -16,6 +16,10 @@
#include <string>
#include "/home/root/nrf2/json-include/json/json.h"
#include "NFProfile.h"
#include "discoverInformation.h"
#include <stdbool.h>
#include <regex>
#include "inforMatch.h"
namespace org {
namespace openapitools {
namespace server {
......@@ -36,8 +40,10 @@ void NFInstanceIDDocumentApi::init() {
void NFInstanceIDDocumentApi::setupRoutes() {
using namespace Pistache::Rest;
//此处控制接收的http信息的格式
const std::string baseGET = "/nnrf-disc/v1";
Routes::Delete(*router, base + "/nf-instances/:nfInstanceID", Routes::bind(&NFInstanceIDDocumentApi::deregister_nf_instance_handler, this));
Routes::Get(*router, base + "/nf-instances/:nfInstanceID", Routes::bind(&NFInstanceIDDocumentApi::get_nf_instance_handler, this));
Routes::Get(*router, baseGET + "/nf-instances/:nfInstanceID", Routes::bind(&NFInstanceIDDocumentApi::get_nf_instance_handler, this));
Routes::Put(*router, base + "/nf-instances/:nfInstanceID", Routes::bind(&NFInstanceIDDocumentApi::register_nf_instance_handler, this));
Routes::Patch(*router, base + "/nf-instances/:nfInstanceID", Routes::bind(&NFInstanceIDDocumentApi::update_nf_instance_handler, this));
......@@ -48,7 +54,7 @@ void NFInstanceIDDocumentApi::setupRoutes() {
void NFInstanceIDDocumentApi::deregister_nf_instance_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response) {
// Getting the path params
auto nfInstanceID = request.param(":nfInstanceID").as<std::string>();
try {
this->deregister_nf_instance(nfInstanceID, response);
} catch (nlohmann::detail::exception &e) {
......@@ -69,7 +75,93 @@ void NFInstanceIDDocumentApi::deregister_nf_instance_handler(const Pistache::Res
void NFInstanceIDDocumentApi::get_nf_instance_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response) {
// Getting the path params
auto nfInstanceID = request.param(":nfInstanceID").as<std::string>();
std::cout << "get_nf_instance_handler启动了" << std::endl;
std::cout << "nfInstanceID是: " << nfInstanceID << std::endl;
NFType nFType;
nFType.nfType = "已赋值!";
auto a = request.query();
//test
/* std::stringstream streamBuf;
auto query = request.query();
streamBuf << request.method() << " ";
streamBuf << '/';
streamBuf << query.as_str();
streamBuf << " HTTP/1.1" << Pistache::Http::crlf;
std::string value;
while(streamBuf>>value){
std::cout << value << " ";
}
auto c = query.get("targetNfType");
*/
//testend
//std::cout << "a 是:" << a << std::endl;
std::cout << typeid(a).name() << std::endl;
const std::string aS = a.as_str();
/*
* 定义显性信息对象
*/
discoverInformation DiscoverInformation;
auto query = request.query();
auto targetNfType = query.get("targetNfType");
std::string targetNfTypeString = targetNfType.get();
std::cout << "targetNfType是:" << targetNfTypeString << std::endl;
bool flagTargetNfType = DiscoverInformation.setOneInformation("targetNfType",targetNfTypeString);//显性信息对象赋值
auto requesterNfType = query.get("requesterNfType");
std::string requesterNfTypeString = requesterNfType.get();
std::cout << "requesterNfType是:" << requesterNfTypeString << std::endl;
/*
* 其他信息赋值
*/
bool queryTest1 = query.has("ANYINFORMATION1");
if(queryTest1 == 1){
auto ANYINFORMATION1 = query.get("ANYINFORMATION1");
std::string ANYINFORMATION1String = ANYINFORMATION1.get();
std::cout << "ANYINFORMATION1是:" << ANYINFORMATION1String <<std::endl;
bool flagANYINFORMATION1 = DiscoverInformation.setOneInformation("ANYINFORMATION1",ANYINFORMATION1String);//显性信息对象赋值
}
bool queryTest2 = query.has("ANYINFORMATION2");
if(queryTest2 == 1){
auto ANYINFORMATION2 = query.get("ANYINFORMATION2");
std::string ANYINFORMATION2String = ANYINFORMATION2.get();
std::cout << "ANYINFORMATION2是:" << ANYINFORMATION2String <<std::endl;
bool flagANYINFORMATION2 = DiscoverInformation.setOneInformation("ANYINFORMATION2",ANYINFORMATION2String);//显性信息对象赋值
}
//===============
/*
* 显性信息对象转json
*/
nlohmann::json jsonInformation = DiscoverInformation.toJson();
std::cout << jsonInformation << std::endl;
std::string testJ = jsonInformation.dump();
std::cout << testJ << std::endl;
/*
* 取出某二级节点下的显性信息
*/
std::string instancePath = "/AMF/duklAMF";//可以更改
inforMatch InforMatch;
bool restBool = InforMatch.ifIsMatching(instancePath, jsonInformation);//判断实例duklAMF是否是要寻找的
if(restBool) printf("匹配成功!");
else printf("匹配失败!");
std::cout << aS << std::endl;
std::cout << nFType.nfType << std::endl;
try {
this->get_nf_instance(nfInstanceID, response);
} catch (nlohmann::detail::exception &e) {
......@@ -90,6 +182,8 @@ void NFInstanceIDDocumentApi::register_nf_instance_handler(const Pistache::Rest:
// Getting the path params
auto nfInstanceID = request.param(":nfInstanceID").as<std::string>();
printf("request body : %s\n",request.body().c_str());
printf("=================================================");
std::cout << "nfInstanceID::" << nfInstanceID << std::endl;
// Getting the body param
NFProfile nFProfile;
......
{
"nfInstanceId": "AMF",
"nfStatus": "REGISTERED",
"nfType": "AMF"
}
{
"nfInstanceId": "AMFInstance1",
"nfStatus": "REGISTERED",
"nfType": "AMF"
}
{
"nfInstanceId": "AMFInstanceID1",
"nfStatus": "REGISTERED",
"nfType": "AMF"
}
{
"nfInstanceId": "AMFInstanceID2",
"nfStatus": "REGISTERED",
"nfType": "AMF"
}
set(CMAKE_HOST_SYSTEM "Linux-4.15.0-112-generic")
set(CMAKE_HOST_SYSTEM "Linux-4.15.0-118-generic")
set(CMAKE_HOST_SYSTEM_NAME "Linux")
set(CMAKE_HOST_SYSTEM_VERSION "4.15.0-112-generic")
set(CMAKE_HOST_SYSTEM_VERSION "4.15.0-118-generic")
set(CMAKE_HOST_SYSTEM_PROCESSOR "x86_64")
set(CMAKE_SYSTEM "Linux-4.15.0-112-generic")
set(CMAKE_SYSTEM "Linux-4.15.0-118-generic")
set(CMAKE_SYSTEM_NAME "Linux")
set(CMAKE_SYSTEM_VERSION "4.15.0-112-generic")
set(CMAKE_SYSTEM_VERSION "4.15.0-118-generic")
set(CMAKE_SYSTEM_PROCESSOR "x86_64")
set(CMAKE_CROSSCOMPILING "FALSE")
......
This diff is collapsed.
......@@ -101,6 +101,8 @@ string
-
vector
-
discoverInformation.h
../impl/discoverInformation.h
../impl/NFInstancesStoreApiImpl.h
pistache/endpoint.h
......@@ -976,6 +978,32 @@ vector
sstream
-
../zkH/discoverInformation.h
string
-
stdio.h
-
nlohmann/json.hpp
-
stdbool.h
-
../zkH/inforMatch.h
stdio.h
-
stdbool.h
-
string
-
iostream
-
nlohmann/json.hpp
-
zookeeperClient.h
../zkH/zookeeperClient.h
regex
-
../zkH/zk_cpp.h
stdint.h
-
......@@ -1059,6 +1087,14 @@ string
-
NFProfile.h
/home/root/nrf2/api/NFProfile.h
discoverInformation.h
/home/root/nrf2/api/discoverInformation.h
stdbool.h
-
regex
-
inforMatch.h
/home/root/nrf2/api/inforMatch.h
/home/root/nrf2/api/NFInstanceIDDocumentApi.h
pistache/http.h
......@@ -1187,6 +1223,8 @@ string
-
vector
-
discoverInformation.h
/home/root/nrf2/impl/discoverInformation.h
/home/root/nrf2/impl/NFInstancesStoreApiImpl.cpp
NFInstancesStoreApiImpl.h
......@@ -2694,11 +2732,51 @@ vector
sstream
-
/home/root/nrf2/zkH/discoverInformation.cpp
discoverInformation.h
/home/root/nrf2/zkH/discoverInformation.h
stdio.h
-
string
-
/home/root/nrf2/zkH/discoverInformation.h
string
-
stdio.h
-
nlohmann/json.hpp
-
stdbool.h
-
/home/root/nrf2/zkH/inforMatch.cpp
inforMatch.h
/home/root/nrf2/zkH/inforMatch.h
/home/root/nrf2/zkH/inforMatch.h
stdio.h
-
stdbool.h
-
string
-
iostream
-
nlohmann/json.hpp
-
zookeeperClient.h
/home/root/nrf2/zkH/zookeeperClient.h
regex
-
/home/root/nrf2/zkH/zk_cpp.cpp
zk_cpp.h
/home/root/nrf2/zkH/zk_cpp.h
zookeeper.h
/home/root/nrf2/zkH/zookeeper.h
iostream
-
/home/root/nrf2/zkH/zk_cpp.h
stdint.h
......
......@@ -111,6 +111,8 @@ set(CMAKE_DEPENDS_CHECK_CXX
"/home/root/nrf2/model/VendorSpecificFeature.cpp" "/home/root/nrf2/build/CMakeFiles/api-server.dir/model/VendorSpecificFeature.cpp.o"
"/home/root/nrf2/model/WAgfInfo.cpp" "/home/root/nrf2/build/CMakeFiles/api-server.dir/model/WAgfInfo.cpp.o"
"/home/root/nrf2/zkH/Register.cpp" "/home/root/nrf2/build/CMakeFiles/api-server.dir/zkH/Register.cpp.o"
"/home/root/nrf2/zkH/discoverInformation.cpp" "/home/root/nrf2/build/CMakeFiles/api-server.dir/zkH/discoverInformation.cpp.o"
"/home/root/nrf2/zkH/inforMatch.cpp" "/home/root/nrf2/build/CMakeFiles/api-server.dir/zkH/inforMatch.cpp.o"
"/home/root/nrf2/zkH/zk_cpp.cpp" "/home/root/nrf2/build/CMakeFiles/api-server.dir/zkH/zk_cpp.cpp.o"
"/home/root/nrf2/zkH/zookeeperClient.cpp" "/home/root/nrf2/build/CMakeFiles/api-server.dir/zkH/zookeeperClient.cpp.o"
)
......
......@@ -2601,9 +2601,57 @@ CMakeFiles/api-server.dir/zkH/Register.cpp.o.provides: CMakeFiles/api-server.dir
CMakeFiles/api-server.dir/zkH/Register.cpp.o.provides.build: CMakeFiles/api-server.dir/zkH/Register.cpp.o
CMakeFiles/api-server.dir/zkH/discoverInformation.cpp.o: CMakeFiles/api-server.dir/flags.make
CMakeFiles/api-server.dir/zkH/discoverInformation.cpp.o: ../zkH/discoverInformation.cpp
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green --progress-dir=/home/root/nrf2/build/CMakeFiles --progress-num=$(CMAKE_PROGRESS_107) "Building CXX object CMakeFiles/api-server.dir/zkH/discoverInformation.cpp.o"
/usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -o CMakeFiles/api-server.dir/zkH/discoverInformation.cpp.o -c /home/root/nrf2/zkH/discoverInformation.cpp
CMakeFiles/api-server.dir/zkH/discoverInformation.cpp.i: cmake_force
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing CXX source to CMakeFiles/api-server.dir/zkH/discoverInformation.cpp.i"
/usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -E /home/root/nrf2/zkH/discoverInformation.cpp > CMakeFiles/api-server.dir/zkH/discoverInformation.cpp.i
CMakeFiles/api-server.dir/zkH/discoverInformation.cpp.s: cmake_force
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling CXX source to assembly CMakeFiles/api-server.dir/zkH/discoverInformation.cpp.s"
/usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -S /home/root/nrf2/zkH/discoverInformation.cpp -o CMakeFiles/api-server.dir/zkH/discoverInformation.cpp.s
CMakeFiles/api-server.dir/zkH/discoverInformation.cpp.o.requires:
.PHONY : CMakeFiles/api-server.dir/zkH/discoverInformation.cpp.o.requires
CMakeFiles/api-server.dir/zkH/discoverInformation.cpp.o.provides: CMakeFiles/api-server.dir/zkH/discoverInformation.cpp.o.requires
$(MAKE) -f CMakeFiles/api-server.dir/build.make CMakeFiles/api-server.dir/zkH/discoverInformation.cpp.o.provides.build
.PHONY : CMakeFiles/api-server.dir/zkH/discoverInformation.cpp.o.provides
CMakeFiles/api-server.dir/zkH/discoverInformation.cpp.o.provides.build: CMakeFiles/api-server.dir/zkH/discoverInformation.cpp.o
CMakeFiles/api-server.dir/zkH/inforMatch.cpp.o: CMakeFiles/api-server.dir/flags.make
CMakeFiles/api-server.dir/zkH/inforMatch.cpp.o: ../zkH/inforMatch.cpp
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green --progress-dir=/home/root/nrf2/build/CMakeFiles --progress-num=$(CMAKE_PROGRESS_108) "Building CXX object CMakeFiles/api-server.dir/zkH/inforMatch.cpp.o"
/usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -o CMakeFiles/api-server.dir/zkH/inforMatch.cpp.o -c /home/root/nrf2/zkH/inforMatch.cpp
CMakeFiles/api-server.dir/zkH/inforMatch.cpp.i: cmake_force
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing CXX source to CMakeFiles/api-server.dir/zkH/inforMatch.cpp.i"
/usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -E /home/root/nrf2/zkH/inforMatch.cpp > CMakeFiles/api-server.dir/zkH/inforMatch.cpp.i
CMakeFiles/api-server.dir/zkH/inforMatch.cpp.s: cmake_force
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling CXX source to assembly CMakeFiles/api-server.dir/zkH/inforMatch.cpp.s"
/usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -S /home/root/nrf2/zkH/inforMatch.cpp -o CMakeFiles/api-server.dir/zkH/inforMatch.cpp.s
CMakeFiles/api-server.dir/zkH/inforMatch.cpp.o.requires:
.PHONY : CMakeFiles/api-server.dir/zkH/inforMatch.cpp.o.requires
CMakeFiles/api-server.dir/zkH/inforMatch.cpp.o.provides: CMakeFiles/api-server.dir/zkH/inforMatch.cpp.o.requires
$(MAKE) -f CMakeFiles/api-server.dir/build.make CMakeFiles/api-server.dir/zkH/inforMatch.cpp.o.provides.build
.PHONY : CMakeFiles/api-server.dir/zkH/inforMatch.cpp.o.provides
CMakeFiles/api-server.dir/zkH/inforMatch.cpp.o.provides.build: CMakeFiles/api-server.dir/zkH/inforMatch.cpp.o
CMakeFiles/api-server.dir/zkH/zk_cpp.cpp.o: CMakeFiles/api-server.dir/flags.make
CMakeFiles/api-server.dir/zkH/zk_cpp.cpp.o: ../zkH/zk_cpp.cpp
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green --progress-dir=/home/root/nrf2/build/CMakeFiles --progress-num=$(CMAKE_PROGRESS_107) "Building CXX object CMakeFiles/api-server.dir/zkH/zk_cpp.cpp.o"
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green --progress-dir=/home/root/nrf2/build/CMakeFiles --progress-num=$(CMAKE_PROGRESS_109) "Building CXX object CMakeFiles/api-server.dir/zkH/zk_cpp.cpp.o"
/usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -o CMakeFiles/api-server.dir/zkH/zk_cpp.cpp.o -c /home/root/nrf2/zkH/zk_cpp.cpp
CMakeFiles/api-server.dir/zkH/zk_cpp.cpp.i: cmake_force
......@@ -2627,7 +2675,7 @@ CMakeFiles/api-server.dir/zkH/zk_cpp.cpp.o.provides.build: CMakeFiles/api-server
CMakeFiles/api-server.dir/zkH/zookeeperClient.cpp.o: CMakeFiles/api-server.dir/flags.make
CMakeFiles/api-server.dir/zkH/zookeeperClient.cpp.o: ../zkH/zookeeperClient.cpp
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green --progress-dir=/home/root/nrf2/build/CMakeFiles --progress-num=$(CMAKE_PROGRESS_108) "Building CXX object CMakeFiles/api-server.dir/zkH/zookeeperClient.cpp.o"
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green --progress-dir=/home/root/nrf2/build/CMakeFiles --progress-num=$(CMAKE_PROGRESS_110) "Building CXX object CMakeFiles/api-server.dir/zkH/zookeeperClient.cpp.o"
/usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -o CMakeFiles/api-server.dir/zkH/zookeeperClient.cpp.o -c /home/root/nrf2/zkH/zookeeperClient.cpp
CMakeFiles/api-server.dir/zkH/zookeeperClient.cpp.i: cmake_force
......@@ -2651,7 +2699,7 @@ CMakeFiles/api-server.dir/zkH/zookeeperClient.cpp.o.provides.build: CMakeFiles/a
CMakeFiles/api-server.dir/main-api-server.cpp.o: CMakeFiles/api-server.dir/flags.make
CMakeFiles/api-server.dir/main-api-server.cpp.o: ../main-api-server.cpp
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green --progress-dir=/home/root/nrf2/build/CMakeFiles --progress-num=$(CMAKE_PROGRESS_109) "Building CXX object CMakeFiles/api-server.dir/main-api-server.cpp.o"
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green --progress-dir=/home/root/nrf2/build/CMakeFiles --progress-num=$(CMAKE_PROGRESS_111) "Building CXX object CMakeFiles/api-server.dir/main-api-server.cpp.o"
/usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -o CMakeFiles/api-server.dir/main-api-server.cpp.o -c /home/root/nrf2/main-api-server.cpp
CMakeFiles/api-server.dir/main-api-server.cpp.i: cmake_force
......@@ -2781,6 +2829,8 @@ api__server_OBJECTS = \
"CMakeFiles/api-server.dir/model/VendorSpecificFeature.cpp.o" \
"CMakeFiles/api-server.dir/model/WAgfInfo.cpp.o" \
"CMakeFiles/api-server.dir/zkH/Register.cpp.o" \
"CMakeFiles/api-server.dir/zkH/discoverInformation.cpp.o" \
"CMakeFiles/api-server.dir/zkH/inforMatch.cpp.o" \
"CMakeFiles/api-server.dir/zkH/zk_cpp.cpp.o" \
"CMakeFiles/api-server.dir/zkH/zookeeperClient.cpp.o" \
"CMakeFiles/api-server.dir/main-api-server.cpp.o"
......@@ -2894,12 +2944,14 @@ api-server: CMakeFiles/api-server.dir/model/UriScheme.cpp.o
api-server: CMakeFiles/api-server.dir/model/VendorSpecificFeature.cpp.o
api-server: CMakeFiles/api-server.dir/model/WAgfInfo.cpp.o
api-server: CMakeFiles/api-server.dir/zkH/Register.cpp.o
api-server: CMakeFiles/api-server.dir/zkH/discoverInformation.cpp.o
api-server: CMakeFiles/api-server.dir/zkH/inforMatch.cpp.o
api-server: CMakeFiles/api-server.dir/zkH/zk_cpp.cpp.o
api-server: CMakeFiles/api-server.dir/zkH/zookeeperClient.cpp.o
api-server: CMakeFiles/api-server.dir/main-api-server.cpp.o
api-server: CMakeFiles/api-server.dir/build.make
api-server: CMakeFiles/api-server.dir/link.txt
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green --bold --progress-dir=/home/root/nrf2/build/CMakeFiles --progress-num=$(CMAKE_PROGRESS_110) "Linking CXX executable api-server"
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green --bold --progress-dir=/home/root/nrf2/build/CMakeFiles --progress-num=$(CMAKE_PROGRESS_112) "Linking CXX executable api-server"
$(CMAKE_COMMAND) -E cmake_link_script CMakeFiles/api-server.dir/link.txt --verbose=$(VERBOSE)
# Rule to build all files generated by this target.
......@@ -3013,6 +3065,8 @@ CMakeFiles/api-server.dir/requires: CMakeFiles/api-server.dir/model/UriScheme.cp
CMakeFiles/api-server.dir/requires: CMakeFiles/api-server.dir/model/VendorSpecificFeature.cpp.o.requires
CMakeFiles/api-server.dir/requires: CMakeFiles/api-server.dir/model/WAgfInfo.cpp.o.requires
CMakeFiles/api-server.dir/requires: CMakeFiles/api-server.dir/zkH/Register.cpp.o.requires
CMakeFiles/api-server.dir/requires: CMakeFiles/api-server.dir/zkH/discoverInformation.cpp.o.requires
CMakeFiles/api-server.dir/requires: CMakeFiles/api-server.dir/zkH/inforMatch.cpp.o.requires
CMakeFiles/api-server.dir/requires: CMakeFiles/api-server.dir/zkH/zk_cpp.cpp.o.requires
CMakeFiles/api-server.dir/requires: CMakeFiles/api-server.dir/zkH/zookeeperClient.cpp.o.requires
CMakeFiles/api-server.dir/requires: CMakeFiles/api-server.dir/main-api-server.cpp.o.requires
......
......@@ -105,6 +105,8 @@ file(REMOVE_RECURSE
"CMakeFiles/api-server.dir/model/VendorSpecificFeature.cpp.o"
"CMakeFiles/api-server.dir/model/WAgfInfo.cpp.o"
"CMakeFiles/api-server.dir/zkH/Register.cpp.o"
"CMakeFiles/api-server.dir/zkH/discoverInformation.cpp.o"
"CMakeFiles/api-server.dir/zkH/inforMatch.cpp.o"
"CMakeFiles/api-server.dir/zkH/zk_cpp.cpp.o"
"CMakeFiles/api-server.dir/zkH/zookeeperClient.cpp.o"
"CMakeFiles/api-server.dir/main-api-server.cpp.o"
......
......@@ -80,6 +80,10 @@ CMakeFiles/api-server.dir/api/NFInstanceIDDocumentApi.cpp.o
../model/UriScheme.h
../model/VendorSpecificFeature.h
../model/WAgfInfo.h
../zkH/discoverInformation.h
../zkH/inforMatch.h
../zkH/zk_cpp.h
../zkH/zookeeperClient.h
/home/root/nrf2/api/NFInstanceIDDocumentApi.cpp
/home/root/nrf2/api/NFInstanceIDDocumentApi.h
/home/root/nrf2/json-include/json/allocator.h
......@@ -208,6 +212,7 @@ CMakeFiles/api-server.dir/impl/NFInstanceIDDocumentApiImpl.cpp.o
../model/VendorSpecificFeature.h
../model/WAgfInfo.h
../zkH/Register.h
../zkH/discoverInformation.h
../zkH/zk_cpp.h
../zkH/zookeeperClient.h
/home/root/nrf2/impl/NFInstanceIDDocumentApiImpl.cpp
......@@ -340,6 +345,7 @@ CMakeFiles/api-server.dir/main-api-server.cpp.o
../model/UriScheme.h
../model/VendorSpecificFeature.h
../model/WAgfInfo.h
../zkH/discoverInformation.h
/home/root/nrf2/main-api-server.cpp
CMakeFiles/api-server.dir/model/AccessType.cpp.o
/home/root/nrf2/model/AccessType.cpp
......@@ -969,6 +975,14 @@ CMakeFiles/api-server.dir/zkH/Register.cpp.o
/home/root/nrf2/zkH/Register.cpp
/home/root/nrf2/zkH/Register.h
/home/root/nrf2/zkH/zk_cpp.h
CMakeFiles/api-server.dir/zkH/discoverInformation.cpp.o
/home/root/nrf2/zkH/discoverInformation.cpp
/home/root/nrf2/zkH/discoverInformation.h
CMakeFiles/api-server.dir/zkH/inforMatch.cpp.o
/home/root/nrf2/zkH/inforMatch.cpp
/home/root/nrf2/zkH/inforMatch.h
/home/root/nrf2/zkH/zk_cpp.h
/home/root/nrf2/zkH/zookeeperClient.h
CMakeFiles/api-server.dir/zkH/zk_cpp.cpp.o
../zookeeper-3.4.5/proto.h
../zookeeper-3.4.5/recordio.h
......
......@@ -79,6 +79,10 @@ CMakeFiles/api-server.dir/api/NFInstanceIDDocumentApi.cpp.o: ../model/UpfInfo.h
CMakeFiles/api-server.dir/api/NFInstanceIDDocumentApi.cpp.o: ../model/UriScheme.h
CMakeFiles/api-server.dir/api/NFInstanceIDDocumentApi.cpp.o: ../model/VendorSpecificFeature.h
CMakeFiles/api-server.dir/api/NFInstanceIDDocumentApi.cpp.o: ../model/WAgfInfo.h
CMakeFiles/api-server.dir/api/NFInstanceIDDocumentApi.cpp.o: ../zkH/discoverInformation.h
CMakeFiles/api-server.dir/api/NFInstanceIDDocumentApi.cpp.o: ../zkH/inforMatch.h
CMakeFiles/api-server.dir/api/NFInstanceIDDocumentApi.cpp.o: ../zkH/zk_cpp.h
CMakeFiles/api-server.dir/api/NFInstanceIDDocumentApi.cpp.o: ../zkH/zookeeperClient.h
CMakeFiles/api-server.dir/api/NFInstanceIDDocumentApi.cpp.o: ../api/NFInstanceIDDocumentApi.cpp
CMakeFiles/api-server.dir/api/NFInstanceIDDocumentApi.cpp.o: ../api/NFInstanceIDDocumentApi.h
CMakeFiles/api-server.dir/api/NFInstanceIDDocumentApi.cpp.o: ../json-include/json/allocator.h
......@@ -207,6 +211,7 @@ CMakeFiles/api-server.dir/impl/NFInstanceIDDocumentApiImpl.cpp.o: ../model/UriSc
CMakeFiles/api-server.dir/impl/NFInstanceIDDocumentApiImpl.cpp.o: ../model/VendorSpecificFeature.h
CMakeFiles/api-server.dir/impl/NFInstanceIDDocumentApiImpl.cpp.o: ../model/WAgfInfo.h
CMakeFiles/api-server.dir/impl/NFInstanceIDDocumentApiImpl.cpp.o: ../zkH/Register.h
CMakeFiles/api-server.dir/impl/NFInstanceIDDocumentApiImpl.cpp.o: ../zkH/discoverInformation.h
CMakeFiles/api-server.dir/impl/NFInstanceIDDocumentApiImpl.cpp.o: ../zkH/zk_cpp.h
CMakeFiles/api-server.dir/impl/NFInstanceIDDocumentApiImpl.cpp.o: ../zkH/zookeeperClient.h
CMakeFiles/api-server.dir/impl/NFInstanceIDDocumentApiImpl.cpp.o: ../impl/NFInstanceIDDocumentApiImpl.cpp
......@@ -339,6 +344,7 @@ CMakeFiles/api-server.dir/main-api-server.cpp.o: ../model/UpfInfo.h
CMakeFiles/api-server.dir/main-api-server.cpp.o: ../model/UriScheme.h
CMakeFiles/api-server.dir/main-api-server.cpp.o: ../model/VendorSpecificFeature.h
CMakeFiles/api-server.dir/main-api-server.cpp.o: ../model/WAgfInfo.h
CMakeFiles/api-server.dir/main-api-server.cpp.o: ../zkH/discoverInformation.h
CMakeFiles/api-server.dir/main-api-server.cpp.o: ../main-api-server.cpp
CMakeFiles/api-server.dir/model/AccessType.cpp.o: ../model/AccessType.cpp
......@@ -969,6 +975,14 @@ CMakeFiles/api-server.dir/zkH/Register.cpp.o: ../zkH/Register.cpp
CMakeFiles/api-server.dir/zkH/Register.cpp.o: ../zkH/Register.h
CMakeFiles/api-server.dir/zkH/Register.cpp.o: ../zkH/zk_cpp.h
CMakeFiles/api-server.dir/zkH/discoverInformation.cpp.o: ../zkH/discoverInformation.cpp
CMakeFiles/api-server.dir/zkH/discoverInformation.cpp.o: ../zkH/discoverInformation.h
CMakeFiles/api-server.dir/zkH/inforMatch.cpp.o: ../zkH/inforMatch.cpp
CMakeFiles/api-server.dir/zkH/inforMatch.cpp.o: ../zkH/inforMatch.h
CMakeFiles/api-server.dir/zkH/inforMatch.cpp.o: ../zkH/zk_cpp.h
CMakeFiles/api-server.dir/zkH/inforMatch.cpp.o: ../zkH/zookeeperClient.h
CMakeFiles/api-server.dir/zkH/zk_cpp.cpp.o: ../zookeeper-3.4.5/proto.h
CMakeFiles/api-server.dir/zkH/zk_cpp.cpp.o: ../zookeeper-3.4.5/recordio.h
CMakeFiles/api-server.dir/zkH/zk_cpp.cpp.o: ../zookeeper-3.4.5/zookeeper.h
......
This diff is collapsed.
......@@ -7,105 +7,107 @@ CMAKE_PROGRESS_6 = 5
CMAKE_PROGRESS_7 = 6
CMAKE_PROGRESS_8 = 7
CMAKE_PROGRESS_9 = 8
CMAKE_PROGRESS_10 = 9
CMAKE_PROGRESS_11 = 10
CMAKE_PROGRESS_12 =
CMAKE_PROGRESS_10 =
CMAKE_PROGRESS_11 = 9
CMAKE_PROGRESS_12 = 10
CMAKE_PROGRESS_13 = 11
CMAKE_PROGRESS_14 = 12
CMAKE_PROGRESS_15 = 13
CMAKE_PROGRESS_16 = 14
CMAKE_PROGRESS_17 = 15
CMAKE_PROGRESS_18 = 16
CMAKE_PROGRESS_19 = 17
CMAKE_PROGRESS_20 = 18
CMAKE_PROGRESS_21 = 19
CMAKE_PROGRESS_22 = 20
CMAKE_PROGRESS_23 =
CMAKE_PROGRESS_19 =
CMAKE_PROGRESS_20 = 17
CMAKE_PROGRESS_21 = 18
CMAKE_PROGRESS_22 = 19
CMAKE_PROGRESS_23 = 20
CMAKE_PROGRESS_24 = 21
CMAKE_PROGRESS_25 = 22
CMAKE_PROGRESS_26 = 23
CMAKE_PROGRESS_27 = 24
CMAKE_PROGRESS_28 = 25
CMAKE_PROGRESS_29 = 26
CMAKE_PROGRESS_30 = 27
CMAKE_PROGRESS_31 = 28
CMAKE_PROGRESS_32 = 29
CMAKE_PROGRESS_33 = 30
CMAKE_PROGRESS_34 =
CMAKE_PROGRESS_29 =
CMAKE_PROGRESS_30 = 26
CMAKE_PROGRESS_31 = 27
CMAKE_PROGRESS_32 = 28
CMAKE_PROGRESS_33 = 29
CMAKE_PROGRESS_34 = 30
CMAKE_PROGRESS_35 = 31
CMAKE_PROGRESS_36 = 32
CMAKE_PROGRESS_37 = 33
CMAKE_PROGRESS_38 = 34
CMAKE_PROGRESS_39 = 35
CMAKE_PROGRESS_40 = 36
CMAKE_PROGRESS_41 = 37
CMAKE_PROGRESS_42 = 38
CMAKE_PROGRESS_43 = 39
CMAKE_PROGRESS_44 = 40
CMAKE_PROGRESS_45 =
CMAKE_PROGRESS_38 =
CMAKE_PROGRESS_39 = 34
CMAKE_PROGRESS_40 = 35
CMAKE_PROGRESS_41 = 36
CMAKE_PROGRESS_42 = 37
CMAKE_PROGRESS_43 = 38
CMAKE_PROGRESS_44 = 39
CMAKE_PROGRESS_45 = 40
CMAKE_PROGRESS_46 = 41
CMAKE_PROGRESS_47 = 42
CMAKE_PROGRESS_48 = 43
CMAKE_PROGRESS_49 = 44
CMAKE_PROGRESS_50 = 45
CMAKE_PROGRESS_51 = 46
CMAKE_PROGRESS_52 = 47
CMAKE_PROGRESS_53 = 48
CMAKE_PROGRESS_54 = 49
CMAKE_PROGRESS_55 = 50
CMAKE_PROGRESS_56 =
CMAKE_PROGRESS_57 = 51
CMAKE_PROGRESS_58 = 52
CMAKE_PROGRESS_59 = 53
CMAKE_PROGRESS_60 = 54
CMAKE_PROGRESS_61 = 55
CMAKE_PROGRESS_62 = 56
CMAKE_PROGRESS_63 = 57
CMAKE_PROGRESS_64 = 58
CMAKE_PROGRESS_65 = 59
CMAKE_PROGRESS_66 = 60
CMAKE_PROGRESS_67 =
CMAKE_PROGRESS_68 = 61
CMAKE_PROGRESS_69 = 62
CMAKE_PROGRESS_70 = 63
CMAKE_PROGRESS_71 = 64
CMAKE_PROGRESS_72 = 65
CMAKE_PROGRESS_73 = 66
CMAKE_PROGRESS_74 = 67
CMAKE_PROGRESS_75 = 68
CMAKE_PROGRESS_76 = 69
CMAKE_PROGRESS_77 = 70
CMAKE_PROGRESS_78 =
CMAKE_PROGRESS_79 = 71
CMAKE_PROGRESS_80 = 72
CMAKE_PROGRESS_81 = 73
CMAKE_PROGRESS_82 = 74
CMAKE_PROGRESS_83 = 75
CMAKE_PROGRESS_84 = 76
CMAKE_PROGRESS_85 = 77
CMAKE_PROGRESS_86 = 78
CMAKE_PROGRESS_87 = 79
CMAKE_PROGRESS_88 = 80
CMAKE_PROGRESS_89 =
CMAKE_PROGRESS_90 = 81
CMAKE_PROGRESS_91 = 82
CMAKE_PROGRESS_92 = 83
CMAKE_PROGRESS_93 = 84
CMAKE_PROGRESS_94 = 85
CMAKE_PROGRESS_95 = 86
CMAKE_PROGRESS_96 = 87
CMAKE_PROGRESS_97 = 88
CMAKE_PROGRESS_98 = 89
CMAKE_PROGRESS_99 = 90
CMAKE_PROGRESS_100 =
CMAKE_PROGRESS_101 = 91
CMAKE_PROGRESS_102 = 92
CMAKE_PROGRESS_103 = 93
CMAKE_PROGRESS_104 = 94
CMAKE_PROGRESS_105 = 95
CMAKE_PROGRESS_106 = 96
CMAKE_PROGRESS_107 = 97
CMAKE_PROGRESS_108 = 98
CMAKE_PROGRESS_109 = 99
CMAKE_PROGRESS_110 = 100
CMAKE_PROGRESS_47 =
CMAKE_PROGRESS_48 = 42
CMAKE_PROGRESS_49 = 43
CMAKE_PROGRESS_50 = 44
CMAKE_PROGRESS_51 = 45
CMAKE_PROGRESS_52 = 46
CMAKE_PROGRESS_53 = 47
CMAKE_PROGRESS_54 = 48
CMAKE_PROGRESS_55 = 49
CMAKE_PROGRESS_56 = 50
CMAKE_PROGRESS_57 =
CMAKE_PROGRESS_58 = 51
CMAKE_PROGRESS_59 = 52
CMAKE_PROGRESS_60 = 53
CMAKE_PROGRESS_61 = 54
CMAKE_PROGRESS_62 = 55
CMAKE_PROGRESS_63 = 56
CMAKE_PROGRESS_64 = 57
CMAKE_PROGRESS_65 = 58
CMAKE_PROGRESS_66 =
CMAKE_PROGRESS_67 = 59
CMAKE_PROGRESS_68 = 60
CMAKE_PROGRESS_69 = 61
CMAKE_PROGRESS_70 = 62
CMAKE_PROGRESS_71 = 63
CMAKE_PROGRESS_72 = 64
CMAKE_PROGRESS_73 = 65
CMAKE_PROGRESS_74 = 66
CMAKE_PROGRESS_75 =
CMAKE_PROGRESS_76 = 67
CMAKE_PROGRESS_77 = 68
CMAKE_PROGRESS_78 = 69
CMAKE_PROGRESS_79 = 70
CMAKE_PROGRESS_80 = 71
CMAKE_PROGRESS_81 = 72
CMAKE_PROGRESS_82 = 73
CMAKE_PROGRESS_83 = 74
CMAKE_PROGRESS_84 = 75
CMAKE_PROGRESS_85 =
CMAKE_PROGRESS_86 = 76
CMAKE_PROGRESS_87 = 77
CMAKE_PROGRESS_88 = 78
CMAKE_PROGRESS_89 = 79
CMAKE_PROGRESS_90 = 80
CMAKE_PROGRESS_91 = 81
CMAKE_PROGRESS_92 = 82
CMAKE_PROGRESS_93 = 83
CMAKE_PROGRESS_94 =
CMAKE_PROGRESS_95 = 84
CMAKE_PROGRESS_96 = 85
CMAKE_PROGRESS_97 = 86
CMAKE_PROGRESS_98 = 87
CMAKE_PROGRESS_99 = 88
CMAKE_PROGRESS_100 = 89
CMAKE_PROGRESS_101 = 90
CMAKE_PROGRESS_102 = 91
CMAKE_PROGRESS_103 =
CMAKE_PROGRESS_104 = 92
CMAKE_PROGRESS_105 = 93
CMAKE_PROGRESS_106 = 94
CMAKE_PROGRESS_107 = 95
CMAKE_PROGRESS_108 = 96
CMAKE_PROGRESS_109 = 97
CMAKE_PROGRESS_110 = 98
CMAKE_PROGRESS_111 = 99
CMAKE_PROGRESS_112 = 100
......@@ -3058,6 +3058,60 @@ zkH/Register.cpp.s:
$(MAKE) -f CMakeFiles/api-server.dir/build.make CMakeFiles/api-server.dir/zkH/Register.cpp.s
.PHONY : zkH/Register.cpp.s
zkH/discoverInformation.o: zkH/discoverInformation.cpp.o
.PHONY : zkH/discoverInformation.o
# target to build an object file
zkH/discoverInformation.cpp.o:
$(MAKE) -f CMakeFiles/api-server.dir/build.make CMakeFiles/api-server.dir/zkH/discoverInformation.cpp.o
.PHONY : zkH/discoverInformation.cpp.o
zkH/discoverInformation.i: zkH/discoverInformation.cpp.i
.PHONY : zkH/discoverInformation.i
# target to preprocess a source file
zkH/discoverInformation.cpp.i:
$(MAKE) -f CMakeFiles/api-server.dir/build.make CMakeFiles/api-server.dir/zkH/discoverInformation.cpp.i
.PHONY : zkH/discoverInformation.cpp.i
zkH/discoverInformation.s: zkH/discoverInformation.cpp.s
.PHONY : zkH/discoverInformation.s
# target to generate assembly for a file
zkH/discoverInformation.cpp.s:
$(MAKE) -f CMakeFiles/api-server.dir/build.make CMakeFiles/api-server.dir/zkH/discoverInformation.cpp.s
.PHONY : zkH/discoverInformation.cpp.s
zkH/inforMatch.o: zkH/inforMatch.cpp.o
.PHONY : zkH/inforMatch.o
# target to build an object file
zkH/inforMatch.cpp.o:
$(MAKE) -f CMakeFiles/api-server.dir/build.make CMakeFiles/api-server.dir/zkH/inforMatch.cpp.o
.PHONY : zkH/inforMatch.cpp.o
zkH/inforMatch.i: zkH/inforMatch.cpp.i
.PHONY : zkH/inforMatch.i
# target to preprocess a source file
zkH/inforMatch.cpp.i:
$(MAKE) -f CMakeFiles/api-server.dir/build.make CMakeFiles/api-server.dir/zkH/inforMatch.cpp.i
.PHONY : zkH/inforMatch.cpp.i
zkH/inforMatch.s: zkH/inforMatch.cpp.s
.PHONY : zkH/inforMatch.s
# target to generate assembly for a file
zkH/inforMatch.cpp.s:
$(MAKE) -f CMakeFiles/api-server.dir/build.make CMakeFiles/api-server.dir/zkH/inforMatch.cpp.s
.PHONY : zkH/inforMatch.cpp.s
zkH/zk_cpp.o: zkH/zk_cpp.cpp.o
.PHONY : zkH/zk_cpp.o
......@@ -3446,6 +3500,12 @@ help:
@echo "... zkH/Register.o"
@echo "... zkH/Register.i"
@echo "... zkH/Register.s"
@echo "... zkH/discoverInformation.o"
@echo "... zkH/discoverInformation.i"
@echo "... zkH/discoverInformation.s"
@echo "... zkH/inforMatch.o"
@echo "... zkH/inforMatch.i"
@echo "... zkH/inforMatch.s"
@echo "... zkH/zk_cpp.o"
@echo "... zkH/zk_cpp.i"
@echo "... zkH/zk_cpp.s"
......
{
"nfInstanceId": "AMF",
"nfStatus": "REGISTERED",
"nfType": "AMF"
}
{
"nfInstanceId": "SMFInstanceId1",
"nfStatus": "REGISTERED",
"nfType": "SMF"
}
No preview for this file type
No preview for this file type
{
"nfInstanceId": "AMF",
"nfStatus": "REGISTERED",
"nfType": "AMF"
}
......@@ -33,6 +33,11 @@ void NFInstanceIDDocumentApiImpl::deregister_nf_instance(const std::string &nfIn
response.send(Pistache::Http::Code::Ok, "Do some magic\n");
}
void NFInstanceIDDocumentApiImpl::get_nf_instance(const std::string &nfInstanceID, Pistache::Http::ResponseWriter &response) {
cout << "get_nf_instance已启动!" << endl;
std::string nfInstanceId = nfInstanceID;
cout << "nfInstaceId是:" << nfInstanceId << endl;
response.send(Pistache::Http::Code::Ok, "Do some magic\n");
}
void NFInstanceIDDocumentApiImpl::register_nf_instance(const std::string &nfInstanceID, const NFProfile &nFProfile, const Pistache::Optional<Pistache::Http::Header::Raw> &contentEncoding, const Pistache::Optional<Pistache::Http::Header::Raw> &acceptEncoding, Pistache::Http::ResponseWriter &response) {
......@@ -50,12 +55,20 @@ void NFInstanceIDDocumentApiImpl::register_nf_instance(const std::string &nfInst
to_json(j , nFProfile);
cout << "json信息为" << j << "\r\n";
//以上为测试内容
//j.erase("");删除无用标志信息剩余有用信息的json
j.erase("nfStatus");
//将剩余的有用信息化为string
//std::string jS = j.dump();
//输出json文件
std::string nfInstanceId;
j.at("nfInstanceId").get_to(nfInstanceId);
std::string pointJson = ".json";
std::string value;
value = nfInstanceId + pointJson;
value = nfInstanceId + pointJson;//Value 文件名
std::ofstream myfile(value);
myfile << std::setw(75) << j << std::endl;
......@@ -64,6 +77,32 @@ void NFInstanceIDDocumentApiImpl::register_nf_instance(const std::string &nfInst
bool a = zooK.connect2ZKServer("192.168.110.129:2181");
utility::zk_cpp* zk;
zk = zooK.getZk();
/*
* 显性信息提取:
*/
//一定含有nfType与instanceID
discoverInformation DiscoverInformation;
std::string nfType;
j.at("nfType").get_to(nfType);
bool flagTargetNfType = DiscoverInformation.setOneInformation("targetNfType",nfType);
if(j.contains("ANYINFORMATION1")){
//do something
std::string ANYINFORMATION1 = j.at("ANYINFORMATION1").get_to(ANYINFORMATION1);
bool flagANYINFORMATION1 = DiscoverInformation.setOneInformation("ANYINFORMATION1", ANYINFORMATION1);
}
if(j.contains("ANYINFORMATION2")){
//do something
std::string ANYINFORMATION2 = j.at("ANYINFORMATION2").get_to(ANYINFORMATION2);
bool flagANYINFORMATION2 = DiscoverInformation.setOneInformation("ANYINFORMATION2", ANYINFORMATION2);
}
nlohmann::json InforJson = DiscoverInformation.toJson();
std::string InforValue = InforJson.dump();
//实例化Register
Register Register;
std::string source = "/";
......@@ -71,16 +110,16 @@ void NFInstanceIDDocumentApiImpl::register_nf_instance(const std::string &nfInst
std::string nfType;
j.at("nfType").get_to(nfType);
//std::string nfType;
//j.at("nfType").get_to(nfType);
std::string path;
std::string fullPath;
path = source + nfType;
fullPath = path + "/" + nfInstanceId;
fullPath = path + "/" + nfInstanceId ;//fullPath是每一个实例的全部路径,包含关键信息
cout << " path: " << path << endl;
bool b;
b = Register.registerZK("this_is_A_nfType", path, zk);
b = Register.registerZK(value, fullPath, zk);
b = Register.registerZK(InforValue, fullPath, zk);
response.send(Pistache::Http::Code::Ok, "Do some magic\n");
}
void NFInstanceIDDocumentApiImpl::update_nf_instance(const std::string &nfInstanceID, const std::vector<PatchItem> &patchItem, const Pistache::Optional<Pistache::Http::Header::Raw> &contentEncoding, const Pistache::Optional<Pistache::Http::Header::Raw> &acceptEncoding, Pistache::Http::ResponseWriter &response) {
......
......@@ -34,7 +34,7 @@
#include "ProblemDetails.h"
#include <string>
#include <vector>
#include "discoverInformation.h"
namespace org {
namespace openapitools {
namespace server {
......
......@@ -20,7 +20,7 @@ namespace model {
NFType::NFType()
{
this->nfType = "";
}
NFType::~NFType()
......
......@@ -39,6 +39,7 @@ public:
/////////////////////////////////////////////
/// NFType members
std::string nfType;
friend void to_json(nlohmann::json& j, const NFType& o);
......
#include "discoverInformation.h"
#include <stdio.h>
#include <string>
std::string discoverInformation::getOneInformation(std::string InforName){
std::string targetNfType1 = this->targetNfType;
std::string ANYINFORMATION11 = this->ANYINFORMATION1;
std::string ANYINFORMATION22 = this->ANYINFORMATION2;
std::string strcmpTargetNfType = "targetNfType";
if(InforName==strcmpTargetNfType){
return this->targetNfType;
}
else if(InforName=="ANYINFORMATION1"){
return this->ANYINFORMATION1;
}
else if(InforName=="ANYINFORMATION2"){
return this->ANYINFORMATION2;
}
else{
std::string defaultStr = "The infor is not exist!";
return defaultStr;
}
}
bool discoverInformation::setOneInformation(std::string InforName,std::string Infor){
if(InforName=="targetNfType"){
this->targetNfType = Infor;
return true;
}
else if(InforName=="ANYINFORMATION1"){
this->ANYINFORMATION1 = Infor;
return true;
}
else if(InforName=="ANYINFORMATION2"){
this->ANYINFORMATION2 = Infor;
return true;
}
else{
return false;
}
}
nlohmann::json discoverInformation::toJson(){
nlohmann::json jsonInformation;
jsonInformation["targetNfType"] = this->targetNfType;
jsonInformation["ANYINFORMATION1"] = this->ANYINFORMATION1;
jsonInformation["ANYINFORMATION2"] = this->ANYINFORMATION2;
return jsonInformation;
}
#include <string>
#include <stdio.h>
#include <nlohmann/json.hpp>
#include <stdbool.h>
class discoverInformation{
private:
std::string targetNfType = "null";
std::string ANYINFORMATION1 = "null";
std::string ANYINFORMATION2 = "null";
public:
std::string getOneInformation(std::string InforName);
bool setOneInformation(std::string InforName,std::string Infor);
nlohmann::json toJson();
};
#include "inforMatch.h"
bool inforMatch::ifIsMatching(std::string instancePath, nlohmann::json jsonInformation){
std::string value;
zookeeperClient zooK;
bool flag1,flag2,flag3;
bool atest = zooK.connect2ZKServer("192.168.110.129:2181");
utility::zk_cpp* zk;
zk = zooK.getZk();
utility::zoo_rc ret = zk->get_node(instancePath.c_str(), value, nullptr, true);
printf("try get tesrPath[%s]'s value, value[%s] ret[%d][%s]\n",instancePath.c_str(), value.c_str(), ret, utility::zk_cpp::error_string(ret));
//此时二级节点下存储的显性信息已被取出存储在value中
std::string zkValueString = value.c_str();//将value信息存储在zkValueString中
/*
* 开始逐项匹配
*/
//匹配显性信息中的targetNfType:
std::string InforTargetNfType;
std::cout << "=============" << std::endl;
std::cout << jsonInformation << std::endl;
jsonInformation.at("targetNfType").get_to(InforTargetNfType);//InforTargetNfType信息为:duklAMF
InforTargetNfType = InforTargetNfType + "\"";
InforTargetNfType = "\"" + InforTargetNfType;//InforTargetNfType前后加引号
InforTargetNfType = "\"targetNfType\":" + InforTargetNfType;
std::cout << InforTargetNfType << std::endl;/* 此处可写为函数,输入为左加右,输出一个string! */
//正则表达式匹配:
std::regex e1(InforTargetNfType);//e是目标字符串,也就是get的需求
std::smatch sMatchResult1;
std::regex_search(zkValueString, sMatchResult1, e1);
std::cout << "targetNfType的匹配结果是:" << sMatchResult1.size() << std::endl;//正常运行情况下,此处返回值应为1
if(sMatchResult1.size()==0) flag1 = 0;
else flag1 = 1;
//匹配显性信息中的第二个ANYINFORMATION1
std::string InforANYINFORMATION1;
jsonInformation.at("ANYINFORMATION1").get_to(InforANYINFORMATION1);//InforTargetNfType信息为第二个显性信息的值
if(InforANYINFORMATION1 == "null") flag2 = 1;
else{
InforANYINFORMATION1 = InforANYINFORMATION1 + "\"";
InforANYINFORMATION1 = "\"" + InforANYINFORMATION1;
InforANYINFORMATION1 = "\"ANYINFORMATION1\":" + InforANYINFORMATION1;
std::cout << InforANYINFORMATION1 << std::endl;
std::regex e2(InforANYINFORMATION1);
std::smatch sMatchResult2;
std::regex_search(zkValueString, sMatchResult2, e2);
if(sMatchResult2.size()==0) flag2 = 0;
else flag2 = 1;
}
//匹配线型信息中的第三个ANYINFORMATION2std::string InforANYINFORMATION1;
std::string InforANYINFORMATION2;
jsonInformation.at("ANYINFORMATION2").get_to(InforANYINFORMATION2);//InforTargetNfType信息为第二个显性信息的值
if(InforANYINFORMATION2 == "null") flag3 = 1;
else{
InforANYINFORMATION2 = InforANYINFORMATION2 + "\"";
InforANYINFORMATION2 = "\"" + InforANYINFORMATION2;
InforANYINFORMATION2 = "\"ANYINFORMATION2\":" + InforANYINFORMATION2;
std::cout << InforANYINFORMATION2 << std::endl;
std::regex e3(InforANYINFORMATION2);
std::smatch sMatchResult3;
std::regex_search(zkValueString, sMatchResult3, e3);
if(sMatchResult3.size()==0) flag3 = 0;
else flag3 = 1;
}
std::cout << "flag为" << flag1 << " " << flag2 << " " << flag3 << " " << std::endl;
if(flag1&&flag2&&flag3) return true;
else return false;
}
#include <stdio.h>
#include <stdbool.h>
#include <string>
#include <iostream>
#include <nlohmann/json.hpp>
#include "zookeeperClient.h"
#include <regex>
class inforMatch{
public:
bool ifIsMatching(std::string instancePath, nlohmann::json jsonInformation);
};
#include "zk_cpp.h"
#include "zookeeper.h"
#include <iostream>
namespace utility {
......@@ -271,8 +272,10 @@ zoo_rc zk_cpp::get_node(const char* path, std::string& out_value, zoo_state
char buf[zoo_value_buf_len] = { 0 };
int buf_size = sizeof(buf);
char *data_buffer = buf;
char *data_buffer = &buf[0];
std::cout << "标记点1" << std::endl;
zoo_rc rt = (zoo_rc)zoo_get((zhandle_t*)m_zh, path, watch, data_buffer, &buf_size, &s);
std::cout << "标记点2" << std::endl;
do {
if (rt != z_ok) {
break;
......@@ -280,9 +283,12 @@ zoo_rc zk_cpp::get_node(const char* path, std::string& out_value, zoo_state
// check data complete
if (s.dataLength > buf_size) {
std::cout << "标记点2" << std::endl;
data_buffer = (char*)malloc(s.dataLength + 1);
buf_size = s.dataLength;
std::cout << "标记点3" << std::endl;
rt = (zoo_rc)zoo_get((zhandle_t*)m_zh, path, watch, data_buffer, &buf_size, &s);
std::cout << "标记点4" << std::endl;
if (rt != z_ok) {
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