Method, device and computer readable storage medium for data querying
By generating and carrying a custom timestamp-based tracking ID in the service system, the problem of users being unable to obtain specific data is solved, enabling fast and accurate data querying and analysis.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- PING AN BANK CO LTD
- Filing Date
- 2023-03-20
- Publication Date
- 2026-05-19
AI Technical Summary
Users are unable to obtain specific data from service systems using existing technologies, making data analysis difficult.
The first server cluster generates a tracking ID, which carries a custom timestamp, and sends it to the second server cluster. The second server cluster queries and sends data based on the custom timestamp.
Users can obtain data accurately and quickly without manually modifying the system date, simplifying the data query process and improving the speed and accuracy of data acquisition.
Smart Images

Figure CN116303681B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of data processing technology, and in particular to a method, apparatus and computer-readable storage medium for data querying. Background Technology
[0002] With the gradual development of service systems (such as intelligent management systems), these systems also store massive amounts of data. Generally, service systems use the `localdate.now()` method to determine the current system time. However, if data is retrieved based on the current system time, users cannot obtain the specific data they need and cannot analyze it. Therefore, how users can obtain the specific data has become a pressing technical problem to be solved. Summary of the Invention
[0003] This application provides at least one method, apparatus, and computer-readable storage medium for data querying, which can improve the speed and accuracy of data acquisition by user terminals.
[0004] To address the aforementioned technical problems, a first aspect of this application provides a data query method, comprising: a first server cluster receiving a request sent by a client, wherein the request includes a first custom timestamp; generating a tracking ID based on the request, the tracking ID carrying a second custom timestamp, and the first custom timestamp corresponding to the second custom timestamp; and sending the tracking ID to a second server cluster.
[0005] To address the aforementioned technical problems, a second aspect of this application provides a data query method, comprising: a second server cluster receiving a tracking ID sent by a first server cluster; obtaining a second custom timestamp carried by the tracking ID; querying data based on the second custom timestamp, wherein the data is pre-stored in a storage terminal; and sending the data to a client.
[0006] To address the aforementioned technical problems, a third aspect of this application provides a data query device, comprising a communication circuit, a processor, and a memory. The communication circuit and the memory are coupled to the processor, and the memory stores program instructions. The processor executes the program instructions to implement the data query methods described in the first and second aspects.
[0007] To address the aforementioned technical problems, a fourth aspect of this application provides a computer-readable storage medium having program instructions stored thereon, which, when executed by a processor, implement the data query methods described in the first and second aspects above.
[0008] In the above scheme, the first server cluster receives requests from various clients, generates a tracking ID based on the request, and sends the tracking ID to the second server cluster. The second server cluster then receives the tracking ID sent by the first server cluster, obtains the second custom timestamp carried by the tracking ID, queries data based on the second custom timestamp, and sends the data to the client. Due to the special setting of the custom timestamp, only the user needs to determine the timestamp. After the custom timestamp is parsed, the data corresponding to the timestamp can be obtained. Therefore, compared to the user needing to manually modify the system date of all servers, the user only needs to set a custom timestamp to obtain the data, without the complicated process of manually modifying the system date. Thus, it is possible to accurately, quickly, and conveniently query and obtain data.
[0009] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit this application. Attached Figure Description
[0010] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with this application and, together with the specification, serve to explain the technical solutions of this application.
[0011] Figure 1 This is a flowchart illustrating an embodiment of the data query method of this application;
[0012] Figure 2 This is a flowchart illustrating another embodiment of the data query method of this application;
[0013] Figure 3 This is a schematic diagram of the framework of an embodiment of the data query device of this application;
[0014] Figure 4 This is a schematic diagram of a framework of an embodiment of the computer-readable storage medium of this application. Detailed Implementation
[0015] The embodiments of this application will now be described in detail with reference to the accompanying drawings.
[0016] In the following description, specific details such as particular system architectures, interfaces, and technologies are presented for illustrative purposes rather than for limiting purposes, in order to provide a thorough understanding of this application.
[0017] In this document, the term "and / or" is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, and B existing alone. Additionally, the character " / " generally indicates that the preceding and following related objects have an "or" relationship. Furthermore, "many" in this document means two or more. Moreover, the term "at least one" in this document means any combination of at least two of any one or more of a plurality of objects. For example, including at least one of A, B, and C can mean including any one or more elements selected from the set consisting of A, B, and C.
[0018] Please see Figure 1 , Figure 1 This is a flowchart illustrating an embodiment of the data query method of this application.
[0019] Specifically, this may include the following steps:
[0020] Step S11: The first server cluster receives the request sent by the client.
[0021] Optionally, the request may include a first custom timestamp.
[0022] In one implementation scenario, the first server cluster consists of several single servers connected in parallel. The first server can be, but is not limited to, application servers or web servers. Furthermore, the first server can also be a computer.
[0023] In one implementation scenario, the first custom timestamp can be set to date information by the client. For example, the first custom timestamp can be September 25, 2018, or October 31, 2016. The first custom timestamp can also be set to time information by the client. For example, the second custom timestamp can be 10:30 AM on September 25, 2018, and there is no limitation here.
[0024] In one implementation scenario, the request may also include user information. User information may include employee ID, address, etc.
[0025] Step S12: Generate a tracking ID based on the request. The tracking ID carries a second custom timestamp, and the first custom timestamp corresponds to the second custom timestamp.
[0026] In one implementation scenario, the second custom timestamp can be equivalent to the first custom timestamp (for example, the second custom timestamp can be 10:30 AM on September 25, 2018 in the above embodiment), or it can be a timestamp with a time difference from the first custom timestamp. For example, the second custom timestamp can be a timestamp with a 5-hour time difference in the above embodiment, specifically 5:30 AM on September 25, 2018.
[0027] Step S13: Send the tracking ID to the second server cluster.
[0028] In one implementation scenario, the second server cluster comprises several single servers connected in parallel. The second server may include, but is not limited to, application servers and web servers. Furthermore, the second server may also be a computer, enabling it to query data. In the above embodiment, the first server cluster and the second server cluster are connected in series, thereby ensuring that the second server cluster receives the tracking ID sent by the first server cluster.
[0029] In one implementation scenario, to clearly understand which server in the first server cluster sent the tracking ID to the second server cluster, it is necessary to form first request link information after the first server cluster sends the tracking ID to the second server cluster. The status information of the first server cluster is then determined based on this first request link information, where the first request link carries the tracking ID. Taking a distributed tracing model as an example, the distributed tracing model intercepts client requests in several individual servers within the first server cluster. When a request is intercepted in individual server 'a', a tracking ID is generated. Individual server 'a' in the first server cluster then sends the tracking ID to the second server cluster, thus forming the first request link information. In the above embodiment, the tracking ID is a unique identifier in the first request link information, and the tracking ID may include, but is not limited to, TraceID. Specifically, determining the status information of the first server cluster through the first request link information may include, but is not limited to, the time information of the first server cluster sending the tracking ID to the second server cluster, and the model information of the individual server that sent the tracking ID. The above method, in response to the first server cluster sending the tracking ID to the second server cluster, forms the first request link information. Based on the first request link information, the status information of the first server cluster is determined, which can quickly locate the single server that sent the tracking ID to the second server cluster, thereby realizing link monitoring and reducing the working time of checking each server in the first server cluster to send the tracking ID to the second server cluster.
[0030] Please see Figure 2 , Figure 2This is a flowchart illustrating another embodiment of the data query method of this application.
[0031] Specifically, this may include the following steps:
[0032] Step S21: The second server cluster receives the tracking ID sent by the first server cluster.
[0033] In one implementation scenario, to clearly understand which server in the second server cluster receives the trace ID sent by the first server cluster, a second request link information needs to be formed after the second server cluster receives the trace ID sent by the first server cluster. The status information of the second server cluster is then determined based on the second request link information, which carries the trace ID. Unlike the previous embodiments that identified the single server sending the trace ID to the second server cluster, this embodiment uses the second request link information to determine the single server receiving the trace ID sent by the first server cluster. Based on this, the status information of the second server cluster can be determined using the second request link information, which may include, but is not limited to: the time point at which the second server cluster receives the trace ID (such as the TraceID mentioned in the previous embodiments), the time taken for the second server cluster to execute the next step after receiving the trace ID, and the model information of the single server receiving the trace ID sent by the first server cluster. The above method, in response to the second server cluster receiving the tracking ID sent by the first server cluster, forms the second request link information. Based on the second request link information, the status information of the second server cluster is determined, which can quickly locate the single server that received the tracking ID sent by the first server cluster, thereby realizing link monitoring and reducing the working time of checking each server in the second server cluster to receive the tracking ID sent by the first server cluster.
[0034] Step S22: Obtain the second custom timestamp carried by the tracking ID, and query the data based on the second custom timestamp.
[0035] Optionally, the data is pre-stored on the storage device.
[0036] In one implementation scenario, to accurately obtain the second custom timestamp, a parameter needs to be added to the JVM startup parameters before the second server cluster receives the tracking ID sent by the first server cluster. This parameter is `Javaagent:Javaagentpath / target / custtime.jar`. After setting the startup parameters, the second custom timestamp can be set without code intrusion, eliminating the need to repeatedly change the system time. After setting the second custom timestamp, a proxy application, such as a Java agent, is used to obtain the second custom timestamp carried by the tracking ID, instead of the local time application. The proxy application can obtain the second custom timestamp based on the Java agent. The local time application can be `localdate.now()`, `LocalDateTime`, or `LocalTime`, and is not limited here. The above method involves setting up a proxy application to obtain the second custom timestamp carried by the tracking ID. This not only allows the client to easily change the custom timestamp at any time, but also improves the server's speed in obtaining the custom timestamp, thus helping to improve the efficiency of the client in querying data. At the same time, by determining the custom timestamp in a non-code intrusion manner, compared to the user needing to manually modify the system dates of all servers, the user only needs to set the custom timestamp to obtain the data, without the complicated process of manually modifying the system dates.
[0037] In one implementation scenario, to facilitate the determination of changes in the queried data, after the proxy application (e.g., Java agent) in the aforementioned embodiment obtains the second custom timestamp carried by the tracking ID, it is also necessary to obtain the data corresponding to the second custom timestamp using the same proxy application (e.g., Java agent). The data can be first data queried using the second custom timestamp, or it can be the first data queried using the second custom timestamp and second data associated with the time of the first data. Of course, the first data queried using the second custom timestamp is based on the premise that the second data exists on the client side, comparing the second data with the first data. The first and second data queried can be related in time. For example, the timestamp of the second data can have a time difference of several years from the timestamp of the first data; for instance, if the second custom timestamp set by the client is September 25, 2018 (i.e., the timestamp of the first data) in the aforementioned embodiment, the timestamp of the second data can include, but is not limited to, September 25, 2017, and September 25, 2016, etc., and is not limited here. For example, the timestamp of the second data can have a time difference of several months from the timestamp of the first data; for example, the second custom timestamp set by the client is September 25, 2018 (i.e., the timestamp of the first data) in the aforementioned embodiment, and the timestamp of the second data can include, but is not limited to, August 25, 2018 and July 25, 2018, which are not limited here. For example, the timestamp of the second data can have a difference of any number of days from the timestamp of the first data; for example, the timestamp of the second data can include, but is not limited to, September 20, 2018. Of course, when retrieving data corresponding to the second custom timestamp, it is also necessary to receive the trace ID (e.g., TraceID in the aforementioned embodiment) sent from the second server cluster to the storage terminal. Only after the storage terminal receives the trace ID can the second server cluster retrieve data from the storage terminal. Compared to the second server cluster retrieving data directly from the storage terminal, this allows for timely understanding of the time from when the second server cluster starts retrieving data from the storage terminal to when it successfully retrieves the data, thus determining the efficiency of the second server cluster in retrieving data. This enables effective monitoring of the second server cluster and avoids situations where data is not retrieved for extended periods due to the second server cluster's own reasons. The above method, based on querying data using the second custom timestamp, can help users determine data changes while simultaneously retrieving the first and second data, thereby improving the efficiency of users' data analysis work.
[0038] In one implementation scenario, to facilitate timely data viewing for users, it's necessary to determine whether data is stored in the cache. Upon determining that no data is stored in the cache at the storage end, it's checked whether the amount of data stored in the cache storage space exceeds a preset data amount. If so, the data exceeding the preset data amount in the cache storage space is deleted, and the data queried based on a second custom timestamp is stored in the cache. The aforementioned embodiments disclose that data is pre-stored in the storage end, i.e., the second server cluster queries data in the storage end. However, to ensure users can quickly view the data, it's also necessary to store the data in the cache at the storage end. Furthermore, the storage end can store not only data but also user information. User information has been disclosed in the aforementioned embodiments and will not be repeated here. For example, the storage end can store sales data for an employee with an address in a certain area of Shanghai and an employee number of xxxx (not specifically described here). The storage end can also store sales data under different timestamps. The storage end can be an Elasticsearch database, and the cache is a cache within the Elasticsearch database. The cache can store data queried using a second custom timestamp within a set time period (e.g., the last two days). If the amount of data stored in the cache storage space (e.g., keywords) exceeds a preset data size (e.g., 200), then the data in the cache storage space corresponding to the data size exceeding the preset data size is deleted. Furthermore, the method for deleting the data corresponding to the data size in the cache storage space can be an LRU mechanism, which is not limited here. The above method, by deleting the data in the cache storage space corresponding to the data size exceeding the preset data size and storing the data queried based on the second custom timestamp in the cache, not only speeds up the second server's query for data corresponding to the custom timestamp as described in the previous embodiment, but also helps users quickly view the queried data, reducing the time users spend waiting to view the data.
[0039] Step S23: Send data to the client.
[0040] In one implementation scenario, the second server cluster can send data from the cache to the client, prompting the user to view the data queried by the second server cluster on the client. Alternatively, the second server can send data from the cache to the client, allowing the user to actively view the data queried by the second server cluster on the client. This is not a limitation.
[0041] Please see Figure 3 , Figure 3This is a schematic diagram of the framework of an embodiment of the data query device of this application. Specifically, it includes a communication circuit 301, a processor 302, and a memory 303. The communication circuit 301 and the memory 303 are coupled to the processor 302. The communication circuit 301 is used to process requests sent by clients to a first server. The memory 303 stores program instructions. Specifically, the processor 302 is used to control itself, and the communication circuit 301 and the memory 303 execute the steps of any of the above-described data query method embodiments. The processor 302 can also be called a CPU (Central Processing Unit). The processor 302 may be an integrated circuit chip with signal processing capabilities. The processor 302 can also be a general-purpose processor 302, a digital signal processor 302 (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. The general-purpose processor 302 can be a microprocessor 302, or any conventional processor 302. Furthermore, the processor 302 can be implemented using integrated circuit chips.
[0042] The above method, due to the special settings of the custom timestamp, only requires the user to determine the timestamp. After the custom timestamp is parsed, the data corresponding to the timestamp can be obtained. Therefore, compared to the user having to manually modify the system date of all servers, the user only needs to set a custom timestamp to obtain the data, without the complicated process of manually modifying the system date. Thus, it can accurately, quickly and conveniently query and obtain data.
[0043] Please see Figure 4 , Figure 4 This is a schematic diagram of a framework of an embodiment of the computer-readable storage medium of this application. The computer-readable storage medium 401 stores program instructions 402 that can be executed by a processor. The program instructions 402 are used to implement the data query method in any of the above embodiments.
[0044] The above method, due to the special settings of the custom timestamp, only requires the user to determine the timestamp. After the custom timestamp is parsed, the data corresponding to the timestamp can be obtained. Therefore, compared to the user having to manually modify the system date of all servers, the user only needs to set a custom timestamp to obtain the data, without the complicated process of manually modifying the system date. Thus, it can accurately, quickly and conveniently query and obtain data.
[0045] In some embodiments, the functions or modules of the apparatus provided in this disclosure can be used to perform the methods described in the above method embodiments. The specific implementation can be referred to the description of the above method embodiments, and for the sake of brevity, it will not be repeated here.
[0046] The description of the various embodiments above tends to emphasize the differences between the various embodiments. The similarities or similarities between them can be referred to, and for the sake of brevity, they will not be repeated here.
[0047] In the several embodiments provided in this application, it should be understood that the disclosed methods and apparatus can be implemented in other ways. For example, the apparatus implementations described above are merely illustrative. For instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between devices or units may be electrical, mechanical, or other forms.
[0048] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment, depending on actual needs.
[0049] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0050] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) or processor to execute all or part of the steps of the methods of various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
Claims
1. A data query method, characterized in that, include: The first server cluster receives a request sent by the client, wherein the request includes a first custom timestamp, and the first custom timestamp is set by the client; A tracking ID is generated based on the request. The tracking ID carries a second custom timestamp, and the first custom timestamp corresponds to the second custom timestamp. The second custom timestamp is equal to the first custom timestamp, or there is a time difference between the second custom timestamp and the first custom timestamp. Send the tracking ID to the second server cluster; The second server cluster receives the tracking ID sent by the first server cluster; A proxy application is used instead of a local time application to obtain a second custom timestamp carried by the tracking ID, and the proxy application is used to query data based on the second custom timestamp, wherein the data is pre-stored in the storage. The data is sent to the client.
2. The method according to claim 1, characterized in that, Sending the tracking ID to the second server cluster includes: In response to the first server cluster sending the tracking ID to the second server cluster, a first request link information is formed, and the status information of the first server cluster is determined based on the first request link information, wherein the request link carries the tracking ID.
3. The method according to claim 1, characterized in that, The second server cluster receives the tracking ID sent by the first server cluster, including: In response to the second server cluster receiving the tracking ID sent by the first server cluster, a second request link information is formed, and the status information of the second server cluster is determined based on the second request link information, wherein the second request link information carries the tracking ID.
4. The method according to claim 1, characterized in that, The proxy application is a Java proxy application, and the second server cluster includes the following steps before receiving the tracking ID sent by the first server cluster: Add the following parameter to the JVM startup parameters: Java agent:Javaagentpath / target / custtime.jar.
5. The method according to claim 1, characterized in that, The querying of the data based on the second custom timestamp includes: Determine whether the data is stored in the cache; In response to determining that the data is not stored in the cache in the storage terminal, it is determined whether the amount of data stored in the cache storage space is greater than a preset amount of data; If so, delete the data in the cache storage space that exceeds the preset data amount, and store the data queried based on the second custom timestamp in the cache.
6. A data query device, characterized in that, The device includes a communication circuit, a processor, and a memory, wherein the communication circuit and the memory are coupled to the processor, the memory stores program instructions, and the processor executes the program instructions to implement the data query method according to any one of claims 1 to 5.
7. A computer-readable storage medium having program instructions stored thereon, characterized in that, When the program instructions are executed by the processor, they implement the data query method according to any one of claims 1 to 5.