CN114860669A - Service call link acquisition method and device - Google Patents

Service call link acquisition method and device Download PDF

Info

Publication number
CN114860669A
CN114860669A CN202210595952.7A CN202210595952A CN114860669A CN 114860669 A CN114860669 A CN 114860669A CN 202210595952 A CN202210595952 A CN 202210595952A CN 114860669 A CN114860669 A CN 114860669A
Authority
CN
China
Prior art keywords
service
calling
link
target
name
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.)
Pending
Application number
CN202210595952.7A
Other languages
Chinese (zh)
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.)
Industrial and Commercial Bank of China Ltd ICBC
Original Assignee
Industrial and Commercial Bank of China Ltd ICBC
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 Industrial and Commercial Bank of China Ltd ICBC filed Critical Industrial and Commercial Bank of China Ltd ICBC
Priority to CN202210595952.7A priority Critical patent/CN114860669A/en
Publication of CN114860669A publication Critical patent/CN114860669A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/16File or folder operations, e.g. details of user interfaces specifically adapted to file systems

Landscapes

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

Abstract

The disclosure provides a method for acquiring a service calling link, which can be applied to the technical field of cloud computing. The method comprises the following steps: determining implementation type source files corresponding to all services in a service registration list according to the service registration list, wherein the service registration list is obtained by scanning a configuration file of a service provider; code scanning is carried out on the implementation type source file according to a preset service calling rule so as to obtain a plurality of service calling relations, wherein the preset service calling rule is used for representing service calling forms in the implementation type source file, and each service calling relation is a calling relation between two services; and calling a target function to process the service calling relations so as to generate a target service calling link. The disclosure also provides an acquisition device, equipment, a storage medium and a program product of the service call link.

Description

Service call link acquisition method and device
Technical Field
The present disclosure relates to the field of computer technologies, and in particular, to the field of test technologies, and in particular, to a method, an apparatus, a device, a storage medium, and a program product for acquiring a service invocation link.
Background
With the gradual maturity of the distributed technology, the number of services under the distributed system architecture is increasing, the service call link is more complex, and the range to be tested is also enlarged, when the micro-service in the distributed system is changed and upgraded, how to determine the test range and how to know the modified service in the test range and the call link of the service in detail so as to generate a specific test case, which is beneficial to improving the test efficiency, so that an acquisition method of the service call link is urgently needed.
It is to be noted that the information disclosed in the above background section is only for enhancement of understanding of the background of the present disclosure, and thus may include information that does not constitute prior art known to those of ordinary skill in the art.
Disclosure of Invention
In view of the foregoing, the present disclosure provides an acquisition method, apparatus, device, medium, and program product of a service invocation link.
According to a first aspect of the present disclosure, there is provided a method for acquiring a service invocation link, including:
determining implementation type source files corresponding to all services in a service registration list according to the service registration list, wherein the service registration list is obtained by scanning a configuration file of a service provider;
code scanning is carried out on the implementation type source file according to a preset service calling rule so as to obtain a plurality of service calling relations, wherein the preset service calling rule is used for representing service calling forms in the implementation type source file, and each service calling relation is a calling relation between two services; and
and calling a target function to process the service calling relations so as to generate a target service calling link.
According to an embodiment of the present disclosure, the determining, according to the service registration list, the implementation class source files corresponding to all services includes:
determining registered service information according to the service registration list, wherein the registered service information comprises a service name and a realization type file name;
and determining an implementation class source file of the service according to the service name and the implementation class file name.
According to an embodiment of the present disclosure, the determining an implementation class source file associated with the service according to the service name and the implementation class file name includes:
determining a mirror image file of the service according to the service name and the implementation class file name; and
and performing decompiling on the image file to generate an implementation source file of the service.
According to an embodiment of the present disclosure, the code scanning the implementation class source file according to a preset service invocation rule to obtain a plurality of service invocation relations includes:
determining a target key field according to a preset service calling rule;
scanning the implementation class source file according to the target key field to determine a context code of the target key field;
determining a service caller and a service callee according to the context code of the target key field; and
and generating a plurality of service calling relations according to the service calling party and the service called party.
According to an embodiment of the present disclosure, the invoking the target function to process the plurality of service invocation relationships to generate a target service invocation link includes:
determining an incoming parameter of an objective function, wherein the incoming parameter is a single service name or a service chain;
determining the type of the incoming parameters according to preset identification of the incoming parameters;
and circularly searching the plurality of service calling relations according to the incoming parameter types until a target service calling link is generated.
According to an embodiment of the present disclosure, said searching the plurality of service invocation relationships in a loop according to the incoming parameter type until a target service invocation link is generated comprises:
when the incoming parameter type is determined to be a service chain, acquiring an end service name of the service chain;
searching the plurality of service calling relations according to the terminal service name to determine a first service list, wherein the first service list is a service set called by the terminal service;
adding each service of the first service list to the end service name to generate a plurality of service call links;
and circularly searching the service calling relations to prolong the service calling links until a plurality of target service calling links are generated.
According to an embodiment of the present disclosure, said searching the plurality of service invocation relationships cyclically according to the incoming parameter type until a target service invocation link is generated further comprises:
when the incoming parameter type is determined to be a single service name, searching the plurality of service calling relations according to the single service name to determine a second service list, wherein the second service list is a service set called by the single service name;
adding each service of the second service list to the single service name to generate a plurality of service invocation links;
and circularly searching the plurality of service calling relations to prolong the plurality of service calling links until a plurality of target service calling links are generated.
According to the embodiment of the disclosure, the preset service call form comprises a function call and an annotation call.
According to an embodiment of the present disclosure, further comprising:
comparing the target service calling link with an actual calling link to determine an unknown service calling link;
analyzing the unknown service calling link to generate a target service calling rule; and
and updating the preset service calling rule according to the target service calling rule.
A second aspect of the present disclosure provides an apparatus for acquiring a service invocation link, including: the determining module is used for determining implementation source files corresponding to all services according to a service registration list, wherein the service registration list is obtained by scanning configuration files of a service provider;
the code scanning module is used for carrying out code scanning on the implementation type source file according to a preset service calling rule so as to obtain a plurality of service calling relations, wherein the preset service calling rule is used for representing a service calling form in the implementation type source file, and the service calling relation is a calling relation between two services;
and the service call link generation module is used for calling a target function according to the service call relations so as to generate a target service call link, and the target function is used for prolonging the service call link.
According to an embodiment of the disclosure, the determining module includes:
the first determining submodule is used for determining registered service information according to the service registration list, wherein the registered service information comprises a service name and a realization type file name; and
and the second determining submodule is used for determining the implementation class source file of the service according to the service name and the implementation class file name.
According to an embodiment of the present disclosure, the second determination submodule includes:
the first determining unit is used for determining a mirror image file of the service according to the service name and the implementation class file name; and
and the first generation unit is used for decompiling the image file to generate the implementation source file of the service.
According to an embodiment of the present disclosure, a code scanning module includes:
the third determining submodule is used for determining a target key field according to a preset service calling rule;
the scanning sub-module is used for scanning the implementation class source file according to the target key field so as to determine the context code of the target key field;
the fourth determining submodule is used for determining a service caller and a service callee according to the context code of the target key field; and
and the first generation submodule is used for generating a plurality of service calling relations according to the service calling party and the service called party.
According to the embodiment of the disclosure, the service call link generation module includes:
a fifth determining submodule, configured to determine an incoming parameter of an objective function, where the incoming parameter is a single service name or a service chain;
a sixth actual sub-module, configured to determine the type of the incoming parameter according to a preset identifier of the incoming parameter;
and the cyclic search submodule is used for cyclically searching the plurality of service calling relations according to the transmitted parameter types until a target service calling link is generated.
According to an embodiment of the present disclosure, the cyclic search sub-module includes:
the acquisition unit is used for acquiring the tail end service name of the service chain when the type of the incoming parameter is determined to be the service chain;
a second determining unit, configured to search the multiple service invocation relationships according to the end service name to determine a first service list, where the first service list is a service set invoked by an end service;
a second generating unit, configured to add each service of the first service list to the end service name to generate a plurality of service invocation links; and
and the first circulation searching unit is used for circularly searching the service calling relations so as to prolong the service calling links until a plurality of target service calling links are generated.
According to an embodiment of the present disclosure, the cyclic search sub-module further includes:
a third determining unit, configured to, when it is determined that the incoming parameter type is a single service name, search the multiple service invocation relationships according to the single service name to determine a second service list, where the second service list is a service set invoked by the single service name;
a third generating unit, configured to add each service of the second service list to the single service name to generate a plurality of service invocation links; and
and the second cyclic search unit is used for cyclically searching the plurality of service calling relations so as to prolong the plurality of service calling links until a plurality of target service calling links are generated.
According to an embodiment of the present disclosure, the apparatus further comprises:
the comparison module is used for comparing the target service calling link with an actual calling link to determine an unknown service calling link;
the analysis module is used for analyzing the unknown service calling link to generate a target service calling rule; and
and the updating module is used for updating the preset service calling rule according to the target service calling rule.
A third aspect of the present disclosure provides an electronic device, comprising: one or more processors; a memory for storing one or more programs, wherein the one or more programs, when executed by the one or more processors, cause the one or more processors to perform the method for obtaining a service invocation link as described above.
The fourth aspect of the present disclosure also provides a computer-readable storage medium having stored thereon executable instructions, which when executed by a processor, cause the processor to execute the above-mentioned service invocation link acquisition method.
A fifth aspect of the present disclosure also provides a computer program product comprising a computer program that, when executed by a processor, implements the method for acquiring a service invocation link as described above.
According to the method for acquiring the service call link, the service registration list is acquired by scanning the configuration file of the service provider, the implementation type source file corresponding to the registration service is acquired by reverse compiling according to the service registration list, the implementation type source file is scanned according to the preset service call rule through the static code scanning technology to generate a plurality of service call relations, and then the target service call link is generated, so that the test is more targeted, the test efficiency is improved, and the guarantee is provided for safe production.
Drawings
The foregoing and other objects, features and advantages of the disclosure will be apparent from the following description of embodiments of the disclosure, which proceeds with reference to the accompanying drawings, in which:
FIG. 1 schematically illustrates an application scenario diagram of a method, apparatus, device, medium, and program product for obtaining a service invocation link according to an embodiment of the present disclosure;
fig. 2 schematically shows a flow chart of a method of obtaining a service invocation link according to an embodiment of the present disclosure;
FIG. 3a schematically shows one of the flow diagrams of a service implementation class source file acquisition method according to an embodiment of the present disclosure;
FIG. 3b schematically illustrates a second flowchart of a service implementation class source file acquisition method according to an embodiment of the present disclosure;
FIG. 4 schematically illustrates a flow diagram for obtaining service invocation relationships through static code scanning, in accordance with an embodiment of the present disclosure;
FIG. 5a schematically illustrates one of the flow diagrams of a method of generating a target service invocation link from a plurality of service invocation relationships according to an embodiment of the present disclosure;
FIG. 5b schematically illustrates a second flowchart of a method for generating a target service invocation link according to a plurality of service invocation relationships, in accordance with an embodiment of the present disclosure;
FIG. 5c schematically illustrates a third flowchart of a method for generating a target service invocation link according to a plurality of service invocation relationships, in accordance with an embodiment of the present disclosure;
FIG. 6 schematically illustrates a flow chart of a preset service invocation rule update method according to an embodiment of the present disclosure;
fig. 7 schematically shows a block diagram of an obtaining apparatus of a service invocation link according to an embodiment of the present disclosure; and
fig. 8 schematically illustrates a block diagram of an electronic device suitable for implementing a cloud platform interface generation method according to an embodiment of the present disclosure.
Detailed Description
Hereinafter, embodiments of the present disclosure will be described with reference to the accompanying drawings. It should be understood that the description is illustrative only and is not intended to limit the scope of the present disclosure. In the following detailed description, for purposes of explanation, numerous specific details are set forth in order to provide a thorough understanding of the embodiments of the disclosure. It may be evident, however, that one or more embodiments may be practiced without these specific details. Moreover, in the following description, descriptions of well-known structures and techniques are omitted so as to not unnecessarily obscure the concepts of the present disclosure.
The terminology used herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the disclosure. The terms "comprises," "comprising," and the like, as used herein, specify the presence of stated features, steps, operations, and/or components, but do not preclude the presence or addition of one or more other features, steps, operations, or components.
All terms (including technical and scientific terms) used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention belongs, unless otherwise defined. It is noted that the terms used herein should be interpreted as having a meaning that is consistent with the context of this specification and should not be interpreted in an idealized or overly formal sense.
Where a convention analogous to "at least one of A, B and C, etc." is used, in general such a construction is intended in the sense one having skill in the art would understand the convention (e.g., "a system having at least one of A, B and C" would include but not be limited to systems that have a alone, B alone, C alone, a and B together, a and C together, B and C together, and/or A, B, C together, etc.).
The embodiment of the disclosure provides a method for acquiring a service call link, which includes: determining implementation source files corresponding to all services in a service registration list according to the service registration list, wherein the service registration list is obtained by scanning configuration files of service providers; code scanning is carried out on the implementation type source file according to a preset service calling rule so as to obtain a plurality of service calling relations, wherein the preset service calling rule is used for representing service calling forms in the implementation type source file, and each service calling relation is a calling relation between two services; and calling a target function to process the service calling relations so as to generate a target service calling link.
Fig. 1 schematically illustrates an application scenario diagram of a method, an apparatus, a device, a medium, and a program product for acquiring a service invocation link according to an embodiment of the present disclosure.
As shown in fig. 1, the application scenario 100 according to this embodiment may include a cloud platform interface usage scenario. The network 104 serves as a medium for providing communication links between the terminal devices 101, 102, 103 and the server 105. Network 104 may include various connection types, such as wired, wireless communication links, or fiber optic cables, to name a few.
The user may use the terminal devices 101, 102, 103 to interact with the server 105 via the network 104 to receive or send messages or the like. The terminal devices 101, 102, 103 may have installed thereon various communication client applications, such as shopping-like applications, web browser applications, search-like applications, instant messaging tools, mailbox clients, social platform software, etc. (by way of example only).
The terminal devices 101, 102, 103 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop portable computers, desktop computers, and the like.
The server 105 may be a server, and provides a service call link generation service for a user, for example, a background server (for example only) providing corresponding support in response to a call link acquisition instruction issued by the user using the terminal device 101, 102, 103. The background server can analyze and process the received data such as the acquisition request of the user service call link, and feed back the generated service call link to the terminal equipment.
It should be noted that the method for acquiring the service invocation link provided by the embodiment of the present disclosure may be generally executed by the server 105. Accordingly, the obtaining device of the service invocation link provided by the embodiment of the present disclosure can be generally disposed in the server 105. The method for acquiring the service invocation link provided by the embodiment of the present disclosure may also be executed by a server or a server cluster that is different from the server 105 and is capable of communicating with the terminal devices 101, 102, 103 and/or the server 105. Correspondingly, the obtaining device of the service invocation link provided by the embodiment of the present disclosure may also be disposed in a server or a server cluster different from the server 105 and capable of communicating with the terminal devices 101, 102, 103 and/or the server 105.
It should be understood that the number of terminal devices, networks, and servers in fig. 1 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
It should be noted that the method and apparatus for acquiring a service invocation link determined in the embodiment of the present disclosure may be applied to the application in the field of testing technology in the financial field, and may also be applied to any field other than the financial field.
The following describes in detail an acquisition method of a service invocation link according to an embodiment of the present disclosure with reference to fig. 2 to 6 based on the scenario described in fig. 1.
Fig. 2 schematically shows a flowchart of a method for acquiring a service invocation link according to an embodiment of the present disclosure. As shown in fig. 2, the method for acquiring a service invocation link of the embodiment includes operations S210 to S230, and the method may be executed by a server or other computing device.
In operation S210, implementation class source files corresponding to all services in the service registration list are determined according to the service registration list.
According to an embodiment of the present disclosure, the service registration list is obtained by scanning a service provider profile.
In one example, under the Dubbo micro service framework, a service provider needs to register its own service in a provider. The process of obtaining the service implementation type source file is not described herein again. See operations S211 through S212 shown in fig. 3 a.
In operation S220, code scanning is performed on the implementation class source file according to a preset service invocation rule to obtain a plurality of service invocation relationships.
According to the embodiment of the disclosure, the preset service calling rule is used for representing service calling forms in the implementation class source file, and each service calling relationship is a calling relationship between two services.
According to an embodiment of the present disclosure, the service call form includes a function call and an annotation call.
In one example, after an implementation class source file of any service is obtained, static code scanning is performed on a source file code of the service according to a preset service calling rule, wherein the preset service calling rule refers to various service calling forms in the implementation class source file, including function calls, annotation calls and other forms of calls. Identifying codes related to preset service calling rules, and further determining a caller and a callee of the service, for example, determining in a certain row of codes that the method M1 of the service called the service S1, and continuing to search the implementation class source files of the service S1 for which services are called, until a certain service only serves as the callee and does not call other services, and then representing that the service calling chain search is ended. And all the source files are subjected to the scanning process to obtain all the service calling links. When the number of services is large and the call link is complex, the situation that the same file is scanned for multiple times may occur, which results in long time consumption and reduced acquisition rate of the service call link, in order to improve the scanning efficiency, in the embodiment of the present disclosure, all source files need to be scanned once to acquire multiple service call relations, and the service call relations only represent the call relations between two services, that is, the service call link acquired through operation S220 only includes two services, namely, a calling party and a called party. For a specific static code scanning process, refer to operations S221 to S224 shown in fig. 4, which are not described herein again.
In operation S230, the target function is called to generate the target service call link from the plurality of service call relations.
In one example, the target function is used to serially connect the service call relations to extend the service call link, and the process of generating the target service call link according to the service call relations may refer to operations S231 to S233 described in fig. 5 a.
According to the method for acquiring the service call link, the service registration list is acquired by scanning the configuration file of the service provider, the implementation type source file corresponding to the registration service is acquired by reverse compiling according to the service registration list, the implementation type source file is scanned according to the preset service call rule through the static code scanning technology to generate a plurality of service call relations, and then the target service call link is generated, so that the test is more targeted, the test efficiency is improved, and the guarantee is provided for safe production.
Fig. 3a schematically shows one of the flowcharts of the service implementation type source file acquisition method according to the embodiment of the disclosure, and fig. 3b schematically shows the second flowchart of the service implementation type source file acquisition method according to the embodiment of the disclosure. As shown in fig. 3a, operation S210 includes operations S211 to S212.
In operation S211, registered service information is determined according to the service registration list.
According to an embodiment of the present disclosure, the registered service information includes a service name and an implementation class file name.
In operation S212, an implementation class source file associated with the service is determined according to the service name and the implementation class file name.
As shown in fig. 3b, operation S212 includes operation S2121 and operation S2122.
In operation S2121, an image file of the service is determined according to the service name and the implementation class file name.
In operation S2222, the image file is decompiled to generate an implementation class source file of the service.
In an example, the registered service information includes a service name, a method name, and an implementation-class file name, in an example of F-PRRS (personal remittance), registered service atsc border remittance asm (cross-border remittance service) is found in provider.xml, an implementation-class source file name corresponding to the service is com.xxx.xx.app.service.atsc border remittance asmimmpll, an image file of the cross-border remittance service is determined in a mirror database according to the implementation-class source file name, and since the image file is a compiled file, the image file needs to be reversely compiled to generate a source code file of the service, that is, the implementation-class source file.
FIG. 4 schematically shows a flow diagram for obtaining service invocation relationships through static code scanning, in accordance with an embodiment of the present disclosure. As shown in fig. 4, operation S220 includes operations S221 through S224.
In operation S221, a target key field is determined according to a preset service invocation rule.
In operation S222, the implementation class source file is scanned according to the target key field to determine a context code of the target key field.
In operation S223, a service caller and a service callee are determined according to the context code of the target key field.
In operation S224, a plurality of service invocation relations are generated according to the service invoker and the service invoker.
In one example, the services of different layers under the Dubbo service framework are mainly called each other through functions getpeak, invokeService, invokeasyncervice, bearer. In addition, each service can invoke each functional component by implementing the injection of beans using the annotations @ automated, @ resources. And taking the function calling method and the annotation as target key fields, identifying the key fields, positioning context codes of the target key fields in the source codes, extracting a service calling party and a service called party in the context codes, and generating a service calling relation. To obtain the call relationship between two services, all source code needs to be scanned. And traversing the source code files in the source code directory, and for each source code file, adopting a line-by-line scanning method to extract which service is called by a specific method in the file according to a service calling rule, so that a calling relation between two services in the form of service1 → service2 can be obtained.
The procedure and results for obtaining a service link will be described with F-PRRS (personal money transfer) as an example. For example, a registered service atsc border remittance asm (cross-border remittance service) is found in provider.xml, and a corresponding implementation class is com.icbc.prrs.app.service.atsc border remittance mampl, and by scanning the file, it can be found that an @ auto wired annotation exists in the file, a module a is introduced, and then, an object of the module is used in a plurality of methods of the service. As in the doRemit method of the service, the object B created by the module is used. The crossboarderlimit file is then scanned to see if another service or module is called in the B method. And searching to obtain the method, calling a component C, further searching to find that the component C calls a method D, and then searching whether the method D calls other services or modules until the method does not call other services or components. Through the operation, a plurality of service calling relations can be obtained, wherein A calls B, B calls C, and C calls D.
Fig. 5a schematically shows one of the flowcharts of the method for generating a target service invocation link according to a plurality of service invocation relations according to the embodiment of the present disclosure, fig. 5b schematically shows the second flowchart of the method for generating a target service invocation link according to a plurality of service invocation relations according to the embodiment of the present disclosure, and fig. 5c schematically shows the third flowchart of the method for generating a target service invocation link according to a plurality of service invocation relations according to the embodiment of the present disclosure. As shown in fig. 5a, operations S231 to S233 are included.
In operation S231, incoming parameters of the objective function are determined, wherein the incoming parameters are a single service name or a service chain.
In operation S232, the incoming parameter type is determined according to the preset identification of the incoming parameter.
In one example, the incoming parameter of the target function is determined first, for example, all services that belong to the caller and are not the callee, that is, the target source service, are screened out according to a plurality of service call relations, and for each screened out target source service, the call target function continuously extends the call link of the target source service until a complete target service call link is generated. The input parameter of the objective function is service, and the input parameter can be a single service name or a service chain. First, the type of the incoming parameter service, that is, a single service name or a service chain, is determined, specifically, whether a preset identifier exists in the incoming parameter may be identified, for example, the identifier may be an identifier indicating a service invocation relationship, such as "-", "→", "@", or the like.
In operation S233, the plurality of service invocation relationships are circularly searched according to the incoming parameter type until a target service invocation link is generated.
There are two possible implementations of operation S233:
in one possible implementation, as shown in fig. 5b, operations S310 to S340 are included.
In operation S310, when it is determined that the incoming parameter type is a service chain, an end service name of the service chain is acquired.
In operation S320, the plurality of service invocation relations are searched according to the end service name to determine a first service list.
According to an embodiment of the present disclosure, the first service list is a set of services that are invoked by an end service.
In operation S330, each service of the first service list is added to the end service name to generate a plurality of service invocation links.
In operation S340, the plurality of service invocation relations are searched in a loop to extend the plurality of service invocation links until a plurality of target service invocation links are generated.
In one example, when a service chain is determined, the last service name in the service chain is determined and assigned to the variable tempsrv. Searching the service calling relation to obtain all services called by tempsrv to form a first service list calledbytempsrv, if the calledbytempsrv is empty, representing that the current service is the last service in the service calling link, and ending the search. Each service in the calledbytempsrv can be added as a called party to an original service or a service call chain, and if the calledbytempsrv has n elements, n new service chains can be obtained: service → element 1, service → element 2. And assigning each new service chain acquired in operation S330 to a service, and re-executing the above process until multiple target service call links are obtained.
In another possible embodiment, as shown in fig. 5c, operations S410 to S430 are included.
In operation S410, when it is determined that the incoming parameter type is a single service name, the plurality of service invocation relations are searched according to the single service name to determine a second service list.
According to an embodiment of the present disclosure, the second service list is a set of services called by the single service name.
In operation S420, each service of the second service list is added to the single service name to generate a plurality of service call links.
In operation S430, the plurality of service invocation relationships are searched in a loop to extend the plurality of service invocation links until a plurality of target service invocation links are generated.
In one example, the principles of operations S410-S430 are substantially the same, and upon determining that the incoming parameter is a single service name, the single service name is assigned to the variable tempsrv. Searching the service calling relation to obtain all services called by tempsrv, forming a second service list calledbytempsrv, if the calledbytempsrv is empty, representing that the current service is the last service in the service calling link, and ending the search. Each service in the calledbytempsrv can be added as a called party to an original service or a service call chain, and if the calledbytempsrv has n elements, n new service chains can be obtained: service → element 1, service → element 2.
For example, the following call relationship between two services can be obtained by the first scanning: a → B, B → C, C → D.
Firstly, inputting a parameter of a service A, determining that the service calls a service B to obtain a service chain A → B, continuously inputting the service chain into a target function, determining that the input parameter is a service chain parameter through judgment, determining the last called service name B in the service chain, and determining that the service B calls a service C through searching, wherein the service chain is further extended as follows: a → B → C, until the last service in the service chain can not be searched to call other service scenes, i.e. service D is the last called service, the service chain search is finished, i.e. the target service call link A → B → C → D is generated.
Since the preset service invocation rule only includes a commonly used invocation form, sometimes developers do not invoke according to the specification, the service invocation rule in the embodiment of the present disclosure may also be dynamically updated and adjusted, and then, the updating process of the preset service invocation rule will be described with reference to fig. 6.
Fig. 6 schematically shows a flowchart of a preset service invocation rule updating method according to an embodiment of the present disclosure. Specifically, the method includes operations S510 to S530.
In operation S510, the target service invocation link is compared with the actual invocation link to determine an unknown service invocation link.
In operation S520, the unknown service invocation link is parsed to generate a target service invocation rule.
In operation S530, the preset service invocation rule is updated according to the target service invocation rule.
In one example, a target service call link obtained by scanning a static code may be compared with an actual call link, where the actual call link refers to a real call link occurring in the actual transaction flow process and is recorded by a holographic monitoring system, and a service call link that does not exist in the target service call link, that is, an unknown service call link, is determined to exist in the actual call link through comparison, and a new target service call rule is abstracted and a preset service call rule is updated by analyzing a code file corresponding to the unknown service call link. For example, the service call link obtained in the operation of fig. 4 is a-B-C-D, the service a is searched in the holographic monitoring system, and a-B-D-E-C is obtained, at this time, it is determined that the service D calls the service E as an unknown service call link, the codes of the implementation class source files of the service D and the service E are analyzed, the behavior form of the service call is analyzed to exist, and is abstracted into a call rule, for example, a corresponding call function name or method name is determined, and the rule is updated to a preset service call rule for subsequent code scanning.
Based on the method for acquiring the service call link, the disclosure also provides an acquisition device of the service call link. The apparatus will be described in detail below with reference to fig. 7.
Fig. 7 schematically shows a block diagram of an acquisition apparatus of a service invocation link according to an embodiment of the present disclosure.
As shown in fig. 7, the apparatus 800 for acquiring a service invocation link of this embodiment includes a determining module 810, a code scanning module 820 and a service invocation link generating module 830.
The determining module 810 is configured to determine implementation class source files corresponding to all services in the service registration list according to the service registration list, where the service registration list is obtained by scanning a service provider configuration file. In an embodiment, the determining module 810 may be configured to perform the operation S210 described above, which is not described herein again.
The code scanning module 820 is configured to perform code scanning on the implementation-type source file according to a preset service invocation rule to obtain a plurality of service invocation relations, where the preset service invocation rule is used to represent service invocation forms in the implementation-type source file, and each service invocation relation is an invocation relation between two services. In an embodiment, the code scanning module 820 may be configured to perform the operation S220 described above, which is not described herein again.
The service call link generation module 830 is configured to call a target function according to the plurality of service call relations to generate a target service call link. In an embodiment, the service invocation link generating module 830 may be configured to perform the operation S230 described above, and is not described herein again.
According to an embodiment of the disclosure, the determining module 810 includes: a first determination submodule 811 and a second determination submodule 812.
The first determining submodule 811 is configured to determine registered service information according to the service registration list, where the registered service information includes a service name and an implementation class file name. In an embodiment, the first determining submodule 811 may be configured to perform the operation S211 described above, and will not be described herein again.
The second determining submodule 812 is configured to determine an implementation class source file associated with the service according to the service name and the implementation class file name. In an embodiment, the second determining sub-module 812 may be configured to perform the operation S212 described above, and will not be described herein again.
According to an embodiment of the present disclosure, the second determination submodule 812 includes a first determination unit 8121 and a first generation unit 8122.
The first determining unit 8121 is configured to determine an image file of a service according to the service name and the implementation class file name. In an embodiment, the first determining unit 8121 may be configured to perform the operation S2121 described above, which is not described herein again.
The first generating unit 8122 is configured to decompile the image file to generate an implementation class source file of the service. In an embodiment, the first generating unit 8122 may be configured to perform the operation S2122 described above, which is not described herein again.
According to an embodiment of the present disclosure, the code scanning module 820 includes: a third determination submodule 821, a scanning submodule 822, a fourth determination submodule 823 and a first generation submodule 824.
The third determining sub-module 821 is used for determining the target key field according to the preset service calling rule. In an embodiment, the third determining submodule 821 may be configured to perform the operation S221 described above, and will not be described herein again.
The scanning sub-module 822 is configured to scan the implementation class source file according to the target key field to determine a context code of the target key field. In an embodiment, the scan sub-module 822 may be configured to perform the operation S232 described above, and will not be described herein again.
The fourth determining sub-module 823 is configured to determine a service caller and a service callee according to the context code of the target key field. In an embodiment, the fourth determining sub-module 823 may be configured to perform the operation S223 described above, and is not described herein again.
The first generation submodule 824 is configured to generate a plurality of service invocation relationships according to the service invoker and the service invoker. In an embodiment, the first generation submodule 824 may be configured to perform the operation S224 described above, and is not described herein again.
According to an embodiment of the present disclosure, the service invocation link generating module 830 includes: a fifth determination sub-module 831, a sixth determination sub-module 832, and a circular search sub-module 833.
According to an embodiment of the present disclosure, the fifth determining submodule 831 is configured to determine an incoming parameter of the objective function, wherein the incoming parameter is a single service name or a service chain. In an embodiment, the fifth determining sub-module 831 may be configured to perform the operation S231 described above, and will not be described herein again.
A sixth determining submodule 832 is configured to determine the incoming parameter type according to a preset identification of the incoming parameter. In an embodiment, the sixth determining submodule 832 may be configured to perform the operation S232 described above, and will not be described herein again.
The circular search sub-module 833 is configured to search the plurality of service invocation relationships circularly according to the incoming parameter type until a target service invocation link is generated. In an embodiment, the cyclic search sub-module 833 may be configured to perform the operation S233 described above, and is not described herein again.
According to an embodiment of the present disclosure, the circular search sub-module 833 includes: an acquisition unit 8331, a second determination unit 8332, a second generation unit 8333, and a first loop search unit 8334.
The obtaining unit 8331 is configured to obtain an end service name of the service chain when the incoming parameter type is determined to be the service chain. In an embodiment, the obtaining unit 8331 may be configured to perform the operation S310 described above, which is not described herein again.
The second determining unit 8332 is configured to search the plurality of service invocation relations according to the end service name to determine a first service list, where the first service list is a service set invoked by the end service. In an embodiment, the second determining unit 8332 may be configured to perform the operation S320 described above, which is not described herein again.
The second generating unit 8333 is configured to add each service of the first service list to the end service name to generate a plurality of service call links. In an embodiment, the second generating unit 8333 may be configured to perform the operation S330 described above, which is not described herein again.
The first loop search unit 8334 is configured to loop search the plurality of service invocation relationships to extend the plurality of service invocation links until a plurality of target service invocation links are generated. In an embodiment, the first loop search unit 8334 may be configured to perform the operation S340 described above, which is not described herein again.
According to an embodiment of the present disclosure, the cyclic search sub-module 833 further includes: a third determination unit 8335, a third generation unit 8336, and a second loop search unit 8337.
The third determining unit 8335 is configured to, when it is determined that the incoming parameter type is a single service name, search the multiple service invocation relationships according to the single service name to determine a second service list, where the second service list is a service set invoked by the single service name. In an embodiment, the third determining unit 8335 may be configured to perform the operation S410 described above, which is not described herein again.
The third generating unit 8336 is configured to add each service of the second service list to the single service name to generate a plurality of service call links. In an embodiment, the third generating unit 8336 may be configured to perform the operation S420 described above, which is not described herein again.
The second loop search unit 8337 is configured to loop search the plurality of service invocation relationships to extend the plurality of service invocation links until a plurality of target service invocation links are generated. In an embodiment, the second loop search unit 8337 may be configured to perform the operation S430 described above, and will not be described herein again.
According to the embodiment of the present disclosure, the obtaining apparatus of the service invocation link further includes a comparing module 840, a parsing module 850 and an updating module 860.
The comparison module 840 is configured to compare the target service invocation link with the actual invocation link to determine an unknown service invocation link. In an embodiment, the comparing module 840 may be configured to perform the operation S510 described above, which is not described herein again.
Parsing module 850 is configured to parse the unknown service invocation link to generate a target service invocation rule. In an embodiment, the parsing module 850 may be configured to perform the operation S520 described above, which is not described herein again.
The updating module 860 is configured to update the preset service invocation rule according to the target service invocation rule. In an embodiment, the update module 860 may be configured to perform the operation S530 described above, which is not described herein again.
Any of the modules of the determining module 810, the code scanning module 820 and the service invocation link generating module 830 may be combined into one module to be implemented, or any one of them may be split into a plurality of modules according to the embodiments of the present disclosure. Alternatively, at least part of the functionality of one or more of these modules may be combined with at least part of the functionality of other modules and implemented in one module. According to an embodiment of the present disclosure, at least one of the determining module 810, the code scanning module 820, and the service invocation link generating module 830 may be implemented at least partially as a hardware circuit, such as a Field Programmable Gate Array (FPGA), a Programmable Logic Array (PLA), a system on a chip, a system on a substrate, a system on a package, an Application Specific Integrated Circuit (ASIC), or may be implemented in hardware or firmware in any other reasonable manner of integrating or packaging a circuit, or in any one of or a suitable combination of software, hardware, and firmware. Alternatively, at least one of the determining module 810, the code scanning module 820 and the service invocation link generating module 830 may be at least partially implemented as a computer program module, which when executed, may perform corresponding functions.
Fig. 8 schematically illustrates a block diagram of an electronic device adapted to implement the acquisition method of the service invocation link according to an embodiment of the present disclosure.
As shown in fig. 8, an electronic apparatus 900 according to an embodiment of the present disclosure includes a processor 901 which can perform various appropriate actions and processes in accordance with a program stored in a Read Only Memory (ROM)902 or a program loaded from a storage portion 908 into a Random Access Memory (RAM) 903. Processor 901 may comprise, for example, a general purpose microprocessor (e.g., a CPU), an instruction set processor and/or associated chipset, and/or a special purpose microprocessor (e.g., an Application Specific Integrated Circuit (ASIC)), among others. The processor 901 may also include on-board memory for caching purposes. The processor 901 may comprise a single processing unit or a plurality of processing units for performing the different actions of the method flows according to embodiments of the present disclosure.
In the RAM 903, various programs and data necessary for the operation of the electronic apparatus 900 are stored. The processor 901, the ROM 902, and the RAM 903 are connected to each other through a bus 904. The processor 901 performs various operations of the method flows according to the embodiments of the present disclosure by executing programs in the ROM 902 and/or the RAM 903. Note that the programs may also be stored in one or more memories other than the ROM 902 and the RAM 903. The processor 901 may also perform various operations of the method flows according to embodiments of the present disclosure by executing programs stored in the one or more memories.
Electronic device 900 may also include input/output (I/O) interface 905, input/output (I/O) interface 905 also connected to bus 904, according to an embodiment of the present disclosure. The electronic device 900 may also include one or more of the following components connected to the I/O interface 905: an input portion 906 including a keyboard, a mouse, and the like; an output section 907 including components such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, and a speaker; a storage portion 908 including a hard disk and the like; and a communication section 909 including a network interface card such as a LAN card, a modem, or the like. The communication section 909 performs communication processing via a network such as the internet. The drive 910 is also connected to the I/O interface 905 as necessary. A removable medium 911 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 910 as necessary, so that a computer program read out therefrom is mounted into the storage section 908 as necessary.
The present disclosure also provides a computer-readable storage medium, which may be embodied in the device/apparatus/system described in the above embodiments; or may exist separately and not be assembled into the device/apparatus/system. The computer-readable storage medium carries one or more programs which, when executed, implement a method for acquiring a service invocation link according to an embodiment of the present disclosure.
According to embodiments of the present disclosure, the computer-readable storage medium may be a non-volatile computer-readable storage medium, which may include, for example but is not limited to: a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present disclosure, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. For example, according to embodiments of the present disclosure, a computer-readable storage medium may include the ROM 902 and/or the RAM 903 described above and/or one or more memories other than the ROM 902 and the RAM 903.
Embodiments of the present disclosure also include a computer program product comprising a computer program containing program code for performing the method illustrated in the flow chart. When the computer program product runs in a computer system, the program code is used for causing the computer system to realize the acquisition method of the service call link provided by the embodiment of the disclosure.
The computer program performs the above-described functions defined in the system/apparatus of the embodiments of the present disclosure when executed by the processor 901. The systems, apparatuses, modules, units, etc. described above may be implemented by computer program modules according to embodiments of the present disclosure.
In one embodiment, the computer program may be hosted on a tangible storage medium such as an optical storage device, a magnetic storage device, or the like. In another embodiment, the computer program may also be transmitted, distributed in the form of a signal on a network medium, and downloaded and installed through the communication section 909 and/or installed from the removable medium 911. The computer program containing program code may be transmitted using any suitable network medium, including but not limited to: wireless, wired, etc., or any suitable combination of the foregoing.
In such an embodiment, the computer program may be downloaded and installed from a network through the communication section 909, and/or installed from the removable medium 911. The computer program, when executed by the processor 901, performs the above-described functions defined in the system of the embodiment of the present disclosure. The systems, devices, apparatuses, modules, units, etc. described above may be implemented by computer program modules according to embodiments of the present disclosure.
In accordance with embodiments of the present disclosure, program code for executing computer programs provided by embodiments of the present disclosure may be written in any combination of one or more programming languages, and in particular, these computer programs may be implemented using high level procedural and/or object oriented programming languages, and/or assembly/machine languages. The programming language includes, but is not limited to, programming languages such as Java, C + +, python, the "C" language, or the like. The program code may execute entirely on the user computing device, partly on the user device, partly on a remote computing device, or entirely on the remote computing device or server. In the case of a remote computing device, the remote computing device may be connected to the user computing device through any kind of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to an external computing device (e.g., through the internet using an internet service provider).
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
Those skilled in the art will appreciate that various combinations and/or combinations of features recited in the various embodiments and/or claims of the present disclosure can be made, even if such combinations or combinations are not expressly recited in the present disclosure. In particular, various combinations and/or combinations of the features recited in the various embodiments and/or claims of the present disclosure may be made without departing from the spirit or teaching of the present disclosure. All such combinations and/or associations are within the scope of the present disclosure.
The embodiments of the present disclosure have been described above. However, these examples are for illustrative purposes only and are not intended to limit the scope of the present disclosure. Although the embodiments are described separately above, this does not mean that the measures in the embodiments cannot be used in advantageous combination. The scope of the disclosure is defined by the appended claims and equivalents thereof. Various alternatives and modifications can be devised by those skilled in the art without departing from the scope of the present disclosure, and such alternatives and modifications are intended to be within the scope of the present disclosure.

Claims (13)

1. A method for acquiring a service call link is characterized by comprising the following steps:
determining implementation type source files corresponding to all services in a service registration list according to the service registration list, wherein the service registration list is obtained by scanning a configuration file of a service provider;
code scanning is carried out on the implementation type source file according to a preset service calling rule so as to obtain a plurality of service calling relations, wherein the preset service calling rule is used for representing service calling forms in the implementation type source file, and each service calling relation is a calling relation between two services; and
and calling a target function to process the service calling relations so as to generate a target service calling link.
2. The method of claim 1, wherein determining implementation class source files corresponding to all services according to the service registration list comprises:
determining registered service information according to the service registration list, wherein the registered service information comprises a service name and a realization type file name; and
and determining an implementation class source file of the service according to the service name and the implementation class file name.
3. The method of claim 2, wherein determining an implementation class source file associated with the service based on the service name and the implementation class filename comprises:
determining a mirror image file of the service according to the service name and the implementation class file name; and
and performing decompiling on the image file to generate an implementation source file of the service.
4. The method according to claim 3, wherein the code scanning the implementation class source file according to a preset service call rule to obtain a plurality of service call relations comprises:
determining a target key field according to a preset service calling rule;
scanning the implementation class source file according to the target key field to determine a context code of the target key field;
determining a service caller and a service callee according to the context code of the target key field; and
and generating a plurality of service calling relations according to the service calling party and the service called party.
5. The method of claim 4, wherein the invoking the target function processes the plurality of service invocation relationships to generate a target service invocation link, comprising:
determining an incoming parameter of an objective function, wherein the incoming parameter is a single service name or a service chain;
determining the type of the incoming parameters according to preset identification of the incoming parameters; and
and circularly searching the plurality of service calling relations according to the incoming parameter types until a target service calling link is generated.
6. The method of claim 5, wherein the circularly searching the plurality of service invocation relationships according to the incoming parameter type until a target service invocation link is generated comprises:
when the incoming parameter type is determined to be a service chain, acquiring an end service name of the service chain;
searching the plurality of service calling relations according to the terminal service name to determine a first service list, wherein the first service list is a service set called by the terminal service;
adding each service of the first service list to the end service name to generate a plurality of service call links; and
and circularly searching the plurality of service calling relations to prolong the plurality of service calling links until a plurality of target service calling links are generated.
7. The method of claim 5, wherein the circularly searching the plurality of service invocation relationships according to the incoming parameter type until a target service invocation link is generated further comprises:
when the incoming parameter type is determined to be a single service name, searching the plurality of service calling relations according to the single service name to determine a second service list, wherein the second service list is a service set called by the single service name;
adding each service of the second service list to the single service name to generate a plurality of service invocation links; and
and circularly searching the plurality of service calling relations to prolong the plurality of service calling links until a plurality of target service calling links are generated.
8. The method of any of claims 1-7, wherein the service call form comprises a function call and an annotation call.
9. The method of claim 8, further comprising:
comparing the target service calling link with an actual calling link to determine an unknown service calling link;
analyzing the unknown service calling link to generate a target service calling rule; and
and updating the preset service calling rule according to the target service calling rule.
10. An apparatus for acquiring a service invocation link, comprising:
the determining module is used for determining implementation type source files corresponding to all services according to a service registration list, wherein the service registration list is obtained by scanning a configuration file of a service provider;
the code scanning module is used for carrying out code scanning on the implementation type source file according to a preset service calling rule so as to obtain a plurality of service calling relations, wherein the preset service calling rule is used for representing a service calling form in the implementation type source file, and the service calling relation is a calling relation between two services;
and the service call link generation module is used for calling a target function according to the service call relations so as to generate a target service call link, and the target function is used for prolonging the service call link.
11. An electronic device, comprising:
one or more processors;
a storage device for storing one or more programs,
wherein the one or more programs, when executed by the one or more processors, cause the one or more processors to perform the method of any of claims 1-9.
12. A computer readable storage medium having stored thereon executable instructions which, when executed by a processor, cause the processor to perform the method of any one of claims 1 to 9.
13. A computer program product comprising a computer program which, when executed by a processor, implements a method according to any one of claims 1 to 9.
CN202210595952.7A 2022-05-27 2022-05-27 Service call link acquisition method and device Pending CN114860669A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210595952.7A CN114860669A (en) 2022-05-27 2022-05-27 Service call link acquisition method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210595952.7A CN114860669A (en) 2022-05-27 2022-05-27 Service call link acquisition method and device

Publications (1)

Publication Number Publication Date
CN114860669A true CN114860669A (en) 2022-08-05

Family

ID=82641680

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210595952.7A Pending CN114860669A (en) 2022-05-27 2022-05-27 Service call link acquisition method and device

Country Status (1)

Country Link
CN (1) CN114860669A (en)

Similar Documents

Publication Publication Date Title
CN109359194B (en) Method and apparatus for predicting information categories
CN110764760A (en) Method, apparatus, computer system, and medium for drawing process flow diagrams
CN107368407B (en) Information processing method and device
CN113419740A (en) Program data stream analysis method and device, electronic device and readable storage medium
CN115357761A (en) Link tracking method and device, electronic equipment and storage medium
CN115982491A (en) Page updating method and device, electronic equipment and computer readable storage medium
CN113535577B (en) Application testing method and device based on knowledge graph, electronic equipment and medium
CN111414154A (en) Method and device for front-end development, electronic equipment and storage medium
CN113176907A (en) Interface data calling method and device, computer system and readable storage medium
CN111581431A (en) Data exploration method and device based on dynamic evaluation
CN113535565B (en) Interface use case generation method, device, equipment and medium
US11921863B2 (en) Determining a source of a vulnerability in software
CN111158777A (en) Component calling method and device and computer readable storage medium
CN114237765B (en) Functional component processing method, device, electronic equipment and medium
CN116166547A (en) Code change range analysis method, device, equipment and storage medium
CN114860669A (en) Service call link acquisition method and device
CN114691527A (en) Unit test case generation method, apparatus, device, medium, and program product
CN113032256A (en) Automatic test method, device, computer system and readable storage medium
US20230103049A1 (en) Developer-focused context-aware application security platform
CN115629983A (en) Test case set generation method, device, equipment and medium
CN114385229A (en) Code processing method, device, equipment, medium and program product
CN118331634A (en) Method, apparatus, device, storage medium and program product for generating interface document
CN113535153A (en) Method, device, equipment and medium for encoding custom label
CN115878396A (en) Interface testing method, device, equipment and medium for enterprise service bus
CN117931613A (en) Test case screening method and device

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