Dynamic script compiling and hot updating system based on Grouping and implementation method of dynamic script compiling and hot updating system

By using a Groovy-based dynamic script compilation and hot update system, the problems of low compilation efficiency, inadequate exception handling, and insecurity of hot updates in enterprise application development are solved, achieving high reliability, high performance, zero-downtime deployment and data consistency, and supporting flexible expansion and customization.

CN121029183APending Publication Date: 2025-11-28SICHUAN CHANGHONG JIAHUA INFORMATION PROD CO LTD
View PDF 0 Cites 4 Cited by

Patent Information

Application Number
CN202511383137.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-09-25
Publication Date
2025-11-28

AI Technical Summary

Technical Problem

Traditional static compilation methods require recompilation and deployment when business logic changes occur in enterprise application development, affecting system availability and maintainability. They lack effective script compilation caching mechanisms, repeatedly compiling consumes system resources, have insufficient exception handling capabilities, are insecure with hot updates, and have prominent concurrency security issues in compilation and execution under multi-threaded environments.

Method used

It adopts a Groovy-based dynamic script compilation and hot update system, including a script source code management module, a dynamic compilation engine, an intelligent cache manager, an exception handling and recovery system, and a hot update controller. It uses hash values ​​to generate unique identifiers for cache management, achieving efficient caching and version control of compilation results. It provides a complete exception handling and recovery mechanism to ensure the security and reliability of hot updates.

Benefits of technology

It improves system reliability by over 85%, enhances compilation performance by 70%, enables zero-downtime deployment, ensures data integrity and consistency, provides comprehensive execution monitoring and anomaly alerts, and supports flexible expansion and customization.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121029183A_ABST
    Figure CN121029183A_ABST
Patent Text Reader

Abstract

The invention discloses a dynamic script compiling and hot updating system based on Grouping and an implementation method of the dynamic script compiling and hot updating system. The system comprises a script source code management module, a dynamic compiling engine, an intelligent cache manager, an exception handling and recovery system and a hot update controller. And the script source code management module receives and preprocesses the Grouping script to generate a unique identifier for subsequent management. And the dynamic compilation engine executes compilation operation according to the identifier to ensure that a compilation result accords with a specification. And the intelligent cache manager efficiently stores and retrieves the compiling result, so that the repeated compiling cost is reduced. And the exception handling and recovery system monitors the execution state in real time, and automatically starts a recovery process in case of exception to guarantee stable operation of the system. The hot update controller realizes seamless update and version switching of scripts, and ensures service continuity. Through cooperative work of the modules, high-reliability, high-performance and zero-shutdown deployment is realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the fields of computer software technology and dynamic script execution technology, and in particular to a dynamic script compilation and hot update system based on Groovy and its implementation method. Background Technology

[0002] In enterprise application development, dynamic expansion and hot deployment of business logic are common requirements. However, traditional static compilation methods have many technical problems, which seriously affect the availability and maintainability of the system.

[0003] First, changes to business logic often require recompiling and redeploying the entire application, a process that is not only time-consuming but also causes system downtime, impacting user experience. Second, the lack of an effective script compilation caching mechanism leads to repeated compilation consuming significant system resources and reducing system efficiency. Furthermore, insufficient exception handling during script execution and the lack of a robust error recovery mechanism make the system prone to crashes when encountering exceptions, making it difficult to guarantee data integrity and consistency. Simultaneously, the lack of secure version management and rollback strategies during hot script updates makes it difficult to quickly restore a stable state if a new version encounters problems. Finally, in a multi-threaded environment, the concurrency safety issues of script compilation and execution urgently need to be addressed. Summary of the Invention

[0004] Based on this, this application provides a Groovy-based dynamic script compilation and hot update system and its implementation method, which solves the technical problems of low script compilation efficiency, imperfect exception handling, and insecurity of hot updates in the prior art.

[0005] Firstly, a method for dynamic script compilation and hot updating based on Groovy is provided, which includes:

[0006] The script source code management module is used to receive Groovy script source code, generate a unique script identifier by calculating the hash value of the script source code, and use the script identifier for cache management and version control.

[0007] A dynamic compilation engine is used to perform compilation operations on the script identifiers to obtain compilation results; wherein, the compilation operations on the script identifiers include retrieving already compiled classes from the cache or executing a new compilation process, and ensuring that the compiled classes conform to predefined interface specifications and instantiation requirements;

[0008] The intelligent cache manager receives compilation results and manages the cache according to the caching strategy, while also providing cached compilation results for script execution.

[0009] The exception handling and recovery system is used to monitor the execution status during script execution and immediately initiate the recovery process when an exception occurs.

[0010] A hot update controller is used to perform version control based on the script identifier during the hot update process to ensure the correct switching between old and new versions, and to obtain or update the cached compilation results.

[0011] Optionally, the script source code management module specifically includes:

[0012] Remove comments and extra whitespace from Groovy script source code using regular expressions;

[0013] The GroovyCodeAnalyzer is invoked to perform syntax analysis, and the syntax correctness is checked through the AST parser.

[0014] Verify that the script class implements the ExtensionProcess interface and contains the necessary process method;

[0015] Automatically add standardized wrappers to encapsulate user scripts into complete class definitions, and add necessary import statements and package declarations;

[0016] Calculate the SHA256 hash value of the source code as the script's unique identifier.

[0017] Optionally, the dynamic compilation engine specifically includes:

[0018] Check the compilation cache and construct the format of the cache keys;

[0019] Search for the compiled class in the ConcurrentHashMap cache. If the cache is hit and the timestamp is valid, return the cached result directly.

[0020] If the cache is not hit, create a separate GroovyClassLoader instance and configure the compilation parameters, including character encoding, debugging information, target JVM version, and classpath settings.

[0021] Perform the compilation operation, and verify the validity of the class after compilation.

[0022] The compilation results are stored in a cache, and the compilation timestamp, access count, and source code hash value are recorded.

[0023] When the cache capacity exceeds the limit, the LRU algorithm is used to automatically evict the least recently used compilation result.

[0024] Optionally, the smart cache manager specifically includes:

[0025] Use ConcurrentHashMap to implement a thread-safe cache for compilation results;

[0026] A unique cache identifier is generated based on the source code hash value and version information;

[0027] The LRU eviction policy is adopted, and when the cache capacity reaches the threshold, the least recently used compilation result is automatically evicted.

[0028] Implement a cache preheating mechanism to preload the compilation results of commonly used scripts at startup;

[0029] Integrate Redis to enable cross-node sharing of compilation results.

[0030] Optionally, the exception handling and recovery system specifically includes:

[0031] Create an ExceptionHandler exception handler and a RecoveryManager recovery manager before the script is executed;

[0032] Perform a pre-processing state check to verify the validity of input parameters and the availability of system resources, and create a backup snapshot of the execution context;

[0033] During script execution, the exception monitor continuously monitors the execution status, captures various exceptions, and classifies and processes them according to predefined rules.

[0034] For recoverable exceptions, a retry mechanism is initiated, with a maximum of 3 retries, restoring the initial state before each retry.

[0035] For fatal exceptions, execution is immediately stopped and a rollback process is triggered to restore the system to its stable state before execution.

[0036] Optionally, the hot update controller specifically includes:

[0037] Perform compatibility checks on the new version of the script; this includes interface compatibility, dependency checks, and backward compatibility verification.

[0038] A double buffering mechanism is adopted to prepare new script instances but not replace them immediately. Switching is performed according to a preset time, and version history is maintained, including version number, update time, change description, and rollback point information.

[0039] When a problem is detected in the new version, the rollback mechanism is automatically triggered to restore the previous stable version, and the rollback event and reason are recorded.

[0040] Optionally, the system also includes a data backup and fast recovery module, including:

[0041] Perform a deep copy backup of the input parameters before the script is executed;

[0042] Incremental backups are performed on key intermediate results during script execution;

[0043] Use the LZ4 compression algorithm to reduce the storage space for backup data;

[0044] Data recovery using memory-mapped file technology.

[0045] Optionally, the system also includes a status check and data integrity verification module, including:

[0046] Before the script is executed, verify the completeness, correctness of the format, and compliance with business rules of the input parameters;

[0047] Monitor the script execution status in real time during script execution;

[0048] After the script is executed, check the data type, business constraints, and integrity requirements of the output results;

[0049] Data consistency is verified by comparing hash values ​​and statistically analyzing data volume.

[0050] Optionally, the system also includes an interruption point recovery module, comprising:

[0051] Set checkpoints at key nodes in script execution to save execution status, variable values, and execution location information;

[0052] It supports resuming execution from any checkpoint and verifies the correctness of the state and the consistency of the data after resuming execution.

[0053] Secondly, a method for implementing a Groovy-based dynamic script compilation and hot update system, implemented in any of the systems described in the first aspect above, wherein the implementation method includes:

[0054] Script preprocessing and verification: Receive Groovy script source code, perform preprocessing and verification, and generate script identifiers;

[0055] Intelligent compilation and cache management: The dynamic compilation engine performs compilation operations based on script identifiers, retrieves or executes new compilation processes from the cache, and ensures that the compiled classes conform to predefined interface specifications and instantiation requirements; the intelligent cache manager receives the compilation results, manages the cache according to the caching strategy, and provides cached compilation results for script execution;

[0056] Exception handling and recovery: Monitor the execution status during script execution, capture exceptions, and initiate the recovery process;

[0057] Hot update and version management: During the hot update process, the hot update controller performs version control based on the script identifier to ensure the correct switching between old and new versions, and obtains or updates the cached compilation results.

[0058] The beneficial effects of the technical solutions provided in this application include at least the following:

[0059] 1. High reliability: Through a robust anomaly handling and recovery mechanism, system reliability is improved by more than 85%;

[0060] 2. High performance: The intelligent caching mechanism reduces the overhead of repeated compilation, improving compilation performance by 70%;

[0061] 3. Zero-downtime deployment: Supports hot updates and seamless rollbacks, achieving true zero-downtime deployment;

[0062] 4. Strong consistency: Ensure data integrity and consistency through status checks and data backups;

[0063] 5. Intelligent monitoring: Provides comprehensive execution monitoring and anomaly early warning capabilities;

[0064] 6. Scalability: Modular design supports flexible expansion and customization of functions. Attached Figure Description

[0065] To more clearly illustrate the embodiments of this application or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are merely exemplary, and those skilled in the art can derive other embodiments based on the provided drawings without creative effort.

[0066] Figure 1 A block diagram of a Groovy-based dynamic script compilation and hot update system provided for embodiments of this application;

[0067] Figure 2 The diagram illustrates the implementation steps of a Groovy-based dynamic script compilation and hot update system provided in this application embodiment. Detailed Implementation

[0068] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.

[0069] In the description of this application, the terms "comprising," "having," and any variations thereof are intended to cover non-exclusive inclusion, such as a process, method, system, product, or apparatus that includes a series of steps or units, not necessarily limited to those steps or units that are expressly listed, but may also include other steps or units that are not expressly listed but are inherent to these processes, methods, products, or apparatuses, or steps or units added based on further optimizations conceived in this application.

[0070] This invention can be widely applied to enterprise application development, microservice architecture, business rule engines, workflow engines, and other scenarios, and is particularly suitable for internet applications and financial systems that require frequent changes to business logic. Through this invention, enterprises can achieve rapid iteration and secure deployment of business logic, significantly improving system flexibility and maintainability.

[0071] Please refer to Figure 1 The diagram illustrates a block diagram of a Groovy-based dynamic script compilation and hot update system provided in this application embodiment. The system specifically includes:

[0072] The script source code management module is used to receive Groovy script source code, generate a unique script identifier by calculating the hash value of the script source code, and use the script identifier for cache management and version control.

[0073] A dynamic compilation engine is used to perform compilation operations on the script identifiers to obtain compilation results; wherein, the compilation operations on the script identifiers include retrieving already compiled classes from the cache or executing a new compilation process, and ensuring that the compiled classes conform to predefined interface specifications and instantiation requirements;

[0074] The intelligent cache manager receives compilation results and manages the cache according to the caching strategy, while also providing cached compilation results for script execution.

[0075] The exception handling and recovery system is used to monitor the execution status during script execution and immediately initiate the recovery process when an exception occurs.

[0076] A hot update controller is used to perform version control based on the script identifier during the hot update process to ensure the correct switching between old and new versions, and to obtain or update the cached compilation results.

[0077] In optional embodiments of this application, the script source code management module specifically includes: removing comments and redundant whitespace characters in the Groovy script source code using regular expressions; calling GroovyCodeAnalyzer for syntax analysis and checking syntax correctness using an AST parser; verifying whether the script class implements the ExtensionProcess interface and contains the necessary process method; automatically adding standardized wrappers to encapsulate the user script into a complete class definition, adding necessary import statements and package declarations; and calculating the SHA256 hash value of the source code as the script's unique identifier.

[0078] The dynamic compilation engine specifically includes: checking the compilation cache and constructing the cache key format; searching for compiled classes in the ConcurrentHashMap cache; if the cache is hit and the timestamp is valid, the cached result is returned directly; if the cache is not hit, an independent GroovyClassLoader instance is created, and compilation parameters including character encoding, debugging information, target JVM version, and classpath settings are configured; the compilation operation is performed, and the validity of the class is verified after compilation; the compilation result is stored in the cache, and the compilation timestamp, access count, and source code hash value are recorded; when the cache capacity exceeds the limit, the least recently used compilation result is automatically evicted using the LRU algorithm.

[0079] The intelligent cache manager specifically includes: using ConcurrentHashMap to implement thread-safe compilation result caching; generating unique cache identifiers based on source code hash values ​​and version information; adopting an LRU eviction policy to automatically evict the least recently used compilation results when the cache capacity reaches a threshold; implementing a cache preheating mechanism to preload the compilation results of frequently used scripts at startup; and integrating Redis to achieve cross-node sharing of compilation results.

[0080] The exception handling and recovery system specifically includes: creating an ExceptionHandler and a RecoveryManager before script execution; performing pre-execution state checks to verify the validity of input parameters and the availability of system resources, and creating a backup snapshot of the execution context; during script execution, an exception monitor continuously monitors the execution status, captures various exceptions, and classifies and handles them according to predefined rules; for recoverable exceptions, a retry mechanism is initiated, with a maximum of 3 retries, restoring to the initial state before each retry; for fatal exceptions, execution is immediately stopped and a rollback process is triggered to restore to the stable state before execution.

[0081] The hot update controller specifically includes: performing compatibility checks on new version scripts, including interface compatibility, dependency checks, and backward compatibility verification; employing a double buffering mechanism to prepare new script instances but not immediately replace them, switching according to preset times, and maintaining version history records, including version number, update time, change description, and rollback point information; when a problem is detected in the new version, automatically triggering the rollback mechanism to restore to the previous stable version, and recording the rollback event and reason.

[0082] The system also includes a data backup and fast recovery module, which includes: performing a deep copy backup of input parameters before script execution; performing incremental backup of key intermediate results during script execution; using the LZ4 compression algorithm to reduce the storage space of backup data; and performing data recovery through memory-mapped file technology.

[0083] The system also includes a status check and data integrity verification module, which includes: verifying the integrity, format correctness, and compliance of input parameters before script execution; monitoring the script execution status in real time during script execution; checking the data type, business constraints, and integrity requirements of the output results after script execution; and verifying data consistency through hash value comparison and data volume statistics.

[0084] The system also includes an interruption point recovery module, which includes: setting checkpoints at critical nodes of script execution, saving execution status, variable values, and execution location information; supporting resumption of execution from any checkpoint, and verifying the correctness of the status and the consistency of the data after resumption of execution.

[0085] In summary, this application provides a Groovy-based dynamic script compilation and hot update system, comprising:

[0086] 1. Script source code management module: Responsible for script version control and source code preprocessing.

[0087] 2. Dynamic compilation engine: Provides runtime compilation functionality for Groovy scripts.

[0088] 3. Intelligent Cache Manager: Implements efficient caching and eviction strategies for compilation results.

[0089] 4. Exception handling and recovery system: Provides a comprehensive exception capture and error recovery mechanism.

[0090] 5. Hot update controller: Supports secure hot deployment and version rollback of scripts.

[0091] The following are specific technical features of the embodiments of this application:

[0092] Feature 1: Intelligent script preprocessing technology

[0093] The system employs a multi-layered script preprocessing mechanism to ensure script security and compliance.

[0094] 1. Syntax compliance check: Verify the correctness and security of the script syntax through AST (Abstract Syntax Tree) analysis.

[0095] 2. Interface specification verification: Automatically checks whether the script correctly implements the ExtensionProcess interface specification.

[0096] 3. Dependency Analysis: Scan the import statements and class dependencies in the script to build a dependency graph.

[0097] 4. Source code standardization: Automatically add wrapper classes and default imports to ensure that the script conforms to system specifications.

[0098] 5. Hash value calculation: The SHA256 algorithm is used to calculate the unique identifier of the script source code.

[0099] Feature 2: High-performance compile caching mechanism

[0100] Improve compilation performance by using a multi-level caching architecture:

[0101] 1. Memory caching: Implements thread-safe compilation result caching based on ConcurrentHashMap.

[0102] 2. Cache key design: Generate a unique cache identifier based on the source code hash value and version information.

[0103] 3. LRU eviction policy: When the cache capacity reaches the threshold, the least recently used compilation result is automatically evicted.

[0104] 4. Cache preheating mechanism: The compilation results of commonly used scripts are preloaded when the system starts.

[0105] 5. Distributed caching support: Integration with Redis enables cross-node sharing of compilation results.

[0106] Feature 3: Dynamic Compilation Engine Technology

[0107] Efficient dynamic compilation based on GroovyClassLoader:

[0108] 1. Compiler configuration optimization: Set UTF-8 encoding, enable debugging information, and target JVM version control.

[0109] 2. Class loader management: A parent delegation mechanism is adopted to ensure the security and isolation of class loading.

[0110] 3. Compilation result verification: Check whether the compiled class meets the interface constraints and instantiation requirements.

[0111] 4. Memory management: Release unused class loaders in a timely manner to prevent memory leaks.

[0112] 5. Compilation performance monitoring: Records key metrics such as compilation time and success rate.

[0113] Feature 4: Comprehensive Anomaly Handling and Recovery Mechanism

[0114] Implement a multi-layered exception handling strategy:

[0115] 1. Anomaly detection and classification

[0116] The system implements fine-grained exception handling at each stage of script compilation and execution:

[0117] Compilation phase exceptions: catch syntax errors, classpath exceptions, and out-of-memory exceptions.

[0118] Execution phase exceptions: catch runtime exceptions, business logic exceptions, and resource access exceptions.

[0119] System-level exceptions: catch thread interruption, class loading failure, and JVM exception.

[0120] Exception handling mechanism: fatal_exceptions (fatal exceptions require service to be stopped), recoverable_exceptions (recoverable exceptions allow retries), warning_exceptions (warning exceptions are logged and execution continues).

[0121] 2. Intelligent rollback strategy

[0122] Design a script execution rollback mechanism based on transaction semantics:

[0123] Version management: Maintains version history for each script and supports multiple versions coexisting.

[0124] State snapshot: Creates a system state snapshot before the script is executed, including variable values, resource status, and execution context.

[0125] Atomicity rollback: When an exception occurs, the system automatically restores the system to its stable state before execution.

[0126] Segmented rollback: Supports incremental rollback for partially successful scenarios, avoiding the performance loss of full rollback.

[0127] Rollback verification: After the rollback is executed, a state consistency check is performed to ensure the correctness of the rollback operation.

[0128] 3. Data backup and quick recovery

[0129] Implement a multi-layered data protection mechanism:

[0130] Input data backup: Perform a deep copy backup of the input parameters before the script is executed.

[0131] Intermediate result backup: Perform incremental backups of key intermediate results during script execution.

[0132] Context backup: Saves context information such as thread-local variables, global variables, and environment configurations.

[0133] Backup and compressed storage: The LZ4 compression algorithm is used to reduce the storage space of backup data.

[0134] Fast recovery: Achieve millisecond-level data recovery through memory-mapped file technology.

[0135] 4. Status checks and data integrity verification

[0136] Establish a comprehensive status monitoring and verification system:

[0137] Pre-condition check: Verify the completeness, correctness of format, and compliance of business rules of input parameters.

[0138] Execution process monitoring: Real-time monitoring of script execution status, including memory usage, execution time, and resource consumption.

[0139] Post-result verification: Check the data type, business constraints, and integrity requirements of the output results.

[0140] Consistency verification: Verify data consistency through methods such as hash value comparison and data volume statistics.

[0141] Anomaly warning: Issues an early warning when an abnormal trend is detected to avoid serious failures.

[0142] 5. Interruption point recovery mechanism

[0143] Implement fine-grained execution state saving and restoration:

[0144] Checkpoint design: Set checkpoints at critical nodes in script execution to save the execution state.

[0145] State serialization: Serializes and stores information such as execution context, variable values, and execution location.

[0146] Resume execution from any checkpoint: Supports resuming execution from any checkpoint, avoiding redundant calculations.

[0147] Fault detection: Automatically detects abnormal interruptions in script execution and triggers the recovery process.

[0148] Recovery verification: Verify the correctness of the state and the consistency of the data after recovery execution.

[0149] Feature 5: Safe Hot Update Technology

[0150] Achieve zero-downtime hot deployment of scripts:

[0151] 1. Version Management: Uses semantic version control, supporting major version, minor version, and patch version management.

[0152] 2. Gray release: Supports phased deployment of new version scripts, reducing update risks.

[0153] 3. Atomic replacement: A double buffering mechanism ensures the atomicity of script replacement.

[0154] 4. Compatibility check: Automatically detects the compatibility of the new version of the script with the existing system.

[0155] 5. Automatic rollback: Automatically roll back to the previous stable version when a hot update fails.

[0156] Please refer to Figure 2 This document illustrates the steps of an implementation method for a Groovy-based dynamic script compilation and hot update system provided in an embodiment of this application. The method may include:

[0157] Step 1: Script Preprocessing and Verification

[0158] After receiving the Groovy script source code, the system first performs comprehensive preprocessing and validation. The ScriptProcessor reads the source code string, uses regular expressions to remove comments and redundant whitespace, and then calls the GroovyCodeAnalyzer for syntax analysis. The system checks the syntax correctness using an AST (Abstract Syntax Tree) parser, verifying that class definitions, method signatures, variable declarations, etc., conform to specifications. Next, an interface compatibility check is performed to ensure that the script class implements the ExtensionProcess interface and contains the necessary process method. The system automatically adds a standardized wrapper, encapsulating the user script into a complete class definition, adding necessary import statements and package declarations. Finally, the SHA256 hash value of the source code is calculated as a unique identifier for the script, used for subsequent cache management and version control.

[0159] Step 2: Intelligent Compilation and Cache Management

[0160] The dynamic compilation module first checks the compilation cache, building the cache key format as "compiled_class:"+source_hash+:"+version". It searches for the compiled class in the ConcurrentHashMap cache. If the cache hits and the timestamp is valid (within the default 24 hours), the cached result is returned directly. If the cache misses, the system creates a separate GroovyClassLoader instance, configuring compilation parameters including character encoding (UTF-8), debugging information (enabled), target JVM version (1.8), and classpath settings. The compilation operation `compiled_class = groovyClassLoader.parseClass(wrappedScript)` is executed. After compilation, the validity of the class is verified, checking for normal instantiation and interface compatibility. The compilation result is stored in the cache, recording metadata such as compilation timestamp, access count, and source code hash value. When the cache capacity exceeds the limit, the LRU algorithm automatically evicts the least recently used compilation result.

[0161] Step 3: Exception Handling and Resumption of Execution

[0162] Before script execution, the system creates an ExceptionHandler and a RecoveryManager. First, a pre-execution state check is performed to verify the validity of input parameters and the availability of system resources, creating a backup snapshot of the execution context, including parameter values, environment variables, thread states, and other information. During script execution, the exception monitor continuously monitors the execution status, capturing various exceptions and classifying them according to predefined rules. For recoverable exceptions, the system initiates a retry mechanism, retrying up to three times, restoring to the initial state before each retry. For fatal exceptions, execution is immediately stopped and a rollback process is triggered, restoring to the stable state before execution. After exception handling is complete, detailed exception logs are recorded, including exception type, occurrence time, execution context, and stack information, for fault analysis and system optimization. Simultaneously, exception alarm notifications are sent to operations and maintenance personnel to ensure timely response and handling.

[0163] Step 4: Hot Updates and Version Management

[0164] The HotUpdateManager manages the secure hot deployment process for scripts. First, it performs compatibility checks on the new script version, including interface compatibility, dependency checks, and backward compatibility verification. The system supports a canary release strategy; initially, only 5% of requests use the new script version, monitoring execution effectiveness and exception rates. If the new version runs stably, the proportion of traffic using the new version is gradually increased until a complete switch is achieved. The update process employs a double-buffering mechanism, preparing new script instances but not immediately replacing them, waiting for an appropriate time for an atomic switch. The system maintains a version history, including version number, update time, change description, and rollback point information. When a problem is detected in the new version, a rollback mechanism is automatically triggered, restoring to the previous stable version, and recording the rollback event and reason. The entire hot update process is completely transparent to users, ensuring service continuity and stability.

[0165] In summary, the innovative aspects of this application are as follows:

[0166] 1. Multi-level exception handling architecture: It innovatively designs a three-level exception handling system at the compilation, execution, and system levels.

[0167] 2. Intelligent recovery mechanism: Automatic recovery technology based on state snapshots supports fine-grained fault recovery.

[0168] 3. Hot update security strategy: Employ canary release and double buffering technology to ensure the security of hot updates.

[0169] 4. Distributed caching optimization: Supports sharing of compilation results across nodes, improving the performance of the cluster environment.

[0170] 5. Interruption point recovery technology: Fine-grained saving of execution state, supporting breakpoint resumption of execution.

[0171] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0172] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this patent application should be determined by the appended claims.

Claims

1. A dynamic script compilation and hot update system based on Groovy, characterized in that, The system includes: The script source code management module is used to receive Groovy script source code, generate a unique script identifier by calculating the hash value of the script source code, and use the script identifier for cache management and version control. A dynamic compilation engine is used to perform compilation operations on the script identifiers to obtain compilation results; wherein, the compilation operations on the script identifiers include retrieving already compiled classes from the cache or executing a new compilation process, and ensuring that the compiled classes conform to predefined interface specifications and instantiation requirements; The intelligent cache manager receives compilation results and manages the cache according to the caching strategy, while also providing cached compilation results for script execution. The exception handling and recovery system is used to monitor the execution status during script execution and immediately initiate the recovery process when an exception occurs. A hot update controller is used to perform version control based on the script identifier during the hot update process to ensure the correct switching between old and new versions, and to obtain or update the cached compilation results.

2. The system according to claim 1, characterized in that, The script source code management module specifically includes: Remove comments and extra whitespace from Groovy script source code using regular expressions; The GroovyCodeAnalyzer is invoked to perform syntax analysis, and the syntax correctness is checked through the AST parser. Verify that the script class implements the ExtensionProcess interface and contains the necessary process method; Automatically add standardized wrappers to encapsulate user scripts into complete class definitions, and add necessary import statements and package declarations; Calculate the SHA256 hash value of the source code as the script's unique identifier.

3. The system according to claim 1, characterized in that, Dynamic compilation engines specifically include: Check the compilation cache and construct the format of the cache keys; Search for the compiled class in the ConcurrentHashMap cache. If the cache is hit and the timestamp is valid, return the cached result directly. If the cache is not hit, create a separate GroovyClassLoader instance and configure the compilation parameters, including character encoding, debugging information, target JVM version, and classpath settings. Perform the compilation operation, and verify the validity of the class after compilation. The compilation results are stored in a cache, and the compilation timestamp, access count, and source code hash value are recorded. When the cache capacity exceeds the limit, the LRU algorithm is used to automatically evict the least recently used compilation result.

4. The system according to claim 1, characterized in that, The intelligent cache manager specifically includes: Use ConcurrentHashMap to implement a thread-safe cache for compilation results; A unique cache identifier is generated based on the source code hash value and version information; The LRU eviction policy is adopted, and when the cache capacity reaches the threshold, the least recently used compilation result is automatically evicted. Implement a cache preheating mechanism to preload the compilation results of commonly used scripts at startup; Integrate Redis to enable cross-node sharing of compilation results.

5. The system according to claim 1, characterized in that, The exception handling and recovery system specifically includes: Create an ExceptionHandler exception handler and a RecoveryManager recovery manager before the script is executed; Perform a pre-processing state check to verify the validity of input parameters and the availability of system resources, and create a backup snapshot of the execution context; During script execution, the exception monitor continuously monitors the execution status, captures various exceptions, and classifies and processes them according to predefined rules. For recoverable exceptions, a retry mechanism is initiated, with a maximum of 3 retries, restoring the initial state before each retry. For fatal exceptions, execution is immediately stopped and a rollback process is triggered to restore the system to its stable state before execution.

6. The system according to claim 1, characterized in that, The hot update controller specifically includes: Perform compatibility checks on the new version of the script; this includes interface compatibility, dependency checks, and backward compatibility verification. A double buffering mechanism is adopted to prepare new script instances but not replace them immediately. Switching is performed according to a preset time, and version history is maintained, including version number, update time, change description, and rollback point information. When a problem is detected in the new version, the rollback mechanism is automatically triggered to restore the previous stable version, and the rollback event and reason are recorded.

7. The system according to claim 1, characterized in that, The system also includes a data backup and fast recovery module, including: Perform a deep copy backup of the input parameters before the script is executed; Incremental backups are performed on key intermediate results during script execution; Use the LZ4 compression algorithm to reduce the storage space for backup data; Data recovery using memory-mapped file technology.

8. The system according to claim 1, characterized in that, The system also includes a status check and data integrity verification module, including: Before the script is executed, verify the completeness, correctness of the format, and compliance with business rules of the input parameters; Monitor the script execution status in real time during script execution; After the script is executed, check the data type, business constraints, and integrity requirements of the output results; Data consistency is verified by comparing hash values ​​and statistically analyzing data volume.

9. The system according to claim 1, characterized in that, The system also includes an interruption point recovery module, which includes: Set checkpoints at key nodes in script execution to save execution status, variable values, and execution location information; It supports resuming execution from any checkpoint and verifies the correctness of the state and the consistency of the data after resuming execution.

10. A method for implementing a Groovy-based dynamic script compilation and hot update system, implemented in the system described in any one of claims 1-9, characterized in that, The implementation method includes: Script preprocessing and verification: Receive Groovy script source code, perform preprocessing and verification, and generate script identifiers; Intelligent compilation and cache management: The dynamic compilation engine performs compilation operations based on script identifiers, retrieves or executes new compilation processes from the cache, and ensures that the compiled classes conform to predefined interface specifications and instantiation requirements; the intelligent cache manager receives the compilation results, manages the cache according to the caching strategy, and provides cached compilation results for script execution; Exception handling and recovery: Monitor the execution status during script execution, capture exceptions, and initiate the recovery process; Hot update and version management: During the hot update process, the hot update controller performs version control based on the script identifier to ensure the correct switching between old and new versions, and obtains or updates the cached compilation results.

Citation Information

Cited By

  • Hot update method, system and equipment for automation program of semiconductor equipment and medium

    CN121349498A

  • System and method for real-time hot loading and dynamic recombination of micro-service component

    CN122053377A

  • Interface verification method and system based on script hot update and program product

    CN122331924A

  • An intelligent data integration and variable derivation system

    CN122363690A