Method, device and equipment for obtaining application configuration file
By switching between local cache and network shared cache, reading and persisting configuration files, the problem of applications that cannot obtain configuration files when the distributed configuration center service is unavailable is solved, ensuring high availability of applications in the cloud environment and function normally.
Patent Information
- Application Number
- CN202210109395.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-01-28
- Publication Date
- 2025-01-10
- Estimated Expiration
- 2042-01-28
AI Technical Summary
When the distributed configuration center service is unavailable, the application cannot obtain the configuration file, especially in a cloud environment, where the node server address changes lead to the loss of cache files.
By reading the active profile from the local cache, if it fails, the main version profile is read from the network share cache and persists it to ensure that the application will run properly on restart.
When the distributed configuration center service is unavailable, the persistent configuration files in the network share cache ensure that the application can be restarted and run normally, solving the problem of configuration file loss and improving high availability.
Smart Images

Figure CN114489856B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a method, device and equipment for obtaining an application configuration file. Background Art
[0002] As application functions become increasingly complex, application configurations are increasing. In the actual development process, many configuration parameters have different values in different environments, such as switch configurations and service addresses, which makes management difficult. The development of applications requires a dedicated configuration management system to achieve centralized management of parameters and separation of program and configuration parameters, and a distributed configuration center came into being.
[0003] In traditional technology, after the application is started, the configuration file is obtained from the distributed configuration center and cached in the local file system. The cached configuration file is identified by the node server address corresponding to the application. When the distributed configuration center service is unavailable, the application searches for the corresponding configuration file in the local cache through the node server address after restarting.
[0004] However, nodes in a distributed environment are stateless, and the corresponding node server address may change after the application is restarted, resulting in the inability to obtain the required configuration file through the node server address. Summary of the invention
[0005] The present application provides a method, apparatus and device for obtaining an application configuration file, so as to solve the problem that the application cannot obtain the configuration file when the distributed configuration center service is unavailable.
[0006] In a first aspect, the present application provides a method for obtaining an application configuration file, comprising:
[0007] In response to a configuration instruction for a target application, reading an effective configuration file from a local cache corresponding to the target application, the effective configuration file representing a configuration file obtained from a distributed configuration center and cached in the local cache;
[0008] If reading the effective configuration file from the local cache fails, reading the main version configuration file from the network shared cache corresponding to the target application;
[0009] If the main version configuration file is read from the network shared cache, the target application is run based on the main version configuration file read from the network shared cache.
[0010] In a second aspect, the present application provides a device for obtaining an application configuration file, comprising:
[0011] A first reading unit, configured to read an effective configuration file from a local cache corresponding to a target application in response to a configuration instruction for the target application, wherein the effective configuration file represents a configuration file obtained from a distributed configuration center and cached in the local cache;
[0012] A second reading unit is configured to read a main version configuration file from a network shared cache corresponding to the target application program if reading the effective configuration file from the local cache fails;
[0013] The running unit is configured to run the target application based on the main version configuration file read from the network shared cache if the main version configuration file is read from the network shared cache.
[0014] In a third aspect, the present application provides an electronic device, comprising: a processor, and a memory communicatively connected to the processor; the memory stores computer-executable instructions; the processor executes the computer-executable instructions stored in the memory to implement the method described in the first aspect above.
[0015] In a fourth aspect, the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer-executable instructions, and when the computer-executable instructions are executed by a processor, they are used to implement the method described in the first aspect above.
[0016] In a fifth aspect, the present application provides a computer program product, including a computer program, which, when executed by a processor, implements the method described in the first aspect above.
[0017] The application configuration file acquisition method, device and equipment provided in the present application respond to the configuration instruction for the target application, read the effective configuration file from the local cache corresponding to the target application, and the effective configuration file represents the configuration file obtained from the distributed configuration center and cached in the local cache; if the effective configuration file fails to be read from the local cache, the main version configuration file is read from the network shared cache corresponding to the target application; if the main version configuration file is read from the network shared cache, the target application is run based on the main version configuration file read from the network shared cache. Among them, the data in the network shared cache is stored in a persistent type and will not be destroyed when the application is restarted. The main version configuration file is persisted in the network shared cache. When the application is restarted in a cloud environment and cannot connect to the service of the distributed configuration center, the main version configuration file in the network shared cache can be read as the configuration file of the application, thereby ensuring the normal restart of the application. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0019] Figure 1 A schematic diagram of a persistent local storage configuration shown in an exemplary embodiment;
[0020] Figure 2 A schematic diagram of a flow chart of a method for obtaining an application configuration file according to an exemplary embodiment;
[0021] Figure 3 A schematic diagram of a configuration file cache is shown as an exemplary embodiment;
[0022] Figure 4 A schematic flow chart of a method for obtaining an application configuration file shown in another exemplary embodiment;
[0023] Figure 5 A schematic flow chart of a method for obtaining an application configuration file shown in another exemplary embodiment;
[0024] Figure 6 A schematic flow chart of a method for obtaining an application configuration file shown in another exemplary embodiment;
[0025] Figure 7 A schematic diagram of a flow chart of a method for obtaining an application configuration file according to an exemplary embodiment;
[0026] Figure 8 A schematic diagram of the structure of an application configuration file acquisition device shown in an exemplary embodiment;
[0027] Fig. 9 A schematic diagram of the structure of an apparatus for obtaining an application configuration file is shown as another exemplary embodiment;
[0028] Fig.10 is a schematic structural diagram of an electronic device in an exemplary embodiment;
[0029] Fig.11 is a block diagram of an electronic device in an exemplary embodiment.
[0030] The above drawings have shown clear embodiments of the present application, which will be described in more detail later. These drawings and text descriptions are not intended to limit the scope of the present application in any way, but to illustrate the concept of the present application to those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION
[0031] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application. Instead, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.
[0032] First, the terms involved in this application are explained:
[0033] PaaS: Platform as a Service, Platform as a Service, refers to a business model that provides the operation and development environment of application services as services. As an application-centric platform, the application foundation cloud (PaaS) is generally divided into two major parts: container cloud platform and cloud management cloud platform, providing a one-stop complete distributed application system development, operation and support platform for containerized applications running across machines.
[0034] PVC: Persistent Volume Claim, which is used to manage external storage resources. If the application system has NAS (Network Attached Storage) storage requirements, you need to apply for PVC to manage NAS storage.
[0035] Distributed configuration center: An application system that supports the separation of consumer programs and configuration parameters, provides centralized management and real-time push of configuration parameters, and has configuration release capabilities such as main version release and grayscale release.
[0036] The specific application scenario of this application can be a distributed configuration center client. The development of application programs requires a dedicated configuration management system to achieve centralized management of parameters and separation of programs and configurations during service construction. The reasons are as follows: First, as program functions become increasingly complex, program configurations increase, making management more difficult; second, in the actual development process, many configurations have different values in different environments, such as switch configurations, service addresses, etc., which also increases management difficulty. Distributed configuration centers came into being, and their high availability is becoming more and more important.
[0037] Application Foundation Cloud PaaS has functions such as image management, rapid integration and release, application automation release, middleware rapid release, elastic scaling, health check, etc. More and more applications are deployed to PaaS. High-availability solutions need to adapt to PaaS cloud scenarios. To enhance the high availability of configuration acquisition, the distributed configuration center client will cache the configuration in the local cache file after starting to obtain it. When the distributed configuration center service is unavailable, the client can restart to obtain the configuration from the local cache file, thereby ensuring high availability.
[0038] For clients deployed on PaaS, local cache files are stored inside the Pod by default and are uniquely identified by PodName. The file storage has the same life cycle as the Pod. After the Pod is stopped or destroyed, the file storage no longer exists and loses its original function.
[0039] In one example, you can use PVC to declare the required persistent storage type and size to the platform to persist application data and prevent it from being destroyed when the Pod is destroyed. Figure 1 FIG. 1 is a schematic diagram showing a persistent local storage configuration according to an exemplary embodiment. Figure 1 As shown in the figure, one or more Pods are running on the node (Node), and different Pods cache configurations in the NAS shared storage. After the Pod is restarted, the PodName changes. At this time, the configuration used before the restart cannot be found through the PodName.
[0040] In the existing technical solution, after the application is started, the configuration file is obtained from the distributed configuration center and cached in the local file system. The cached configuration file is identified by the node server address (IP). When the distributed configuration center service is unavailable, the application will search for the corresponding cache file through the IP after restarting.
[0041] However, the existing technical solution is not applicable to PaaS cloud scenarios. Under the existing solution, the configuration file is stored on the server as a local file, but the Pod node on the cloud is stateless, and the IP may change after restarting. The original Pod cache file cannot be found through the IP. In addition, the Pod resource server is destroyed and rebuilt with the restart of the application, resulting in the loss of the configuration file stored in the Pod server, so the configuration file cannot be obtained.
[0042] The application configuration file acquisition method, device and equipment provided in this application are intended to solve the above technical problems in the prior art.
[0043] The technical solution of the present application and how the technical solution of the present application solves the above-mentioned technical problems are described in detail below with specific embodiments. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present application will be described below in conjunction with the accompanying drawings.
[0044] Figure 2 FIG. 1 is a flow chart of a method for obtaining an application configuration file according to an exemplary embodiment. Figure 2 As shown, the method includes:
[0045] S201, in response to a configuration instruction for a target application, reading an effective configuration file from a local cache corresponding to the target application, where the effective configuration file represents a configuration file obtained from a distributed configuration center and cached in the local cache.
[0046] This embodiment is introduced with the execution subject being a distributed configuration center client.
[0047] The target application is the application for which the configuration file is to be obtained, and the configuration instruction is used to trigger the execution of obtaining the configuration file. Optionally, the user starts the target application through the distributed configuration center client to initiate the configuration instruction for the target application. After receiving the configuration instruction, the client reads the effective configuration file from the local cache corresponding to the target application.
[0048] Figure 3 This is a schematic diagram of configuration file caching according to an exemplary embodiment. The client sends a configuration request to the distributed configuration center server to request the configuration file of application 1; after receiving the configuration request, the distributed configuration center server returns a configuration response to the client, which includes the effective configuration file of application 1; after the client pulls the effective configuration file of application 1, it caches the effective configuration file of application 1 in the local cache inside the Pod, and caches the main version configuration in the network shared cache (NAS).
[0049] Exemplarily, if application 1 is a grayscale instance, the effective configuration file of application 1 pulled by the client from the distributed configuration center server is a grayscale configuration file; if application 1 is a master version instance, the effective configuration file of application 1 pulled by the client from the distributed configuration center server is a master version configuration file.
[0050] S202: If reading the effective configuration file from the local cache fails, then reading the main version configuration file from the network shared cache corresponding to the target application.
[0051] The client fails to read the effective configuration file from the local cache, that is, the client cannot obtain the configuration file of the target application from the local cache. This may be because the target application is restarted, resulting in the loss of the file in the local cache corresponding to the target application.
[0052] If the client fails to read the effective configuration file from the local cache, it reads the main version configuration file from the network shared cache corresponding to the target application. The main version configuration file in the network shared cache represents the main version configuration file obtained from the distributed configuration center and cached in the network shared cache. The data in the network shared cache is stored in a persistent type and will not be lost when the target application is restarted. Therefore, after the main version configuration file obtained from the distributed configuration center is cached in the network shared cache, even if the target application is restarted, the main version configuration file can be obtained from the network shared cache corresponding to the target application.
[0053] S203: If the main version configuration file is read from the network shared cache, the target application is run based on the main version configuration file read from the network shared cache.
[0054] Exemplarily, the master version configuration file of the target application may be updated. If the configuration is updated, the updated master version configuration file is stored in the network shared cache. The client reads the latest stored master version configuration file from the network shared cache and runs the target application based on the latest stored master version configuration file read from the network shared cache.
[0055] In this embodiment, in response to the configuration instruction for the target application, the effective configuration file is read from the local cache corresponding to the target application, and the effective configuration file represents the configuration file obtained from the distributed configuration center and cached in the local cache; if the reading of the effective configuration file from the local cache fails, the main version configuration file is read from the network shared cache corresponding to the target application; if the main version configuration file is read from the network shared cache, the target application is run based on the main version configuration file read from the network shared cache. Among them, the data in the network shared cache is stored in a persistent type and will not be destroyed when the application is restarted. The main version configuration file is persisted in the network shared cache. When the application is restarted in a cloud environment and cannot connect to the service of the distributed configuration center, the main version configuration file in the network shared cache can be read as the configuration file of the application, thereby ensuring the normal restart of the application.
[0056] Figure 4 FIG. 1 is a flow chart of a method for obtaining an application configuration file according to an exemplary embodiment. Figure 4 As shown, the method includes:
[0057] S401 , in response to a configuration instruction for a target application, detecting whether the target application is in a local mode.
[0058] The distributed configuration center provides local mode configuration items. When the application is in local mode, it can read the configuration file directly from the cache file without trying to access the distributed configuration center server. After the client receives the configuration instructions for the target application, it first determines whether the application is in local mode.
[0059] S402, when the target application is in local mode, reading an effective configuration file from a local cache corresponding to the target application.
[0060] When the client determines that the target application is in local mode, it directly reads the effective configuration file from the local cache corresponding to the target application.
[0061] Exemplarily, the implementation of reading the effective configuration file from the local cache corresponding to the target application in step S402 is similar to the implementation of reading the effective configuration file from the local cache corresponding to the target application in step S201, which will not be repeated here.
[0062] S403: If reading the effective configuration file from the local cache fails, then reading the main version configuration file from the network shared cache corresponding to the target application.
[0063] Exemplarily, the implementation of step S403 is similar to that of step S202, and will not be described in detail here.
[0064] S404: If the main version configuration file is read from the network shared cache, the target application is run based on the main version configuration file read from the network shared cache.
[0065] Exemplarily, the implementation of step S404 is similar to that of step S203 and will not be described in detail here.
[0066] S405: storing the main version configuration file read from the network shared cache as the effective configuration file in the local cache.
[0067] After the client reads the main version configuration file from the network shared cache, it stores the main version configuration file read from the network shared cache as the effective configuration file in the local cache corresponding to the target application, so that the effective configuration file can be read from the local cache corresponding to the target application at this time.
[0068] Figure 5 FIG. 1 is a flow chart of a method for obtaining an application configuration file according to an exemplary embodiment. Figure 5 As shown, the method includes:
[0069] S501 , in response to a configuration instruction for a target application, detecting whether the target application is in a local mode.
[0070] Exemplarily, the implementation of step S501 is similar to that of step S401 and will not be described in detail here.
[0071] S502: When the target application is in a non-local mode, obtain a valid configuration file corresponding to the target application from a distributed configuration center.
[0072] When the client determines that the target application is in non-local mode, it obtains the effective configuration file corresponding to the target application from the distributed configuration center. Exemplarily, if the target application is a grayscale instance, the effective configuration file corresponding to the target application obtained by the client from the distributed configuration center server is a grayscale configuration file; if the target application is a master version instance, the effective configuration file corresponding to the target application obtained by the client from the distributed configuration center server is a master version configuration file.
[0073] S503: If the acquisition of the effective configuration file corresponding to the target application from the distributed configuration center fails, the effective configuration file is read from the local cache corresponding to the target application.
[0074] The client fails to obtain the effective configuration file corresponding to the target application from the distributed configuration center, that is, the client cannot obtain the effective configuration file corresponding to the target application from the distributed configuration center, indicating that the distributed configuration center server is unavailable at this time. When the distributed configuration center server is unavailable, the client reads the effective configuration file from the local cache corresponding to the target application.
[0075] Exemplarily, the implementation of reading the effective configuration file from the local cache corresponding to the target application in step S503 is similar to the implementation of reading the effective configuration file from the local cache corresponding to the target application in step S201, which will not be repeated here.
[0076] S504: If reading the effective configuration file from the local cache fails, then reading the main version configuration file from the network shared cache corresponding to the target application.
[0077] Exemplarily, the implementation of step S504 is similar to that of step S202 and will not be described in detail here.
[0078] S505: If the main version configuration file is read from the network shared cache, the target application is run based on the main version configuration file read from the network shared cache.
[0079] Exemplarily, the implementation of step S505 is similar to that of step S203 and will not be described in detail here.
[0080] S506: The main version configuration file read from the network shared cache is stored in the local cache as the effective configuration file.
[0081] Exemplarily, the implementation of step S506 is similar to that of step S405 and will not be described in detail here.
[0082] Figure 6 FIG. 1 is a flow chart of a method for obtaining an application configuration file according to an exemplary embodiment. Figure 6 As shown, the method includes:
[0083] S601 , in response to a configuration instruction for a target application, detecting whether the target application is in a local mode.
[0084] Exemplarily, the implementation of step S601 is similar to that of step S401 and will not be described in detail here.
[0085] S602, when the target application is in non-local mode, obtaining an effective configuration file corresponding to the target application from a distributed configuration center.
[0086] Exemplarily, the implementation of step S602 is similar to that of step S502 and will not be described in detail here.
[0087] S603: If the effective configuration file corresponding to the target application is obtained from the distributed configuration center, the target application is run based on the effective configuration file obtained from the distributed configuration center.
[0088] The client obtains the effective configuration file corresponding to the target application from the distributed configuration center, indicating that the distributed configuration center server is available at this time. After the client obtains the effective configuration file corresponding to the target application from the distributed configuration center, it runs the target application based on the effective configuration file obtained from the distributed configuration center.
[0089] S604: If the effective configuration file obtained from the distributed configuration center includes a grayscale configuration file, a main version configuration file corresponding to the target application is obtained from the distributed configuration center.
[0090] Grayscale configuration refers to the distribution of new configurations to a specified part of clients, while the configurations of other clients remain unchanged, in order to verify the impact of the new configuration on the clients and ensure the smooth release of the configuration.
[0091] The effective configuration files obtained by the client from the distributed configuration center include grayscale configuration files, indicating that the target application running on the client is a grayscale instance. At this time, the client continues to obtain the main version configuration file corresponding to the target application from the distributed configuration center.
[0092] S605, if the main version configuration file corresponding to the target application is obtained from the distributed configuration center, the effective configuration file cached in the local cache is updated according to the update status of the effective configuration file obtained from the distributed configuration center, and the main version configuration file cached in the network shared cache is updated according to the update status of the main version configuration file obtained from the distributed configuration center.
[0093] The update status of the effective configuration file includes two states, one of which indicates that the effective configuration file has a configuration update, and the other indicates that the effective configuration file has no configuration update. The update status of the main version configuration file includes two states, one of which indicates that the main version configuration file has a configuration update, and the other indicates that the main version configuration file has no configuration update.
[0094] In one example, the effective configuration file cached in the local cache is updated according to the update status of the effective configuration file obtained from the distributed configuration center, including: if the update status of the effective configuration file obtained from the distributed configuration center indicates that there is a configuration update, the effective configuration file obtained from the distributed configuration center is stored in the local cache.
[0095] If the client determines that there is a configuration update in the effective configuration file based on the update status of the effective configuration file obtained from the distributed configuration center, the effective configuration file obtained by the client from the distributed configuration center is the updated effective configuration file. The client stores the updated effective configuration file in the local cache to update the effective configuration file in the local cache corresponding to the target application, so that the subsequent client can read the latest effective configuration file from the local cache.
[0096] In one example, the master version configuration file cached in the network shared cache is updated according to the update status of the master version configuration file obtained from the distributed configuration center, including: if the update status of the master version configuration file obtained from the distributed configuration center indicates that there is a configuration update, the master version configuration file obtained from the distributed configuration center is stored in the network shared cache.
[0097] If the client determines that there is a configuration update for the main version configuration file based on the update status of the main version configuration file obtained from the distributed configuration center, the main version configuration file obtained by the client from the distributed configuration center is the updated main version configuration file. The client stores the updated main version configuration file in the network shared cache to update the main version configuration file in the network shared cache, so that subsequent clients can read the latest main version configuration file from the network shared cache.
[0098] In the above embodiment, when there is a grayscale configuration file, the client obtains the main version configuration file from the distributed configuration center server and caches it in the network shared cache. When the distributed configuration center service is unavailable, the application deployed on the cloud can complete the configuration update by modifying the cache file in the network shared cache and restarting.
[0099] S606: If the effective configuration file obtained from the distributed configuration center does not include a grayscale configuration file, the effective configuration file obtained from the distributed configuration center is stored in the local cache, and the effective configuration file obtained from the distributed configuration center is stored as a main version configuration file in the network shared cache.
[0100] The effective configuration file obtained by the client from the distributed configuration center does not include the grayscale configuration file, indicating that the target application running on the client is not a grayscale instance. In this case, the effective configuration file obtained by the client from the distributed configuration center is the main version configuration file.
[0101] Optionally, if there is a configuration update in the effective configuration file obtained by the client from the distributed configuration center, the effective configuration file obtained from the distributed configuration center is stored in the local cache, and the effective configuration file obtained from the distributed configuration center is stored as the main version configuration file in the network shared cache.
[0102] Optionally, if the effective configuration file obtained by the client from the distributed configuration center has no configuration update, the effective configuration file obtained from the distributed configuration center will be stored as the main version configuration file in the network shared cache, and the effective configuration file obtained from the distributed configuration center can be further stored in the local cache at the same time.
[0103] Figure 7 FIG. 1 is a flow chart of a method for obtaining an application configuration file according to an exemplary embodiment. Figure 7 As shown, the method includes:
[0104] Step 1, determine whether the target application is in local mode, if so, execute steps 2 to 5; if not, proceed to step 6;
[0105] Step 2: read the effective configuration file from the local cache (POD) corresponding to the target application. If it fails, go to step 3;
[0106] Step 3, read the latest master version configuration file from the network shared cache (NAS) corresponding to the target application. If successful, proceed to step 4;
[0107] Step 4: Determine that the effective configuration file is equal to the main version configuration file;
[0108] Step 5: Cache the effective configuration file into the POD;
[0109] Step 6: Obtain the effective configuration file corresponding to the target application from the distributed configuration center. If it fails, execute steps 2 to 5; if it succeeds, proceed to step 7;
[0110] Step 7, determine whether there is a configuration update in the effective configuration file, if yes, execute steps 8 to 14; if no, execute steps 15 to 20;
[0111] Step 8, determining whether the effective configuration file includes a grayscale configuration file, if so, executing steps 9 to 12; if not, executing steps 13 to 14;
[0112] Step 9: Obtain the main version configuration file corresponding to the target application from the distributed configuration center;
[0113] Step 10, determine whether the main version configuration file has a configuration update, if yes, execute steps 11 to 12; if no, execute step 12;
[0114] Step 11, cache the main version configuration file to NAS;
[0115] Step 12: Cache the effective configuration file into the POD;
[0116] Step 13, determine that the main version configuration file is equal to the effective configuration file, and cache the main version configuration file to the NAS;
[0117] Step 14: Cache the effective configuration file into the POD;
[0118] Step 15, determining whether the effective configuration file includes a grayscale configuration file, if so, executing steps 16 to 18; if not, executing steps 19 to 20;
[0119] Step 16, obtaining the main version configuration file corresponding to the target application from the distributed configuration center;
[0120] Step 17, determine whether the main version configuration file has a configuration update, if so, execute step 18;
[0121] Step 18, cache the main version configuration file to NAS;
[0122] Step 19, determine that the main version configuration file is equal to the effective configuration file, and cache the main version configuration file to the NAS;
[0123] Step 20: Cache the effective configuration file inside the POD.
[0124] In the above embodiment, NAS can be mounted based on PaaS PVC, and the main version configuration file can be persisted in the NAS device to ensure that when the Pod is restarted in the cloud environment and cannot connect to the service of the distributed configuration center, the normal restart of the service is ensured by reading the configuration information stored in the NAS. Based on this, an emergency plan can be provided for cloud applications when the distributed configuration center is unavailable, and a solution for emergency configuration of cloud applications can be provided; it is also applicable to traditional server environments, has scalability, and realizes the unification of high-availability solutions under and on the cloud; it can also support direct modification of configuration data in the NAS configuration file in emergency scenarios, which is simple and efficient.
[0125] Figure 8 is a schematic diagram of a structure of an application configuration file acquisition device according to an exemplary embodiment. The device can be a software module or a hardware module, or a combination of the two to form a part of a computer device, such as Figure 8 As shown, the device 800 includes:
[0126] A first reading unit 810 is configured to read an effective configuration file from a local cache corresponding to a target application in response to a configuration instruction for the target application, where the effective configuration file represents a configuration file obtained from a distributed configuration center and cached in the local cache;
[0127] The second reading unit 820 is configured to read the main version configuration file from the network shared cache corresponding to the target application program if reading the effective configuration file from the local cache fails;
[0128] The running unit 830 is configured to run the target application based on the main version configuration file read from the network shared cache if the main version configuration file is read from the network shared cache.
[0129] Fig. 9 is a schematic diagram of a structure of an apparatus for obtaining an application configuration file according to an exemplary embodiment. Figure 8 Based on the illustrated embodiment, the device 900 further includes:
[0130] The detection unit 840 is used to detect whether the target application is in the local mode before reading the effective configuration file from the local cache corresponding to the target application.
[0131] In an example, when the first reading unit 810 reads the effective configuration file from the local cache corresponding to the target application, it is specifically used to: when the target application is in local mode, read the effective configuration file from the local cache corresponding to the target application.
[0132] In one example, the apparatus 900 further includes:
[0133] The acquisition unit 850 is used to acquire a valid configuration file corresponding to the target application from the distributed configuration center when the target application is in a non-local mode;
[0134] When the first reading unit 810 reads the effective configuration file from the local cache corresponding to the target application, it is specifically used to: if the effective configuration file corresponding to the target application fails to be obtained from the distributed configuration center, then read the effective configuration file from the local cache corresponding to the target application.
[0135] In one example, the apparatus 900 further includes:
[0136] The storage unit 860 is used to store the main version configuration file read from the network shared cache as an effective configuration file in the local cache.
[0137] In one example, the running unit 830 is further used to: if a valid configuration file corresponding to the target application is obtained from the distributed configuration center, run the target application based on the valid configuration file obtained from the distributed configuration center.
[0138] In one example, the acquisition unit 850 is further configured to: if the effective configuration file acquired from the distributed configuration center includes a grayscale configuration file, then acquire a main version configuration file corresponding to the target application from the distributed configuration center; the device 900 also includes:
[0139] The update unit 870 is used to update the effective configuration file cached in the local cache according to the update status of the effective configuration file obtained from the distributed configuration center if the main version configuration file corresponding to the target application is obtained from the distributed configuration center, and to update the main version configuration file cached in the network shared cache according to the update status of the main version configuration file obtained from the distributed configuration center.
[0140] In one example, the update unit 870 is specifically used to: if the update status representation of the effective configuration file obtained from the distributed configuration center indicates that there is a configuration update, then the effective configuration file obtained from the distributed configuration center is stored in the local cache; if the update status representation of the main version configuration file obtained from the distributed configuration center indicates that there is a configuration update, then the main version configuration file obtained from the distributed configuration center is stored in the network shared cache.
[0141] In one example, the update unit 870 is also used to: if the effective configuration file obtained from the distributed configuration center does not include a grayscale configuration file, then the effective configuration file obtained from the distributed configuration center is stored in the local cache, and the effective configuration file obtained from the distributed configuration center is stored as a main version configuration file in the network shared cache.
[0142] Fig.10 It is a structural diagram of an electronic device according to an exemplary embodiment, the electronic device includes: a processor 1001, and a memory 1002 communicatively connected to the processor 1001; the memory 1002 stores computer-executable instructions; the processor 1001 executes the computer-executable instructions stored in the memory 1002 to implement the application configuration file acquisition method provided in the above embodiment.
[0143] The electronic device further includes a receiver 1003 and a transmitter 1004. The receiver 1003 is used to receive instructions and data sent by an external device, and the transmitter 1004 is used to send instructions and data to the external device.
[0144] Fig.11 It is a block diagram of a terminal device according to an exemplary embodiment. The device may be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, a fitness device, a personal digital assistant, etc.
[0145] Device 1100 may include one or more of the following components: a processing component 1102 , a memory 1104 , a power component 1106 , a multimedia component 1108 , an audio component 1110 , an input / output (I / O) interface 1112 , a sensor component 1114 , and a communication component 1116 .
[0146] The processing component 1102 generally controls the overall operation of the device 1100, such as operations associated with display, phone calls, data communications, camera operations, and recording operations. The processing component 1102 may include one or more processors 1120 to execute instructions to perform all or part of the steps of the above-described method. In addition, the processing component 1102 may include one or more modules to facilitate interaction between the processing component 1102 and other components. For example, the processing component 1102 may include a multimedia module to facilitate interaction between the multimedia component 1108 and the processing component 1102.
[0147] The memory 1104 is configured to store various types of data to support the operation of the device 1100. Examples of such data include instructions for any application or method operating on the device 1100, contact data, phone book data, messages, pictures, videos, etc. The memory 1104 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.
[0148] The power supply component 1106 provides power to the various components of the device 1100. The power supply component 1106 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to the device 1100.
[0149] The multimedia component 1108 includes a screen that provides an output interface between the device 1100 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundaries of the touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 1108 includes a front camera and / or a rear camera. When the device 1100 is in an operating mode, such as a shooting mode or a video mode, the front camera and / or the rear camera may receive external multimedia data. Each front camera and rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.
[0150] The audio component 1110 is configured to output and / or input audio signals. For example, the audio component 1110 includes a microphone (MIC), and when the device 1100 is in an operating mode, such as a call mode, a recording mode, and a speech recognition mode, the microphone is configured to receive an external audio signal. The received audio signal can be further stored in the memory 1104 or sent via the communication component 1116. In some embodiments, the audio component 1110 also includes a speaker for outputting audio signals.
[0151] I / O interface 1112 provides an interface between processing component 1102 and peripheral interface modules, which may be keyboards, click wheels, buttons, etc. These buttons may include but are not limited to: a home button, a volume button, a start button, and a lock button.
[0152] The sensor assembly 1114 includes one or more sensors for providing various aspects of the status assessment of the device 1100. For example, the sensor assembly 1114 can detect the open / closed state of the device 1100, the relative positioning of components, such as the display and keypad of the device 1100, the sensor assembly 1114 can also detect the position change of the device 1100 or a component of the device 1100, the presence or absence of user contact with the device 1100, the orientation or acceleration / deceleration of the device 1100, and the temperature change of the device 1100. The sensor assembly 1114 can include a proximity sensor configured to detect the presence of a nearby object without any physical contact. The sensor assembly 1114 can also include an optical sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 1114 can also include an accelerometer, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
[0153] The communication component 1116 is configured to facilitate wired or wireless communication between the device 1100 and other devices. The device 1100 can access a wireless network based on a communication standard, such as WiFi, 2G or 3G, or a combination thereof. In an exemplary embodiment, the communication component 1116 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 1116 also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technologies.
[0154] In an exemplary embodiment, the device 1100 can be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors or other electronic components to perform the above methods.
[0155] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 1104 including instructions, and the instructions can be executed by the processor 1120 of the device 1100 to perform the above method. For example, the non-transitory computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.
[0156] An embodiment of the present application also provides a non-temporary computer-readable storage medium. When the instructions in the storage medium are executed by a processor of a computer device, the computer device is enabled to execute the method provided in any of the above embodiments.
[0157] An embodiment of the present invention also provides a computer program product, which includes: a computer program, the computer program is stored in a readable storage medium, at least one processor of a computer device can read the computer program from the readable storage medium, and at least one processor executes the computer program so that the computer device executes the method provided in any of the above embodiments.
[0158] It should be understood that the terms "first", "second", etc. in the above embodiments are only used for descriptive purposes and cannot be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. In addition, in the description of this application, unless otherwise specified, the meaning of "multiple" refers to at least two.
[0159] Those skilled in the art will readily appreciate other embodiments of the present application after considering the specification and practicing the invention disclosed herein. The present application is intended to cover any modification, use or adaptation of the present application, which follows the general principles of the present application and includes common knowledge or customary techniques in the art that are not disclosed in the present application. The specification and examples are intended to be exemplary only, and the true scope and spirit of the present application are indicated by the following claims.
[0160] It should be understood that the present application is not limited to the precise structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present application is limited only by the appended claims.
Claims
1. A method for obtaining an application configuration file, characterized in that: The method comprises: In response to a configuration instruction for a target application, detecting whether the target application is in local mode, and when the target application is in local mode, reading an effective configuration file from a local cache corresponding to the target application, wherein the effective configuration file represents a configuration file obtained from a distributed configuration center and cached to the local cache; wherein the target application is deployed on an application base cloud; If reading the effective configuration file from the local cache fails, then reading the main version configuration file from the network shared cache corresponding to the target application; wherein the main version configuration file in the network shared cache is the main version configuration file obtained from the distributed configuration center and cached to the network shared cache, and the data in the network shared cache is stored in a persistent type; If the main version configuration file is read from the network shared cache, running the target application based on the main version configuration file read from the network shared cache; When the target application is in non-local mode, obtaining a valid configuration file corresponding to the target application from the distributed configuration center; if obtaining the valid configuration file corresponding to the target application from the distributed configuration center fails, reading the valid configuration file from the local cache corresponding to the target application; if reading the valid configuration file from the local cache fails, reading the main version configuration file from the network shared cache corresponding to the target application; if obtaining the valid configuration file corresponding to the target application from the distributed configuration center, running the target application based on the valid configuration file obtained from the distributed configuration center; If the effective configuration file obtained from the distributed configuration center includes a grayscale configuration file, obtaining a main version configuration file corresponding to the target application from the distributed configuration center; If the master version configuration file corresponding to the target application is obtained from the distributed configuration center, the effective configuration file cached in the local cache is updated according to the update status of the effective configuration file obtained from the distributed configuration center, and the master version configuration file cached in the network shared cache is updated according to the update status of the master version configuration file obtained from the distributed configuration center; If the distributed configuration center service is unavailable, the target application deployed on the cloud completes the configuration update by modifying the cache file in the network shared cache and then restarting. The cache file includes the main version configuration file.
2. The method according to claim 1, characterized in that: Also includes: The main version configuration file read from the network shared cache is stored in the local cache as an effective configuration file.
3. The method according to claim 1, characterized in that According to the update status of the effective configuration file obtained from the distributed configuration center, the effective configuration file cached in the local cache is updated, and according to the update status of the main version configuration file obtained from the distributed configuration center, the main version configuration file cached in the network shared cache is updated, including: If the update status of the effective configuration file obtained from the distributed configuration center indicates that there is a configuration update, storing the effective configuration file obtained from the distributed configuration center in the local cache; If the update status of the main version configuration file obtained from the distributed configuration center indicates that there is a configuration update, the main version configuration file obtained from the distributed configuration center is stored in the network shared cache.
4. The method according to claim 1, characterized in that: Also includes: If the effective configuration file obtained from the distributed configuration center does not include a grayscale configuration file, the effective configuration file obtained from the distributed configuration center is stored in the local cache, and the effective configuration file obtained from the distributed configuration center is stored as a main version configuration file in the network shared cache.
5. An electronic device comprising: A processor, and a memory communicatively connected to the processor; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory to implement the method according to any one of claims 1 to 4.
Citation Information
Patent Citations
Distributed configuration management method and device and system for realization of distributed configuration management
CN107483250A
Cloud application deployment method, device and system
CN112698847A