Business burying point method, device and equipment for non-intrusive write-in of multiple storage engines
Through non-intrusive writing of business points into multiple storage engines, configuration files and Java bytecode technology are used to asynchronously report data to multiple storage engines without modifying the business code, which solves the high development cost of existing technologies. and the problem of low system stability, achieving efficient processing of unstructured data and ensuring system stability.
Patent Information
- Application Number
- CN202410836141.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-26
- Publication Date
- 2024-09-27
AI Technical Summary
Existing business systems need to modify the code when accessing business buried points, resulting in high development costs and reduced system stability. In addition, a single storage engine has limitations when processing unstructured data.
Adopt a non-intrusive business burying method of writing to multiple storage engines, generate back-end business burying data through configuration files, and asynchronously report data to multiple storage engines without invading business code, and support data fusing functions to Prevent system anomalies. Specific implementation includes method interception based on Java bytecode, asynchronous thread pool assembly data, non-blocking queue technology of off-heap ring queue and circuit breaker mechanism.
It enables the use of multiple storage engine advantages to analyze business data without invading business code, reduces development costs, improves system stability, and prevents storage engine abnormalities from affecting the system through the circuit breaker mechanism.
Smart Images

Figure CN118708258A
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a method, device and equipment for non-invasively writing business points into multiple storage engines. Background Art
[0002] Business tracking is to store business data in a single storage medium by reporting it, but a single storage medium will have limitations in subsequent business processing. For example, relational databases have great advantages in data consistency, data association, query language standardization, and backup and recovery. They are particularly suitable for storing structured data and scenarios where data integrity needs to be guaranteed. However, the performance and storage cost of relational data are relatively high, and they are not suitable for processing unstructured data. Non-relational databases can handle such problems very well. For existing business systems, if business tracking is required, the code needs to be modified, which will undoubtedly greatly increase the development cost and reduce the stability of the existing system.
[0003] In view of this, it is necessary to propose a business tracking method for non-invasive writing to multiple storage engines to prevent system anomalies caused by storage engines. Summary of the invention
[0004] The purpose of the present invention is to provide a business tracking method, device and equipment for non-invasive writing to multiple storage engines, generate back-end business tracking data according to a configuration file, and asynchronously report data to multiple storage devices without intruding on the business code, so as to utilize the advantages of different storage engines to analyze business data; at the same time, support the reporting data fuse function to prevent system abnormalities due to storage engine problems.
[0005] The present invention provides a business tracking method for non-intrusive writing to multiple storage engines, comprising:
[0006] Responding to a target service request;
[0007] Confirm the business tracking requirements according to the target business request, compile a configuration file, and load it on the Java application server;
[0008] When the application is started, method interception is performed based on Java bytecode to determine the assembly logic of the method to be intercepted and the tracking data. When the current business process enters the code segment to be intercepted, target interception is performed at the bytecode level to obtain the tracking data to be reported.
[0009] By creating a thread pool to start an asynchronous thread, the acquired tracking data is asynchronously assembled to obtain the assembled data model and store it in the corresponding storage engine. Different business data can be asynchronously reported directly from the client to the adapted storage engine without intruding the business code.
[0010] Traverse the storage bucket. When the storage bucket is not enabled, introduce a non-blocking queue engine and write the tracking data into the non-blocking queue to ensure the timing of the tracking data. Read the tracking data in the off-heap circular queue according to the scheduled task, and write it into the actual storage unit through the storage engine to push the tracking data. The non-blocking queue is an off-heap circular queue formed by combining the off-heap memory and the circular queue.
[0011] Determine whether there is an exception when pushing the tracking data. When there is an exception in pushing the tracking data, determine whether it is necessary to perform a fuse operation on the configured tracking architecture. When performing a fuse operation, disable the current storage engine until the storage engine resumes normal service.
[0012] Preferably, the step of confirming the service tracking point requirement and writing a configuration file according to the target service request includes:
[0013] Methods for determining target request classes for business tracking in cross-border transaction scenarios;
[0014] The indicator is declared through the measurement indicator. Tags declare the value of the tracking field. The input and output parameters of the target request are extracted to the tracking field through the expression.
[0015] The configuration requires a data storage engine, wherein the MySQL database is used to associate and count current business information, and the InfluxDB database is used to predict the data status of the business within a preset time in the future. Preferably, the Java bytecode includes a series of target instructions, and the target instructions are configured to be interpreted and executed by the Java virtual machine, and the code corresponding to the target instructions is dynamically compiled into local machine code, and the bytecode can be modified during compilation or runtime to implement AOP.
[0016] Preferably, the method interception based on Java bytecode and the assembly logic of determining the method to be intercepted and the embedded data include:
[0017] Automatically intercept when executing the method of the target request class;
[0018] Perform a pre-check according to the storage engine specified in the configuration file. The specific steps of the pre-check are as follows:
[0019] If the current storage engine is in shutdown state, skip writing data to the current storage engine;
[0020] If the current storage engine is in the on state, the intercepted buried point data will be written into the off-heap circular queue corresponding to the current storage engine for storage. The off-heap circular queue is a limited queue based on off-heap memory, which is used to store a preset amount of data to avoid memory overflow in the application system.
[0021] Preferably, the off-heap circular queue utilizes an array as the underlying data structure, and implements circular storage of the off-heap circular queue by cyclically utilizing the array space. The relative positions of the head and tail of the off-heap circular queue in the array change cyclically to form a circular buffer; wherein, the off-heap circular queue stores the data packet outside the application memory, and the queue only stores the reference address of the data packet outside the application memory.
[0022] Preferably, the step of reading the tracking data in the off-heap circular queue according to the scheduled task and writing the tracking data into the actual storage unit through the storage engine to push the tracking data includes:
[0023] The tracking data is stored in an off-heap circular queue according to the time sequence attribute of the order. Before all indicators are written into the storage engine, they are stored in the off-heap circular queue to ensure the orderliness of the order;
[0024] Initially, the front of the off-heap ring queue and the rear of the off-heap ring queue both point to the start of the queue;
[0025] When a new element needs to be queued, the element is inserted into the position pointed to by the rear of the off-heap ring queue, and the rear of the off-heap ring queue is moved backward by one position. If the rear of the off-heap ring queue moves to the end of the array, the loop returns to the starting position of the array to implement a loop to use the position of the last dequeue to store the new element;
[0026] When an element in the off-heap ring queue needs to be dequeued, the element pointed to by the head front of the off-heap ring queue is taken out, and the head front of the off-heap ring queue is moved back one position. If the head front of the off-heap ring queue moves to the end of the array, the loop returns to the starting position of the array to maintain the ring characteristics;
[0027] When the indicator enters the off-heap ring queue, the position relationship between the front pointer at the head of the off-heap ring queue and the rear pointer at the tail of the off-heap ring queue is used to determine whether the off-heap ring queue is empty or full. If the queue is not full, it is appended to the back of the off-heap ring queue. If the queue is full, the current indicator is discarded. When the off-heap ring queue is empty, front == rear. When the off-heap ring queue is full, ((rear+1)% capacity == front).
[0028] Preferably, the determining whether there is an exception when pushing the burying point data, and when there is an exception in pushing the burying point data, determining whether it is necessary to perform a fuse operation on the configured burying point architecture, and when performing a fuse operation, disabling the current storage engine until the storage engine resumes normal service includes: when the burying point data stored in the off-heap circular queue reaches a threshold, actively triggering an event to push the burying point data;
[0029] If the number of exceptions in any storage engine service per unit time reaches the threshold, the configured tracking framework will perform a fuse process, directly discard the subsequent tracking data, and prohibit it from entering the off-heap ring queue;
[0030] When the storage engine waiting time after the fuse reaches the self-recovery time, it will automatically detect whether the storage engine after the fuse has resumed normal service. If it has resumed, subsequent data will continue to flow normally.
[0031] The present invention also provides a business tracking device for non-intrusive writing to multiple storage engines, comprising:
[0032] A request module, used to respond to a target service request;
[0033] A configuration module is used to confirm the business tracking point requirements according to the target business request, write a configuration file, and load it on a Java application server;
[0034] The interception module is used to intercept methods based on Java bytecode when the application is started, determine the assembly logic of the method to be intercepted and the tracking data, and perform target interception at the bytecode level when the current business process enters the code segment to be intercepted, so as to obtain the tracking data to be reported;
[0035] The asynchronous module is used to start asynchronous threads by creating a thread pool, asynchronously assemble the acquired tracking data, obtain the assembled data model and store it in the corresponding storage engine. It can asynchronously report different business data directly from the client to the adapted storage engine without intruding the business code;
[0036] A storage module is used to traverse the storage bucket. When the storage bucket is not enabled, a non-blocking queue engine is introduced and the buried point data is written into the non-blocking queue to ensure the timing of the buried point data. The buried point data in the off-heap circular queue is read according to the scheduled task, and written into the actual storage unit through the storage engine to push the buried point data. The non-blocking queue is an off-heap circular queue formed by combining the off-heap memory and the circular queue.
[0037] The judgment module is used to determine whether there is an exception when pushing the tracking data. When there is an exception in pushing the tracking data, it is used to determine whether it is necessary to perform a fuse operation on the configured tracking architecture. When the fuse is performed, the current storage engine is disabled until the storage engine resumes normal service.
[0038] The present invention provides an electronic device, comprising:
[0039] A memory, the memory being used to store a processing program;
[0040] A processor, when executing the processing program, implements the business tracking method of non-intrusive writing to multiple storage engines as described in an embodiment of the present invention.
[0041] The present invention provides a readable storage medium, characterized in that a processing program is stored on the readable storage medium, and when the processing program is executed by a processor, the business tracking method of non-invasively writing to multiple storage engines as described in an embodiment of the present invention is implemented.
[0042] With respect to the prior art, the present invention has the following beneficial effects:
[0043] The present invention provides a method and device for non-invasively writing to multiple storage engines, which generates back-end business burying data according to a configuration file, and asynchronously reports data to multiple storage devices without intruding the business code, so as to facilitate the use of the advantages of different storage engines to analyze business data. At the same time, it supports the function of reporting data fuse to prevent system abnormalities caused by problems with the storage device; it solves the problem of using Java bytecode technology to collect business data generated by the system without intruding the business code, and stores different business data in a suitable data storage engine through a variety of collection methods, providing data support for subsequent statistics, predictions and alarms; the back-end business burying data can be written to multiple data storage engines, making full use of the advantages of different storage engines; the code intrusion to the business system is zero, and the access threshold is lowered by using a simple configuration method, and the stability of the system is ensured by using off-heap memory technology and a circular queue cache method; the present invention adopts a combination of off-heap memory and a circular queue, which can ensure the sequentiality of the burying data, and at the same time, the occupancy of the application memory can be controlled to ensure the stability of the application system. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] Figure 1 This is an example diagram of the steps of a method for non-invasively writing business points to multiple storage engines in an embodiment of the present invention;
[0045] Figure 2 It is a flowchart of a method for non-invasively writing business points into multiple storage engines in an embodiment of the present invention;
[0046] Figure 3This is a scenario example diagram of a business tracking method for non-invasively writing to multiple storage engines in an embodiment of the present invention. DETAILED DESCRIPTION
[0047] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0048] Embodiment 1
[0049] The term "including" and its variations used herein are open inclusions, i.e., "including but not limited to". The term "based on" means "based at least in part on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". The relevant definitions of other terms will be given in the following description.
[0050] It should be noted that the concepts such as "once" and "second" mentioned in the present application are only used to distinguish different devices, modules or units, and are not used to limit the order or interdependence of the functions performed by these devices, modules or units.
[0051] It should be noted that the modifications of "one" and "plurality" mentioned in the disclosure of this application are illustrative rather than restrictive, and those skilled in the art should understand that unless otherwise clearly indicated in the context, it should be understood as "one or more".
[0052] Traditional reporting or monitoring methods all require intrusion into business codes, and then these corresponding business codes need to be manually modified to improve or optimize the system. In order to avoid increasing development costs by intrusion into the code and improve the stability of the system, this application uses a preset standard configuration file and is configured according to the standard. After the configuration is completed, the framework will automatically intercept the program code directly according to the configuration, obtain the key data reported and aggregate it. At this time, the data cannot be directly piled there after being aggregated, which is prone to several problems. 1. Storage problem: When reporting, the server receives the aggregated data. When the service receiving the aggregated data is unstable, the aggregated data will accumulate more and more in the business system, which is easy to cause instability in the business system; 2. When the aggregated data is piled into the business system, it is backlogged in the Java program. When a Java application is normally started, a JVM, that is, Java's virtual memory, will be started, that is, all the data is placed in a JVM heap. The JVM heap will have a timed recovery strategy to recover data. The timed recovery strategy will actually interrupt the response of the application, and it also needs to be based on the size of the data. If it is very large, the interruption application response time is still relatively long. Once the application response is interrupted, the application will not be able to respond to the outside for a period of time.
[0053] In order to solve the above defects and meet the above requirements, Figure 1-3 As shown, the present invention provides a business tracking method for non-invasively writing multiple storage engines, which is applicable to Java application servers and takes the collection of flow information of transaction orders in cross-border payment scenarios as an example, including:
[0054] S1: respond to the target service request;
[0055] S2: Confirm the service tracking point requirements according to the target service request, compile a configuration file, and load it on a Java application server;
[0056] S3: When the application is started, method interception is performed based on Java bytecode to determine the assembly logic of the method to be intercepted and the tracking data. When the current business process enters the code segment to be intercepted, target interception at the bytecode level is performed to obtain the tracking data to be reported. The specific steps are as follows:
[0057] Methods for determining target request classes for business tracking in cross-border transaction scenarios;
[0058] The indicator is declared through the measurement indicator. Tags declare the value of the tracking field. The input and output parameters of the target request are extracted to the tracking field through the expression.
[0059] Configuration requires a data storage engine, where the MySQL database is used to associate and count current business information, and the InfluxDB database is used to predict the data status of the business within a preset time in the future. Those skilled in the art can understand that the specific steps of writing a configuration file according to business and tracking point requirements in this embodiment are as follows:
[0060] 1.1 Write configuration files based on actual business. The generated data is extracted from input parameters, output parameters or business context. Simple expressions can be used to generate tracking data. To create an order, you need payer information and payee information, as well as order amount and currency. These are input parameters. After the order is completed, it will return information such as creation time and transaction order number. These are output parameters. If the system needs to collect this information, it needs to declare the configuration of this tracking point, such as
[0061]
[0062] The indicator is declared as orderInfo through measurement, and the values of the tracking fields are declared through tags. For example, the payerName information is extracted from REQ (request parameter) through the expression (REQ.payeeName). Similarly, the orderNo (order number) is extracted from RES (return parameter) through (RES.orderNo).
[0063] 1.2 Configure the relevant data storage engine and identify the options for storing embedded data.
[0064] 1.3 Specify which storage engines the generated tracking data needs to be stored in, which can be one or more. For example, the order information indicator needs to be stored in MySQL or InfluxDB at the same time. MySQL can associate and count the order information of a certain user, while InfluxDB can predict the order volume in the future.
[0065] S4: Start an asynchronous thread by creating a thread pool, asynchronously assemble the acquired tracking data, obtain the assembled data model and store it in the corresponding storage engine, so that different business data can be asynchronously reported directly from the client to the adapted storage engine without intruding the business code; integrate the configured tracking framework into the business system, and when the business process enters the preset interception code segment / method, intercept the program code according to the configuration file to obtain the target data to be reported; the Java bytecode includes a series of target instructions, and the target instructions are configured to be interpreted and executed by the Java virtual machine, and the code corresponding to the target instruction is dynamically compiled into local machine code, and the bytecode can be modified at compile time or runtime to implement AOP (aspect-oriented programming).
[0066] The method interception based on Java bytecode, determining the method to be intercepted and the assembly logic of the tracking point data include:
[0067] The configuration is as follows:
[0068] conf i gs:
[0069] -cl assName:com.pi ngpongx.order.kun.contro ll er.OrderContro l ler
[0070] methods:
[0071] -name:createOrder
[0072] Points:
[0073] -bucket I d:kun_i nf l ux2
[0074] measurement:order Info
[0075] -bucket I d:kun_mysq l
[0076] measurement:order I nfo_mysq l
[0077] Configure the intercepted Java class and createOrder method, and automatically intercept when the createOrder method of the target request class is executed; it can be understood that the intercepted Java class and are configured as "com.pi ngpongx.order.kun.controller.OrderController", and the method is "createOrder", and it will automatically intercept when the "createOrder" method is executed.
[0078] When creating an order, the indicator data needs to be collected in MySQL and InfluxDB, so these two storage engines need to be configured. If the order Info is not specified to be stored in MySQL and InfluxDB or a non-existent storage engine is specified, the indicator will be ignored. In this case, it is necessary to perform a pre-check according to the storage engine specified in the configuration file. The specific steps of the pre-check are as follows:
[0079] If the current storage engine is in shutdown state, skip writing data to the current storage engine;
[0080] If the current storage engine is in the on state, the intercepted buried point data will be written into the off-heap circular queue corresponding to the current storage engine for storage. The off-heap circular queue is a limited queue based on off-heap memory, which is used to store a preset amount of data to avoid memory overflow in the application system.
[0081] S5: traverse the storage bucket. When the storage bucket is not enabled, introduce a non-blocking queue engine and write the buried data into the non-blocking queue to ensure the timing of the buried data. Read the buried data in the off-heap circular queue according to the scheduled task, and write it into the actual storage unit through the storage engine to push the buried data. The non-blocking queue is an off-heap circular queue formed by combining the off-heap memory and the circular queue. The queue used in this embodiment can cache the data before it is pushed. When the amount of data reaches a certain threshold, batch push can increase the transmission efficiency. The queue can naturally achieve timing to avoid disorder of buried data. The circular queue recycles fixed space to provide a data structure with high space efficiency and stable operation efficiency. This makes the circular queue in application scenarios that require efficient space use and high performance. Generally speaking, when the queue is used for data caching, the data is still stored in the memory space applied by the application. When the queue capacity is relatively large and the data packet is also relatively large, it will occupy a lot of application memory. However, by combining off-heap memory and circular queues, data packets can be stored outside the application memory. The queue only stores a reference address of the data packet outside the application memory. This allows the application memory space occupied by the circular queue to be fixed and controllable, thus ensuring the stability of the application system.
[0082] The off-heap circular queue used in this embodiment has no locks, and the read and write operations are relatively fast, which will not affect the performance of the business system. This data will not affect the application. No matter how much data is written, as long as it exceeds this range, the business application will not be affected by the amount of data. Avoid the need to lock operations when there is not enough memory to store data, which causes the business system to respond slowly. The off-heap circular queue uses an array as the underlying data structure, and implements the circular storage of the off-heap circular queue by recycling the array space. The head and tail of the off-heap circular queue change cyclically in relative position in the array to form a circular buffer; wherein, the off-heap circular queue stores the data packet outside the application memory, and the queue only stores the reference address of the data packet outside the application memory.
[0083] The step of reading the tracking data in the off-heap circular queue according to the scheduled task and writing the tracking data into the actual storage unit through the storage engine to push the tracking data includes:
[0084] The tracking data is stored in an off-heap circular queue according to the time sequence attribute of the order. Before all indicators are written into the storage engine, they are stored in the off-heap circular queue to ensure the orderliness of the order;
[0085] Initially, the front of the off-heap ring queue and the rear of the off-heap ring queue both point to the start of the queue;
[0086] When a new element needs to be queued, the element is inserted into the position pointed to by the rear of the off-heap ring queue, and the rear of the off-heap ring queue is moved backward by one position. If the rear of the off-heap ring queue moves to the end of the array, the loop returns to the starting position of the array to implement a loop to use the position of the last dequeue to store the new element;
[0087] When an element in the off-heap ring queue needs to be dequeued, the element pointed to by the head front of the off-heap ring queue is taken out, and the head front of the off-heap ring queue is moved back one position. If the head front of the off-heap ring queue moves to the end of the array, the loop returns to the starting position of the array to maintain the ring characteristics;
[0088] When the indicator enters the off-heap circular queue, the position relationship between the front pointer at the head of the off-heap circular queue and the rear pointer at the tail of the off-heap circular queue is used to determine whether the off-heap circular queue is empty or full. If the queue is not full, it is appended to the back of the off-heap circular queue. If the queue is full, the current indicator is discarded. Among them, when the off-heap circular queue is empty, front == rear, and when the off-heap circular queue is full, ((rear+1)%capacity == front). The indicator here is the element stored in the queue. Because orders have a time sequence attribute, the order information stored in the queue needs to be sequential. Before all indicators are written to the storage engine, they will be stored in this circular queue, and the order order is guaranteed by this circular queue. When the indicator enters the queue, it will determine whether the queue is full. If it is not full, it will be appended to the back of the queue. If it is full, the current indicator will be discarded. After a storage bucket is abnormal and a fuse occurs, there will be a change in the status mark in the memory, from available to unavailable. This status can be used to determine whether the storage bucket is enabled. The circular queue opens up a continuous array space in the JVM memory. The default is 8192 slots, which takes up about 2.8M of JVM memory. Each slot points to an off-heap memory. In this way, no matter how large the indicator data is, it will not occupy the JVM's memory space, thus ensuring the stability of the system.
[0089] S6: Determine whether there is an exception when pushing the tracking data. When there is an exception in pushing the tracking data, determine whether it is necessary to perform a fuse operation on the configured tracking architecture. When performing a fuse operation, disable the current storage engine until the storage engine resumes normal service.
[0090] Those skilled in the art can understand that this embodiment automatically identifies the target code segment or target method to be monitored through configuration of the program code, and automatically injects interception to intercept input and output when the method is executed. When a business process enters this code segment, it will generate data, and this data will be intercepted by the interception method, and then assembled into the data stream to be reported and reported to the server.
[0091] The determining whether there is an exception when pushing the burying point data, and when there is an exception in pushing the burying point data, determining whether it is necessary to perform a fuse operation on the configured burying point architecture, and when performing a fuse operation, disabling the current storage engine until the storage engine resumes normal service includes: when the burying point data stored in the off-heap circular queue reaches a threshold, actively triggering an event to push the burying point data;
[0092] If the number of exceptions in any storage engine service per unit time reaches the threshold, the configured tracking framework will perform a fuse process, directly discard the subsequent tracking data, and prohibit it from entering the off-heap ring queue;
[0093] When the storage engine waiting time after the fuse reaches the self-recovery time, it will automatically detect whether the storage engine after the fuse has resumed normal service. If it has resumed, subsequent data will continue to flow normally.
[0094] Embodiment 2
[0095] Based on the same inventive concept, the present invention provides a service tracking device for non-intrusive writing to multiple storage engines, including:
[0096] A request module, used to respond to a target service request;
[0097] A configuration module is used to confirm the business tracking point requirements according to the target business request, write a configuration file, and load it on the Java application server;
[0098] The interception module is used to intercept methods based on Java bytecode when the application is started, determine the assembly logic of the method to be intercepted and the tracking data, and perform target interception at the bytecode level when the current business process enters the code segment to be intercepted, so as to obtain the tracking data to be reported;
[0099] The asynchronous module is used to start asynchronous threads by creating a thread pool, asynchronously assemble the acquired tracking data, obtain the assembled data model and store it in the corresponding storage engine. It can asynchronously report different business data directly from the client to the adapted storage engine without intruding the business code;
[0100] A storage module is used to traverse the storage bucket. When the storage bucket is not enabled, a non-blocking queue engine is introduced and the buried point data is written into the non-blocking queue to ensure the timing of the buried point data. The buried point data in the off-heap circular queue is read according to the scheduled task, and written into the actual storage unit through the storage engine to push the buried point data. The non-blocking queue is an off-heap circular queue formed by combining the off-heap memory and the circular queue.
[0101] The judgment module is used to determine whether there is an exception when pushing the tracking data. When there is an exception in pushing the tracking data, it is used to determine whether it is necessary to perform a fuse operation on the configured tracking architecture. When the fuse is performed, the current storage engine is disabled until the storage engine resumes normal service.
[0102] The principles, contents and implementation methods of the above-mentioned request module, configuration module, interception module, asynchronous module, storage module and judgment module are as described in Example 1 and will not be repeated here.
[0103] Embodiment 3
[0104] In some embodiments of the present application, an electronic device is also provided. The electronic device includes a memory and a processor, wherein the memory is used to store a processing program, and the processor executes the processing program according to instructions. When the processor executes the processing program, the business tracking method of non-intrusive writing to multiple storage engines in the above-mentioned embodiment is implemented.
[0105] In some embodiments of the present application, a readable storage medium is also provided, which can be a non-volatile readable storage medium or a volatile readable storage medium. The readable storage medium stores instructions, and when the instructions are executed on a computer, an electronic device including the readable storage medium executes the aforementioned non-intrusive writing to multiple storage engines business tracking method.
[0106] It is understandable that, for the aforementioned non-invasive writing multi-storage engine business tracking method, if it is implemented in the form of a software function module 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 the present invention is essentially 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, and the computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the various embodiments of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-on l ymemory, ROM), random access memory (Random access memory, RAM), disk or optical disk and other media that can store program code.
[0107] Computer readable storage media may include data signals propagated in baseband or as part of a carrier wave, wherein readable program codes are carried. Such propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. The readable storage medium may also be any readable medium other than a readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, device, or device. The program codes contained on the readable storage medium may be transmitted using any suitable medium, including but not limited to wireless, wired, optical cable, RF, etc., or any suitable combination thereof.
[0108] The program code involved in executing the technical solution disclosed in the present application can be written in any combination of one or more programming languages, including object-oriented programming languages such as Java, C++, etc., and also conventional procedural programming languages such as C language or similar programming languages. The program code can be executed entirely on the user computing device, partially on the user device, as an independent software package, partially on the user computing device and partially on the remote computing device, or completely on the remote computing device or server. In the case of a remote computing device, the remote computing device can be connected to the user computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computing device (for example, using an Internet service provider to connect through the Internet).
[0109] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for non-invasively writing business points to multiple storage engines, characterized in that: include: responding to a target service request; Confirm the business tracking requirements according to the target business request, compile a configuration file, and load it on the Java application server; When the application is started, method interception is performed based on Java bytecode to determine the assembly logic of the method to be intercepted and the tracking data. When the current business process enters the code segment to be intercepted, target interception is performed at the bytecode level to obtain the tracking data to be reported. By creating a thread pool to start an asynchronous thread, the acquired tracking data is asynchronously assembled to obtain the assembled data model and store it in the corresponding storage engine. Different business data can be asynchronously reported directly from the client to the adapted storage engine without intruding the business code. Traverse the storage bucket. When the storage bucket is not enabled, introduce a non-blocking queue engine and write the tracking data into the non-blocking queue to ensure the timing of the tracking data. Read the tracking data in the off-heap circular queue according to the scheduled task, and write it into the actual storage unit through the storage engine to push the tracking data. The non-blocking queue is an off-heap circular queue formed by combining the off-heap memory and the circular queue. Determine whether there is an exception when pushing the tracking data. When there is an exception in pushing the tracking data, determine whether it is necessary to perform a fuse operation on the configured tracking architecture. When performing a fuse operation, disable the current storage engine until the storage engine resumes normal service.
2. The method for non-invasively writing to multiple storage engines as claimed in claim 1, characterized in that: The step of confirming the service tracking point requirement and writing the configuration file according to the target service request includes: Methods for determining target request classes for business tracking in cross-border transaction scenarios; The indicator is declared through the measurement indicator. Tags declare the value of the tracking field. The input and output parameters of the target request are extracted to the tracking field through the expression. Configuration requires a data storage engine, where the MySQL database is used to associate and count current business information, and the InfluxDB database is used to predict business data within a preset time in the future.
3. The method for non-invasively writing to multiple storage engines as claimed in claim 1, characterized in that: The Java bytecode includes a series of target instructions, which are configured to be interpreted and executed by a Java virtual machine, dynamically compile the code corresponding to the target instructions into native machine code, and can modify the bytecode at compile time or runtime to implement AOP.
4. The method for non-invasively writing to multiple storage engines as claimed in claim 1, characterized in that: The method interception based on Java bytecode, determining the method to be intercepted and the assembly logic of the tracking point data include: Automatically intercept when executing the method of the target request class; Perform a pre-check according to the storage engine specified in the configuration file. The specific steps of the pre-check are as follows: If the current storage engine is in shutdown state, skip writing data to the current storage engine; If the current storage engine is in the on state, the intercepted buried point data will be written into the off-heap circular queue corresponding to the current storage engine for storage. The off-heap circular queue is a limited queue based on off-heap memory, which is used to store a preset amount of data to avoid memory overflow in the application system.
5. The method for non-invasively writing to multiple storage engines as claimed in claim 1, characterized in that: The off-heap circular queue uses an array as the underlying data structure and implements circular storage of the off-heap circular queue by cyclically utilizing the array space. The relative positions of the head and tail of the off-heap circular queue in the array change cyclically to form a circular buffer. The off-heap circular queue stores the data packet outside the application memory, and only the reference address of the data packet outside the application memory is stored in the queue.
6. The method for non-invasively writing to multiple storage engines as claimed in claim 1, characterized in that: The step of reading the tracking data in the off-heap circular queue according to the scheduled task and writing the tracking data into the actual storage unit through the storage engine to push the tracking data includes: The tracking data is stored in an off-heap circular queue according to the time sequence attribute of the order. Before all indicators are written into the storage engine, they are stored in the off-heap circular queue to ensure the orderliness of the order; Initially, the front of the off-heap ring queue and the rear of the off-heap ring queue both point to the start of the queue; When a new element needs to be queued, the element is inserted into the position pointed to by the rear of the off-heap ring queue, and the rear of the off-heap ring queue is moved backward by one position. If the rear of the off-heap ring queue moves to the end of the array, the loop returns to the starting position of the array to implement a loop to use the position of the last dequeue to store the new element; When an element in the off-heap ring queue needs to be dequeued, the element pointed to by the head front of the off-heap ring queue is taken out, and the head front of the off-heap ring queue is moved back one position. If the head front of the off-heap ring queue moves to the end of the array, the loop returns to the starting position of the array to maintain the ring characteristics; When the indicator enters the off-heap ring queue, the position relationship between the front pointer at the head of the off-heap ring queue and the rear pointer at the tail of the off-heap ring queue is used to determine whether the off-heap ring queue is empty or full. If the queue is not full, it is appended to the back of the off-heap ring queue. If the queue is full, the current indicator is discarded. When the off-heap ring queue is empty, front == rear. When the off-heap ring queue is full, ((rear+1)%capacity == front).
7. The method for non-invasively writing to multiple storage engines as claimed in claim 1, characterized in that: The determining whether there is an exception when pushing the burying point data, and when there is an exception in pushing the burying point data, determining whether it is necessary to perform a fuse operation on the configured burying point architecture, and when performing a fuse operation, disabling the current storage engine until the storage engine resumes normal service includes: when the burying point data stored in the off-heap circular queue reaches a threshold, actively triggering an event to push the burying point data; If the number of exceptions in any storage engine service per unit time reaches the threshold, the configured tracking framework will perform a fuse process, directly discard the subsequent tracking data, and prohibit it from entering the off-heap ring queue; When the storage engine waiting time after the fuse reaches the self-recovery time, it will automatically detect whether the storage engine after the fuse has resumed normal service. If it has resumed, subsequent data will continue to flow normally.
8. A business tracking device for non-intrusive writing to multiple storage engines, characterized in that: include: A request module, used to respond to a target service request; A configuration module is used to confirm the business tracking point requirements according to the target business request, write a configuration file, and load it on a Java application server; The interception module is used to intercept methods based on Java bytecode when the application is started, determine the assembly logic of the method to be intercepted and the tracking data, and perform target interception at the bytecode level when the current business process enters the code segment to be intercepted, so as to obtain the tracking data to be reported; The asynchronous module is used to start asynchronous threads by creating a thread pool, asynchronously assemble the acquired tracking data, obtain the assembled data model and store it in the corresponding storage engine. It can asynchronously report different business data directly from the client to the adapted storage engine without intruding the business code; A storage module is used to traverse the storage bucket. When the storage bucket is not enabled, a non-blocking queue engine is introduced and the buried point data is written into the non-blocking queue to ensure the timing of the buried point data. The buried point data in the off-heap circular queue is read according to the scheduled task, and written into the actual storage unit through the storage engine to push the buried point data. The non-blocking queue is an off-heap circular queue formed by combining the off-heap memory and the circular queue. The judgment module is used to determine whether there is an exception when pushing the tracking data. When there is an exception in pushing the tracking data, it is used to determine whether it is necessary to perform a fuse operation on the configured tracking architecture. When the fuse is performed, the current storage engine is disabled until the storage engine resumes normal service.
9. An electronic device, characterized in that: include: A memory, the memory being used to store a processing program; A processor, wherein when executing the processing program, the processor implements the business tracking method for non-intrusive writing to multiple storage engines as described in any one of claims 1 to 7.
10. A readable storage medium, characterized in that: The readable storage medium stores a processing program, which, when executed by a processor, implements the business tracking method for non-invasively writing to multiple storage engines as described in any one of claims 1 to 7.
