Running method and device of data query task, processor and electronic equipment
By analyzing the running process and configuration files of data query tasks, and using state machines to manage service status, the problem of low data query efficiency in complex business scenarios is solved, and flexible control and efficiency improvement of data query tasks are achieved.
Patent Information
- Application Number
- CN202310181750.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-02-28
- Publication Date
- 2024-08-30
AI Technical Summary
In complex business scenarios, when customers query data, due to the strong dependence between multiple services, the parallel call logic is complex, making it difficult to control the running process of the query task, thereby reducing the query efficiency, and the exception handling is imperfect, making it difficult to be compatible with complex businesses. scene.
By receiving customer data query requests, it analyzes the running process of the data query task, obtains the configuration file, determines the service calling sequence based on the configuration file, and uses the state machine to uniformly manage the service status and dynamically adjust the running process until the query results are obtained.
It achieves flexible control over the running process of data query tasks, improves the efficiency of customer queries, and ensures compatibility with complex business scenarios and improved query efficiency.
Smart Images

Figure CN118567792A
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer software, and in particular to a method, device, processor and electronic device for executing a data query task. Background Art
[0002] At present, when customers query data in complex business scenarios, the server will call multiple services to obtain query results in response to the query instructions. Since there may be a mutual dependence relationship between multiple services, it is necessary to wait for one service to run before continuing to run the next service. Therefore, responding to the customer's query instruction may consume a lot of the customer's time. In the prior art, in order to reduce the response time of the customer's query instruction, the customer's query task is generally run by calling multiple services in parallel. However, when calling multiple services in parallel, the calling logic between multiple services is relatively complex, and the dependency between multiple services is strong. In addition, during the operation of multiple services, there is a lack of unified management of the operation of multiple services, which makes it difficult to control the operation process of the query task, thereby consuming a lot of time. In addition, the operation order of multiple services in the operation process of the query task is often fixed, which makes it impossible to flexibly run multiple services according to actual conditions, reducing the efficiency of running the customer's query task. At the same time, during the parallel operation of multiple services, the processing mechanism for abnormalities in a single service is not perfect, which makes the operation process of the query task difficult to be compatible with complex business scenarios.
[0003] When querying data in complex business scenarios in related technologies, it is usually necessary to cross-call various services, which increases the complexity of calling asynchronous threads and synchronous threads, resulting in low efficiency of customer data query. No effective solution has been proposed yet. Summary of the invention
[0004] The main purpose of the present application is to provide a method, device, processor and electronic device for running a data query task, so as to solve the problem in the related technology that when querying data in complex business scenarios, it is usually necessary to cross-call various services, which increases the complexity of calling asynchronous threads and synchronous threads, resulting in low efficiency of customer data query.
[0005] In order to achieve the above-mentioned purpose, according to one aspect of the present application, a method for running a data query task is provided, the method comprising: receiving a data request triggered when a customer queries data, and obtaining a data query task; analyzing the running process of the data query task, and obtaining a configuration file; running the data query task according to the configuration file, and updating the running status of the data query task to a state machine, and obtaining the running status of the data query task; and controlling the running process of the data query task according to the running status of the data query task until a data query result corresponding to the data query task is obtained.
[0006] Furthermore, the running process of the data query task is analyzed to obtain a configuration file including: obtaining at least one service called by the data query task according to the data query task; using a preset string to represent the calling order of the at least one service; configuring the time interval for loading the configuration file to obtain a preset value; and obtaining the configuration file from the preset string and the preset value.
[0007] Furthermore, after obtaining the configuration file from the preset string and the preset value, the method also includes: loading the configuration file once every time the preset value has passed, and determining the running process of the data query task based on the read configuration file; if a modification instruction to the configuration file is detected, obtaining the modified configuration file, and when the configuration file is loaded next time, determining the running process of the data query task based on the modified configuration file.
[0008] Furthermore, the data query task is run according to the configuration file, and the running status of the data query task is updated to the state machine, and the running status of the data query task is obtained, including: obtaining at least one service called in the running process of the data query task in the configuration file; when each of the at least one service is finished running, using a callback function to update the running status of each service to the state machine of the Redis database; based on the running status of the at least one service stored in the state machine, the running status of the data query task is obtained.
[0009] Further, according to the running status of the data query task, controlling the running process of the data query task until the data query result corresponding to the data query task is obtained includes: judging according to the configuration file whether the first service in the at least one service continues to call other services after the running is completed; if the first service continues to call other services after the running is completed, judging according to the running status of the data query task whether there is a second service running in parallel with the first service before calling other services; if there is a second service running in parallel with the first service before calling other services, then according to the running status of the data query task, waiting for the second service to run to end before calling other services until the data query result corresponding to the data query task is obtained; if there is no second service running in parallel with the first service before calling other services, directly calling other services until the data query result corresponding to the data query task is obtained; if the first service does not call other services after the running is completed, the running result of the first service is used as the data query result corresponding to the data query task.
[0010] Furthermore, after determining whether to continue calling other services after the first service in at least one service has finished running based on the configuration file, the method also includes: if it is necessary to call multiple services in parallel when calling other services, configuring the same number of threads as the multiple services to run the multiple services in parallel; after each of the multiple services has finished running, using the callback function to write the running status of each service into the state machine; when the states of the multiple services stored in the state machine have all become after the running has ended, continuing to run the data query task according to the configuration file.
[0011] Furthermore, before determining whether to continue calling other services after the first service in at least one service is finished running based on the configuration file, the method also includes: if the first service fails to run, rolling back each service that the data query task has run, to obtain a working environment in which the data query task has not run; and re-running the data query task in the working environment in which the data query task has not run based on the configuration file.
[0012] In order to achieve the above-mentioned purpose, according to another aspect of the present application, a device for running a data query task is provided, and the device includes: a first acquisition unit, used to receive a data request triggered when a customer queries data, and obtain a data query task; a processing unit, used to analyze the running process of the data query task and obtain a configuration file; a second acquisition unit, used to run the data query task according to the configuration file, and update the running status of the data query task to a state machine, and obtain the running status of the data query task; an execution unit, used to control the running process of the data query task according to the running status of the data query task until a data query result corresponding to the data query task is obtained.
[0013] Furthermore, the processing unit includes: a first acquisition subunit, used to acquire at least one service called by the data query task based on the data query task; a first processing subunit, used to use a preset string to represent the calling order of the at least one service; a first configuration subunit, used to configure the time interval for loading the configuration file to obtain a preset value; and a second acquisition subunit, used to obtain the configuration file from the preset string and the preset value.
[0014] Furthermore, the processing unit also includes: a first determination subunit, which is used to load the configuration file once every time the preset value has passed after the configuration file is obtained from the preset character string and the preset numerical value, and determine the running process of the data query task based on the read configuration file; a second determination subunit, which is used to obtain the modified configuration file if a modification instruction to the configuration file is detected, and determine the running process of the data query task based on the modified configuration file when the configuration file is loaded next time.
[0015] Furthermore, the second acquisition unit includes: a third acquisition sub-unit, used to obtain at least one service called in the running process of the data query task in the configuration file; an update sub-unit, used to update the running status of each service to the state machine of the Redis database using a callback function after each of the at least one service is completed; and a fourth acquisition sub-unit, used to obtain the running status of the data query task based on the running status of the at least one service stored in the state machine.
[0016] Further, the execution unit includes: a first judgment subunit, used to judge whether to continue to call other services after the first service in the at least one service is finished running according to the configuration file; a second judgment subunit, used to judge whether there is a second service running in parallel with the first service before calling other services according to the running status of the data query task if the first service continues to call other services after the first service is finished running; a second processing subunit, used to wait for the second service to run and then call other services according to the running status of the data query task if there is a second service running in parallel with the first service before calling other services, until the data query result corresponding to the data query task is obtained; a calling subunit, used to directly call other services if there is no second service running in parallel with the first service before calling other services, until the data query result corresponding to the data query task is obtained; a third processing subunit, used to use the running result of the first service as the data query result corresponding to the data query task if the first service is finished running and no other services are called.
[0017] Furthermore, the execution unit includes: a second configuration sub-unit, which is used to determine whether to continue calling other services after the first service in at least one service is finished running according to the configuration file, and if multiple services need to be called in parallel when calling other services, configure the same number of threads as the multiple services to run the multiple services in parallel; a writing sub-unit, which is used to write the running status of each service in the state machine using the callback function after each of the multiple services is finished running; and a first execution sub-unit, which is used to continue running the data query task according to the configuration file when the states of the multiple services stored in the state machine are all changed to finished running.
[0018] Furthermore, the execution unit also includes: a fifth acquisition sub-unit, which is used to determine whether to continue calling other services after the first service in the at least one service is completed based on the configuration file, and if the first service fails to run, roll back each service that the data query task has run to obtain the working environment in which the data query task has not run; a second execution sub-unit, which is used to re-run the data query task in the working environment in which the data query task has not run based on the configuration file.
[0019] In order to achieve the above-mentioned purpose, according to one aspect of the present application, a processor is provided, and the processor is used to run a program, wherein when the program is run, the running method of any one of the data query tasks described above is executed.
[0020] In order to achieve the above-mentioned purpose, according to one aspect of the present application, an electronic device is provided, including one or more processors and a memory, the memory being used to store one or more programs, wherein when the one or more programs are executed by one or more processors, the one or more processors implement an operation method of any of the data query tasks described above.
[0021] Through this application, the following steps are adopted: receiving a data request triggered when a customer queries data, and obtaining a data query task; analyzing the running process of the data query task, and obtaining a configuration file; running the data query task according to the configuration file, and updating the running status of the data query task to the state machine, and obtaining the running status of the data query task; according to the running status of the data query task, controlling the running process of the data query task until the data query result corresponding to the data query task is obtained, which solves the problem that various services are usually required to be cross-called when querying data in complex business scenarios in related technologies, which increases the complexity of calling asynchronous threads and synchronous threads, resulting in low efficiency of customer query data. The order in which the data query task calls the service is determined by the configuration file, and the running process of the data query task can be dynamically adjusted according to the state machine, so as to achieve the effect of unified management of the running process of the data query task, achieve the effect of flexibly controlling the running process of the data query task according to the configuration file, and further achieve the effect of improving the efficiency of customer query. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] The drawings constituting a part of the present application are used to provide a further understanding of the present application. The illustrative embodiments and descriptions of the present application are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0023] Figure 1 It is a flowchart of a method for running a data query task provided in Embodiment 1 of the present application;
[0024] Figure 2 This is a schematic diagram of an optional data query task operation method provided in Example 1 of the present application. Figure 1 ;
[0025] Figure 3 This is a schematic diagram of an optional data query task operation method provided in Example 1 of the present application. Figure 2 ;
[0026] Figure 4 is a schematic diagram of a running device for a data query task provided in Embodiment 2 of the present application;
[0027] Figure 5 It is a schematic diagram of an electronic device running a data query task provided in Embodiment 5 of the present application. DETAILED DESCRIPTION
[0028] It should be noted that, in the absence of conflict, the embodiments and features in the embodiments of the present application can be combined with each other. The present application will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.
[0029] It should be noted that the user information (including but not limited to user device information, user personal information, user requested data, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, queried data, requested data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of the relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.
[0030] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present application.
[0031] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequential order. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present application described here. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0032] Embodiment 1
[0033] The present invention is described below in conjunction with preferred implementation steps. Figure 1 is a flowchart of a method for executing a data query task according to the first embodiment of the present application. Figure 1 As shown, the method comprises the following steps:
[0034] Step S101, receiving a data request triggered by a customer's data query, and obtaining a data query task.
[0035] In the first embodiment, the data query task is determined according to the data query request issued by the client at the client end. For example, when the customer queries the deposit in the application, the client end issues a request to call the service to query the deposit balance in the customer account. At this time, the data query task is to query the account balance.
[0036] Step S102, analyzing the running process of the data query task to obtain a configuration file.
[0037] After obtaining the data query task, the data query task needs to be analyzed to determine at least one service that needs to be called to complete the data query task. Then, according to the dependency relationship between each service in the at least one service, the calling order of the at least one service is determined, and the calling order of the at least one service is stored in the configuration file.
[0038] Step S103, running the data query task according to the configuration file, and updating the running status of the data query task into the state machine to obtain the running status of the data query task.
[0039] After obtaining the configuration file, at least one service is called in sequence according to the calling sequence in the configuration file and the running state of each service is written into the state machine, so that the called services are uniformly managed in the state machine.
[0040] Step S104, controlling the running process of the data query task according to the running status of the data query task until a data query result corresponding to the data query task is obtained.
[0041] In order to conveniently manage the services called by the data query tasks, in the first embodiment of the present invention, it is necessary to determine the operation status of each service based on the values stored in the state machine, and then appropriately adjust the calling order of the services to control the operation process of the data query tasks to obtain the data query results corresponding to the data query tasks.
[0042] In summary, the method for running a data query task provided in the first embodiment of the present application is to obtain a data query task by receiving a data request triggered when a customer queries data; to obtain a configuration file by analyzing the running process of the data query task; to run the data query task according to the configuration file, and to update the running status of the data query task to the state machine, to obtain the running status of the data query task; to control the running process of the data query task according to the running status of the data query task until the data query result corresponding to the data query task is obtained, which solves the problem that various services usually need to be cross-called when querying data in complex business scenarios in the related technology, which increases the complexity of calling asynchronous threads and synchronous threads, resulting in low efficiency of customer query data. The order in which the data query task calls the service is determined by the configuration file, and the running process of the data query task can be dynamically adjusted according to the state machine, so as to achieve the effect of unified management of the running process of the data query task, and achieve the effect of flexibly controlling the running process of the data query task according to the configuration file, and further achieve the effect of improving the efficiency of customer queries.
[0043] Optionally, in the running method of the data query task provided in Example 1 of the present application, the running process of the data query task is analyzed to obtain the configuration file, including: based on the data query task, obtaining at least one service called by the data query task; using a preset string to represent the calling order of at least one service; configuring the time interval for loading the configuration file to obtain a preset value; and obtaining the configuration file from the preset string and the preset value.
[0044] In the first embodiment of the present invention, in order to control the running process of the data query task according to the configuration file, it is necessary to write at least one service called by the data query task and other relevant information required by the data query task into the configuration file. When representing the service call sequence of the data query task in the configuration file, the preset character strings "->" and "," can be used to represent the service call sequence, wherein "->" indicates that the two services before and after the character string are in a sequential running relationship, and "," indicates that the two services before and after the character string are in a parallel running relationship. In addition, in order to flexibly control the running process of the data query task, it is necessary to set the time interval for loading the configuration file in the configuration file to realize dynamic hot loading of the configuration file. It should be noted that the preset character strings "->" and "," representing the service call sequence can also be represented in other ways according to actual conditions. At the same time, the content in the configuration file can also be changed according to actual conditions to control the running process of the data query task.
[0045] For example, the data stored in the configuration file can be expressed as {"Task Name": "fsm_trade_task", "Service Call Order": "Service A->Service B->Service F, Service C, Service E->Service G, Service H", "Maximum Number of Threads": "10", "Number of Core Threads": "25", "Does Local Exception Interrupt the Main Process": "Yes", "Does Transaction Start": "Yes", "Loading Time Interval": "10 Seconds"}. Among them, "Task Name" is "fsm_trade_task", which means that the task name of the data query task is "fsm_trade_task"; "Service Call Order" means that the "Service A" service and the "Service B" service are called in sequence first, and then the "Service F", "Service C" and "Service E" services are called in parallel, and finally the "Service G" and "Service H" services are called in parallel. In addition, the "maximum number of threads" in the configuration file is "10", which means that a maximum of 10 threads are allowed to exist simultaneously when running data query tasks. If 50 data need to be queried at this time, 5 threads need to be called for parallel query; "number of core threads" indicates the maximum number of core threads running when running data query tasks; "whether local exceptions interrupt the main process" indicates whether to stop the running process of the entire data query task when a single service runs abnormally; "whether to start a transaction" indicates whether to roll back the execution results of multiple services in the data query task when a single service runs abnormally; "loading time interval" indicates the time interval for loading the configuration file, and the value of "loading time interval" is the preset value.
[0046] By writing the service call sequence and the relevant information required to run data query tasks into the configuration file, the complexity of running multiple services in parallel is reduced, the running process of data query tasks can be flexibly controlled, the response time of data query tasks can be reduced, and the efficiency of customer queries can be further improved.
[0047] Optionally, in the method for running a data query task provided in Example 1 of the present application, after obtaining the configuration file from a preset character string and a preset numerical value, the method further includes: loading the configuration file once every preset numerical time, and determining the running process of the data query task based on the read configuration file; if a modification instruction to the configuration file is detected, obtaining the modified configuration file, and determining the running process of the data query task based on the modified configuration file when the configuration file is loaded next time.
[0048] After obtaining the configuration file, the configuration file is continuously loaded according to the preset values stored in the configuration file, and the running process of the data query task is adjusted according to the values of each field stored in the configuration file. For example, in the configuration file, the "service call sequence" is "Service A->Service B", and the preset value is 10 seconds. After starting to run the data query task, first call "Service A"; then, during the running of "Service A", modify the "service call sequence" of the configuration file to "Service A->Service C"; then, load the configuration file again after 10 seconds to determine that the next service to be called is "Service C"; finally, after the running of "Service A" is completed, call "Service C" and return the running result of "Service C". In addition, the value of the "maximum number of threads" can also be modified according to different data query tasks or different services to obtain the running results of data query tasks or services more quickly.
[0049] By setting the time interval for loading the configuration file in the configuration file, the effect of dynamic hot loading of the configuration file is achieved, the effect of flexibly controlling the running process of the data query task is achieved, and the effect of further improving the efficiency of customer queries is achieved.
[0050] Optionally, in the method for running a data query task provided in Example 1 of the present application, the data query task is run according to a configuration file, and the running status of the data query task is updated to a state machine, and obtaining the running status of the data query task includes: obtaining at least one service called in the running process of the data query task in the configuration file; when each of the at least one service is finished running, using a callback function to update the running status of each service to the state machine of the Redis database; and obtaining the running status of the data query task based on the running status of at least one service stored in the state machine.
[0051] In the first embodiment, at least one service is called in sequence according to the service call sequence of the configuration file, and after each service is finished running, the running status of the service is written into the state machine of the Redis cluster. Finally, the running status of the data query task can be clearly and intuitively obtained based on the data stored in the state machine.
[0052] Specifically, Figure 2 This is a schematic diagram of the process of running data query tasks according to the configuration file. Figure 2As shown, when running a data query task, it is first necessary to dynamically load the configuration file and obtain the running process of the data query task (that is, the calling order of at least one service); then call at least one service in sequence according to the calling order of the services, and after each service is completed, use the callback function to query the running result of the service, and write the running status of the service into the state machine; then determine whether it is necessary to continue calling the next service after the service is completed. If the next service needs to be called, call the next service until the data query task is completed. If the next service does not need to be called, return the running result of the service.
[0053] in addition, Figure 3 This is a schematic diagram of the process of updating the values in the state machine when running a data query task. Figure 3 As shown, at least one service is called in sequence through the configuration file. After each service and each thread contained in each service finishes running, the running result of the thread or the service is stored in the host or slave of the Redis cluster according to the data query task to which the thread or the service belongs.
[0054] The running status of each service and each thread after completion is written into the state machine through the callback function, and the callback function is encapsulated to improve the code reuse rate. The running status of the data query task can be clearly and intuitively obtained based on the data stored in the state machine, thereby achieving the effect of flexibly controlling the running process of the data query task. At the same time, it can also uniformly manage the asynchronous threads within a single service, achieve the effect of more reasonable allocation of thread resources, and further achieve the effect of improving the efficiency of customer queries.
[0055] Optionally, in the running method of the data query task provided in Example 1 of the present application, the running process of the data query task is controlled according to the running status of the data query task until the data query result corresponding to the data query task is obtained, including: judging according to the configuration file whether to continue to call other services after the first service in at least one service is completed; if the first service continues to call other services after the first service is completed, judging according to the running status of the data query task whether there is a second service running in parallel with the first service before calling other services; if there is a second service running in parallel with the first service before calling other services, then according to the running status of the data query task, waiting for the second service to run to end before calling other services until the data query result corresponding to the data query task is obtained; if there is no second service running in parallel with the first service before calling other services, directly calling other services until the data query result corresponding to the data query task is obtained; if other services are no longer called after the first service is completed, the running result of the first service is used as the data query result corresponding to the data query task.
[0056] In the first embodiment, in order to flexibly control the running process of the data query task, it is necessary to determine whether to continue to call other services based on the result of the current configuration file loading after a service is finished. For example, the service call sequence when running a data query task is as follows: Figure 3 As shown in the running process example 1 in the example, service A is called first, and then service B, service C, and service D are called in parallel. When service A is finished running, it is determined according to the configuration file that services B, service C, and service D need to be called in parallel. Finally, after it is determined that services B, service C, and service D have all finished running, the query results of the data query task can be obtained.
[0057] The configuration file determines the order of service calls during data query task runtime, and can flexibly control the timing of service calls, thereby achieving the effect of flexibly controlling the running process of data query tasks, achieving the effect of unified management of multiple services, and further improving the efficiency of customer queries.
[0058] Optionally, in the method for running a data query task provided in Example 1 of the present application, after determining whether to continue calling other services after the first service in at least one service is finished running based on a configuration file, the method further includes: if it is necessary to call multiple services in parallel when calling other services, configuring the same number of threads as the multiple services to run the multiple services in parallel; after each of the multiple services is finished running, using a callback function to write the running status of each service into a state machine; when the states of the multiple services stored in the state machine are all changed to after the running is finished, continuing to run the data query task according to the configuration file.
[0059] In the first embodiment, when multiple services are called to run in parallel, multiple threads are used to run multiple services in parallel, and after each service runs, the running status of the service is updated to the state machine to determine the running status of the multiple services running in parallel. Specifically, the service call sequence when running a data query task is as follows: Figure 3 As shown in Example 3 of the running process, first, three threads are used to execute service B, service C, and service D in parallel; when service B is finished, the running status of service B is written into the state machine through the callback function; then, after waiting for service C and service D to be finished, the running status of service C and service D is written into the state machine; finally, after determining that service B, service C, and service D have all finished running according to the data stored in the state machine, service A is called to continue running the data query task.
[0060] Through the data stored in the state machine, the operating status of multiple services during the data query task is determined, so that the timing of calling the service and the operating process of the data query task can be flexibly controlled, thereby achieving the effect of unified management of multiple services and multiple threads based on the state machine, reducing the impact of the complex dependencies between multiple services on the running of data query tasks, and achieving the effect of improving the running efficiency of data query tasks, and further achieving the effect of improving the efficiency of customer queries.
[0061] Optionally, in the method for running a data query task provided in Example 1 of the present application, before determining, based on a configuration file, whether to continue calling other services after the first service in at least one service has finished running, the method further includes: if the first service fails to run, rolling back each service in which the data query task has run, to obtain a working environment in which the data query task has not run; and re-running the data query task in the working environment in which the data query task has not run, based on the configuration file.
[0062] In the first embodiment, when a program execution error or a failed first service occurs, the operation log of the first service is output, and the operation result of the data query task corresponding to the first service is rolled back. Then, in the working environment where the data query task is not running, the data query task is run again according to the configuration file. For example, the service call sequence for running the data query task is as follows: Figure 3 As shown in the running process example 2 in , service A is called first, then service B, and finally service C and service D are called in parallel. If the running fails when calling service C, the running log of service C is output, the running results of service A, service B, service C, and service D are rolled back, and then the data query task is run again according to the configuration file. Among them, if the configuration file has not changed, the data query task is run in the service call sequence of "calling service A, service B, and calling service C and service D in parallel"; if the configuration file has been modified, the data query task is run according to the new configuration file.
[0063] By configuring an exception handling mechanism for failed services, we can obtain the service failure log when the service fails, and re-run the data query task to ensure the normal execution of the customer's data request. This improves the running process of the data query task and makes the running process of the data query task more reliable.
[0064] It should be noted that the steps shown in the flowcharts of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and that, although a logical order is shown in the flowcharts, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0065] Embodiment 2
[0066] The second embodiment of the present application also provides a data query task running device. It should be noted that the data query task running device of the second embodiment of the present application can be used to execute the data query task running method provided in the first embodiment of the present application. The following introduces the data query task running device provided in the second embodiment of the present application.
[0067] Figure 4 Schematic diagram of a device for executing a data query task according to the second embodiment of the present application. Figure 4 As shown, the device includes: a first acquisition unit 401, a processing unit 402, a second acquisition unit 403 and an execution unit 404.
[0068] Specifically, the first acquisition unit 401 is used to receive a data request triggered when a client queries data, and obtain a data query task.
[0069] The processing unit 402 is used to analyze the running process of the data query task and obtain a configuration file.
[0070] The second acquisition unit 403 is used to run the data query task according to the configuration file, and update the running status of the data query task into the state machine to obtain the running status of the data query task.
[0071] The execution unit 404 is used to control the running process of the data query task according to the running status of the data query task until the data query result corresponding to the data query task is obtained.
[0072] The running device of the data query task provided in the second embodiment of the present application receives the data request triggered when the customer queries the data through the first acquisition unit 401, and obtains the data query task; the processing unit 402 analyzes the running process of the data query task and obtains the configuration file; the second acquisition unit 403 runs the data query task according to the configuration file, and updates the running status of the data query task to the state machine, and obtains the running status of the data query task; the execution unit 404 controls the running process of the data query task according to the running status of the data query task until the data query result corresponding to the data query task is obtained, which solves the problem that various services are usually required to be cross-called when querying data in complex business scenarios in the related technology, which increases the complexity of calling asynchronous threads and synchronous threads, resulting in low efficiency of customer query data. The order of calling services by the data query task is determined by the configuration file, and the running process of the data query task can be dynamically adjusted according to the state machine, so as to achieve the effect of unified management of the running process of the data query task, achieve the effect of flexibly controlling the running process of the data query task according to the configuration file, and further achieve the effect of improving the efficiency of customer query.
[0073] Optionally, in the data query task running device provided in Example 2 of the present application, the above-mentioned processing unit 402 includes: a first acquisition sub-unit, used to acquire at least one service called by the data query task based on the data query task; a first processing sub-unit, used to use a preset string to represent the calling order of at least one service; a first configuration sub-unit, used to configure the time interval for loading the configuration file to obtain a preset value; a second acquisition sub-unit, used to obtain the configuration file from the preset string and the preset value.
[0074] Optionally, in the data query task running device provided in Example 2 of the present application, the above-mentioned processing unit 402 also includes: a first determination subunit, which is used to load the configuration file once every preset value of time after the configuration file is obtained from the preset character string and the preset numerical value, and determine the running process of the data query task based on the read configuration file; a second determination subunit, which is used to obtain the modified configuration file if a modification instruction to the configuration file is detected, and determine the running process of the data query task based on the modified configuration file when the configuration file is loaded next time.
[0075] Optionally, in the running device of the data query task provided in Example 2 of the present application, the above-mentioned second acquisition unit 403 includes: a third acquisition sub-unit, used to obtain at least one service called in the running process of the data query task in the configuration file; an update sub-unit, used to update the running status of each service to the state machine of the Redis database by using a callback function after each of the at least one service is finished running; a fourth acquisition sub-unit, used to obtain the running status of the data query task based on the running status of at least one service stored in the state machine.
[0076] Optionally, in the data query task running device provided in Example 2 of the present application, the above-mentioned execution unit 404 includes: a first judgment sub-unit, which is used to judge whether to continue to call other services after the first service in at least one service is completed based on the configuration file; a second judgment sub-unit, which is used to judge whether there is a second service running in parallel with the first service before calling other services based on the running status of the data query task if the first service continues to call other services after the first service is completed; a second processing sub-unit, which is used to wait for the second service to run after the second service is completed before calling other services based on the running status of the data query task if there is a second service running in parallel with the first service before calling other services, until the data query result corresponding to the data query task is obtained; a calling sub-unit, which is used to directly call other services if there is no second service running in parallel with the first service before calling other services, until the data query result corresponding to the data query task is obtained; and a third processing sub-unit, which is used to use the running result of the first service as the data query result corresponding to the data query task if other services are no longer called after the first service is completed.
[0077] Optionally, in the running device of the data query task provided in Example 2 of the present application, the above-mentioned execution unit 404 includes: a second configuration sub-unit, which is used to determine whether to continue to call other services after the first service in at least one service is completed according to the configuration file. If multiple services need to be called in parallel when calling other services, the same number of threads as the multiple services are configured to run multiple services in parallel; a writing sub-unit, which is used to write the running status of each service in the state machine by a callback function after the running of each of the multiple services is completed; and a first execution sub-unit, which is used to continue running the data query task according to the configuration file when the states of the multiple services stored in the state machine are all changed to the end of the running.
[0078] Optionally, in the data query task running device provided in Example 2 of the present application, the above-mentioned execution unit 404 also includes: a fifth acquisition sub-unit, which is used to determine whether to continue to call other services after the first service in at least one service is completed based on the configuration file. If the first service fails to run, each service in which the data query task has run is rolled back to obtain a working environment in which the data query task has not run; and a second execution sub-unit, which is used to re-run the data query task in the working environment in which the data query task has not run based on the configuration file.
[0079] The running device of the data query task includes a processor and a memory. The above-mentioned first acquisition unit 401, processing unit 402, second acquisition unit 403 and execution unit 404 are all stored in the memory as program units, and the processor executes the above-mentioned program units stored in the memory to realize corresponding functions.
[0080] The processor includes a kernel, which retrieves the corresponding program unit from the memory. One or more kernels can be set, and the efficiency of customer queries can be improved by adjusting kernel parameters.
[0081] The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM, and the memory includes at least one memory chip.
[0082] Embodiment 3 of the present invention provides a computer-readable storage medium on which a program is stored. When the program is executed by a processor, a method for executing a data query task is implemented.
[0083] A fourth embodiment of the present invention provides a processor, which is used to run a program, wherein a method for executing a data query task is executed when the program is running.
[0084] like Figure 5As shown, embodiment 5 of the present invention provides an electronic device, the device includes a processor, a memory, and a program stored in the memory and executable on the processor, and the processor implements the following steps when executing the program: receiving a data request triggered when a customer queries data, and obtaining a data query task; analyzing the running process of the data query task, and obtaining a configuration file; running the data query task according to the configuration file, and updating the running status of the data query task to a state machine, and obtaining the running status of the data query task; and controlling the running process of the data query task according to the running status of the data query task until a data query result corresponding to the data query task is obtained.
[0085] When the processor executes the program, the following steps are also implemented: analyzing the running process of the data query task to obtain a configuration file including: obtaining at least one service called by the data query task based on the data query task; using a preset string to represent the calling order of at least one service; configuring the time interval for loading the configuration file to obtain a preset value; and obtaining the configuration file from the preset string and the preset value.
[0086] When the processor executes the program, the following steps are also implemented: after obtaining the configuration file from the preset character string and the preset numerical value, the above method also includes: loading the configuration file once every preset numerical time, and determining the running process of the data query task based on the read configuration file; if a modification instruction to the configuration file is detected, the modified configuration file is obtained, and when the configuration file is loaded next time, the running process of the data query task is determined based on the modified configuration file.
[0087] When the processor executes the program, the following steps are also implemented: running the data query task according to the configuration file, and updating the running status of the data query task to the state machine. Obtaining the running status of the data query task includes: obtaining at least one service called in the running process of the data query task in the configuration file; when each of the at least one service is finished running, using a callback function to update the running status of each service to the state machine of the Redis database; obtaining the running status of the data query task based on the running status of at least one service stored in the state machine.
[0088] When the processor executes the program, the following steps are also implemented: according to the running status of the data query task, the running process of the data query task is controlled until the data query result corresponding to the data query task is obtained, including: according to the configuration file, whether to continue to call other services after the first service in at least one service is completed; if the first service continues to call other services after the first service is completed, then according to the running status of the data query task, whether there is a second service running in parallel with the first service before calling other services; if there is a second service running in parallel with the first service before calling other services, then according to the running status of the data query task, wait for the second service to run and then call other services until the data query result corresponding to the data query task is obtained; if there is no second service running in parallel with the first service before calling other services, directly call other services until the data query result corresponding to the data query task is obtained; if the first service does not call other services after the first service is completed, the running result of the first service is used as the data query result corresponding to the data query task.
[0089] When the processor executes the program, the following steps are also implemented: after determining whether to continue calling other services after the first service in at least one service has finished running based on the configuration file, the above method also includes: if it is necessary to call multiple services in parallel when calling other services, configure the same number of threads as the multiple services to run multiple services in parallel; after each of the multiple services has finished running, use a callback function to write the running status of each service into the state machine; when the states of the multiple services stored in the state machine have all changed to after the running has ended, continue to run the data query task according to the configuration file.
[0090] When the processor executes the program, the following steps are also implemented: before determining, based on the configuration file, whether to continue calling other services after the first service in at least one service has finished running, the above method also includes: if the first service fails to run, then roll back each service in which the data query task has run, and obtain a working environment in which the data query task has not run; based on the configuration file, re-run the data query task in the working environment in which the data query task has not run.
[0091] The devices in this article can be servers, PCs, PADs, mobile phones, etc.
[0092] The present application also provides a computer program product, which, when executed on a data processing device, is suitable for executing a program that is initialized with the following method steps: receiving a data request triggered when a customer queries data, and obtaining a data query task; analyzing the running process of the data query task, and obtaining a configuration file; running the data query task according to the configuration file, and updating the running status of the data query task to a state machine, and obtaining the running status of the data query task; and controlling the running process of the data query task according to the running status of the data query task until a data query result corresponding to the data query task is obtained.
[0093] When executed on a data processing device, it is also suitable for executing an initialization program having the following method steps: analyzing the running process of a data query task to obtain a configuration file including: obtaining at least one service called by the data query task based on the data query task; using a preset string to represent the calling order of at least one service; configuring the time interval for loading the configuration file to obtain a preset value; and obtaining the configuration file from the preset string and the preset value.
[0094] When executed on a data processing device, it is also suitable for executing an initialization program having the following method steps: after obtaining a configuration file from a preset character string and a preset numerical value, the above method also includes: loading the configuration file once every preset numerical time, and determining the running process of the data query task based on the read configuration file; if a modification instruction to the configuration file is detected, the modified configuration file is obtained, and when the configuration file is loaded next time, the running process of the data query task is determined based on the modified configuration file.
[0095] When executed on a data processing device, it is also suitable for executing an initialization program having the following method steps: running a data query task according to a configuration file, and updating the running status of the data query task to a state machine, and obtaining the running status of the data query task includes: obtaining at least one service called in the running process of the data query task in the configuration file; when each of the at least one service is finished running, using a callback function to update the running status of each service to the state machine of the Redis database; and obtaining the running status of the data query task according to the running status of at least one service stored in the state machine.
[0096] When executed on a data processing device, it is also suitable for executing a program that is initialized with the following method steps: according to the running status of the data query task, controlling the running process of the data query task until the data query result corresponding to the data query task is obtained, including: according to the configuration file, judging whether the first service in at least one service continues to call other services after the running is completed; if the first service continues to call other services after the running is completed, judging whether there is a second service running in parallel with the first service before calling other services according to the running status of the data query task; if there is a second service running in parallel with the first service before calling other services, then according to the running status of the data query task, waiting for the second service to run to end and then calling other services until the data query result corresponding to the data query task is obtained; if there is no second service running in parallel with the first service before calling other services, directly calling other services until the data query result corresponding to the data query task is obtained; if the first service does not call other services after the running is completed, the running result of the first service is used as the data query result corresponding to the data query task.
[0097] When executed on a data processing device, it is also suitable for executing an initialization program having the following method steps: after determining whether to continue calling other services after the first service in at least one service has finished running based on a configuration file, the above method also includes: if it is necessary to call multiple services in parallel when calling other services, configure the same number of threads as the multiple services to run multiple services in parallel; after each of the multiple services has finished running, use a callback function to write the running status of each service into a state machine; when the status of multiple services stored in the state machine has all changed to after the running has ended, continue to run the data query task according to the configuration file.
[0098] When executed on a data processing device, it is also suitable for executing an initialization program having the following method steps: before judging whether to continue to call other services after the first service in at least one service is finished running based on a configuration file, the above method also includes: if the first service fails to run, then roll back each service that the data query task has run to obtain a working environment in which the data query task has not run; based on the configuration file, re-run the data query task in the working environment in which the data query task has not run.
[0099] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.
[0100] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0101] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0102] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0103] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0104] The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.
[0105] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0106] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0107] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.
[0108] The above are only embodiments of the present application and are not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included within the scope of the claims of the present application.
Claims
1. A method for running a data query task, It is characterized in that include: Receive data requests triggered by customers' data inquiries and obtain data query tasks; Analyze the operation process of the data query task to obtain a configuration file; Running the data query task according to the configuration file, and updating the running status of the data query task into the state machine to obtain the running status of the data query task; According to the running status of the data query task, the running process of the data query task is controlled until the data query result corresponding to the data query task is obtained.
2. The method according to claim 1, It is characterized in that Analyze the operation process of the data query task and obtain the configuration file including: According to the data query task, obtaining at least one service called by the data query task; Using a preset character string to represent the calling order of the at least one service; Configure the time interval for loading the configuration file to obtain a preset value; The configuration file is obtained from the preset character string and the preset value.
3. The method according to claim 2, It is characterized in that After obtaining the configuration file from the preset character string and the preset value, the method further includes: The configuration file is loaded once every time the preset value of time has passed, and the operation process of running the data query task is determined according to the read configuration file; If a modification instruction to the configuration file is detected, the modified configuration file is obtained, and when the configuration file is loaded next time, the running process of the data query task is determined according to the modified configuration file.
4. The method according to claim 1, It is characterized in that Running the data query task according to the configuration file, and updating the running status of the data query task to the state machine, and obtaining the running status of the data query task includes: Obtaining at least one service called in the running process of the data query task in the configuration file; When each of the at least one service is finished running, a callback function is used to update the running status of each service to the state machine of the Redis database; The running state of the data query task is obtained according to the running state of the at least one service stored in the state machine.
5. The method according to claim 4, It is characterized in that According to the running state of the data query task, controlling the running process of the data query task until obtaining the data query result corresponding to the data query task includes: Determining, based on the configuration file, whether to continue to call other services after the first service in the at least one service ends running; If the first service continues to call other services after the first service is finished running, judging whether there is a second service running in parallel with the first service before calling other services according to the running status of the data query task; If there is a second service running in parallel with the first service before calling other services, then according to the running status of the data query task, wait for the second service to finish running before calling other services until the data query result corresponding to the data query task is obtained; If there is no second service running in parallel with the first service before calling other services, directly calling other services until the data query result corresponding to the data query task is obtained; If no other services are called after the first service is completed, the running result of the first service is used as the data query result corresponding to the data query task.
6. The method according to claim 5, It is characterized in that After determining, based on the configuration file, whether to continue to call other services after the first service in the at least one service ends running, the method further includes: If multiple services need to be called in parallel when calling other services, configure the same number of threads as the multiple services to run the multiple services in parallel; After each of the multiple services has finished running, the running status of each service is written into the state machine using the callback function; When the states of the multiple services stored in the state machine are all changed to being completed, the data query task is continued to be executed according to the configuration file.
7. The method according to claim 5, It is characterized in that Before determining, based on the configuration file, whether to continue to call other services after the first service in the at least one service ends running, the method further includes: If the first service fails to run, each service that the data query task has run is rolled back to obtain a working environment in which the data query task has not run; According to the configuration file, the data query task is re-run in the working environment where the data query task is not run.
8. A device for running a data query task, It is characterized in that include: The first acquisition unit is used to receive a data request triggered by a customer querying data and obtain a data query task; A processing unit, used to analyze the operation process of the data query task and obtain a configuration file; A second acquisition unit is used to run the data query task according to the configuration file, and update the running state of the data query task into the state machine to obtain the running state of the data query task; The execution unit is used to control the running process of the data query task according to the running state of the data query task until the data query result corresponding to the data query task is obtained.
9. A processor, It is characterized in that The processor is used to run a program, wherein the program, when running, executes the method for running a data query task described in any one of claims 1 to 7.
10. An electronic device, It is characterized in that It includes one or more processors and a memory, wherein the memory is used to store one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the operation method of the data query task described in any one of claims 1 to 7.
