CN111736844B - Database cloud service standard interface and implementation method - Google Patents

Database cloud service standard interface and implementation method Download PDF

Info

Publication number
CN111736844B
CN111736844B CN202010504556.XA CN202010504556A CN111736844B CN 111736844 B CN111736844 B CN 111736844B CN 202010504556 A CN202010504556 A CN 202010504556A CN 111736844 B CN111736844 B CN 111736844B
Authority
CN
China
Prior art keywords
interface
file
type
analysis
service
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
CN202010504556.XA
Other languages
Chinese (zh)
Other versions
CN111736844A (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.)
State Grid Gansu Electric Power Co Ltd
Nari Technology Co Ltd
State Grid Electric Power Research Institute
Information and Telecommunication Branch of State Grid Gansu Electric Power Co Ltd
Original Assignee
State Grid Gansu Electric Power Co Ltd
Nari Technology Co Ltd
State Grid Electric Power Research Institute
Information and Telecommunication Branch of State Grid Gansu Electric Power 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 State Grid Gansu Electric Power Co Ltd, Nari Technology Co Ltd, State Grid Electric Power Research Institute, Information and Telecommunication Branch of State Grid Gansu Electric Power Co Ltd filed Critical State Grid Gansu Electric Power Co Ltd
Priority to CN202010504556.XA priority Critical patent/CN111736844B/en
Publication of CN111736844A publication Critical patent/CN111736844A/en
Application granted granted Critical
Publication of CN111736844B publication Critical patent/CN111736844B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/42Syntactic analysis
    • G06F8/425Lexical analysis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/25Integrating or interfacing systems involving database management systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/31Programming languages or programming paradigms
    • G06F8/315Object-oriented languages
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/42Syntactic analysis
    • G06F8/427Parsing
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/44Encoding
    • G06F8/447Target code generation

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Databases & Information Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Computing Systems (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention discloses a database cloud service standard interface and an implementation method thereof, and provides a standardized cloud service interface under a database cloud service application framework based on physical resources, the interface dynamic expansion is realized through a user-defined interface file, a client/server interface code file is automatically generated through a code generator, and a user can quickly realize the function customization development of the database cloud service interface and generate corresponding interface service after compiling. The invention provides a method for quickly realizing the standard database cloud service aiming at physical resources, so that a user can concentrate on the processing of business logic without concerning the transmission details of an interface bottom layer.

Description

Database cloud service standard interface and implementation method
Technical Field
The invention relates to the technical field of computers, in particular to a database cloud service standard interface and an implementation method.
Background
With the development of internet applications, the types and usage modes of database cloud services are increasing. The required related services are obtained through the network in an on-demand and easily-expandable mode, the required software and hardware resources are uploaded to the network, and different IT devices are used for being connected with each other at specific time and places to achieve the purposes of data access operation and the like.
However, the number of related data resources is large, resource management and scheduling are complex, and rapid and reasonable adaptation of resources cannot be performed on service system data with large scale and high use frequency in time, so that the use efficiency of the data resources in a cloud environment is affected. Aiming at the change of database cloud service of physical resources, an automatic interface service is urgently needed, and business customization is quickly responded.
Disclosure of Invention
The purpose of the invention is as follows: aiming at the problems, the invention provides a database cloud service standard interface and an implementation method thereof, which realize the integrated management, the centralized automatic deployment and the standardized operation of database resources through the standardized interface service.
The technical scheme is as follows: in order to realize the purpose of the invention, the technical scheme adopted by the invention is as follows: a database cloud service standard interface comprises an interface file and a code generator; the interface file is used for defining the data type and the service type of the communication interface; the service type defines an interactive interface between a client and a server; the code generator is used for checking the interface file, performing lexical/syntactic analysis on the data type and the service type defined in the interface file, checking the data type, generating an analysis tree, placing each service type into the analysis tree, and generating a code according to the analysis tree; and creating a service according to the service type, and generating interface frame codes of the client and the server through a protocol stack.
Further, the data types include a basic type, an entity type, a container type, an enumeration type, and an exception type.
Furthermore, the protocol stack adopts a layered design, including a service layer, an interface layer, a protocol layer, a transmission layer, and a bottom layer. The service layer is used for realizing service logic codes; the interface layer is used for automatically generating a client/server interface code; the protocol layer is used for defining a data transmission format; the transmission layer is used for defining a data transmission mode; the bottom layer is used to implement the actual data transfer.
A method for realizing a database cloud service standard interface comprises the following steps:
(1) generating an interface file according to the data type and the service type;
(2) and the code generator reads the interface file, completes data type check, performs lexical/syntactic analysis on the service type defined in the interface file, generates a parsing tree and finally generates a code file.
Further, the step (2) specifically includes:
(2.1) analyzing the interface file, checking the data type and generating a corresponding analysis tree;
(2.2) carrying out lexical/syntactic analysis on the service type of the interface file, and filling the analysis result into the generated analysis tree;
and (2.3) generating a code file according to the analysis tree.
Further, the step (2.1) further includes finding out a directory where the file is located according to the interface file name, setting the directory containing the file, and setting a subsequent code output path.
Further, the step (2.2) comprises:
(2.2.1) checking whether an interface file is embedded, setting an analysis mode to be INCLUDE, and caching an analysis result in a global variable of a main program class; if the embedded interface files are contained, recursively calling an analysis function to perform lexical/syntactic analysis on each interface file;
(2.2.2) carrying out lexical/syntactic analysis on the data type and the service type defined in the interface file, setting an analysis mode to be PROGRAM, and initializing global variables.
Has the beneficial effects that: according to the method, for different database cloud services, interface service dynamic expansion is realized through an interface file according to service requirements; by automatically generating codes, on the basis of an interface framework, service logic is packaged, and interface functions are quickly customized and developed; the protocol stack shields the complexity of bottom layer communication, so that a user can concentrate on the realization of business logic without paying attention to network programming details, and the working efficiency is improved.
Drawings
FIG. 1 is an overall architecture diagram of the present invention;
fig. 2 is a schematic diagram of a code generator in the present invention.
Detailed Description
The technical solution of the present invention is further described below with reference to the accompanying drawings and examples.
As shown in fig. 1, the database cloud service standard interface according to the present invention includes an interface file, a code generator, and a protocol stack.
The interface file is used to define the communication interface data type and the service type. The data types include basic types, entity types, container types, enumeration types, exception types.
The code generator is used for checking the interface file, performing lexical/syntactic analysis on the data type and the service type defined in the interface file, checking the data type, generating an analysis tree, placing each service type into the analysis tree, automatically generating a code according to the analysis tree, and executing compilation; then, the user realizes business logic processing, and the database cloud service is embodied in a standard interface form.
The protocol stack is used for internal realization of the code generator and adopts a layered design idea. The protocol stack is used for connecting the client and the server, the client calls the service, and the server provides the service. The protocol stack comprises a service layer, an interface layer, a protocol layer, a transmission layer and a bottom layer.
As shown in fig. 1 and 2, the method for implementing a standard interface of a database cloud service according to the present invention includes the following steps:
(1) generating an interface file according to the data type and the service type;
the service type defines an interactive interface between the client and the server, and the service is created to finally generate frame codes of the client and the server.
The data types include basic types, entity types, container types, enumeration types, exception types.
The basic types include: boolean type, 8-bit signed byte, 16/32/64-bit signed integer, 64-bit floating point number, character string, binary string; the entity type is a self-defined general entity object, and basic types are combined; an enumeration type is used for defining enumeration; the exception type is used for self-defining exception, appointing a state code and state description information; the container types include: list: ordered list of a series of data (elements may be repeated), set: a series of unordered sets of data (elements may not be repeated), map: dictionary structure, key-value form.
(2) The code generator reads the interface file, completes data type check, performs lexical/syntactic analysis on the service type defined in the interface file, generates an analysis tree, and finally generates a code file.
The specific execution flow comprises the following steps:
(2.1) analyzing the parameters, executing corresponding functions according to the parameter contents, mainly comprising checking version information, whether to print detailed execution process information, alarm levels and the like, and storing the information into a character string array;
(2.2) initializing global variables including variables of the main program class and class variables of various entity types, and allocating memory resources;
(2.3) analyzing the interface file, checking the data type and generating a corresponding analysis tree;
meanwhile, the directory where the file is located is found according to the name of the interface file, the directory containing the file is set, and a subsequent code output path is set.
(2.4) performing lexical/syntactic analysis on the data type and the service type defined in the interface file, and performing the lexical/syntactic analysis in two steps;
firstly, checking whether an interface file is embedded, setting an analysis mode to be INCLUDE, and caching an analysis result in a global variable of a main program class; if the embedded interface files are contained, recursively calling an analysis function to perform lexical/syntactic analysis on each interface file;
secondly, performing lexical/syntactic analysis on the data type and the service type defined in the interface file, setting an analysis mode to be PROGRAM, and initializing a global variable;
and the two analyses need to open an interface file to provide an analysis source, exception handling and file closing for an analysis program. And storing the analysis results of the two times into the global variable of the main program class, and filling the analysis results into the generated analysis tree.
And (2.5) analyzing the language type, wherein the default is Java, adapting to a plurality of development languages, and supporting cross-platform interface calling.
And (2.6) generating codes, namely generating a unique identification ID for each entity, enumeration and exception, and generating a client/server interface code framework, namely a protocol stack, of a corresponding language according to the language type, wherein the protocol stack comprises a service layer, an interface layer, a protocol layer, a transmission layer and a bottom layer.
The service layer packages service logic for users to use and is used for customizing service interface development.
The interface layer is used for automatically generating client/server interface codes and supporting synchronous, asynchronous, structured analysis and read-write operation.
The protocol layer defines a data transmission format, such as binary, JSON/XML, etc. The protocol layer assembles the structured data into a message structure or reads the structured data from the message structure. According to data transmission protocols under different scenes, such as binary system, compression, JSON and the like, object types are subjected to streaming processing, byte streams in a transmission layer are converted into data streams, and data are read out and written in according to specified data types. The transmission types of the communication protocols of the client and the server can be selected during calling, and are divided into text and binary transmission protocols; in order to save bandwidth and improve transmission efficiency, a binary transmission protocol is generally used.
The transport layer defines data transmission modes, such as blocking IO, non-blocking IO, memory IO, compression mode, file mode, and the like. The default of the transmission layer is to use TCP Socket to transmit data, and other transmission modes are defined as follows:
http transmission: carrying out data transmission by adopting an Http transmission protocol;
file transmission: allowing the client to transmit the file to the server, wherein the server can write the received data into the file;
compression and transmission: the method is matched with other Transport for use, and data is transmitted after being compressed or received data is decompressed;
buffering and transmission: and performing buffer buffering on the data operated by the Transport object, namely reading the data from the buffer for transmission, or directly writing the data into the buffer.
The underlying IO is responsible for actual data transmission, including Socket, file, or compressed data stream, etc.
The method for realizing the service layer interface framework comprises the following steps:
(2.6.1) API server side packaging;
A. declare a service agent, appoint a port, a service and an implementation class;
B. defining a server monitor, acquiring a registered service agent list, and monitoring a client request after service is started;
C. defining a service end agent, which mainly appoints a service type (non-blocking), a transmission protocol (such as binary protocol) and the like; when the container starts, the RPC interface service (Socket listening) is started.
(2.6.2) API client encapsulation;
A. generating a corresponding proxy object according to the designated rpcClass through a dynamic proxy factory, and appointing a host name and a port (to be consistent with the registration of a server) corresponding to the interface service;
B. based on TCP call, RpcClientproxy is defined, JDK dynamic proxy is adopted, InvocitionHandler is inherited, a factory method is realized, a constructor object is obtained from a generated class object through reflection, and a dynamic proxy class instance is created through the constructor object.
Based on the Http call, an RpcServelClientproxy is defined, ClosableHttpClient is realized, and the CloseableHttpClient is used as a parameter and is transmitted to a client of Http. Two Http transmission implementations are respectively provided, the first is a Http-url connection-based mode, and the second is an Http policy-based mode.
And (2.7) finally, clearing the global variable and releasing the originally allocated memory resource.
The invention provides a method for quickly realizing the standard database cloud service aiming at physical resources, so that a user can concentrate on the processing of business logic without concerning the transmission details of an interface bottom layer.
As will be appreciated by one skilled in the art, embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and so forth) having computer-usable program code embodied therein.
The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the application. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
Finally, it should be noted that: the above embodiments are only for illustrating the technical solutions of the present invention and not for limiting the same, and although the present invention is described in detail with reference to the above embodiments, those of ordinary skill in the art should understand that: modifications and equivalents may be made to the embodiments of the invention without departing from the spirit and scope of the invention, which is to be covered by the claims.

Claims (7)

1. The database cloud service standard interface is characterized by comprising an interface file and a code generator;
the interface file is used for defining the data type and the service type of the communication interface; the service type defines an interactive interface between a client and a server;
the code generator is used for checking the interface file, performing lexical/syntactic analysis on the data type and the service type defined in the interface file, checking the data type, generating an analysis tree, placing each service type into the analysis tree, and generating a code according to the analysis tree; the method comprises the steps of establishing service according to service types, and generating interface frame codes of a client and a server through a protocol stack.
2. The database cloud service standard interface of claim 1, wherein the data types include a base type, an entity type, a container type, an enumeration type, and an exception type.
3. The database cloud service standard interface of claim 1, wherein the protocol stack is designed in a layered manner and comprises a service layer, an interface layer, a protocol layer, a transport layer and a bottom layer.
4. The database cloud service standard interface of claim 3, wherein the business layer is configured to implement business logic code; the interface layer is used for automatically generating a client/server interface code; the protocol layer is used for defining a data transmission format; the transmission layer is used for defining a data transmission mode; the bottom layer is used to implement the actual data transfer.
5. A method for realizing a database cloud service standard interface is characterized by comprising the following steps:
(1) generating an interface file according to the data type and the service type;
(2) reading the interface file by the code generator, finishing data type check, generating an analysis tree, carrying out lexical/syntactic analysis on the service type defined in the interface file, and finally generating a code file;
the step (2) specifically comprises:
(2.1) analyzing the interface file, checking the data type and generating a corresponding analysis tree;
(2.2) carrying out lexical/syntactic analysis on the service type of the interface file, and filling the analysis result into the generated analysis tree;
and (2.3) generating a code file according to the analysis tree.
6. The database cloud service standard interface implementation method of claim 5, wherein the step (2.1) further includes finding a directory where the file is located according to the interface file name, setting a directory containing the file, and setting a subsequent generated code output path.
7. The database cloud service standard interface implementation method according to claim 5, wherein the step (2.2) comprises:
(2.2.1) checking whether an interface file is embedded, setting an analysis mode to be INCLUDE, and caching an analysis result in a global variable of a main program class; if the embedded interface files are contained, recursively calling an analysis function to perform lexical/syntactic analysis on each interface file;
(2.2.2) carrying out lexical/syntactic analysis on the data type and the service type defined in the interface file, setting an analysis mode to be PROGRAM, and initializing global variables.
CN202010504556.XA 2020-06-05 2020-06-05 Database cloud service standard interface and implementation method Active CN111736844B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010504556.XA CN111736844B (en) 2020-06-05 2020-06-05 Database cloud service standard interface and implementation method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010504556.XA CN111736844B (en) 2020-06-05 2020-06-05 Database cloud service standard interface and implementation method

Publications (2)

Publication Number Publication Date
CN111736844A CN111736844A (en) 2020-10-02
CN111736844B true CN111736844B (en) 2022-09-09

Family

ID=72648254

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010504556.XA Active CN111736844B (en) 2020-06-05 2020-06-05 Database cloud service standard interface and implementation method

Country Status (1)

Country Link
CN (1) CN111736844B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111913714B (en) * 2020-07-13 2022-08-26 国网电力科学研究院有限公司 Method and device for mapping substation control layer communication service of transformer substation based on Thrift
CN112612452B (en) * 2020-12-18 2023-11-14 华人运通(上海)云计算科技有限公司 API platform realization method, device, equipment and storage medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102063324A (en) * 2010-12-31 2011-05-18 杭州依赛通信有限公司 Method and system for implementing automatic programming
CN105141630A (en) * 2015-09-18 2015-12-09 厦门市光娱投资管理有限公司 Method and apparatus for automatic analysis of communication data between server and client
CN106412086A (en) * 2016-10-31 2017-02-15 武汉斗鱼网络科技有限公司 Method and system for automatically generating communication codes by employing protocol description file
CN108509201A (en) * 2018-03-20 2018-09-07 深圳神州数码云科数据技术有限公司 A kind of code generating method and device
CN110347522A (en) * 2019-07-09 2019-10-18 沈阳欧瑞科技有限公司 A kind of server-side and the integrated implementation method of client

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102063324A (en) * 2010-12-31 2011-05-18 杭州依赛通信有限公司 Method and system for implementing automatic programming
CN105141630A (en) * 2015-09-18 2015-12-09 厦门市光娱投资管理有限公司 Method and apparatus for automatic analysis of communication data between server and client
CN106412086A (en) * 2016-10-31 2017-02-15 武汉斗鱼网络科技有限公司 Method and system for automatically generating communication codes by employing protocol description file
CN108509201A (en) * 2018-03-20 2018-09-07 深圳神州数码云科数据技术有限公司 A kind of code generating method and device
CN110347522A (en) * 2019-07-09 2019-10-18 沈阳欧瑞科技有限公司 A kind of server-side and the integrated implementation method of client

Also Published As

Publication number Publication date
CN111736844A (en) 2020-10-02

Similar Documents

Publication Publication Date Title
US11409949B2 (en) Mobile device resource provisioning system and method
CN111158818B (en) Page rendering method and device
CN109308224B (en) Cross-platform data communication and cross-platform data processing method, device and system
US20200192646A1 (en) Compiler and method for compiling business rules for a serverless runtime environment
CN111399840B (en) Module development method and device
CN111736844B (en) Database cloud service standard interface and implementation method
CN106713469B (en) Dynamic loading method, device and system for distributed container
US11321090B2 (en) Serializing and/or deserializing programs with serializable state
CN108804100B (en) Method and device for creating interface element, storage medium and mobile terminal
CN111209001A (en) Method, system, equipment and medium for batch generation of APKs of android channels
CN113132371A (en) Message conversion method, device, computer readable storage medium and processor
US20230409417A1 (en) Automated generation of application programming interfaces for microservices
CN112052011A (en) Method and device for combining small programs, electronic equipment and medium
CN112134900B (en) Data message processing method and device
CN115934093A (en) Applet cross-terminal application method, related device and computer storage medium
CN112988225B (en) Annotation configuration method, device, equipment and storage medium
CN114327404A (en) File processing method and device, electronic equipment and computer readable medium
CN111857675A (en) Method and system for realizing RESTFUL service based on C + +
CN113127140B (en) Resource management method, device and system
CN113505036B (en) Application monitoring method, client and server
CN115114890A (en) Data analysis method and device, electronic equipment and readable medium
CN116382769A (en) Application program issuing method and device, electronic equipment and storage medium
CN115857891A (en) Front-end application program generation method and device, electronic equipment and storage medium
CN118057306A (en) Method, device, server, medium and program product for generating installation package
CN115878282A (en) Cross-platform interaction method, device and equipment

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