Resource-dependent state query method and device, storage medium, and electronic device

By calling the resource validator and metadata queryer to automatically query the dependent resource status of the database instance, the problem of low efficiency of manual query is solved, and efficient resource status verification is achieved.

CN115344754BActive Publication Date: 2025-11-04BEIJING KINGSOFT CLOUD NETWORK TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210981993.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-08-16
Publication Date
2025-11-04
Estimated Expiration
2042-08-16

AI Technical Summary

Technical Problem

In existing technologies, status queries that depend on resources can only be performed manually, resulting in low query efficiency.

Method used

By calling the resource verifier and metadata queryer corresponding to the database service name, the database instance is queried to find instance information that matches the target scene identifier, the target identifier is determined, and the resource queryer is called to obtain resource data for verification, and finally the verification result is displayed.

Benefits of technology

It improves the efficiency of querying resource status and enables automated and efficient resource status verification.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115344754B_ABST
    Figure CN115344754B_ABST
Patent Text Reader

Abstract

The application discloses a resource-dependent state query method and device, a storage medium and electronic equipment. The method comprises the following steps: in the case that the target information is acquired, a metadata queryer is called by calling a resource verifier corresponding to a database service name to query instance information matched with a target scene mark; a target mark contained in the instance information is determined, wherein the target mark is the mark of target data matched with the target scene mark in the dependent data of the database instance; a resource queryer matched with the database service name is called to obtain resource data corresponding to each target mark; the resource data is verified to obtain a verification result of the resource data; and the verification result is displayed, wherein the verification result is used to represent the state of the resource data. The application solves the technical problem of low efficiency in querying the state of the dependent resource caused by manual query of the state of the dependent resource.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the field of computers, and in particular, to a dependent resource state query method and device, a storage medium, and an electronic device. BACKGROUND

[0002] The creation and deletion of a database instance is associated with the creation and deletion of its dependent resources, so when verifying the creation and deletion of database resources, the creation and deletion of dependent resources also need to be verified. In the prior art, the creation and deletion of dependent resources can only be manually verified. The interface of each dependent service is called to query, and if the query result is obtained, it is considered that the resource is alive, and if the query result is not obtained, it is considered that the resource has been deleted. SUMMARY

[0003] Embodiments of the present application provide a dependent resource state query method and device, a storage medium, and an electronic device, to at least solve the technical problem of low efficiency in querying the state of dependent resources due to manual state query.

[0004] According to an aspect of an embodiment of the present application, a dependent resource state query method is provided, comprising: in the case of obtaining target information, calling a metadata queryer by calling a resource verifier corresponding to a database service name to query instance information of a database instance matching a target scene mark; wherein the target information includes an instance identifier of a database instance of a dependent resource to be queried, a database service name of a database to which the database instance belongs, and a target scene mark of a creation verification scene of the dependent resource; determining a target identifier contained in the instance information, wherein the target identifier is an identifier of target data in dependent data of the database instance matching the target scene mark; calling a resource queryer matched with the database service name to obtain resource data corresponding to each target identifier; verifying the resource data to obtain a verification result of the resource data; and displaying the verification result, wherein the verification result is used to indicate the state of the resource data.

[0005] According to another aspect of the embodiments of the present application, there is provided a state query device for a dependent resource, comprising: a query module configured to, in a case where target information is acquired, invoke a metadata queryer by invoking a resource verifier corresponding to a database service name, to query instance information of a database instance matching a target scenario mark; wherein the target information comprises an instance identifier of a database instance of a dependent resource to be queried, a database service name of a database to which the database instance belongs, and a target scenario mark of a creation verification scenario of the dependent resource; a determination module configured to determine a target identifier contained in the instance information, wherein the target identifier is an identifier of target data matching the target scenario mark in dependent data of the database instance; a calling module configured to call a resource queryer matching the database service name, to obtain resource data corresponding to each target identifier; a verification module configured to verify the resource data, to obtain a verification result of the resource data; and a display module configured to display the verification result, wherein the verification result is used to indicate a state of the resource data.

[0006] As an optional example, the determination module comprises: a traversal unit configured to traverse the instance information from a first character in the instance information; and a first determination unit configured to take each resource identifier traversed as the target identifier.

[0007] As an optional example, the query module comprises: a processing unit configured to take each target identifier as a current identifier, and perform the following operations: sending an acquisition request to a server corresponding to the current identifier; the acquisition request is used to request acquisition of resource data corresponding to the current identifier; and receiving resource data of the current identifier and a current sub-identifier corresponding to the current identifier returned by the server.

[0008] As an optional example, the query module comprises: a second determination unit configured to determine the resource verifier matching the database service name by using the database service name, wherein different database names correspond to different resource verifiers; an input unit configured to input the instance identifier of the database instance into the metadata queryer by using the resource verifier, and connect a database in which the database instance is located by using the metadata queryer to query information related to the instance identifier from the database; and a first encapsulation unit configured to encapsulate the information related to the instance identifier queried by using the metadata queryer into the instance information.

[0009] As an optional example, the apparatus further comprises: a listening module configured to listen to a database table in the database; an encapsulating module configured to, in a case where an instance in the database table changes, encapsulate a change message and push the change message into a message queue; and an obtaining module configured to, in a case where any message in the message queue is consumed, obtain the instance identifier of the changed instance, the database service name, and determine the target scene flag as the first scene flag or the second scene flag according to the consumed message.

[0010] As an optional example, the encapsulating module comprises: a second encapsulating unit configured to, in a case where a new row is added in the database table, determine that a new database instance is added, record a state value of the added database instance as creating, encapsulate the added database instance and the state value as the change message, and determine the target scene flag as the first scene flag.

[0011] As an optional example, the encapsulating module comprises: a third encapsulating unit configured to, in a case where a row is updated in the database table and a task flag is updated to be empty, query a state value of the updated database instance, in a case where the state value is queried and the state value is creating, encapsulate the updated database instance and the state value as the change message, update the state value to be created, and determine the target scene flag as the first scene flag.

[0012] As an optional example, the encapsulating module comprises: a fourth encapsulating unit configured to, in a case where a row is updated in the database table and a deletion flag is updated to be 1, determine that a database instance is deleted, in a case where a state value of the deleted database instance is created, encapsulate the deleted database instance and the state value as the change message, and determine the target scene flag as the second scene flag.

[0013] As an optional example, the verifying module comprises: a first verifying unit configured to, in a case where the target scene flag is the first scene flag, determine that the scene is to create the database instance, determine a resource feature of a dependent resource of the database instance, in a case where the resource feature is queried from the resource data, determine that the verification result is that the dependent resource is successfully created, and in a case where the resource feature is not queried from the resource data, determine that the verification result is that the dependent resource is not successfully created.

[0014] As an optional example, the verification module includes a second verification unit configured to, when the target scene mark is a second scene mark, determine that the scene is deletion of the database instance, and determine a resource feature of a dependent resource of the database instance, wherein the resource feature is a feature unique to the dependent resource of the database instance; when the resource feature is queried from the resource data, determine that the verification result is that the dependent resource is not successfully deleted, and when the resource feature is not queried from the resource data, determine that the verification result is that the dependent resource is successfully deleted.

[0015] According to another aspect of the embodiments of the present application, a storage medium is also provided, which stores a computer program. When the computer program is run by a processor, the state query method of the dependent resource is executed.

[0016] According to another aspect of the embodiments of the present application, an electronic device is also provided, which includes a memory and a processor. The memory stores a computer program, and the processor is configured to execute the state query method of the dependent resource by using the computer program.

[0017] In the embodiments of the present application, when the target information is acquired, the metadata queryer is called by calling the resource verifier corresponding to the database service name to query the instance information of the database instance matched with the target scene mark. The target information includes the instance identification of the database instance of the dependent resource to be queried, the database service name of the database to which the database instance belongs, and the target scene mark of the creation verification scene of the dependent resource. The target identification included in the instance information is determined, wherein the target identification is the identification of the target data matched with the target scene mark in the dependent data of the database instance. The resource data corresponding to each target identification is obtained by calling the resource queryer matched with the database service name. The verification result of the resource data is obtained by verifying the resource data. The verification result is displayed, wherein the verification result is used to represent the state of the resource data. In the method, when the state of the dependent resource of the database instance is queried, the instance identification of the database instance, the database service name of the database in which the database instance is located, and the first scene mark of the creation verification scene of the dependent resource are acquired, so that the resource state of the dependent resource to be queried is further queried according to the information, thereby achieving the purpose of improving the efficiency of querying the resource state of the dependent resource, and further solving the technical problem of low efficiency of querying the state of the dependent resource caused by manual query of the state of the dependent resource. BRIEF DESCRIPTION OF DRAWINGS

[0018] The accompanying drawings, which are included to provide a further understanding of the application and are incorporated in and constitute a part of this application, illustrate embodiments of the application and together with the description serve to explain the application. In the drawings:

[0019] Figure 1 is a flow chart of an optional state query method of a dependent resource according to an embodiment of the application;

[0020] Figure 2 is a schematic diagram of verifying a dependent resource of an optional state query method of a dependent resource according to an embodiment of the application;

[0021] Figure 3 is a schematic diagram of an automatic verification process of an optional state query method of a dependent resource according to an embodiment of the application;

[0022] Figure 4 is a structural schematic diagram of an optional state query device of a dependent resource according to an embodiment of the application;

[0023] Figure 5 is a schematic diagram of an optional electronic device according to an embodiment of the application. DETAILED DESCRIPTION

[0024] In order to make the technical personnel of the present application better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, not all. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative labor should be within the scope of protection of the present application.

[0025] It should be noted that the terms "first", "second", and the like in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and do not necessarily indicate a specific order or a chronological sequence. It should be understood that the data thus used can be interchanged under appropriate circumstances, so that the embodiments of the application described herein can be implemented in an order other than that illustrated or described herein. In addition, the terms "include" and "have" and any variations thereof are intended to cover non-exclusive inclusion, for example, a process, method, system, product or device that includes a series of steps or units does not necessarily limit to those steps or units clearly listed, but can include other steps or units not clearly listed or inherent to these processes, methods, products or devices.

[0026] According to a first aspect of the embodiments of the present application, a state query method of a dependent resource is provided, which is optional, as shown in Figure 1 the above method comprises:

[0027] S102, in the case of obtaining the target information, the metadata queryer is called by calling the resource verifier corresponding to the database service name to query the instance information matched with the target scene mark of the database instance; wherein, the target information includes the instance identification of the database instance to be queried, the database service name of the database instance, the target scene mark of the creation verification scene of the dependent resource;

[0028] S104, determine the target identification contained in the instance information, wherein the target identification is the identification of the target data matched with the target scene mark in the dependent data of the database instance;

[0029] S106, calling the resource queryer matched with the database service name, obtaining the resource data corresponding to each target identification;

[0030] S108, verifying the resource data to obtain the verification result of the resource data;

[0031] S110, display the verification result, wherein the verification result is used to indicate the state of the resource data.

[0032] Optionally, in the embodiment, a script tool can be written, such as a script tool written by using python language. The parameters received by the script tool are: database service name (such as mysql), database instance identity document (Identity document, ID) (such as 1234), verification scene (such as network_alive, indicating verifying whether the network resource exists, and the verification scene is divided into creation verification scene and deletion verification scene).

[0033] For each kind of database service, the metadata queryer is developed, that is, according to the database instance identification, the resource identification (target identification) of each dependent resource of the database instance is queried.

[0034] For each dependent service, the corresponding resource queryer is developed, such as the network resource queryer developed for the network service, which is used to query the dependent resource of the database instance in the network resource.

[0035] For each database service, the resource verifier is developed, such as the MySQL resource verifier developed for the MySQL database, which is used to verify the survival condition of the dependent resource of the database instance of the MySQL.

[0036] When the tool is used, according to the database service name, a corresponding resource verifier is called, first, a metadata queryer is called according to the database instance identifier to query the dependent resource identifier, then corresponding resource queryers are called according to the respective dependent resource identifiers to query the dependent resources, finally, the resource verifier verifies the survival details of the dependent resources, and finally the verification result is returned.

[0037] In the embodiment, when verifying whether the dependent resources of the database instance to be verified are alive, the instance identifier of the database instance, the database service name of the database where the database instance is located, and the first scene flag of the creation verification scene of the dependent resources can be obtained. For example, the network creation verification scene of the dependent resources is verified.

[0038] According to the database service name, a resource verifier corresponding to the database service is called, and then according to the database instance identifier, the metadata queryer is called by the resource verifier to query the instance information corresponding to the database instance identifier, and the dependent resource identifier of the dependent resource of the database instance in the network scene, that is, the target identifier, is found in the instance information. After the target identifier is queried, the resource data corresponding to the target identifier is found by using the resource verifier.

[0039] The resource data is verified. The verification process can be to verify whether the resource data exists or is deleted according to different scenes. The scenes can be divided into creation scenes, update scenes and deletion scenes. The creation scene and the update scene verify whether the resource data exists, and the deletion scene verifies whether the resource data is deleted. When verifying, whether the resource data exists or is deleted is queried by querying the unique resource characteristics of the resource data.

[0040] In the above method, when querying the state of the dependent resources of the database instance, the instance identifier of the database instance, the database service name of the database where the database instance is located, and the first scene flag of the creation verification scene of the dependent resources are obtained, so that the resource state of the dependent resources to be queried is further queried according to the above information, thereby achieving the purpose of improving the efficiency of querying the resource state of the dependent resources.

[0041] As an optional example, the target identifier included in the instance information includes:

[0042] Starting from the first character in the instance information, the instance information is traversed;

[0043] Each resource identifier traversed is taken as the target identifier.

[0044] Optionally, in the embodiment, the resource verifier can be called to verify the corresponding scene. The metadata queryer is called by the resource verifier. The metadata queryer can query the instance information of the database instance according to the instance identifier of the database instance. The instance information can include all information under the instance identifier of the database instance. The metadata queryer can be connected with the database to find all information under the identifier as the instance information. Then, when the target identifier is found in the instance information, the instance information can be traversed, and each resource identifier appearing in the instance information can be taken as the target identifier.

[0045] As an optional example, the resource queryer matched with the database service name is called to query the resource data corresponding to each target identifier, which includes:

[0046] Each target identifier is taken as the current identifier, and the following operations are performed:

[0047] A request for obtaining is sent to the server corresponding to the current identifier. The request for obtaining is used to request to obtain the resource data corresponding to the current identifier;

[0048] The resource data of the current identifier and the current sub-identifier corresponding to the current identifier returned by the server is received.

[0049] Optionally, in the embodiment, when the resource queryer is called to query the resource data corresponding to each target identifier, each target identifier can be taken as the current identifier, and the resource queryer can be taken as the client. The resource queryer sends a request for obtaining to the server providing the resource of the current identifier to request to obtain the resource data of the current identifier. After the server receives the request for obtaining, the resource data of the current identifier is returned. In addition, the resource data of the sub-identifier of the current identifier can also be returned.

[0050] As an optional example, the above method further includes:

[0051] In a case where the instance identifier of the database instance of the to-be-queried dependent resource, the database service name of the database where the database instance is located, and the second scene identifier of the deletion verification scene of the dependent resource are obtained, the resource queryer matched with the database service name is called to query the resource data corresponding to each target identifier;

[0052] The queried resource data is displayed.

[0053] Optionally, in the embodiment, if the database instance is deleted after the dependent resources of the database instance are verified according to the instance identifier of the database instance, the database service name, and the first scene flag, it is further verified whether the dependent resources of the database instance exist, that is, whether they are deleted. When verifying whether the dependent resources are deleted, the resource data of the target identifier queried when the database instance is created can be called, and then the resource data is displayed. When the resource data is displayed, if it is empty, it means that it has been deleted. If it is not empty, it means that it has not been deleted.

[0054] As an optional example, displaying the queried resource data includes:

[0055] generating the resource data into a json format text;

[0056] displaying the json format text.

[0057] Optionally, in the embodiment, when the queried resource data is displayed, the resource data can be generated into a json format text. Displaying the resource data in the json format text can quickly check whether each part of the resource data exists or is deleted.

[0058] As an optional example, the instance information matching the database instance and the target scene flag is queried by calling the resource verifier corresponding to the database service name to call the metadata queryer.

[0059] The resource verifier corresponding to the database service name is determined by the database service name, wherein different database service names correspond to different resource verifiers;

[0060] The instance identifier of the database instance is input into the metadata queryer by the resource verifier, and the metadata queryer is connected to the database where the database instance is located to query the information related to the instance identifier from the database;

[0061] The information related to the instance identifier queried by the metadata queryer is encapsulated into the instance information.

[0062] Optionally, in the embodiment, different database service names match different resource verifiers. The corresponding resource verifier is called by using the database service name. The resource verifier inputs the instance identifier of the database instance into the metadata queryer, and the metadata queryer connects the database where the database instance is located. After the metadata queryer connects the database, information can be queried from the database. The metadata queryer queries the information related to the instance identifier in the database according to the instance identifier. The related information here can be all information under the instance identifier.

[0063] As an optional example, the method further comprises:

[0064] monitoring a database table in a database;

[0065] in case that an instance in the database table changes, encapsulating a change message and pushing the change message to a message queue;

[0066] in case that any message in the message queue is consumed, obtaining an instance identifier of the changed instance, a database service name, and determining a target scene flag as a first scene flag or a second scene flag according to the consumed message.

[0067] Optionally, in the embodiment, a database table in a database can be monitored. The database table can record database instances. If a database instance in the database table changes (addition, deletion or modification), the change is encapsulated as a change message, such as adding an instance, deleting an instance, or modifying an instance. The change message is pushed to a message queue. The messages in the message queue are consumed in turn according to the order in the queue. When any change message is consumed, the instance identifier of the changed database instance, the database service name, and the scene flag determined according to the change message are obtained as creation or deletion or modification.

[0068] As an optional example, in case that an instance in the database table changes, the change message is encapsulated and pushed to the message queue, which comprises:

[0069] in case that a new record is added in the database table, it is determined that a new database instance is added, and the state value of the added database instance is recorded as creating;

[0070] the added database instance and the state value are encapsulated as a change message;

[0071] it is determined that the target scene flag is the first scene flag.

[0072] In the embodiment, when the database instances are maintained in the database, a state value can also be maintained for each database instance. The state value is used to record the state of the database instance. If a new database instance is created, after the new database instance is created, a state value is assigned to the database instance, and the state value is recorded as creating. It indicates that the database instance is created. The added database instance and the state value are encapsulated as a change message, and the change message is sent to the message queue. The scene flag is determined as the creation scene flag.

[0073] As an optional example, in case that an instance in the database table changes, the change message is encapsulated and pushed to the message queue, which comprises:

[0074] In the case of updating a record in the database table and the task flag being updated to empty, the state value of the updated database instance is queried;

[0075] In the case of querying the state value and the state value being creating, the updated database instance and the state value are encapsulated as a change message, and the state value is updated to created;

[0076] The target scene flag is determined to be the first scene flag.

[0077] In this embodiment, if a database instance is updated, the state value of the database instance is queried before the database instance is updated, and the state value is creating. The state value is adjusted to created, indicating that the database instance has been created. The updated database instance and the state value are encapsulated as a change message, and the change message is sent to the message queue. The scene flag is determined to be the creation scene flag.

[0078] As an optional example, in the case of changes in the instance in the database table, encapsulating the change message and pushing the change message to the message queue include:

[0079] In the case of updating a record in the database table and the deletion flag being updated to 1, it is determined that a database instance is deleted;

[0080] In the case of the state value of the deleted database instance being created, the deleted database instance and the state value are encapsulated as a change message;

[0081] The target scene flag is determined to be the second scene flag.

[0082] In this embodiment, if a database instance is deleted, the state value of the database instance is queried when the database instance is deleted, and the state value is created. It indicates that the database instance has been verified. The instance identifier of the deleted database instance and the state value are encapsulated as a change message, and the change message is sent to the message queue. The scene flag is determined to be the deletion scene flag.

[0083] As an optional example, verifying the resource data to obtain a verification result of the resource data includes:

[0084] In the case of the target scene flag being the first scene flag, it is determined that the scene is creating a database instance, and the resource characteristics of the dependent resources of the database instance are determined, wherein the resource characteristics are characteristics unique to the dependent resources of the database instance;

[0085] In a case where the resource feature is queried from the resource data, it is determined that the verification result is that the dependent resource is successfully created. In a case where the resource feature is not queried from the resource data, it is determined that the verification result is that the dependent resource is not successfully created.

[0086] As an optional example, the resource data is verified, and the verification result of the resource data includes:

[0087] In a case where the target scene sign is the second scene sign, it is determined that the scene is the deletion of the database instance, and the resource feature of the dependent resource of the database instance is determined, wherein the resource feature is a feature unique to the dependent resource of the database instance.

[0088] In a case where the resource feature is queried from the resource data, it is determined that the verification result is that the dependent resource is not successfully deleted. In a case where the resource feature is not queried from the resource data, it is determined that the verification result is that the dependent resource is successfully deleted.

[0089] In the creation scene or the deletion scene of the database instance, when verifying whether the dependent resource of the database instance is created or deleted, the resource feature unique to the dependent resource can be used to query the dependent resource in the database. If the dependent resource can be queried, it indicates that the dependent resource is created or not deleted. If the dependent resource is not queried, it indicates that the dependent resource is not created or has been deleted.

[0090] Resource verifier: Different database services correspond to different resource verifiers. For example, Redis resource verifier, MongoDB resource verifier, and the resource verifier contains various verification scenes.

[0091] Verification scene: mainly divided into two categories (creation, deletion), and the corresponding verification logic is different; the same name verification scene corresponding to different database services has different verification logic.

[0092] Metadata queryer: various SQL statements are implemented to query the metadata information of the instance to be verified.

[0093] Resource queryer: different dependent services correspond to different resource queryers. For example, neutron resource queryer (query network resource), nova resource queryer (query computing resource).

[0094] Figure 2 The verification schematic diagram of the embodiment is shown in FIG. 1. For example, the verification scene of creating a network resource is as follows:

[0095] Step 1: User input: database service name: redis, instance identifier: 1234, verification scene: network resource creation

[0096] Step 2: The tool receives input parameters, invokes the

redis resource verifier

network resource creation

[0097] Step 3: According to the query rules in the verification scenario, invoke the

metadata queryer

[1234] , which includes all or part of the identifiers of the

network resources

[0098] Step 4: According to the all or part of the identifiers obtained in step 3, invoke the corresponding

resource queryer

redis

neutron resource queryer

[0099] Step 5: According to the verification rules in the verification scenario, assemble the detailed information obtained in step 4 into a complete json format text

[0100] Step 6: Show the text obtained in step 5 to the user and write it into a file for saving

[0101] For example, the verification scenario of deleting network resources:

[0102] Step 1: User input: database service name: redis, instance identifier: 1234, verification scenario: network resource deletion

[0103] Step 2: The tool receives input parameters, invokes the

redis resource verifier

network resource deletion

[0104] Step 3: Since

metadata

network resource creation

[0105] Step 4: According to the json data obtained in step 3, invoke the corresponding

resource queryer

redis

neutron resource queryer

[0106] Step 5: According to the verification rules in the verification scenario, assemble the detailed information obtained in step 4 into a complete json format text

[0107] Step 6: Show the text obtained in step 5 to the user

[0108] For other xx resources, such as database resources, also follow the above creation scenario and deletion scenario verification.

[0109] In this embodiment, when verifying

creation

metadata

[0110] When verifying

deletion

creation

[0111] In this embodiment, automatic verification can be performed. In the case that the architecture and survival verification logic of the verification tool remain unchanged, the tool can be used to realize automatic verification, and the verification result can be stored. When needed, the user can view the verification result stored in the database without manually verifying the resource. When there are many resources to be verified, the efficiency can be improved. The specific content is as follows:

[0112] Noun explanation:

[0113] Canal is an open source database listening component that supports listening to data changes in the database and importing the changes into the message queue.

[0114] Rabbitmq is a message queue middleware.

[0115] Redis is a cache database.

[0116] By developing an automatic verification tool, real-time and automatic verification is supported, and when resource leakage occurs, automatic alarm can be realized

[0117] 1. Use python to write a verification tool that supports verifying the survival of dependent resources according to the specified database service name and instance identifier (i.e. the script tool described above)

[0118] 2. Deploy canal to a database that records all information corresponding to the instance identifier, and real-time monitor the changes in some data tables in the database

[0119] 3. Deploy rabbitmq and configure canal to encapsulate data changes into messages and push them to rabbitmq

[0120] 4. Use python to write a consumer tool to listen to the rabbitmq message queue. When a message is received, automatically call the verification tool written in 1, to verify and write the verification result to redis cache. When the verification result does not meet the expectation, automatically alarm

[0121] 5. Write API interface and WEB interface to support reading verification results from redis and displaying them on the WEB interface

[0122] Architecture of the automatic solution:

[0123] Database for recording instance details: There is usually a table in this database that records the metadata information of an instance, such as instance identification and instance status.

[0124] Canal: An open-source database monitoring tool. In the configuration of canal, 1) configure the connection address and authentication information of the above database, library name and table name, 2) configure the connection address and authentication information of the downstream message queue and the message routing table. Canal will monitor the data changes of the above database table in real time, and encapsulate the changes into a message and push it to the downstream message queue.

[0125] RabbitMQ: Queue in RabbitMQ is an open-source message queue middleware. Figure 3

[0126] Agent: Consumer tool. Agent listens to Queue and consumes messages in it. When a message is obtained, agent will call the verification tool for verification. Agent will push the verification result to Redis cache, and if resource leakage is found, it will send an alarm (SMS, email, WeChat, etc. Notification)

[0127] Redis: An open-source cache database.

[0128] API&WEB: Self-developed interface and front-end for querying and displaying cached data in Redis.

[0129] Figure 3 ​The automatic verification process of the embodiment is as follows. The canal listens to the database data in real time, pushes the data to the message queue, and the agent listens. When the agent receives the message and makes a judgment. If the data change is

INSERT a record

UPDATE a record, and TASK_STATUS is updated to None

UPDATE a record, and DELETED is updated to 1

[0130] It should be noted that, for the foregoing method embodiments, in order to simply describe, they are all expressed as a series of action combinations, but those skilled in the art should know that the present application is not limited to the action sequence described, because according to the present application, certain steps can be performed in other sequences or simultaneously. Secondly, those skilled in the art should know that the embodiments described in the specification all belong to preferred embodiments, and the actions and modules involved are not necessarily necessary for the present application.

[0131] According to another aspect of the embodiments of the present application, a state query device for dependent resources is also provided, as shown in Figure 4 , comprising:

[0132] The query module 402 is configured to, when the target information is acquired, call a metadata queryer by calling a resource verifier corresponding to the database service name, to query instance information matched with the target scene mark of the database instance; wherein the target information includes an instance identifier of a database instance to be queried for a dependent resource, a database service name of a database to which the database instance belongs, and a target scene mark of a creation verification scene of the dependent resource.

[0133] The determination module 404 is configured to determine a target identifier included in the instance information, wherein the target identifier is an identifier of target data in dependent data of the database instance, which is matched with the target scene mark.

[0134] The calling module 406 is configured to call a resource queryer matched with the database service name, to obtain resource data corresponding to each target identifier.

[0135] The verification module 408 is configured to verify the resource data, to obtain a verification result of the resource data.

[0136] The display module 410 is configured to display the verification result, wherein the verification result is used to represent a state of the resource data.

[0137] Optionally, in the embodiment, a script tool can be written, for example, a script tool written by using a python language. The script tool receives parameters: a database service name (for example, mysql), a database instance identity document (Identity document, ID) (for example, 1234), and a verification scene (for example, network_alive, indicating verifying whether a network resource exists, and the verification scene is divided into a creation verification scene and a deletion verification scene).

[0138] For each kind of database service, a metadata queryer is developed, that is, according to a database instance identifier, resource identifiers (target identifiers) of each dependent resource of the database instance are queried.

[0139] For each dependent service, a corresponding resource queryer is developed, for example, for a network service, a network resource queryer is developed, which is used to query a dependent resource of the database instance in the network resource.

[0140] For each database service, a resource verifier is developed, for example, for a MySQL database, a MySQL resource verifier is developed, which is used to verify a survival condition of a dependent resource of a database instance of the MySQL.

[0141] When the tool is used, according to the database service name, a corresponding resource verifier is called, first, a metadata queryer is called according to the database instance identifier to query the dependent resource identifier, then corresponding resource queryers are called according to the respective dependent resource identifiers to query the dependent resources, finally, the resource verifier verifies the survival details of the dependent resources, and finally the verification result is returned.

[0142] In the embodiment, when verifying whether the dependent resources of the database instance to be verified are alive, the instance identifier of the database instance, the database service name of the database where the database instance is located, and the first scene flag of the creation verification scene of the dependent resources can be obtained. For example, the network creation verification scene of the dependent resources is verified.

[0143] According to the database service name, a resource verifier corresponding to the database service is called, and then according to the database instance identifier, the metadata queryer is called by the resource verifier to query the instance information corresponding to the database instance identifier, and the dependent resource identifier of the dependent resource of the database instance in the network scene, that is, the target identifier, is found in the instance information. After the target identifier is queried, the resource data corresponding to the target identifier is found by using the resource verifier.

[0144] The resource data is verified. The verification process can be to verify whether the resource data exists or is deleted according to different scenes. The scenes can be divided into creation scenes, update scenes and deletion scenes. The creation scene and the update scene verify whether the resource data exists, and the deletion scene verifies whether the resource data is deleted. When verifying, whether the resource data exists or is deleted is queried by querying the unique resource characteristics of the resource data.

[0145] In the above method, when querying the state of the dependent resources of the database instance, the instance identifier of the database instance, the database service name of the database where the database instance is located, and the first scene flag of the creation verification scene of the dependent resources are obtained, so that the resource state of the dependent resources to be queried is further queried according to the above information, thereby achieving the purpose of improving the efficiency of querying the resource state of the dependent resources.

[0146] As an optional example, the determination module comprises:

[0147] The traversal unit is configured to traverse the instance information from the first character in the instance information.

[0148] The first determination unit is configured to take each resource identifier traversed as a target identifier.

[0149] Optionally, in the embodiment, the resource verifier can be called to verify the corresponding scene. The metadata queryer is called by the resource verifier. The metadata queryer can query the instance information of the database instance according to the instance identifier of the database instance. The instance information can include all information under the instance identifier of the database instance. The metadata queryer can be connected with the database to find all information under the identifier as the instance information. Then, when the target identifier is found in the instance information, the instance information can be traversed, and each resource identifier appearing in the instance information can be taken as the target identifier.

[0150] As an optional example, the query module includes:

[0151] The processing unit is configured to take each target identifier as a current identifier and perform the following operations:

[0152] sending a request to a server corresponding to the current identifier to obtain resource data corresponding to the current identifier;

[0153] receiving resource data of the current identifier and a current sub-identifier corresponding to the current identifier returned by the server.

[0154] Optionally, in the embodiment, when the resource queryer is called to query the resource data corresponding to each target identifier, each target identifier can be taken as a current identifier, the resource queryer can be taken as a client, and the resource queryer can be used to send a request to a server providing a resource of the current identifier to obtain resource data of the current identifier. After the server receives the request, the resource data of the current identifier is returned. In addition, the resource data of the sub-identifier of the current identifier can also be returned.

[0155] As an optional example, the query module includes:

[0156] The second determination unit is configured to determine a resource verifier matched with the database service name by the database service name, wherein different database names correspond to different resource verifiers;

[0157] The input unit is configured to input the instance identifier of the database instance into the metadata queryer by the resource verifier, and connect the database where the database instance is located by the metadata queryer to query information related to the instance identifier from the database;

[0158] The first encapsulation unit is configured to encapsulate the information related to the instance identifier queried by the metadata queryer into instance information.

[0159] Optionally, in the embodiment, different database service names match different resource verifiers. The database service name is used to call the corresponding resource verifier. The resource verifier inputs the instance identifier of the database instance into the metadata queryer, and the metadata queryer connects the database where the database instance is located. After the metadata queryer connects the database, information can be queried from the database. The metadata queryer queries information related to the instance identifier in the database according to the instance identifier. The related information here can be all information under the instance identifier.

[0160] As an optional example, the above apparatus further comprises:

[0161] The listening module is configured to listen to a database table in the database.

[0162] The packaging module is configured to, in a case where an instance in the database table changes, package a change message and push the change message to a message queue.

[0163] The obtaining module is configured to, when any message in the message queue is consumed, obtain an instance identifier of the changed instance and a database service name, and determine the target scene flag to be the first scene flag or the second scene flag according to the consumed message.

[0164] Optionally, in the embodiment, the database table in the database can be monitored. The database table can record database instances. If the database instances in the database table change (add, delete, or modify), the change is packaged as a change message, such as adding an instance, deleting an instance, or modifying an instance. The change message is pushed to the message queue. The messages in the message queue are consumed in order according to the order in the queue. When any change message is consumed, the instance identifier of the changed database instance in the change message, the database service name, and the scene flag determined according to the change message are obtained, which are creating, deleting, or modifying.

[0165] As an optional example, the above packaging module comprises:

[0166] The second packaging unit is configured to, in a case where a new row of records is added in the database table, determine that a new database instance is added, record a state value of the added database instance as creating, package the added database instance and the state value as a change message, and determine the target scene flag to be the first scene flag.

[0167] In the embodiment, when the database instance is maintained in the database, a state value can also be maintained for each database instance. The state value is used to record the state of the database instance. If a database instance is newly created, after the database instance is newly created, the database instance is assigned a state value, and the state value is recorded as creating. It indicates that the database instance is created. The newly added database instance and the state value are encapsulated as a change message, and the change message is sent to the message queue. The scene flag is determined as the creation scene flag.

[0168] As an optional example, the encapsulation module includes:

[0169] The third encapsulation unit is configured to, in a case where a row record in the database table is updated and the task flag is updated to be empty, query the state value of the updated database instance; in a case where the state value is queried and the state value is creating, encapsulate the updated database instance and the state value as a change message, update the state value to be created, and determine the target scene flag to be the first scene flag.

[0170] In the embodiment, if a database instance is updated, before the database instance is updated, the state value of the database instance is queried, and the state value is creating. The state value is adjusted to be created, indicating that the database instance has been created. The updated database instance and the state value are encapsulated as a change message, and the change message is sent to the message queue. The scene flag is determined as the creation scene flag.

[0171] As an optional example, the encapsulation module includes:

[0172] The fourth encapsulation unit is configured to, in a case where a row record in the database table is updated and the deletion flag is updated to be 1, determine that a database instance is deleted; in a case where the state value of the deleted database instance is created, encapsulate the deleted database instance and the state value as a change message; and determine the target scene flag to be the second scene flag.

[0173] In the embodiment, if a database instance is deleted, when the database instance is deleted, the state value of the database instance is queried, and the state value is created. It indicates that the database instance has been verified. The instance identifier of the deleted database instance and the state value are encapsulated as a change message, and the change message is sent to the message queue. The scene flag is determined as the deletion scene flag.

[0174] As an optional example, the verification module includes:

[0175] The first verification unit is configured to, in a case where the target scene mark is the first scene mark, determine that the scene is a database instance creation, and determine a resource feature of a dependent resource of the database instance, wherein the resource feature is a feature unique to the dependent resource of the database instance; in a case where the resource feature is queried from the resource data, determine that the verification result is that the dependent resource is successfully created, and in a case where the resource feature is not queried from the resource data, determine that the verification result is that the dependent resource is not successfully created.

[0176] As an optional example, the verification module includes:

[0177] The second verification unit is configured to, in a case where the target scene mark is the second scene mark, determine that the scene is a database instance deletion, and determine a resource feature of a dependent resource of the database instance, wherein the resource feature is a feature unique to the dependent resource of the database instance; in a case where the resource feature is queried from the resource data, determine that the verification result is that the dependent resource is not successfully deleted, and in a case where the resource feature is not queried from the resource data, determine that the verification result is that the dependent resource is successfully deleted.

[0178] In the database instance creation scene or the database instance deletion scene, when verifying whether the dependent resource of the database instance is created or deleted, the resource feature unique to the dependent resource can be used to query the dependent resource in the database. If the dependent resource is queried, it indicates that the dependent resource is created or not deleted, and if the dependent resource is not queried, it indicates that the dependent resource is not created or has been deleted.

[0179] Other examples of the embodiment can refer to the above examples, and will not be described here.

[0180] Figure 5 is a schematic diagram of an optional electronic device according to an embodiment of the present application, as shown in Figure 5 The processor 502, the communication interface 504 and the memory 506 complete communication with each other through the communication bus 508, wherein,

[0181] The memory 506 is configured to store a computer program.

[0182] The processor 502 is configured to, when executing the computer program stored in the memory 506, implement the following steps:

[0183] In the case of obtaining the target information, a resource verifier corresponding to the database service name is called to call the metadata queryer to query instance information matching the target scene mark of the database instance; wherein, the target information includes the instance identifier of the database instance to be queried, the database service name of the database to which the database instance belongs, and the target scene mark of the creation verification scene of the dependent resource.

[0184] The target identifier included in the instance information is determined, wherein the target identifier is the identifier of the target data in the dependent data of the database instance, which matches the target scene mark;

[0185] The resource queryer matched with the database service name is called to obtain the resource data corresponding to each target identifier;

[0186] The resource data is verified to obtain the verification result of the resource data;

[0187] The verification result is displayed, wherein the verification result is used to represent the state of the resource data.

[0188] Optionally, in the embodiment, the communication bus can be a PCI (Peripheral Component Interconnect) bus, or an EISA (Extended Industry Standard Architecture) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For the convenience of representation, Figure 5 In the figure, only one thick line is used to represent, but it does not mean that there is only one bus or one type of bus. The communication interface is used for communication between the electronic device and other devices.

[0189] The memory can include a RAM, and can also include a non-volatile memory, for example, at least one disk memory. Optionally, the memory can also be at least one storage device located away from the aforementioned processor.

[0190] As an example, the memory 506 can include but is not limited to the query module 402, the determination module 404, the calling module 406, the verification module 408 and the display module 410 in the state query device of the dependent resource. In addition, other module units in the state query device of the dependent resource can also be included, but not limited to, which will not be described in detail in this example.

[0191] The processor can be a general processor, which can include but is not limited to a CPU (Central Processing Unit), a NP (Network Processor), etc. The processor can also be a DSP (Digital Signal Processing), an ASIC (Application Specific Integrated Circuit), an FPGA (Field-Programmable Gate Array) or other programmable logic device, a discrete gate or transistor logic device, a discrete hardware component.

[0192] Optionally, the specific examples in the embodiments can refer to the examples described in the above embodiments, and the embodiments will not be described here.

[0193] Those skilled in the art can understand that the above-mentioned embodiments can be implemented by means of software functional modules and transmitted as a carrier wave. Figure 5 The structure shown is only schematic, and the device implementing the above-mentioned resource-dependent state query method can be a terminal device, which can be a smart phone (such as an Andro-identified phone, an iOS phone, etc.), a tablet computer, a palm computer, a Mobile Internet Device (M-identified), a PAD, etc. Figure 5 The structure of the above-mentioned electronic device is not limited. For example, the electronic device can further include more or less components (such as a network interface, a display device, etc.) than those shown in the above-mentioned embodiments, or have a different configuration from that shown in the above-mentioned embodiments. Figure 5 The structure of the above-mentioned electronic device is not limited. For example, the electronic device can further include more or less components (such as a network interface, a display device, etc.) than those shown in the above-mentioned embodiments, or have a different configuration from that shown in the above-mentioned embodiments. Figure 5 The structure of the above-mentioned electronic device is not limited. For example, the electronic device can further include more or less components (such as a network interface, a display device, etc.) than those shown in the above-mentioned embodiments, or have a different configuration from that shown in the above-mentioned embodiments.

[0194] Those skilled in the art can understand that all or part of the steps of the above-mentioned embodiments can be completed by programs instructing the related hardware of the terminal device, and the programs can be stored in a computer-readable storage medium, which can include a flash disk, a ROM, a RAM, a magnetic disk or an optical disk, etc.

[0195] According to another aspect of the embodiments of the present application, a computer-readable storage medium is also provided, which stores a computer program, wherein the computer program is run by a processor to perform the steps of the above-mentioned resource-dependent state query method.

[0196] Optionally, in the embodiment, a person skilled in the art can understand that all or part of the steps of the various methods in the above embodiment can be completed by instructing the terminal device related hardware through a program, and the program can be stored in a computer readable storage medium, and the storage medium can include a flash disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.

[0197] The serial numbers of the above embodiments of the application are only for description, and do not represent the advantages and disadvantages of the embodiments.

[0198] The integrated units in the above embodiments, if realized in the form of software function units and sold or used as independent products, can be stored in the above computer readable storage medium. Based on such understanding, the technical solutions of the application or all or part of the technical solutions that essentially contribute to the prior art can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a plurality of instructions for causing one or more computer devices (which can be personal computers, servers or network devices, etc.) to execute all or part of the steps of the embodiments of the application.

[0199] In the above embodiments of the application, the description of each embodiment has its own focus, and the parts not described in detail in a certain embodiment can be referred to the related description of other embodiments.

[0200] In several embodiments provided in the present application, it should be understood that the disclosed client can be implemented by other ways. Among them, the above described device embodiments are only schematic, for example, the division of units is only a logical function division, and actual implementation can have another division manner, for example, a plurality of units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the coupling or direct coupling or communication connection between the displayed or discussed units can be indirect coupling or communication connection through some interfaces, units or modules, and can be electrical or other forms.

[0201] The units described as separate components can or can not be physically separated, and the components displayed as units can or can not be physical units, that is, they can be located in one place, or can be distributed on a plurality of network units. According to actual needs, part or all of the units can be selected to achieve the purpose of the embodiment.

[0202] In addition, each function unit in each embodiment of the present application can be integrated in one processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The integrated unit can be realized in the form of hardware or in the form of a software function unit.

[0203] The above description is only the preferred embodiment of the present application, and it should be pointed out that, for those skilled in the art, without departing from the principles of the present application, a number of improvements and refinements can be made, and these improvements and refinements should also be considered as the protection scope of the present application.

Claims

1. A method for querying the state of a resource-dependent system, characterized in that, The method comprises the following steps: In the case of obtaining target information, the metadata queryer is called by calling the resource verifier corresponding to the database service name to query the instance information matching the target scene mark of the database instance; wherein, the target information comprises the instance identifier of the database instance to be queried, the database service name of the database to which the database instance belongs, and the target scene mark of the creation verification scene of the dependent resource; Determine the target identifier contained in the instance information, wherein the target identifier is the identifier of the target data in the dependent data of the database instance that matches the target scene mark; Call the resource queryer matched with the database service name to obtain the resource data corresponding to each target identifier; Verify the resource data to obtain the verification result of the resource data; Display the verification result, wherein the verification result is used to represent the state of the resource data.

2. The method of claim 1, wherein, The determination of the target identifier contained in the instance information comprises: Starting from the first character in the instance information, traverse the instance information; Each resource identifier traversed is taken as the target identifier.

3. The method of claim 1, wherein, The calling of the resource queryer matched with the database service name to query the resource data corresponding to each target identifier comprises: Taking each target identifier as the current identifier, the following operations are performed: Send a request to the server corresponding to the current identifier; the request is used to request to obtain the resource data corresponding to the current identifier; Receive the resource data of the current identifier and the current sub-identifier corresponding to the current identifier returned by the server.

4. The method of claim 1, wherein, The calling of the metadata queryer by calling the resource verifier corresponding to the database service name comprises: Determine the resource verifier matched with the database service name through the database service name, wherein different database names correspond to different resource verifiers; Use the resource verifier to input the instance identifier of the database instance into the metadata queryer, and use the metadata queryer to connect the database where the database instance is located to query the information related to the instance identifier from the database; Use the metadata queryer to encapsulate the information related to the instance identifier into the instance information.

5. The method according to claim 1 or 4, characterized in that, The method further comprises: Listen to the database table in the database; In the case that the instance in the database table changes, encapsulate the change message and push it to the message queue; When any message in the message queue is consumed, obtain the instance identifier of the changed instance, the database service name, and determine the target scene mark as the first scene mark or the second scene mark according to the consumed message.

6. The method of claim 5, wherein, The encapsulation of the change message and the pushing of the change message to the message queue in the case that the instance in the database table changes comprises: In the case that a new record is added in the database table, it is determined that a new database instance is added, and the state value of the added database instance is recorded as creating; encapsulate the added database instance and the state value as the change message; determine that the target scenario flag is the first scenario flag.

7. The method of claim 5, wherein, The encapsulating a change message and pushing the change message into the message queue in the case that the instance in the database table changes comprises: In the case that a row record in the database table is updated and the task flag is updated to be empty, querying a state value of the updated database instance; In the case that the state value is queried and the state value is creating, encapsulating the updated database instance and the state value as the change message, and updating the state value to be created; determine that the target scenario flag is the first scenario flag.

8. The method of claim 5, wherein, The encapsulating a change message and pushing the change message into the message queue in the case that the instance in the database table changes comprises: In the case that a row record in the database table is updated and the deletion flag is updated to be 1, it is determined that a database instance is deleted; In the case that the state value of the deleted database instance is created, encapsulating the deleted database instance and the state value as the change message; determine that the target scenario flag is the second scenario flag.

9. The method of claim 1, wherein, The verifying the resource data to obtain a verification result of the resource data comprises: In the case that the target scenario flag is the first scenario flag, it is determined that the scenario is to create the database instance, and a resource feature of a dependent resource of the database instance is determined, wherein the resource feature is a feature unique to the dependent resource of the database instance; In the case that the resource feature is queried from the resource data, it is determined that the verification result is that the dependent resource is successfully created, and in the case that the resource feature is not queried from the resource data, it is determined that the verification result is that the dependent resource is not successfully created.

10. The method of claim 1, wherein, The verifying the resource data to obtain a verification result of the resource data comprises: In the case that the target scenario flag is the second scenario flag, it is determined that the scenario is to delete the database instance, and a resource feature of a dependent resource of the database instance is determined, wherein the resource feature is a feature unique to the dependent resource of the database instance; In the case that the resource feature is queried from the resource data, it is determined that the verification result is that the dependent resource is not successfully deleted, and in the case that the resource feature is not queried from the resource data, it is determined that the verification result is that the dependent resource is successfully deleted.

11. A resource-dependent state query apparatus, characterized by comprising: comprise: The query module is configured to, in the case that target information is acquired, query instance information of a database instance matched with a target scenario flag by calling a resource verifier corresponding to a database service name to call a metadata queryer, wherein the target information comprises an instance identifier of a database instance of a dependent resource to be queried, a database service name of a database to which the database instance belongs, and a target scenario flag of a creation verification scenario of the dependent resource; A determining module is configured to determine a target identifier contained in the instance information, wherein the target identifier is an identifier of target data in dependency data of the database instance that matches the target scenario mark; A calling module is configured to call a resource queryer matching the database service name to obtain resource data corresponding to each target identifier; A verifying module is configured to verify the resource data to obtain a verification result of the resource data; A display module is configured to display the verification result, wherein the verification result is used to represent a state of the resource data.

12. A computer-readable storage medium storing a computer program, the computer-readable storage medium being characterized by, The computer program is run by the processor to execute the method in any one of claims 1 to 10.

13. An electronic device comprising a memory and a processor, characterized in that The memory stores the computer program, and the processor is configured to execute the method in any one of claims 1 to 10 by using the computer program.

Citation Information

Patent Citations

  • Resource sharing method, device and system and storage medium

    CN110113375A

  • Data consistency detection method and device and electronic device

    CN110674153A