Method and device for obtaining service call link

By scanning service provider configuration files and static code scanning technology, the calling link of the service in a distributed system is generated, which solves the problem of difficult testing of complex service calling links and improves the testing efficiency.

CN114860669BActive Publication Date: 2025-04-25INDUSTRIAL AND COMMERCIAL BANK OF CHINA
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202210595952.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-05-27
Publication Date
2025-04-25
Estimated Expiration
2042-05-27

AI Technical Summary

Technical Problem

In distributed systems, as the number of microservices increases, the service calling link becomes complex, resulting in the expansion of the test scope, making it difficult to determine the test scope and understand the modified services and their calling link in detail, affecting the testing efficiency.

Method used

By scanning the service provider configuration file, obtaining the service registration list, reversely compiling and obtaining the implementation class source file of the registration service, using static code scanning technology to generate multiple service call relationships based on preset service call rules, and then generating the target service call link.

Benefits of technology

It realizes accurate acquisition of the service call link, helps tests to be more targeted, improves test efficiency, and provides guarantees for safe production.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114860669B_ABST
    Figure CN114860669B_ABST
Patent Text Reader

Abstract

The present disclosure provides a method for obtaining a service call link, which can be applied to the field of cloud computing technology. The method includes: determining the implementation class source files corresponding to all services in the service registration list according to the service registration list, wherein the service registration list is obtained by scanning the service provider configuration file; performing code scanning on the implementation class source file according to the preset service call rules to obtain multiple service call relationships, wherein the preset service call rules are used to characterize the service call form in the implementation class source file, and each of the service call relationships is a call relationship between two services; and calling the target function to process the multiple service call relationships to generate a target service call link. The present disclosure also provides a device, equipment, storage medium and program product for obtaining a service call link.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of computer technology, specifically to the field of testing technology, and more specifically to a method, device, equipment, storage medium and program product for obtaining a service call link. Background Art

[0002] As distributed technology matures, the number of services under the distributed system architecture continues to increase, the service call link becomes more complex, and the scope of testing also expands. When microservices in a distributed system are changed and upgraded, how to determine the test scope and how to understand in detail the modified service within the test scope and the call link of the service to generate targeted test cases will help improve test efficiency. Therefore, a method for obtaining the service call link is urgently needed.

[0003] It should be noted that the information disclosed in the above background technology section is only used to enhance the understanding of the background of the present disclosure, and therefore may include information that does not constitute the prior art known to ordinary technicians in the field. Summary of the invention

[0004] In view of the above problems, the present disclosure provides a method, apparatus, device, medium and program product for obtaining a service call link.

[0005] According to a first aspect of the present disclosure, a method for acquiring a service call link is provided, comprising:

[0006] Determine, according to a service registration list, implementation class source files corresponding to all services in the service registration list, wherein the service registration list is obtained by scanning a service provider configuration file;

[0007] Scan the implementation class source file according to a preset service call rule to obtain a plurality of service call relationships, wherein the preset service call rule is used to characterize the service call form in the implementation class source file, and each service call relationship is a call relationship between two services; and

[0008] The target function is called to process the multiple service call relationships to generate a target service call link.

[0009] According to an embodiment of the present disclosure, determining the implementation class source files corresponding to all services according to the service registration list includes:

[0010] Determine the registered service information according to the service registration list, wherein the registered service information includes the service name and the implementation class file name;

[0011] Determine the implementation class source file of the service according to the service name and the implementation class file name.

[0012] According to an embodiment of the present disclosure, determining the implementation class source file of the service according to the service name and the implementation class file name includes:

[0013] Determine the image file of the service according to the service name and the implementation class file name; and

[0014] The image file is decompiled to generate an implementation class source file of the service.

[0015] According to an embodiment of the present disclosure, the code scanning of the implementation class source file according to the preset service calling rule to obtain multiple service calling relationships includes:

[0016] Determine the target key fields according to the preset service call rules;

[0017] Scan the implementation class source file according to the target key field to determine the context code of the target key field;

[0018] Determine the service caller and the service callee according to the context code of the target key field; and

[0019] A plurality of service calling relationships are generated according to the service caller and the service callee.

[0020] According to an embodiment of the present disclosure, the calling target function processes the multiple service calling relationships to generate a target service calling link, including:

[0021] Determine an input parameter of the target function, wherein the input parameter is a single service name or a service chain;

[0022] Determine the type of the input parameter according to a preset identifier of the input parameter;

[0023] The multiple service call relationships are searched cyclically according to the input parameter type until a target service call link is generated.

[0024] According to an embodiment of the present disclosure, the cyclically searching the multiple service call relationships according to the input parameter type until a target service call link is generated includes:

[0025] When it is determined that the input parameter type is a service chain, obtaining the end service name of the service chain;

[0026] Search the plurality of service call relationships according to the terminal service name to determine a first service list, where the first service list is a set of services called by the terminal service;

[0027] Add each service in the first service list after the terminal service name to generate multiple service call links;

[0028] The multiple service call relationships are searched cyclically to extend the multiple service call links until multiple target service call links are generated.

[0029] According to an embodiment of the present disclosure, the step of cyclically searching the plurality of service call relationships according to the input parameter type until a target service call link is generated further includes:

[0030] When it is determined that the input parameter type is a single service name, searching the multiple service call relationships according to the single service name to determine a second service list, where the second service list is a set of services called by the single service name;

[0031] Adding each service in the second service list after the single service name to generate multiple service call links;

[0032] The multiple service call relationships are searched cyclically to extend the multiple service call links until multiple target service call links are generated.

[0033] According to an embodiment of the present disclosure, the preset service calling form includes function calling and annotation calling.

[0034] According to an embodiment of the present disclosure, it also includes:

[0035] Compare the target service call link with the actual call link to determine the unknown service call link;

[0036] parsing the unknown service call link to generate a target service call rule; and

[0037] The preset service calling rule is updated according to the target service calling rule.

[0038] A second aspect of the present disclosure provides a device for acquiring a service call link, comprising: a determination module, configured to determine implementation class source files corresponding to all services according to a service registration list, wherein the service registration list is obtained by scanning a service provider configuration file;

[0039] A code scanning module, used to perform code scanning on the implementation class source file according to a preset service calling rule to obtain a plurality of service calling relationships, wherein the preset service calling rule is used to characterize the service calling form in the implementation class source file, and the service calling relationship is a calling relationship between two services;

[0040] The service call link generation module is used to call a target function according to the multiple service call relationships to generate a target service call link, wherein the target function is used to extend the service call link.

[0041] According to an embodiment of the present disclosure, the determination module includes:

[0042] A first determining submodule, configured to determine registered service information according to the service registration list, wherein the registered service information includes a service name and an implementation class file name; and

[0043] The second determination submodule is used to determine the implementation class source file of the service according to the service name and the implementation class file name.

[0044] According to an embodiment of the present disclosure, the second determining submodule includes:

[0045] A first determining unit, configured to determine an image file of a service according to the service name and the implementation class file name; and

[0046] The first generating unit is used to decompile the image file to generate an implementation class source file of the service.

[0047] According to an embodiment of the present disclosure, the code scanning module includes:

[0048] The third determination submodule is used to determine the target key field according to the preset service call rule;

[0049] A scanning submodule, configured to scan the implementation class source file according to the target key field to determine the context code of the target key field;

[0050] A fourth determination submodule, configured to determine a service caller and a service callee according to the context code of the target key field; and

[0051] The first generating submodule is used to generate a plurality of service calling relationships according to the service caller and the service callee.

[0052] According to an embodiment of the present disclosure, the service call link generation module includes:

[0053] A fifth determination submodule, used to determine an input parameter of the target function, wherein the input parameter is a single service name or a service chain;

[0054] A sixth confirmation submodule, configured to determine the type of the input parameter according to a preset identifier of the input parameter;

[0055] The loop search submodule is used to loop search the multiple service call relationships according to the input parameter type until a target service call link is generated.

[0056] According to an embodiment of the present disclosure, the cyclic search submodule includes:

[0057] an acquiring unit, configured to acquire the end service name of the service chain when determining that the input parameter type is a service chain;

[0058] A second determining unit, configured to search the plurality of service calling relationships according to the terminal service name to determine a first service list, wherein the first service list is a set of services called by the terminal service;

[0059] A second generating unit, configured to add each service in the first service list after the terminal service name to generate a plurality of service call links; and

[0060] The first loop search unit is used to loop search the multiple service call relationships to extend the multiple service call links until multiple target service call links are generated.

[0061] According to an embodiment of the present disclosure, the cyclic search submodule further includes:

[0062] A third determining unit is configured to, when determining that the input parameter type is a single service name, search the multiple service call relationships according to the single service name to determine a second service list, where the second service list is a set of services called by the single service name;

[0063] A third generating unit, configured to add each service in the second service list to the end of the single service name to generate multiple service call links; and

[0064] The second loop search unit is used to loop search the multiple service call relationships to extend the multiple service call links until multiple target service call links are generated.

[0065] According to an embodiment of the present disclosure, the device further includes:

[0066] A comparison module, used to compare the target service call link with the actual call link to determine the unknown service call link;

[0067] A parsing module, used for parsing the unknown service call link to generate a target service call rule; and

[0068] An updating module is used to update the preset service calling rule according to the target service calling rule.

[0069] The third aspect of the present disclosure provides an electronic device, comprising: one or more processors; a memory for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors execute the above-mentioned method for obtaining the service call link.

[0070] A fourth aspect of the present disclosure further provides a computer-readable storage medium having executable instructions stored thereon, which, when executed by a processor, causes the processor to execute the above-mentioned method for acquiring the service call link.

[0071] A fifth aspect of the present disclosure further provides a computer program product, including a computer program, which implements the above-mentioned method for obtaining the service call link when executed by a processor.

[0072] A method for obtaining a service call link provided by an embodiment of the present invention obtains a service registration list by scanning a service provider configuration file, reverse compiles the service registration list to obtain an implementation class source file corresponding to the registered service, and uses static code scanning technology to scan the implementation class source file according to preset service call rules to generate multiple service call relationships, and then generates a target service call link, which makes the test more targeted, helps to improve test efficiency, and provides protection for safe production. BRIEF DESCRIPTION OF THE DRAWINGS

[0073] The above contents and other objects, features and advantages of the present disclosure will become more apparent through the following description of the embodiments of the present disclosure with reference to the accompanying drawings, in which:

[0074] Figure 1 The application scenario diagram schematically shows the method, apparatus, device, medium and program product for obtaining the service call link according to the embodiment of the present disclosure;

[0075] Figure 2 A flowchart schematically shows a method for obtaining a service call link according to an embodiment of the present disclosure;

[0076] Figure 3a One of the flow charts of the method for obtaining a service implementation class source file according to an embodiment of the present disclosure is schematically shown;

[0077] Figure 3b The second flowchart of the method for obtaining a service implementation class source file according to an embodiment of the present disclosure is schematically shown;

[0078] Figure 4 A flowchart of obtaining a service call relationship through static code scanning according to an embodiment of the present disclosure is schematically shown;

[0079] Figure 5a Schematically shows one of the flow charts of a method for generating a target service call link according to multiple service call relationships according to an embodiment of the present disclosure;

[0080] Figure 5b Schematically shows a second flowchart of a method for generating a target service call link according to multiple service call relationships according to an embodiment of the present disclosure;

[0081] Figure 5c Schematically shows a third flowchart of a method for generating a target service call link according to multiple service call relationships according to an embodiment of the present disclosure;

[0082] Figure 6 A flowchart of a method for updating a preset service calling rule according to an embodiment of the present disclosure is schematically shown;

[0083] Figure 7 A structural block diagram schematically shows a device for acquiring a service call link according to an embodiment of the present disclosure; and

[0084] Figure 8 A block diagram of an electronic device suitable for implementing a cloud platform interface generation method according to an embodiment of the present disclosure is schematically shown. DETAILED DESCRIPTION

[0085] Hereinafter, embodiments of the present disclosure will be described with reference to the accompanying drawings. However, it should be understood that these descriptions are exemplary only and are not intended to limit the scope of the present disclosure. In the following detailed description, for ease of explanation, many specific details are set forth to provide a comprehensive understanding of the embodiments of the present disclosure. However, it is apparent that one or more embodiments may also be implemented without these specific details. In addition, in the following description, descriptions of known structures and technologies are omitted to avoid unnecessary confusion of the concepts of the present disclosure.

[0086] The terms used herein are only for describing specific embodiments and are not intended to limit the present disclosure. The terms "comprise", "include", etc. used herein indicate the existence of the features, steps, operations and / or components, but do not exclude the existence or addition of one or more other features, steps, operations or components.

[0087] All terms (including technical and scientific terms) used herein have the meanings commonly understood by those skilled in the art, unless otherwise defined. It should be noted that the terms used herein should be interpreted as having a meaning consistent with the context of this specification, and should not be interpreted in an idealized or overly rigid manner.

[0088] When using expressions such as "at least one of A, B, and C, etc.", they should generally be interpreted according to the meaning of the expression commonly understood by those skilled in the art (for example, "a system having at least one of A, B, and C" should include but is not limited to a system having A alone, B alone, C alone, A and B, A and C, B and C, and / or A, B, C, etc.).

[0089] An embodiment of the present disclosure provides a method for obtaining a service call link, comprising: determining, according to a service registration list, implementation class source files corresponding to all services in the service registration list, wherein the service registration list is obtained by scanning a service provider configuration file; performing code scanning on the implementation class source file according to a preset service call rule to obtain multiple service call relationships, wherein the preset service call rule is used to characterize the service call form in the implementation class source file, and each of the service call relationships is a call relationship between two services; and calling a target function to process the multiple service call relationships to generate a target service call link.

[0090] Figure 1 The application scenario diagram of the service call link acquisition method, apparatus, device, medium and program product according to the embodiment of the present disclosure is schematically shown.

[0091] like Figure 1 As shown, the application scenario 100 according to this embodiment may include a cloud platform interface usage scenario. The network 104 is used to provide a medium for a communication link between the terminal devices 101, 102, 103 and the server 105. The network 104 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.

[0092] Users can use terminal devices 101, 102, 103 to interact with server 105 through network 104 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 101, 102, 103, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc. (only examples).

[0093] The terminal devices 101 , 102 , and 103 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, and desktop computers.

[0094] The server 105 may be a server that provides a service call link generation service for users, such as a backend server that provides corresponding support (for example only) in response to a call link acquisition instruction issued by a user using the terminal devices 101, 102, and 103. The backend server may analyze and process the received data such as the user service call link acquisition request, and feed back the generated service call link to the terminal device.

[0095] It should be noted that the method for obtaining the service call link provided in the embodiment of the present disclosure can generally be executed by the server 105. Accordingly, the device for obtaining the service call link provided in the embodiment of the present disclosure can generally be set in the server 105. The method for obtaining the service call link provided in the embodiment of the present disclosure can also be executed by a server or server cluster that is different from the server 105 and can communicate with the terminal devices 101, 102, 103 and / or the server 105. Accordingly, the device for obtaining the service call link provided in the embodiment of the present disclosure can also be set in a server or server cluster that is different from the server 105 and can communicate with the terminal devices 101, 102, 103 and / or the server 105.

[0096] It should be understood that Figure 1 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.

[0097] It should be noted that the method and device for obtaining the service call link determined in the embodiment of the present disclosure can be used for applications in the financial field in the field of testing technology, and can also be used in any field other than the financial field. The application field of the method and device for obtaining the service call link determined in the embodiment of the present disclosure is not limited.

[0098] The following will be based on Figure 1 The scene described by Figure 2 to Figure 6 The method for obtaining the service call link in the embodiment of the present disclosure is described in detail.

[0099] Figure 2 The flowchart of the method for obtaining the service call link according to the embodiment of the present disclosure is schematically shown. Figure 2 As shown, the method for obtaining the service call link of this embodiment includes operations S210 to S230, and the method can be executed by a server or other computing devices.

[0100] In operation S210, implementation class source files corresponding to all services in the service registration list are determined according to the service registration list.

[0101] According to an embodiment of the present disclosure, the service registration list is obtained by scanning a service provider configuration file.

[0102] In an example, in the Dubbo microservice framework, the service provider needs to register its own service in the provider.xml file, that is, the service provider configuration file. By scanning the service provider configuration file, all registered services can be obtained, that is, the full service registration list can be obtained, and the implementation class source file corresponding to each service in the list can be determined according to the service registration list. The process of obtaining the service implementation class source file will not be repeated here. Figure 3a Operations S211 to S212 are shown.

[0103] In operation S220, code scanning is performed on the implementation class source file according to a preset service calling rule to obtain a plurality of service calling relationships.

[0104] According to an embodiment of the present disclosure, the preset service calling rule is used to characterize the service calling form in the implementation class source file, and each of the service calling relationships is a calling relationship between two services.

[0105] According to an embodiment of the present disclosure, the service calling form includes function calling and annotation calling.

[0106] In one example, after obtaining the implementation class source file of any service, the source file code of the service is statically scanned according to the preset service call rules, wherein the preset service call rules refer to a variety of service call forms in the implementation class source file, including function calls, annotation calls and other forms of calls. Identify the code related to the preset service call rules, and then determine the caller and callee of the service. For example, in a certain line of code, determine that the method M1 of the service calls the service S1, and continue to search which services are called by the implementation class source file of the service S1, until a service is only called as the callee and does not call other services, then the search for the service call chain is completed. All source files can be subjected to the above scanning process to obtain all service call links. When the number of services is large and the call links are complex, it may happen that the same file is scanned multiple times, resulting in a long time and a reduced acquisition rate of the service call link. In order to improve the scanning efficiency, in the embodiment of the present disclosure, it is only necessary to scan all source files once to obtain multiple service call relationships, and the service call relationship only represents the call relationship between the two services, that is, the service call link obtained by operation S220 only includes the two services of the caller and the callee. For the specific static code scanning process, please refer to Figure 4 Operations S221 to S224 are shown and are not described in detail here.

[0107] In operation S230, a target function is called to generate a target service call link from the multiple service call relationships.

[0108] In one example, multiple service call relationships are connected in series by calling a target function to generate multiple complete service call links. The target function is used to connect multiple service call relationships in series to extend the service call link. The process of generating a target service call link based on multiple service call relationships can be found in Figure 5a The operations S231 to S233 are described.

[0109] A method for obtaining a service call link provided by an embodiment of the present invention obtains a service registration list by scanning a service provider configuration file, reverse compiles the service registration list to obtain an implementation class source file corresponding to the registered service, and uses static code scanning technology to scan the implementation class source file according to preset service call rules to generate multiple service call relationships, and then generates a target service call link, which makes the test more targeted, helps to improve test efficiency, and provides protection for safe production.

[0110] Figure 3a One of the flowcharts of the method for obtaining a service implementation class source file according to an embodiment of the present disclosure is schematically shown. Figure 3b The second flowchart of the method for obtaining the service implementation class source file according to the embodiment of the present disclosure is schematically shown. Figure 3a As shown, operation S210 includes operations S211 to S212.

[0111] In operation S211, registered service information is determined according to the service registration list.

[0112] According to an embodiment of the present disclosure, the registered service information includes a service name and an implementation class file name.

[0113] In operation S212, an implementation class source file of the service is determined according to the service name and the implementation class file name.

[0114] like Figure 3b As shown, operation S212 includes operation S2121 and operation S2122.

[0115] In operation S2121, an image file of the service is determined according to the service name and the implementation class file name.

[0116] In operation S2222, the image file is decompiled to generate an implementation class source file of the service.

[0117] In an example, the registered service information includes the service name, method name and implementation class file name. Taking F-PRRS (personal remittance) as an example, the registered service ATS CrossBorderRemitASM (cross-border remittance service) is found in provider.xml. The implementation class source file name corresponding to the service is com.xxx.xx.app.service.ATSCrossBorderRemitASMImpl. The mirror file of the cross-border remittance service is determined in the mirror database according to the implementation class source file name. Since the mirror file is a compiled file, the mirror file needs to be decompiled to generate the source code file of the service, that is, the implementation class source file.

[0118] Figure 4The flowchart of obtaining the service call relationship through static code scanning according to an embodiment of the present disclosure is schematically shown. Figure 4 As shown, operation S220 includes operations S221 to S224.

[0119] In operation S221, a target key field is determined according to a preset service calling rule.

[0120] In operation S222, the implementation class source file is scanned according to the target key field to determine the context code of the target key field.

[0121] In operation S223, the service caller and the service callee are determined according to the context code of the target key field.

[0122] In operation S224, a plurality of service calling relationships are generated according to the service caller and the service callee.

[0123] In an example, services at different layers under the Dubbo service framework mainly call each other through functions getbean, invokeService, invokeAsyncservice, and BeanUtil.getAsyncModule. In addition, each service can use annotations @autowired and @resources to implement bean injection and call each functional component. The above function call method and annotation are used as the target key fields, key field identification is performed, the context code of the target key field in the source code is located, the service caller and service callee in the context code are extracted, and a service call relationship is generated. In order to obtain the call relationship between two services, all source codes need to be scanned. The source code files in the source code directory are traversed. For each source code file, a line-by-line scanning method is used to extract what service is called by a specific method in the file according to the service call rules, so that a call relationship between two services in the form of service1→service2 can be obtained.

[0124] Take F-PRRS (personal remittance) as an example to illustrate the process and results of obtaining a service link. For example, the registered service ATS CrossBorderRemitASM (cross-border remittance service) is found in provider.xml, and its corresponding implementation class is com.icbc.prrs.app.service.ATSCrossBorderRemitASMImpl. By scanning the file, it can be found that the file contains the @autowired annotation, which introduces module A, and then the objects of this module are used in multiple methods of the service. For example, in the doRemit method of the service, object B created by the module is used. Then scan the CrossborderRemit file to find out whether other services or modules are called in method B. The search shows that the method calls component C, and further search shows that component C calls method D. Then search whether method D calls other services or modules, until the method no longer calls other services or components. After the above operations, multiple service call relationships can be obtained, A calls B, B calls C, and C calls D.

[0125] Figure 5a One of the flowcharts of the method for generating a target service call link according to multiple service call relationships according to an embodiment of the present disclosure is schematically shown. Figure 5b The second flowchart of the method for generating a target service call link according to multiple service call relationships according to an embodiment of the present disclosure is schematically shown. Figure 5c The third flowchart of the method for generating a target service call link according to multiple service call relationships according to an embodiment of the present disclosure is schematically shown. Figure 5a As shown, it includes operations S231 to S233.

[0126] In operation S231 , an input parameter of the target function is determined, wherein the input parameter is a single service name or a service chain.

[0127] In operation S232, the type of the input parameter is determined according to a preset identifier of the input parameter.

[0128] In one example, the incoming parameters of the target function are first determined. For example, all services that belong to the caller and are not the callee, that is, the target source service, can be screened out based on multiple service call relationships. For each screened target source service, the target function is called to continuously extend the call link of the target source service until a complete target service call link is generated. The input parameter of the target function is service, and the incoming parameter can be a single service name or a service chain. First, determine the type of the incoming parameter service, that is, whether it is a single service name or a service chain. Specifically, it can be determined based on whether there is a preset identifier in the incoming parameter, such as "-", "→", "@", etc., which represent service call relationships.

[0129] In operation S233, the plurality of service call relationships are cyclically searched according to the input parameter type until a target service call link is generated.

[0130] There are two feasible implementations of operation S233:

[0131] In one possible implementation, Figure 5b As shown, operation S310 to operation S340 are included.

[0132] In operation S310, when it is determined that the input parameter type is a service chain, an end service name of the service chain is acquired.

[0133] In operation S320, the plurality of service call relationships are searched according to the terminal service name to determine a first service list.

[0134] According to an embodiment of the present disclosure, the first service list is a set of services called by the terminal service.

[0135] In operation S330, each service in the first service list is added after the terminal service name to generate a plurality of service call links.

[0136] In operation S340, the plurality of service call relationships are searched cyclically to extend the plurality of service call links until a plurality of target service call links are generated.

[0137] In one example, when it is determined to be a service chain, the last service name in the service chain is determined and assigned to the variable tempsrv. The service call relationship is searched to obtain all services called by tempsrv to form the first service list calledbytempsrv. If calledbytempsrv is empty, it indicates that the current service is the last service in the service call chain, and the search ends. Each service in calledbytempsrv can be added as a callee to the original service or service call chain. If calledbytempsrv has n elements, n new service chains can be obtained: service→element 1, service→element 2,..., service→element n. Each new service chain obtained in operation S330 is assigned to service, and the above process is re-executed until multiple target service call links are obtained.

[0138] In another possible implementation, if Figure 5c As shown, operation S410 to operation S430 are included.

[0139] In operation S410, when it is determined that the input parameter type is a single service name, the multiple service call relationships are searched according to the single service name to determine a second service list.

[0140] According to an embodiment of the present disclosure, the second service list is a set of services called by the single service name.

[0141] In operation S420, each service in the second service list is added after the single service name to generate a plurality of service call links.

[0142] In operation S430, the plurality of service call relationships are searched cyclically to extend the plurality of service call links until a plurality of target service call links are generated.

[0143] In one example, the principles of operations S410 to S430 are roughly the same. When it is determined that the incoming parameter is a single service name, the single service name is assigned to the variable tempsrv. Search the service call relationship to obtain all services called by tempsrv to form a second service list calledbytempsrv. If calledbytempsrv is empty, it indicates that the current service is the last service in the service call chain, and the search ends. Each service in calledbytempsrv can be added as a callee to the original service or service call chain. If calledbytempsrv has n elements, n new service chains can be obtained: service→element 1, service→element 2, ..., service→element n.

[0144] For example, the following calling relationships between two services can be obtained through the first scan: A→B, B→C, C→D.

[0145] First, the service A parameter is passed in, and it is determined that the service calls service B, and the service chain A→B is obtained. The service chain is further input into the target function. After judgment, it is determined that the passed parameter is a service chain parameter, and the last called service name B in the service chain is determined. After searching, it is determined that service B calls service C. The service chain is further extended to: A→B→C, until the service at the end of the service chain cannot find a scenario to call other services, that is, service D is the last called service, then the service chain search ends, and the target service call link A→B→C→D is generated.

[0146] Since the preset service call rules only include commonly used call forms, sometimes developers do not call according to the specifications. Therefore, the service call rules in the embodiment of the present disclosure can also be dynamically updated and adjusted. Figure 6 Describes the update process of preset service call rules.

[0147] Figure 6 The flowchart of the preset service calling rule updating method according to the embodiment of the present disclosure is schematically shown, which specifically includes operations S510 to S530.

[0148] In operation S510, the target service call link is compared with the actual call link to determine an unknown service call link.

[0149] In operation S520, the unknown service call link is parsed to generate a target service call rule.

[0150] In operation S530, the preset service calling rule is updated according to the target service calling rule.

[0151] In one example, the target service call link obtained by static code scanning can be compared with the actual call link, which refers to the real call link that occurs during the actual transaction flow and is recorded by the holographic monitoring system. By comparing, it is determined that there is a service call link in the actual call link that does not exist in the target service call link, that is, an unknown service call link. By parsing the code file corresponding to the unknown service call link, a new target service call rule is abstracted, and the preset service call rule is updated. For example, Figure 4 The service call link obtained in the operation is ABCD. Service A is searched in the holographic monitoring system to obtain ABDEC. At this time, it is determined that service D calling service E is an unknown service call link. The code of the implementation class source files of service D and service E is analyzed, and the form of the service call is analyzed and abstracted into a calling rule, such as determining the corresponding calling function name or method name, and updating the rule to the preset service calling rule for subsequent code scanning.

[0152] Based on the above service call link acquisition method, the present disclosure also provides a service call link acquisition device. Figure 7 The device is described in detail.

[0153] Figure 7 The structural block diagram of the device for acquiring the service call link according to the embodiment of the present disclosure is schematically shown.

[0154] like Figure 7 As shown, the service call link acquisition device 800 of this embodiment includes a determination module 810, a code scanning module 820 and a service call link generation module 830.

[0155] The determination module 810 is used to determine the implementation class source files corresponding to all services in the service registration list according to the service registration list, and the service registration list is obtained by scanning the service provider configuration file. In one embodiment, the determination module 810 can be used to perform the operation S210 described above, which will not be repeated here.

[0156] The code scanning module 820 is used to perform code scanning on the implementation class source file according to a preset service call rule to obtain multiple service call relationships, wherein the preset service call rule is used to characterize the service call form in the implementation class source file, and each service call relationship is a call relationship between two services. In one embodiment, the code scanning module 820 can be used to perform the operation S220 described above, which will not be repeated here.

[0157] The service call link generation module 830 is used to call the target function according to the multiple service call relationships to generate a target service call link. In one embodiment, the service call link generation module 830 can be used to perform the operation S230 described above, which will not be repeated here.

[0158] According to an embodiment of the present disclosure, the determination module 810 includes: a first determination submodule 811 and a second determination submodule 812 .

[0159] The first determination submodule 811 is used to determine the registered service information according to the service registration list, and the registered service information includes the service name and the implementation class file name. In one embodiment, the first determination submodule 811 can be used to perform the operation S211 described above, which will not be repeated here.

[0160] The second determination submodule 812 is used to determine the implementation class source file of the service according to the service name and the implementation class file name. In one embodiment, the second determination submodule 812 can be used to perform the operation S212 described above, which will not be repeated here.

[0161] According to an embodiment of the present disclosure, the second determining submodule 812 includes a first determining unit 8121 and a first generating unit 8122 .

[0162] The first determining unit 8121 is used to determine the image file of the service according to the service name and the implementation class file name. In one embodiment, the first determining unit 8121 can be used to perform the operation S2121 described above, which will not be described in detail here.

[0163] The first generating unit 8122 is used to decompile the image file to generate the implementation class source file of the service. In one embodiment, the first generating unit 8122 can be used to perform the operation S2122 described above, which will not be described in detail here.

[0164] 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 .

[0165] The third determination submodule 821 is used to determine the target key field according to the preset service call rule. In one embodiment, the third determination submodule 821 can be used to perform the operation S221 described above, which will not be repeated here.

[0166] The scanning submodule 822 is used to scan the implementation class source file according to the target key field to determine the context code of the target key field. In one embodiment, the scanning submodule 822 can be used to perform the operation S232 described above, which will not be repeated here.

[0167] The fourth determination submodule 823 is used to determine the service caller and the service callee according to the context code of the target key field. In one embodiment, the fourth determination submodule 823 can be used to perform the operation S223 described above, which will not be described in detail here.

[0168] The first generation submodule 824 is used to generate multiple service call relationships according to the service caller and the service callee. In one embodiment, the first generation submodule 824 can be used to perform the operation S224 described above, which will not be repeated here.

[0169] According to an embodiment of the present disclosure, the service call link generation module 830 includes: a fifth determination submodule 831 , a sixth determination submodule 832 , and a loop search submodule 833 .

[0170] According to an embodiment of the present disclosure, the fifth determination submodule 831 is used to determine an incoming parameter of the target function, wherein the incoming parameter is a single service name or a service chain. In one embodiment, the fifth determination submodule 831 can be used to perform the operation S231 described above, which will not be repeated here.

[0171] The sixth determining submodule 832 is used to determine the type of the input parameter according to the preset identifier of the input parameter. In one embodiment, the sixth determining submodule 832 can be used to perform the operation S232 described above, which will not be described in detail here.

[0172] The loop search submodule 833 is used to loop search the multiple service call relationships according to the input parameter type until a target service call link is generated. In one embodiment, the loop search submodule 833 can be used to perform the operation S233 described above, which will not be repeated here.

[0173] According to an embodiment of the present disclosure, the cyclic search submodule 833 includes: an acquisition unit 8331 , a second determination unit 8332 , a second generation unit 8333 and a first cyclic search unit 8334 .

[0174] The acquisition unit 8331 is used to acquire the end service name of the service chain when it is determined that the input parameter type is a service chain. In one embodiment, the acquisition unit 8331 can be used to perform the operation S310 described above, which will not be described in detail here.

[0175] The second determining unit 8332 is used to search the multiple service call relationships according to the terminal service name to determine a first service list, which is a set of services called by the terminal service. In one embodiment, the second determining unit 8332 can be used to perform the operation S320 described above, which will not be repeated here.

[0176] The second generating unit 8333 is used to add each service in the first service list to the end service name to generate multiple service call links. In one embodiment, the second generating unit 8333 can be used to perform the operation S330 described above, which will not be repeated here.

[0177] The first loop search unit 8334 is used to loop search the multiple service call relationships to extend the multiple service call links until multiple target service call links are generated. In one embodiment, the first loop search unit 8334 can be used to perform the operation S340 described above, which will not be repeated here.

[0178] According to an embodiment of the present disclosure, the loop search submodule 833 further includes: a third determination unit 8335 , a third generation unit 8336 , and a second loop search unit 8337 .

[0179] The third determining unit 8335 is used to search the multiple service call relationships according to the single service name to determine a second service list when it is determined that the input parameter type is a single service name, wherein the second service list is a set of services called by the single service name. In one embodiment, the third determining unit 8335 can be used to perform the operation S410 described above, which will not be repeated here.

[0180] The third generating unit 8336 is used to add each service in the second service list to the single service name to generate multiple service call links. In one embodiment, the third generating unit 8336 can be used to perform the operation S420 described above, which will not be repeated here.

[0181] The second loop search unit 8337 is used to loop search the multiple service call relationships to extend the multiple service call links until multiple target service call links are generated. In one embodiment, the second loop search unit 8337 can be used to perform the operation S430 described above, which will not be repeated here.

[0182] According to an embodiment of the present disclosure, the device for acquiring a service call link further includes a comparison module 840 , a parsing module 850 and an updating module 860 .

[0183] The comparison module 840 is used to compare the target service call link with the actual call link to determine the unknown service call link. In one embodiment, the comparison module 840 can be used to perform the operation S510 described above, which will not be repeated here.

[0184] The parsing module 850 is used to parse the unknown service call link to generate a target service call rule. In one embodiment, the parsing module 850 can be used to perform the operation S520 described above, which will not be described in detail here.

[0185] The updating module 860 is used to update the preset service calling rule according to the target service calling rule. In one embodiment, the updating module 860 can be used to perform the operation S530 described above, which will not be described in detail here.

[0186] According to an embodiment of the present disclosure, any multiple modules of the determination module 810, the code scanning module 820 and the service call link generation module 830 can be combined in one module for implementation, or any one of the modules can be split into multiple modules. Alternatively, at least part of the functions of one or more of these modules can be combined with at least part of the functions of other modules and implemented in one module. According to an embodiment of the present disclosure, at least one of the determination module 810, the code scanning module 820 and the service call link generation module 830 can be at least partially implemented 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 can be implemented by hardware or firmware such as any other reasonable way of integrating or packaging the circuit, or implemented in any one of the three implementation methods of software, hardware and firmware or in any appropriate combination of any of them. Alternatively, at least one of the determination module 810, the code scanning module 820 and the service call link generation module 830 can be at least partially implemented as a computer program module, and when the computer program module is run, the corresponding function can be performed.

[0187] Figure 8A block diagram of an electronic device suitable for implementing a method for acquiring a service call link according to an embodiment of the present disclosure is schematically shown.

[0188] like Figure 8 As shown, the electronic device 900 according to an embodiment of the present disclosure includes a processor 901, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 902 or a program loaded from a storage part 908 into a random access memory (RAM) 903. The processor 901 may include, for example, a general-purpose microprocessor (e.g., a CPU), an instruction set processor and / or a related chipset and / or a special-purpose microprocessor (e.g., an application-specific integrated circuit (ASIC)), etc. The processor 901 may also include an onboard memory for caching purposes. The processor 901 may include a single processing unit or multiple processing units for performing different actions of the method flow according to an embodiment of the present disclosure.

[0189] In RAM 903, various programs and data required for the operation of electronic device 900 are stored. Processor 901, ROM 902 and RAM 903 are connected to each other via bus 904. Processor 901 performs various operations of the method flow according to the embodiment of the present disclosure by executing the program in ROM 902 and / or RAM 903. It should be noted that the program can also be stored in one or more memories other than ROM 902 and RAM 903. Processor 901 can also perform various operations of the method flow according to the embodiment of the present disclosure by executing the program stored in the one or more memories.

[0190] According to an embodiment of the present disclosure, the electronic device 900 may further include an input / output (I / O) interface 905, which is also connected to the bus 904. The electronic device 900 may further include one or more of the following components connected to the I / O interface 905: an input portion 906 including a keyboard, a mouse, etc.; an output portion 907 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage portion 908 including a hard disk, etc.; and a communication portion 909 including a network interface card such as a LAN card, a modem, etc. The communication portion 909 performs communication processing via a network such as the Internet. A drive 910 is also connected to the I / O interface 905 as needed. A removable medium 911, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 910 as needed, so that a computer program read therefrom is installed into the storage portion 908 as needed.

[0191] The present disclosure also provides a computer-readable storage medium, which may be included in the device / apparatus / system described in the above embodiment; or may exist independently without being assembled into the device / apparatus / system. The above computer-readable storage medium carries one or more programs, and when the above one or more programs are executed, the method for obtaining the service call link according to the embodiment of the present disclosure is implemented.

[0192] According to an embodiment of the present disclosure, a computer-readable storage medium may be a non-volatile computer-readable storage medium, for example, may include but is not limited to: a portable computer disk, 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 disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program, which may be used by or in combination with an instruction execution system, an apparatus, or a device. For example, according to an embodiment of the present disclosure, a computer-readable storage medium may include the ROM 902 and / or RAM 903 described above and / or one or more memories other than ROM 902 and RAM 903.

[0193] The embodiment of the present disclosure also includes a computer program product, which includes a computer program, and the computer program contains program code for executing the method shown in the flowchart. When the computer program product is run in a computer system, the program code is used to enable the computer system to implement the service call link acquisition method provided by the embodiment of the present disclosure.

[0194] The above functions defined in the system / device of the embodiment of the present disclosure are performed when the computer program is executed by the processor 901. According to the embodiment of the present disclosure, the system, device, module, unit, etc. described above can be implemented by a computer program module.

[0195] In one embodiment, the computer program may be based on a tangible storage medium such as an optical storage device, a magnetic storage device, etc. In another embodiment, the computer program may also be transmitted and distributed in the form of a signal on a network medium, and downloaded and installed through the communication part 909, and / or installed from a removable medium 911. The program code contained in the computer program may be transmitted using any appropriate network medium, including but not limited to: wireless, wired, etc., or any suitable combination of the above.

[0196] In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 909, and / or installed from the removable medium 911. When the computer program is executed by the processor 901, the above functions defined in the system of the embodiment of the present disclosure are performed. According to the embodiment of the present disclosure, the system, device, means, module, unit, etc. described above can be implemented by a computer program module.

[0197] According to an embodiment of the present disclosure, the program code for executing the computer program provided by the embodiment of the present disclosure can be written in any combination of one or more programming languages. Specifically, these computing programs can be implemented using high-level process and / or object-oriented programming languages, and / or assembly / machine languages. Programming languages ​​include, but are not limited to, Java, C++, python, "C" language or similar programming languages. The program code can be executed entirely on the user computing device, partially on the user device, partially on the remote computing device, or entirely on the remote computing device or server. In the case of a remote computing device, the remote computing device can be connected to the user computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computing device (for example, using an Internet service provider to connect through the Internet).

[0198] The flow charts and block diagrams in the accompanying drawings illustrate the possible architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0199] It will be appreciated by those skilled in the art that the features described in the various embodiments and / or claims of the present disclosure may be combined and / or combined in a variety of ways, even if such combinations and / or combinations are not explicitly described in the present disclosure. In particular, the features described in the various embodiments and / or claims of the present disclosure may be combined and / or combined in a variety of ways without departing from the spirit and teachings of the present disclosure. All of these combinations and / or combinations fall within the scope of the present disclosure.

[0200] The embodiments of the present disclosure are described above. However, these embodiments are only for illustrative purposes and are not intended to limit the scope of the present disclosure. Although the embodiments are described above separately, this does not mean that the measures in the various embodiments cannot be used in combination to advantage. The scope of the present disclosure is defined by the attached claims and their equivalents. Without departing from the scope of the present disclosure, those skilled in the art may make a variety of substitutions and modifications, which should all fall within the scope of the present disclosure.

Claims

1. A method for obtaining a service call link, characterized in that: include: Determine, according to a service registration list, implementation class source files corresponding to all services in the service registration list, wherein the service registration list is obtained by scanning a service provider configuration file; Scan the implementation class source file according to a preset service call rule to obtain a plurality of service call relationships, wherein the preset service call rule is used to characterize the service call form in the implementation class source file, and each service call relationship is a call relationship between two services; and Calling a target function to process the multiple service call relationships to generate a target service call link, wherein the target function is used to connect the multiple service call relationships in series to extend the service call link; Compare the target service call link with the actual call link to determine the unknown service call link; parsing the unknown service call link to generate a target service call rule; and The preset service calling rule is updated according to the target service calling rule.

2. The method according to claim 1, characterized in that Determining the implementation class source files corresponding to all services according to the service registration list includes: Determine registered service information according to the service registration list, wherein the registered service information includes a service name and an implementation class file name; and Determine the implementation class source file of the service according to the service name and the implementation class file name.

3. The method according to claim 2, characterized in that Determining the implementation class source file of the service according to the service name and the implementation class file name includes: Determine the image file of the service according to the service name and the implementation class file name; and Decompile the image file to generate an implementation class source file of the service.

4. The method according to claim 3, characterized in that Scanning the source file of the implementation class according to the preset service calling rules to obtain multiple service calling relationships includes: Determine the target key fields according to the preset service call rules; Scan the implementation class source file according to the target key field to determine the context code of the target key field; Determine the service caller and the service callee according to the context code of the target key field; and A plurality of service calling relationships are generated according to the service caller and the service callee.

5. The method according to claim 4, characterized in that The calling target function processes the multiple service calling relationships to generate a target service calling link, including: Determine an input parameter of the target function, wherein the input parameter is a single service name or a service chain; Determining the type of the input parameter according to a preset identifier of the input parameter; and The multiple service call relationships are searched cyclically according to the input parameter type until a target service call link is generated.

6. The method according to claim 5, characterized in that The step of cyclically searching the plurality of service call relationships according to the input parameter type until a target service call link is generated comprises: When it is determined that the input parameter type is a service chain, obtaining the end service name of the service chain; Search the plurality of service call relationships according to the terminal service name to determine a first service list, where the first service list is a set of services called by the terminal service; Adding each service in the first service list after the terminal service name to generate multiple service call links; and The multiple service call relationships are searched cyclically to extend the multiple service call links until multiple target service call links are generated.

7. The method according to claim 5, characterized in that The step of cyclically searching the plurality of service call relationships according to the input parameter type until a target service call link is generated further comprises: When it is determined that the input parameter type is a single service name, searching the multiple service call relationships according to the single service name to determine a second service list, where the second service list is a set of services called by the single service name; Adding each service in the second service list after the single service name to generate multiple service call links; and The multiple service call relationships are searched cyclically to extend the multiple service call links until multiple target service call links are generated.

8. The method according to any one of claims 1 to 7, characterized in that The service calling forms include function calling and annotation calling.

9. A device for acquiring a service call link, comprising: A determination module, used to determine the implementation class source files corresponding to all services according to a service registration list, wherein the service registration list is obtained by scanning a service provider configuration file; A code scanning module, used to perform code scanning on the implementation class source file according to a preset service calling rule to obtain a plurality of service calling relationships, wherein the preset service calling rule is used to characterize the service calling form in the implementation class source file, and the service calling relationship is a calling relationship between two services; A service call link generation module, used to call a target function according to the multiple service call relationships to generate a target service call link, wherein the target function is used to connect the multiple service call relationships in series to extend the service call link; The preset service call rule updating module is used to compare the target service call link with the actual call link to determine the unknown service call link; parse the unknown service call link to generate the target service call rule; and update the preset service call rule according to the target service call rule.

10. An electronic device comprising: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors execute the method according to any one of claims 1 to 8.

11. A computer-readable storage medium having executable instructions stored thereon, which, when executed by a processor, causes the processor to execute the method according to any one of claims 1 to 8.

12. A computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the method according to any one of claims 1 to 8 is implemented.

Citation Information

Patent Citations

  • Patch package generation method and device

    CN111316230A

  • Determination method and device for calling link of underlying interface, computer equipment and medium

    CN112000398A

  • Micro-service data processing method and device, computer equipment and storage medium

    CN113946491A