CN108038796B - C + + based GIS service operation method and storage medium - Google Patents

C + + based GIS service operation method and storage medium Download PDF

Info

Publication number
CN108038796B
CN108038796B CN201711306422.1A CN201711306422A CN108038796B CN 108038796 B CN108038796 B CN 108038796B CN 201711306422 A CN201711306422 A CN 201711306422A CN 108038796 B CN108038796 B CN 108038796B
Authority
CN
China
Prior art keywords
service
request
data structure
interface
web server
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201711306422.1A
Other languages
Chinese (zh)
Other versions
CN108038796A (en
Inventor
陈凌
林黎鸣
孙亚义
林立
孙铭杉
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Xiamen Epgis Information Technology Co ltd
State Grid Corp of China SGCC
State Grid Information and Telecommunication Co Ltd
Great Power Science and Technology Co of State Grid Information and Telecommunication Co Ltd
Original Assignee
Xiamen Epgis Information Technology Co ltd
State Grid Corp of China SGCC
State Grid Information and Telecommunication Co Ltd
Great Power Science and Technology Co of State Grid Information and Telecommunication Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Xiamen Epgis Information Technology Co ltd, State Grid Corp of China SGCC, State Grid Information and Telecommunication Co Ltd, Great Power Science and Technology Co of State Grid Information and Telecommunication Co Ltd filed Critical Xiamen Epgis Information Technology Co ltd
Priority to CN201711306422.1A priority Critical patent/CN108038796B/en
Publication of CN108038796A publication Critical patent/CN108038796A/en
Application granted granted Critical
Publication of CN108038796B publication Critical patent/CN108038796B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q50/00Information and communication technology [ICT] specially adapted for implementation of business processes of specific business sectors, e.g. utilities or tourism
    • G06Q50/10Services
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q50/00Information and communication technology [ICT] specially adapted for implementation of business processes of specific business sectors, e.g. utilities or tourism
    • G06Q50/06Energy or water supply
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/02Protocols based on web technology, e.g. hypertext transfer protocol [HTTP]

Landscapes

  • Business, Economics & Management (AREA)
  • Engineering & Computer Science (AREA)
  • Health & Medical Sciences (AREA)
  • Economics (AREA)
  • Tourism & Hospitality (AREA)
  • Primary Health Care (AREA)
  • Physics & Mathematics (AREA)
  • General Health & Medical Sciences (AREA)
  • Human Resources & Organizations (AREA)
  • Marketing (AREA)
  • Theoretical Computer Science (AREA)
  • Strategic Management (AREA)
  • General Physics & Mathematics (AREA)
  • General Business, Economics & Management (AREA)
  • Signal Processing (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Public Health (AREA)
  • Water Supply & Treatment (AREA)
  • Computer And Data Communications (AREA)
  • Stored Programmes (AREA)

Abstract

The invention provides a C + + based GIS service operation method and a storage medium, wherein the method comprises the following steps: defining a data structure and an interface through a thread; generating a template class according to the data structure and the interface; generating a packaging layer respectively connecting the Web server and the thread; after filling preset functions in the templates, integrally packaging to generate an interface library file and a function library file, and uploading the interface library file and the function library file to a Web server; and appointing the path to be issued by the interface library file and the function library file through the configuration file. The invention provides a framework for releasing GIS service efficiently and simply. The realization developer does not need to pay attention to protocol conversion, does not have any invasive requirement, and can develop according to own habit completely without inheriting classes or realizing interfaces or containing files.

Description

C + + based GIS service operation method and storage medium
Technical Field
The invention relates to the field of power grid geographic information systems, in particular to a GIS service operation method and a storage medium based on C + +.
Background
The power grid geographic information system (power grid GIS system) is a professional information system for managing power transmission, power transformation, power distribution and low-voltage power grids by adopting a geographic information technology, realizes the structural management and graphical display of power grid resources, and realizes the business functions of graphical management, attribute maintenance, power grid analysis and the like of the power grids.
In the daily power grid GIS function service development process, a technical problem which needs to be solved urgently is faced: originally, each function developer needs to build a network layer release service by himself besides completing a function module, and needs to know knowledge of irrelevant business logic and repeat labor.
Therefore, it is necessary to provide a method for operating a GIS service, which enables developers to concentrate on function development without knowing the network transmission, distribution process, and implementation and technical details of a server, thereby implementing development of the GIS function service easily and efficiently.
Disclosure of Invention
The technical problem to be solved by the invention is as follows: a GIS service operation method and a storage medium based on C + + are provided, and developers can efficiently and easily realize Web service release function.
In order to solve the technical problems, the invention adopts the technical scheme that:
a GIS service operation method based on C + + comprises the following steps:
defining a data structure and an interface through a thread; generating a template class according to the data structure and the interface;
generating a packaging layer respectively connecting the Web server and the thread;
after filling preset functions in the templates, integrally packaging to generate an interface library file and a function library file, and uploading the interface library file and the function library file to a Web server;
and appointing the path to be issued by the interface library file and the function library file through the configuration file.
The invention provides another technical scheme as follows:
a computer-readable storage medium, having stored thereon a computer program which, when invoked by a processor, is capable of performing the steps of:
defining a data structure and an interface through a thread; generating a template class according to the data structure and the interface;
generating a packaging layer respectively connecting the Web server and the thread;
after filling preset functions in the templates, integrally packaging to generate an interface library file and a function library file, and uploading the interface library file and the function library file to a Web server;
and appointing the path to be issued by the interface library file and the function library file through the configuration file.
The invention has the beneficial effects that: on the basis of the existing Web service release, the function developer can efficiently and easily release the functions based on the release rule of the invention by combining the Thrift. The data structure defined by the thread can be transmitted in the network without concerning serialization; and after the template class is filled with the required functions, submitting the packed library file to a Web server to realize the publishing of the service. The release details do not need to be concerned by developers and can specify the release path only through the configuration file, so that the efficiency of the release service is greatly improved; meanwhile, the specified requirements on the release path are also ensured, and uniform rules and management are provided for different service releases.
The invention can realize that the service developer can use the Web service publishing function through the network platform without manual intervention, network layer knowledge or RESTful style. Meanwhile, a packaging layer for realizing conversion work from the character string to the structural body is automatically generated by means of the Thrift, so that developers do not need to pay attention to protocol conversion and have any invasive requirement, can develop the character string completely according to own habits, and do not need to inherit classes or realize interfaces or contain files.
Drawings
FIG. 1 is a schematic flow chart of a GIS service operation method based on C + + of the present invention;
FIG. 2 is a schematic flow chart according to a first embodiment of the present invention;
FIG. 3 is a schematic view of the structure of the packaging layer of the present invention;
FIG. 4 is a data flow diagram of an operating framework according to a first embodiment of the present invention;
fig. 5 is a schematic flowchart of a Web server process presence service address according to a first embodiment of the present invention;
fig. 6 is a schematic flowchart of a Web server process without a service address according to a first embodiment of the present invention;
FIG. 7 is a flowchart illustrating a process between a scheduler and a service process according to a first embodiment of the present invention;
fig. 8 is a flowchart illustrating an active creation service according to a first embodiment of the present invention.
Detailed Description
In order to explain technical contents, achieved objects, and effects of the present invention in detail, the following description is made with reference to the accompanying drawings in combination with the embodiments.
The most key concept of the invention is as follows: generating template classes through a Thrift custom data structure and an interface, and realizing custom templates; generating a packaging layer for the server to call, and realizing the analysis conversion between the server and the client; the framework for releasing the GIS service efficiently and simply is provided.
Referring to fig. 1, the present invention provides a method for operating a GIS service based on C + +, which includes:
defining a data structure and an interface through a thread; generating a template class according to the data structure and the interface;
generating a packaging layer respectively connecting the Web server and the thread;
after filling preset functions in the templates, integrally packaging to generate an interface library file and a function library file, and uploading the interface library file and the function library file to a Web server;
and appointing the path to be issued by the interface library file and the function library file through the configuration file.
From the above description, the beneficial effects of the present invention are: the invention is concentrated on the server side for releasing the functions, so that the function library developed by the secondary developer can realize efficient and easy functional service release through the framework provided by the invention. During the period, developers only need to concentrate on function development and do not need to know the implementation and technical details of network transmission, a publishing process and a server. (taking the e-commerce platform as an example: each merchant needs to set up a website to provide product information, the appearance of Taobao provides a uniform e-commerce platform and provides rules for opening shops on the e-commerce platform, integrates pages of home electric appliances of each merchant and provides consistent service for the outside.
Further, the defining a data structure and an interface through a thread specifically includes:
defining a preset data structure by combining various basic types in the thread script language;
the out-going and in-going of the RPC interface are defined by specifying any basic type or specific data structure in the Thrift script language.
As can be seen from the above description, the data structure defined by IDL can be transmitted over the network without concern for serialization.
Further, the method also comprises the following steps:
the client initiates a function request in an REST mode;
after receiving the request, the Web server inquires a dispatcher whether a service address corresponding to the request exists;
if not, a new port is allocated to indicate the Web server to establish a new service process and monitor the RPC call request;
if yes, returning the port number corresponding to the service address;
and initiating RPC call to the Web server according to the packaging layer.
Further, the function request comprises a parameter string in a json format;
RPC calling is carried out according to the packaging layer, and the method specifically comprises the following steps:
acquiring a module and a method name corresponding to the request;
separating the parameter string to obtain each parameter, wherein each parameter consists of a variable name and a corresponding value;
establishing a data dictionary for the variable name and the corresponding value in each parameter, and transmitting the data dictionary to a packaging layer;
and matching assignment in a packaging layer according to the variable name and the member variable name in the data structure defined by the Thrift, and finishing RPC calling.
Further, the query dispatcher judges whether a service address corresponding to the request exists; if not, a new port is allocated to indicate the Web server to establish a new service process and monitor the RPC call request; if yes, returning the port number corresponding to the service address; the method specifically comprises the following steps:
after receiving the inquiry of the Web server, the dispatcher searches a service list of the dispatcher by taking the service name in the request as a key;
if the corresponding service address exists in the service list and the state is a journey, returning the corresponding port number;
if not, a port number is distributed, a service process named by the service name is created on the port number, and the service process is marked to be in an opening state.
According to the description, after the client initiates the service release request, the Web server can initiate the RPC call based on the packaging layer to realize the efficient release of the function.
The invention provides another technical scheme as follows:
a computer-readable storage medium, having stored thereon a computer program which, when invoked by a processor, is capable of performing the steps of:
defining a data structure and an interface through a thread; generating a template class according to the data structure and the interface;
generating a packaging layer respectively connecting the Web server and the thread;
after filling preset functions in the templates, integrally packaging to generate an interface library file and a function library file, and uploading the interface library file and the function library file to a Web server;
and appointing the path to be issued by the interface library file and the function library file through the configuration file.
Further, the step of defining the data structure and the interface through the thread specifically includes:
defining a preset data structure by combining various basic types in the thread script language;
the out-going and in-going of the RPC interface are defined by specifying any basic type or specific data structure in the Thrift script language.
Further, when called, the program can further execute the following steps:
the client initiates a function request in an REST mode;
after receiving the request, the Web server inquires a dispatcher whether a service address corresponding to the request exists;
if not, a new port is allocated to indicate the Web server to establish a new service process and monitor the RPC call request;
if yes, returning the port number corresponding to the service address;
and initiating RPC call to the Web server according to the packaging layer.
Further, the function request in the step includes a parameter string in a json format;
the RPC calling step is carried out according to the packaging layer, and specifically comprises the following steps:
acquiring a module and a method name corresponding to the request;
separating the parameter string to obtain each parameter, wherein each parameter consists of a variable name and a corresponding value;
establishing a data dictionary for the variable name and the corresponding value in each parameter, and transmitting the data dictionary to a packaging layer;
and matching assignment in a packaging layer according to the variable name and the member variable name in the data structure defined by the Thrift, and finishing RPC calling.
Further, the query dispatcher judges whether a service address corresponding to the request exists; if not, a new port is allocated to indicate the Web server to establish a new service process and monitor the RPC call request; if yes, returning to the step of the port number corresponding to the service address; the method specifically comprises the following steps:
after receiving the inquiry of the Web server, the dispatcher searches a service list of the dispatcher by taking the service name in the request as a key;
if the corresponding service address exists in the service list and the state is a journey, returning the corresponding port number;
if not, a port number is distributed, a service process named by the service name is created on the port number, and the service process is marked to be in an opening state.
Example one
Referring to fig. 2, the present embodiment provides a C + + based GIS service operation method, which issues a functional interface using a RESTful style. (RESTful style is the most mainstream and mature design style of Web application, has the advantages of stateless, strong readability, self-description, capability of providing an open interface, convenience for integration of a third-party system, improvement of operability, horizontal extension of application and the like)
A Web server developed based on nginnx opens a platform (good compared with a panning platform), a function development module is established on the present embodiment (good compared with that each merchant opens a shop in panning), and after a client selects a function required by the client (a consumer selects a shop on the platform according to the requirement), a call request is initiated (a panning user sends out a confirmation purchase) and parameters (id, number, receiving address and the like of a purchased commodity) are provided.
And converting the parameters into data objects through json analysis.
The embodiment provides two types of interfaces, namely a registration service interface and a service calling interface, wherein the registration service interface is better than that of a merchant requesting to open a shop on a Taobao platform, and the service calling interface is better than that of a consumer requesting to purchase.
Registering the service request: nginx newly generates a sub-process, and the sub-process starts RPC service through Thrift after loading the function library.
Service invocation request: and informing the Nginx of the service address of the functional module requested by the Nginx through the service scheduling processing program to initiate RPC service call (the Taobao platform finds the merchant and informs the merchant of order information), and returning the result as HTTP Response.
The embodiment provides an access method (similar to the rules of opening a shop on an Taobao platform) by means of a mechanism for automatically generating codes through a thread (the RPC opening source project of the thread, and the characteristics of cross-platform requirements for solving the large data volume transmission communication among systems in a service system and the difference of language environments among the systems) can be summarized as including:
the interface code is generated and a packaging layer (a communication layer between the platform and the service, similar to an interface ordered by Taobao and merchants) is generated at the same time.
And generating parameter structure bodies required by the functional modules, such as information of the number of set parameters and the like of the clients ip and url.
It should be noted that, at present, rules provided by similar service frameworks on the market have a lot of requirements on service developers, and services developed by the developers need to implement at least a specific class or interface thereof or contain files provided by the developers to bind a publishing platform and the services together. In the embodiment, the required packaging layer is automatically generated by means of the thread (modified version), no invasive requirement exists, and a service developer can completely develop the packaging layer according to own habit without inheriting classes or realizing interfaces or containing files.
In this embodiment, on the basis of publishing the Web service by the Nginx, the function module library is automatically loaded (see fig. 4, if the service does not exist, the service is automatically created), and the parameter type is automatically converted to the corresponding data object to provide the data needed by the function developer; the Nginx framework can provide higher load and concurrent access capability, more effectively utilize performance and processing capability of a squeezing machine, and in combination with the Thrift (Thrift source codes are modified according to the embodiment so that the generated codes can be loaded and used by the embodiment), a rule is provided so that a function developer can publish functions based on the embodiment (compared with a case that a merchant needs to shop on a Taobao platform according to Taobao rules, the embodiment provides a platform and also provides function publishing rules). When the Web service is operated, a new function is required to be issued without stopping, the operation framework is restarted (see fig. 4, if the service does not exist, the service is automatically created), manual intervention is not required in the issuing process, and developers can use the Web service issuing function through the network platform without knowing network layer knowledge or even RESTful style.
Specifically, the frame structure of the present invention is mainly composed of two parts: a Web platform (e.g., a Taobao platform that accepts client requests and distributes and manages merchants and service providers), and a wrapper layer (generated by a Thrift) (e.g., an interface between Taobao platform and merchants). The services provided externally are mainly classified into two types: registration of service requests and service invocation requests while providing an access rule and ensuring as simple loose coupling of rules as possible.
A Web platform: and the method is realized based on a custom http module developed above Nginx. Nginx as an open source high performance HTTP and reverse proxy server provides us with a framework for sending and receiving HTTP requests, and our custom module handles all incoming requests and asks the dispatcher, opens up new services for management and hands over to platform-based functions (all shops managed by Taobao) through wrapper resolution.
Packaging layer: data transmitted on a network are byte streams, data structures used by a function developer are various (including numbers, floating point numbers, character strings and even self-defined complex structures), most of the realization modes are that the byte streams are directly handed to the function developer to be analyzed by the function developer (the function developer knows which data, formats and sequences are needed), and other schemes are that the function developer inherits or realizes protocol conversion related interfaces, and the common modes all need the function developer to process things related to protocol conversion (similar to the fact that a Taobao merchant needs only goods id (numbers), quantity (numbers) and remarks (character strings) purchased by a consumer without paying attention to how byte stream data received on the network are converted into information such as numbers).
The thread is an IDL (interface definition language) that defines a data structure for network transmission and a service interface for RPC calls. The user can call the RPC service (seamless switching from byte stream of network transmission to data) through the Thrift client only by defining the required data structure and service interface in the script.
For example, a developer of a mapping service function may define the required data structure and service interface format as follows:
data structure: DrawItem { int Picture id, string Format }
Function name: DrawFunc (parameter: DrawItem)
Then, a c + + code frame of a specified language can be generated according to a script through a Thrift command, a function developer fills a logic function in the generated code frame, and a client (a party requesting for a picture) can call a service interface provided by a picture function party by using a thread client in the following manner:
drawltem request { picture id: 123456, format: "PNG" };
picture drawfunc (request);
the problem here is that the call service has to use a swift client, while our client does not use a swift and the request format is not a DrawItem structure but a json-like string of DrawItem: "{" DrawItem ": { "picture id": 123456, "format": "PNG" } ", it can be seen that the Thrift cannot be directly used in the framework, and here, we modify the Thrift source code, so that a c + + code framework is generated according to the script, and a packaging layer is also generated to perform conversion work between json character strings and a DrawItem structure, so that a function developer does not need to pay attention to protocol conversion (a specific application scenario provided in the second embodiment is described).
Referring to fig. 2, a service publishing process based on a runtime framework includes:
compiling a thread script, and defining a parameter data structure and an interface; namely, the template class is generated by using a Thrift command, wherein the data structure and the interface input and output parameters are generated, and the function is filled.
Generating a template class, and filling required functions according to the service to be issued;
packing the interface library and the function library and uploading to a Web server; the class code with filled functions is packaged, and the class code has two library files of an interface and the functions.
Filling a configuration file, specifying an interface library and a function library, and if necessary, specifying a REST path (default/ip: port/service name/function name $ parameter) which each function interface needs to provide access to a client.
As can be seen from the above description, the function developer need not be concerned with the details of the network and the manner in which the service is distributed.
Further, the "writing a thread script, defining a parameter data structure and an interface" specifically includes:
the swift defines its own script language, which includes various basic types (including i32, string, etc.) and RPC interface, these basic types can be freely assembled into a certain specific data structure, the RPC interface out-reference and in-reference can be any specified swift basic or specific data structure, and the data structure defined by this IDL can be transmitted in the network without concern of serialization.
Further, the "generate class template, fill function" specifically is:
by using the thread command line tool, the written IDL script can be generated into a template class (here, c + + language) of a specified language, for example:
thrift-r--gen cpp./name.thrift
in the embodiment, in order to enable the functional module to be automatically converted into parameters and release service and automatically call the service to achieve the purpose that manual intervention is not needed in the release process, a packaging layer which can be called by the Web service is also generated in the class template code generated by the Thrift; the structure of the packaging layer is shown in fig. 3.
And after receiving the parameters converted by the Web service layer, the packaging layer generates and assigns a structure body defined in the corresponding Thrift IDL according to parameter name matching, and then initiates RPC calling and returns the structure.
Further, the "package interface library and function library and upload" is specifically:
at the moment, function developers have a code generated by the Thrift, a packaging layer code and a logic function code written by the function developers, wherein the packaging layer belongs to an interface for Web calling function service, the logic function belongs to a specific function implementation for starting a service process, the logic function is separated so as to make a Web server for protocol conversion facing a client end logically unrelated, and a service subprocess loads a third party library dependent on the function while loading a function library.
As can be seen from the above description, the function developer can implement service release only by defining each data structure and interface format in the IDL, filling the required functions and submitting the packed library file to the Web server, and the release details do not need the developer to pay attention and can specify the release path through the configuration file, thereby greatly improving the efficiency of service release; meanwhile, the specified requirements on the release path are also ensured, and uniform rules and management are provided for different service releases.
Referring to fig. 4, the data flow of the operation framework includes:
the client side initiates a function request in an REST mode, wherein the function request comprises a json format parameter string, if the function request is in a GET mode, the function request exists in a request path, and if the function request is in a POST request, the function request is in a BODY.
After receiving the request, the Web server firstly inquires a scheduler about a service address corresponding to the request, a server list exists in the scheduler in a thread-safe hash table, and if the service address corresponding to the request does not exist, a new port is allocated to indicate the Web server to create a new service process and monitor an RPC request.
Specifically, if the scheduler determines that a service address corresponding to the request exists, an RPC call is initiated, the called method name and the called parameter come from the client parameter, the Web layer is only responsible for parameter conversion, and the specific call is completed by a code automatically generated in the packaging layer.
If not, then a service process is created on the port specified by the scheduler, with the child process named by the service name.
Referring to fig. 5 and fig. 6, the process executed by the Web server includes:
the Web server is created based on a known open source framework Nginx and is realized in a mode of self-defining modules, and a target service process is found in a module through intercepting all/IP: PORT/EPGIS (prefix) requests and secondary routing.
Client path access rules:
http:// 127.0.0.0.1/EPGIS/module name (directory name)/function name (function name by default)? A parameter;
further, the request is: PORT/EPGIS/Module name/method name? Parameter 1& parameter 2;
after obtaining module and method names in the request processing, determine? ' taking out the parameter string, and separating each parameter by ' & ' to obtain similarity:
param1 is "1234", param2 is "string" of characters; and then, taking the variable name as a key and the value as value, storing the key in the map, transmitting the key to a packaging layer, matching assignment in the packaging layer according to the variable name and the structure and member variable names defined in the Thrift IDL, and completing RPC calling.
Referring to fig. 7, the flow between the scheduler and the service process includes:
the scheduler is independent of Web service and service process, and includes a service name mapping port address and service state list for service registration, discovery, state monitoring, etc.
The single point of existence of the dispatcher can simultaneously serve a plurality of Web terminals and service processes and receive network requests, messages are all information transmission and control between servers, and data packets are usually only 10 bytes.
After receiving the service inquiry of the Web server, the dispatcher searches the service list of the dispatcher by taking the service name as a key:
and if the state is normal, returning the corresponding port number.
If the same-name service does not exist, a port number is allocated, the service is added into the list, the service is marked to be in the starting state, the corresponding state in the list is modified to be a normal mark after the service process sends a successful starting message, and the process is concurrent and safe.
After the service process is started, a heartbeat packet is sent to the scheduler every 1 second to indicate that the service is normal, and if the heartbeat is not received in 5 seconds, the service is considered to be unavailable.
Referring to fig. 8 for an active create service, including:
the Web server can receive the request to create the service, and after receiving the request, the Web server sends the created service module name to the dispatcher to inquire whether the creation of the service is allowed, and if the creation is allowed, the creation flow is the same as the above according to the returned port number.
Example two
This embodiment corresponds to the first embodiment, and provides a specific application scenario
The specific development implementation and release process is explained by taking development of a graph service function as an example as follows:
setting a service name TestServ, wherein parameters required in the request include a picture id and a picture type, an interface name is get, and a return structure clih. status code, data format returned by content _ type ("text/play" string, "img" picture, etc.), (ii) status code, content _ type, etc.),
body (returning data content)
Figure BDA0001502040940000121
Firstly, defining the required data structure Request and interface get formats in a thread script (without the requirement of a script file name) as follows:
Figure BDA0001502040940000122
then, using the customized version of the thread command line tool provided by the invention to generate a functional template frame:
thrift-r--gen cpp test.thrift
the generated class template is as follows (the default generated c + + file is the service name _ server.
Figure BDA0001502040940000123
Figure BDA0001502040940000131
It can be seen that this is a very clean function class template, and we fill our function logic in the function logic fill area, where we simply open a client-requested local picture and then return it
Figure BDA0001502040940000132
The development of a simple service function is completed, and the process can be seen without inheriting any class or interface or including header files and the like, and finally the functions are packaged into a dynamic library to be uploaded:
g++-g-fpermissive-fPIC-shared-std=c++11TestServ_server.skeleton.cpp-o libTestServ.so
the running framework can now be informed of the loading service, and according to the aforementioned we can either actively load or rely on the automatic loading of the framework, if needed, the active loading sends the following request:
http://127.0.0.1/EPGIS/TestServ can load the module with the function service name TestServ.
Nothing is done if automatic loading is to be done.
The client requests the TestServ service, the picture id is 1 and the type is jpeg, and the legal path parameters according to the rule are as follows:
http://127.0.0.1/EPGIS/TestServ/get?{“req”:{“id”:1,“type”:“jpeg”}}
the invention is mainly composed of two parts as mentioned above: a Web platform and a wrapper.
A Web platform:
nginx gives us the defined module after receiving an HTTP request.
Active loading:
the library file submitted by the service function developer before can be found in the module according to the requested service name TestServ: so, libTestServ
Creating a sub-process, creating a service (through the wrapper layer) based on the address assigned to the service by the scheduler (FIG. 6)
Automatic loading:
after receiving the HTTP request, the dispatcher queries the address of the service according to the service name, and if the service is a new service (fig. 4):
the scheduler returns the address assigned to the new service TestServ and marks the need to create the new service, such as: port number: 10089
And the Web platform creates a subprocess according to the marking requirement and loads the library file creating service.
Initiating a request for a service:
first, a function name and a parameter json string are extracted, here: get and get { "req {" id ": 1," type ": jpeg }", and then give the parameter json string to the wrapper, i.e., the thread we have modified passes
third, the wrapper layer will complete the aforementioned conversion work from json character string to structure (here, the Request structure contains a number (id) and a character string (type)), and the function developer need not pay attention to the protocol conversion.
It can be seen that the function developer receives the defined data structure, and can directly implement the function, in the example, after returning the picture information to the Web platform, it will directly return to the client requesting the graph function.
EXAMPLE III
This embodiment corresponds to the first embodiment, and provides a computer-readable storage medium, on which a computer program is stored, which, when called by a processor, can perform all the steps in the first embodiment.
In summary, the C + + based GIS service operation method and the readable storage medium provided by the present invention provide a framework for releasing service functions efficiently and easily. The simple operation and the simple rule are ensured as much as possible; meanwhile, the protocol conversion is realized by generating a packaging layer, so that a function developer does not need to pay attention to the protocol conversion. The invention can realize the function of releasing the Web service by using the network platform without manual intervention of a function developer, network layer knowledge or RESTful style.
The above description is only an embodiment of the present invention, and not intended to limit the scope of the present invention, and all equivalent changes made by using the contents of the present specification and the drawings, or applied directly or indirectly to the related technical fields, are included in the scope of the present invention.

Claims (6)

1. A C + + based GIS service operation method is characterized by comprising the following steps:
defining a data structure and an interface through a thread; generating a template class according to the data structure and the interface, wherein the defined data structure comprises a data structure body Request;
generating a packaging layer respectively connecting the Web server and the thread;
after filling preset functions in the templates, integrally packaging to generate an interface library file and a function library file, and uploading the interface library file and the function library file to a Web server;
appointing paths to be issued by the interface library file and the function library file through the configuration file;
further comprising:
the client initiates a function request in an REST mode;
after receiving the request, the Web server inquires a dispatcher whether a service address corresponding to the request exists;
if not, a new port is allocated to indicate the Web server to establish a new service process and monitor the RPC call request;
if yes, returning the port number corresponding to the service address;
initiating RPC calling to a Web server according to the packaging layer;
the function request comprises a parameter string in a json format;
RPC calling is carried out according to the packaging layer, and the method specifically comprises the following steps:
acquiring a module and a method name corresponding to the request;
separating the parameter string to obtain each parameter, wherein each parameter consists of a variable name and a corresponding value;
establishing a data dictionary for the variable name and the corresponding value in each parameter, and transmitting the data dictionary to a packaging layer;
matching and assigning values in a packaging layer according to variable names and member variable names in a data structure defined by Thrift, converting parameter strings in a json format into the data structure Request, and completing RPC calling.
2. The C + + based GIS service operation method according to claim 1, wherein the data structure and the interface are defined by a thread, and specifically:
defining a preset data structure by combining various basic types in the thread script language;
the out-going and in-going of the RPC interface are defined by specifying any basic type or specific data structure in the Thrift script language.
3. The C + + based GIS service execution method of claim 1, wherein the query dispatcher queries whether a service address corresponding to the request exists; if not, a new port is allocated to indicate the Web server to establish a new service process and monitor the RPC call request; if yes, returning the port number corresponding to the service address; the method specifically comprises the following steps:
after receiving the inquiry of the Web server, the dispatcher searches a service list of the dispatcher by taking the service name in the request as a key;
if the corresponding service address exists in the service list and the state is a journey, returning the corresponding port number;
if not, a port number is distributed, a service process named by the service name is created on the port number, and the service process is marked to be in an opening state.
4. A computer-readable storage medium, on which a computer program is stored, said program, when being called by a processor, being able to carry out the steps of:
defining a data structure and an interface through a thread; generating a template class according to the data structure and the interface, wherein the defined data structure comprises a data structure body Request;
generating a packaging layer respectively connecting the Web server and the thread;
after filling preset functions in the templates, integrally packaging to generate an interface library file and a function library file, and uploading the interface library file and the function library file to a Web server;
appointing a path to be issued by the interface library file and the function library file through a configuration file;
when the program is called, the following steps can be executed:
the client initiates a function request in an REST mode;
after receiving the request, the Web server inquires a dispatcher whether a service address corresponding to the request exists;
if not, a new port is allocated to indicate the Web server to establish a new service process and monitor the RPC call request;
if yes, returning the port number corresponding to the service address;
initiating RPC calling to a Web server according to the packaging layer;
the function request in the step comprises a parameter string in a json format;
the RPC calling step is carried out according to the packaging layer, and specifically comprises the following steps:
acquiring a module and a method name corresponding to the request;
separating the parameter string to obtain each parameter, wherein each parameter consists of a variable name and a corresponding value;
establishing a data dictionary for the variable name and the corresponding value in each parameter, and transmitting the data dictionary to a packaging layer;
matching and assigning values in a packaging layer according to variable names and member variable names in a data structure defined by Thrift, converting parameter strings in a json format into the data structure Request, and completing RPC calling.
5. The computer-readable storage medium according to claim 4, wherein the defining the data structure and the interface by the thread comprises:
defining a preset data structure by combining various basic types in the thread script language;
the out-going and in-going of the RPC interface are defined by specifying any basic type or specific data structure in the Thrift script language.
6. A computer-readable storage medium according to claim 4, wherein the query dispatcher determines whether a service address corresponding to the request exists; if not, a new port is allocated to indicate the Web server to establish a new service process and monitor the RPC call request; if yes, returning to the step of the port number corresponding to the service address; the method specifically comprises the following steps:
after receiving the inquiry of the Web server, the dispatcher searches a service list of the dispatcher by taking the service name in the request as a key;
if the corresponding service address exists in the service list and the state is a journey, returning the corresponding port number;
if not, a port number is distributed, a service process named by the service name is created on the port number, and the service process is marked to be in an opening state.
CN201711306422.1A 2017-12-11 2017-12-11 C + + based GIS service operation method and storage medium Active CN108038796B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201711306422.1A CN108038796B (en) 2017-12-11 2017-12-11 C + + based GIS service operation method and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201711306422.1A CN108038796B (en) 2017-12-11 2017-12-11 C + + based GIS service operation method and storage medium

Publications (2)

Publication Number Publication Date
CN108038796A CN108038796A (en) 2018-05-15
CN108038796B true CN108038796B (en) 2021-02-26

Family

ID=62101577

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201711306422.1A Active CN108038796B (en) 2017-12-11 2017-12-11 C + + based GIS service operation method and storage medium

Country Status (1)

Country Link
CN (1) CN108038796B (en)

Families Citing this family (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109871289B (en) * 2019-02-01 2020-03-10 北京顺丰同城科技有限公司 Remote Procedure Call (RPC) service generation method and device
CN109902274B (en) * 2019-02-22 2023-05-30 今天东翼科技有限公司 Method and system for converting json character string into thraft binary stream
CN110457144B (en) * 2019-08-05 2021-12-07 北京字节跳动网络技术有限公司 Method, device, medium and equipment for realizing front-end application
CN111405029B (en) * 2020-03-12 2023-06-02 北京字节跳动网络技术有限公司 Request processing method and device
CN111414161B (en) * 2020-03-27 2023-05-12 北京字节跳动网络技术有限公司 Method, device, medium and electronic equipment for generating IDL file
CN111475317B (en) * 2020-04-17 2023-09-15 上海中通吉网络技术有限公司 Spark batch time modification method, device, equipment and storage medium
CN112114793B (en) * 2020-09-14 2023-09-22 中国船舶重工集团公司第七0九研究所 Code generation method and system for converting general JSON object into C/C++ structured object
CN113448655B (en) * 2021-07-09 2022-06-17 赞同科技股份有限公司 C standard dynamic library calling method and device

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20040064503A1 (en) * 2002-02-22 2004-04-01 Bea Systems, Inc. System and method for web services Java API-based invocation
CN102323884A (en) * 2011-09-07 2012-01-18 山东中创软件工程股份有限公司 Web service container and method for issuing multiple Web services
CN106776497A (en) * 2016-11-25 2017-05-31 腾讯科技(深圳)有限公司 Information processing method and information processor

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20040064503A1 (en) * 2002-02-22 2004-04-01 Bea Systems, Inc. System and method for web services Java API-based invocation
CN102323884A (en) * 2011-09-07 2012-01-18 山东中创软件工程股份有限公司 Web service container and method for issuing multiple Web services
CN106776497A (en) * 2016-11-25 2017-05-31 腾讯科技(深圳)有限公司 Information processing method and information processor

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
Windows下安装Thrift框架及工程实例;罗李林;《百度文库》;20170226;第1-13页 *
火灾视频识别及远程智能报警系统;吴昭质;《中国优秀硕士学位论文全文数据库信息科技辑》;20160515;正文第44页 *

Also Published As

Publication number Publication date
CN108038796A (en) 2018-05-15

Similar Documents

Publication Publication Date Title
CN108038796B (en) C + + based GIS service operation method and storage medium
WO2019184750A1 (en) Deep learning task scheduling method and system and related apparatus
EP1483671B1 (en) Provisioning aggregated services in a distributed computing environment
US9489243B2 (en) Federating computing resources across the web
US8135668B2 (en) Service composition environment
TWI225990B (en) Autonomic provisioning of network-accessible service behaviors within a federated grid infrastructure
US10091086B2 (en) System and method for providing an application programming interface manager for use with a service bus runtime
US20140033170A1 (en) System and method of generating rest2rest services from wadl
US20050091374A1 (en) Aspect oriented web service invocation
Bouloukakis et al. Automated synthesis of mediators for middleware-layer protocol interoperability in the IoT
WO2019163793A1 (en) Api adapter, api adapter creation method, and program
JP2000322395A (en) Method and device for coordination proxy system for distribution of object rendering
US10353750B2 (en) Discovery and exposure of transactional middleware server-based applications as consumable service endpoints
KR101602099B1 (en) System for Service inter-working based REST in Internet of Things and Method thereof
JP2002132739A (en) Stab retrieval loading system and method, server device, client device and computer readable recording medium
MXPA06000106A (en) Web application architecture.
CN114254606A (en) Microservice framework model
Wainer et al. Standardizing DEVS Simulation Middleware
Kang et al. Android RMI: a user-level remote method invocation mechanism between Android devices
Nakagawa et al. Dripcast-architecture and implementation of server-less Java programming framework for billions of IoT devices
JP2007507028A (en) Web service contract selection system
Baraki et al. Sam: A semantic-aware middleware for mobile cloud computing
Zhang et al. Design and implementation of single-service multi-function Webservice
EP2101474A1 (en) Service bindings for web services
Steele et al. XML-based mobile agents

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
CB03 Change of inventor or designer information

Inventor after: Li Qiang

Inventor after: Chen Ling

Inventor after: Lin Liming

Inventor after: Sun Yayi

Inventor after: Lin Li

Inventor after: Sun Mingshan

Inventor after: Zhao Jianwei

Inventor after: Zhou Hangfan

Inventor after: Fu Ning

Inventor before: Chen Ling

Inventor before: Lin Liming

Inventor before: Sun Yayi

Inventor before: Lin Li

Inventor before: Sun Mingshan

CB03 Change of inventor or designer information