Method and device for cleaning 8a database cluster resources through interface
Patent Information
- Application Number
- CN202511869992.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-12
- Publication Date
- 2026-01-09
- Estimated Expiration
- 2045-12-12
AI Technical Summary
在现有的实现方式中,GBase8aMPP数据库集群虽然已经提供了清理数据库资源的功能,但是该功能操作需要直接操作数据库,而不是通过restful接口方式,且操作步骤复杂,导致无法对接专门用于资源管控的应用,从而在部署时遇到障碍
(1)能够为诸如资源管控应用程序这样的外部程序提供符合restful规范的资源清理接口。
Smart Images

Figure CN121301467A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application belongs to the field of GBase8a MPP database cluster resource cleaning, and particularly relates to a method and device for cleaning 8a database cluster resources through an interface. BACKGROUND
[0002] Currently, GBase8a MPP database clusters are commonly used as data operation and storage scenes. When using GBase8a MPP database clusters, due to the strong service capability of the database cluster, many scenes can provide data operation and storage services for multiple application programs. In this case, in order to isolate the use of resources by the application programs and avoid contention when multiple application programs use database resources, the database needs to provide a resource allocation function to each application program, and the resources limit the use of cpu, memory and other resource quotas. At the same time, when the resources are no longer used, the database also needs to provide a resource cleaning function. The resource cleaning operation is generally implemented through a resource management platform. Since the resource management platform is not usually used for operating one kind of database, the resource management platform does not directly operate the database for operation, but through the restful interface provided by the database, which requires the database to provide a restful interface to support the cleaning of database resources.
[0003] Problems of the prior art: In the existing implementation mode, although GBase8a MPP database clusters have provided a function of cleaning database resources, the function operation needs to directly operate the database, not through the restful interface mode, and the operation steps are complex, which leads to the inability to connect to the application specially used for resource management, thereby encountering obstacles in deployment. SUMMARY
[0004] Therefore, the present application aims to provide a method and device for cleaning 8a database cluster resources through an interface to solve the above problems of the prior art.
[0005] To achieve the above purpose, the technical solution of the present application is as follows: In a first aspect, the present application provides a method for cleaning 8a database cluster resources through an interface, comprising the following steps: S1, a resource management application sends a restful form request to a Web container through an http protocol; S2, the Web container receives the http request, parses the request content, obtains the request parameters, and if there is an exception, executes an exception handling program for parameter acquisition failure, otherwise, continues to execute the next step S3; S3, validity verification is performed on the request parameters of step S2, if abnormal, an exception handling procedure for parameter validity verification failure is executed, otherwise, the next step S4 is continued to be executed; S4, based on the request parameters verified in step S3, stopping the current database resource execution plan, if abnormal, an exception handling procedure for stopping the current database resource execution plan failure is executed, otherwise, the next step S5 is continued to be executed; S5, based on the request parameters verified in step S3, cleaning up resource association, and unbundling the resource allocation plan, resources, and user groups of resources, if abnormal, an exception handling procedure for cleaning up resource association and unbundling the resource allocation plan, resources, and user groups of resources failure is executed, otherwise, the next step S6 is continued to be executed; S6, based on the request parameters verified in step S3, cleaning up the users of the default resource usage, and unbundling the ordinary users and the user groups of resources, if abnormal, an exception handling procedure for cleaning up the users of the default resource usage and unbundling the ordinary users and the user groups of resources failure is executed, otherwise, the next step S7 is continued to be executed; S7, based on the request parameters verified in step S3, cleaning up the user groups using resources, if abnormal, an exception handling procedure for cleaning up the user groups using resources failure is executed, otherwise, the next step S8 is continued to be executed; S8, based on the request parameters verified in step S3, cleaning up resources using the resource identifiers set by the request parameters, if abnormal, an exception handling procedure for cleaning up resources using the resource identifiers set by the request parameters failure is executed, otherwise, the next step S9 is continued to be executed; S9, based on the request parameters verified in step S3, starting the database resource allocation plan, if abnormal, an exception handling procedure for starting the database resource allocation plan failure is executed, otherwise, a result of successful cleaning up of resources is returned to the resource management and control application in the form of restful.
[0006] Further, in step S2, the request parameters are obtained, including: The resource identifier, username, and password for cleaning up resources are obtained.
[0007] Further, the resource identifier is unique.
[0008] Further, in step S2, an exception handling procedure for parameter acquisition failure is executed, including: A result of parameter acquisition failure is returned to the resource management and control application in the form of restful; In step S3, an exception handling procedure for parameter validity verification failure is executed, including: Returns a result indicating parameter validity verification failure to the resource management application in RESTful format; In step S4, an exception handler is executed for the failure to stop the current database resource execution plan, including: Returns a result to the resource management application in RESTful form indicating that the execution plan for stopping the current database resource has failed.
[0009] Furthermore, in step S5, an exception handling procedure is executed for the failure to unbind resource allocation plans, resources, and user groups of resources during the cleanup of resource associations, including: S51. Resume the execution plan for database resources; S52. Returns a result to the resource management application in RESTful form, indicating that the cleanup of resource associations and the unbinding of resource allocation plans, resources, and user groups of resources failed.
[0010] Furthermore, in step S6, an exception handling procedure is executed for the failure to unbind ordinary users from the user group using the default resource cleanup, including: S61. If the user using the default resource has been cleared, then recreate the default resource user. S62. Rebind the resource allocation plan, resources, and user groups of the resources; S63. Resume the execution plan for database resources; S64. Returns the result to the resource management application in RESTful form: the user group that cleaned up the default resource failed to unbind from the user group of the resource.
[0011] Furthermore, in step S7, an exception handling procedure is executed for the failure to clean up user groups using resources, including: S71. Rebind users and user groups; S72. Recreate the default resource user; S73. Rebind the resource allocation plan, resources, and user groups of the resources; S74. Resume the execution plan for database resources; S75. Returns the result of failure to clean up user groups using resources to the resource management application in a RESTful manner.
[0012] Furthermore, in step S8, an exception handling procedure is executed for failure to clean up resources using the resource identifier set with the request parameters, including: S81. Recreate the user group; S82. Rebind users and user groups; S83. Recreate the default resource user; S84. Rebind the resource allocation plan, resources, and user groups of the resources; S85. Resume the execution plan for database resources; S86. Returns a result to the resource management application in RESTful form, indicating that cleanup of resources using the resource identifier set in the request parameters failed.
[0013] Furthermore, in step S9, an exception handler is executed for the failure to start the database resource allocation plan, including: Returns a result to the resource management application in RESTful form indicating that the database resource allocation plan failed to start.
[0014] Secondly, based on the same concept, the present invention also provides an apparatus for cleaning up 8a database cluster resources through an interface, which is deployed in a web container; A resource cleanup interface is provided, and the web container is interacted with through the resource cleanup interface; The web container interacts with the resource management application via RESTful HTTP, and also interacts with the GBase8aMPP database cluster via JDBC.
[0015] Compared with existing technologies, the method and apparatus for cleaning up 8a database cluster resources through an interface as described in this invention have the following beneficial effects: (1) It can provide a RESTful interface for external programs such as resource management applications to clean up resources in accordance with the RESTful specification.
[0016] (2) It can simplify the complexity of external applications cleaning up resources in the GBase8aMPP database.
[0017] (3) It can prevent resource management applications from directly using advanced database user operations to operate the database, thereby avoiding security risks. Attached Figure Description
[0018] The accompanying drawings, which form part of this invention, are used to provide a further understanding of the invention. The illustrative embodiments of the invention and their descriptions are used to explain the invention and do not constitute an undue limitation of the invention. In the drawings: Figure 1 This is a schematic diagram of the device layout for cleaning up 8a database cluster resources via an interface, as described in an embodiment of the present invention. Figure 2 This is a schematic diagram of the method for cleaning up 8a database cluster resources through an interface according to an embodiment of the present invention. Detailed Implementation
[0019] It should be noted that, unless otherwise specified, the embodiments and features described in the present invention can be combined with each other.
[0020] In the description of this invention, it should be understood that the terms "center," "longitudinal," "lateral," "upper," "lower," "front," "rear," "left," "right," "vertical," "horizontal," "top," "bottom," "inner," and "outer," etc., indicating orientations or positional relationships based on the orientations or positional relationships shown in the accompanying drawings, are only for the convenience of describing the invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation, and therefore should not be construed as a limitation of the invention. Furthermore, the terms "first," "second," etc., are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of indicated technical features. Thus, a feature defined with "first," "second," etc., may explicitly or implicitly include one or more of that feature. In the description of this invention, unless otherwise stated, "a plurality of" means two or more.
[0021] The present invention will now be described in detail with reference to the accompanying drawings and embodiments.
[0022] like Figures 1 to 2 As shown, a method and apparatus for cleaning up 8a database cluster resources through an interface are described below: like Figure 1 As shown, a device for cleaning up resources of an 8a database cluster via an interface is deployed in a web container; it has a resource cleaning interface and interacts with the web container through the resource cleaning interface; the web container interacts with the resource management application via RESTful HTTP, and the web container interacts with the GBase8aMPP database cluster via JDBC.
[0023] like Figure 2 As shown, a method for cleaning up 8a database cluster resources via an interface includes the following steps: First, receive a RESTful request from an external application to obtain cleanup resource parameters; second, verify the validity of the parameters; third, stop the current database resource allocation plan; fourth, clean up resource associations by unbinding the resource allocation plan, resources, and resource user groups; fifth, clean up the default users using the resources by unbinding ordinary users from the resource user groups; sixth, clean up the user groups using the resources; seventh, clean up the resources using the resource identifier set in the request parameters; eighth, start the database resource allocation plan; and ninth, return the cleanup results in RESTful format.
[0024] The specific explanation is as follows: RESTful requests refer to HTTP protocol requests that conform to the RESTful request specification. External applications send HTTP protocol requests to the web container, which can be Tomcat or other web containers that support the HTTP protocol. After receiving the request, the web container parses the request and obtains the request parameters, including the resource identifier of the resource to be cleaned up.
[0025] After obtaining the request parameters, the validity and rationality of the request parameters are verified, including whether the sender of the resource cleanup request has the authority to clean up the resources, whether the format of the resource identifier meets the requirements, and whether the resource identifier exists.
[0026] A resource allocation plan is a rule identifier for database resource allocation. The resource allocation plan is associated with resource quotas. Once a resource allocation plan is started, the resource quotas take effect. If you need to change the resource quotas, you need to stop the resource plan that has already been started.
[0027] A resource identifier is a unique identifier for a resource that needs to be cleaned up. In a database, a resource identifier is unique. In a specified target database, resources marked with resource identifiers can be cleaned up using resource identifiers.
[0028] A resource user group refers to a database user group with resource quotas corresponding to a resource identifier. A resource user group can be associated with database users. When logging into the database, database users associated with a resource user group can use the resources allocated by the resource quota. Different database users corresponding to different resources can be created for different applications. These users can log into the database, thereby achieving isolation of database resources. When cleaning up resources, it is necessary to clean up the resource user group according to the resource identifier.
[0029] The default user of a resource refers to the initial user who uses the resource. This user has the right to use the resource. When cleaning up resources, the default user of the resource needs to be unbound from the user group of the resource, and the default user should be deleted according to the resource identifier.
[0030] Resource association refers to the association that links resource allocation plans, resources, and resource user groups together. When cleaning up resources, resource associations are cleaned up based on resource identifiers, and resource allocation plans, resources, and resource user groups are unbound.
[0031] Start the resource allocation plan to make the previously cleaned-up resources, resource user groups, and default resource users effective.
[0032] The cleanup results are assembled into a return result in a manner that conforms to the RESTful specification and returned to the web container. The web container then returns the response result to the requester as an HTTP response.
[0033] Exception handling refers to the ability to roll back completed steps when an exception occurs during processing, and to assemble the returned result in a manner that conforms to RESTful specifications, and then return it to the web container. The web container then returns the response result to the requester as an HTTP response.
[0034] Database operations are performed by connecting to the database via JDBC and executing SQL statements to ensure database security.
[0035] The application is a program that runs on various operating system platforms, connects to the database via JDBC, and stores and processes data by executing SQL statements.
[0036] Resource management applications are applications that run on various operating system platforms, use the RESTful HTTP protocol to request and connect to the RESTful interfaces provided by various databases, and call the interfaces to perform resource management operations on the databases.
[0037] like Figure 1 As shown, a device for cleaning up 8a database cluster resources via an interface is deployed in a web container as a web application. It provides a RESTful resource cleanup interface service to the outside world. The external resource management application sends a RESTful HTTP request to the web container. The web container parses the parameters in the HTTP request and passes them to the device for resource cleanup. After the resource cleanup is completed, the device can assemble the return result in a manner that conforms to the RESTful specification and return it to the web container. The web container returns the response result to the request initiator in the form of an HTTP response.
[0038] Example 1: Failed to obtain cleanup resource parameters A1. Receiving RESTful requests from external applications and obtaining cleanup resource parameters. The resource management application sends a RESTful request to the web container via the HTTP protocol. The request includes the identifier of the resource to be cleaned up, the user and password for cleaning up the resource, in the form of http: / / admin:admin@192.168.0.1:8080 / resouseDelete / resourceId.
[0039] When a web container receives an HTTP request, it parses the request content to obtain the request parameters. During the parsing process, if no request parameters are included, the parameter retrieval will fail.
[0040] A2. Returning the resource cleanup results in a RESTful format (stage) Returning a result indicating a failure to retrieve parameters to the resource management application.
[0041] Example 2: Parameter validity verification failed. B1. Receiving RESTful requests from external applications and obtaining cleanup resource parameters. The resource management application sends a RESTful request to the web container via the HTTP protocol. The request includes the identifier of the resource to be cleaned up, the user and password for cleaning up the resource, in the form of http: / / admin:admin@192.168.0.1:8080 / resouseDelete / resourceId.
[0042] When the web container receives an HTTP request, it parses the request content and obtains the request parameters. During the parsing process, it can normally obtain the resourceId identifier for cleaning up resources, the user account for cleaning up resources (admin), and the password (admin).
[0043] B2. Parameter validity verification stage Verify that the passed-in resourceId identifier, the user admin and password admin for cleaning up resources conform to the format requirement that it can only consist of numbers, letters and underscores. Assume that it does.
[0044] The program compares the username and password "admin" with the username and password stored internally. If they do not match, the user does not have resource cleanup privileges; otherwise, it is assumed that the user does.
[0045] Retrieve the list of existing resource identifiers and compare them with the resourceId to determine if the resourceId to be cleaned exists. If it does not exist, the validity verification fails.
[0046] B3. Return the resource cleanup results in a RESTful format. Returns a result indicating that parameter validity verification failed to the resource management application.
[0047] Example 3: Failed to stop the execution plan for the current database resources C1. Receiving RESTful requests from external applications and obtaining cleanup resource parameters. The resource management application sends a RESTful request to the web container via the HTTP protocol. The request includes the identifier of the resource to be cleaned up, the user and password for cleaning up the resource, in the form of http: / / admin:admin@192.168.0.1:8080 / resouseDelete / resourceId.
[0048] When the web container receives an HTTP request, it parses the request content and obtains the request parameters. During the parsing process, it can normally obtain the resourceId identifier for cleaning up resources, the user account for cleaning up resources (admin), and the password (admin).
[0049] C2. Parameter validity verification stage Verify that the passed-in resourceId identifier, the user admin and password admin for cleaning up resources conform to the format requirement that it can only consist of numbers, letters and underscores. Assume that it does.
[0050] The program compares the username and password "admin" with the username and password stored internally. If they do not match, the user does not have resource cleanup privileges; otherwise, it is assumed that the user does.
[0051] Retrieve the list of existing resource identifiers and compare them with the resourceId. Determine if the resourceId to be cleaned exists. If it does, the validity verification is successful.
[0052] C3. Stop the current database resource execution plan phase. Based on the cleanup resource identifier resourceId, obtain the running status of the current database resource execution plan. If the resource execution plan is running, continue with the following steps.
[0053] By sending the command "deactive resource plan" to the database, the running database resource execution plan is stopped. If the execution of this command fails, then the current database resource execution plan will fail to be stopped.
[0054] C4. Return the resource cleanup results in a RESTful format. Returns a result to the resource management application indicating that the execution plan for stopping the current database resource failed.
[0055] Example 4: Unbinding resource allocation plans, resources, and user groups failed. D1. Receiving RESTful requests from external applications and obtaining cleanup resource parameters. The resource management application sends a RESTful request to the web container via the HTTP protocol. The request includes the identifier of the resource to be cleaned up, the user and password for cleaning up the resource, in the form of http: / / admin:admin@192.168.0.1:8080 / resouseDelete / resourceId.
[0056] When the web container receives an HTTP request, it parses the request content and obtains the request parameters. During the parsing process, it can normally obtain the resourceId identifier for cleaning up resources, the user account for cleaning up resources (admin), and the password (admin).
[0057] D2. Parameter validity verification stage Verify that the passed-in resourceId identifier, the user admin and password admin for cleaning up resources conform to the format requirement that it can only consist of numbers, letters and underscores. Assume that it does.
[0058] The program compares the username and password "admin" with the username and password stored internally. If they do not match, the user does not have resource cleanup privileges; otherwise, it is assumed that the user does.
[0059] Retrieve the list of existing resource identifiers and compare them with the resourceId. Determine if the resourceId to be cleaned exists. If it does, the validity verification is successful.
[0060] D3. Stop the current database resource execution plan phase. Based on the cleanup resource identifier resourceId, obtain the current database resource execution plan resourcePlan and the running status of the resource execution plan. The resource execution plan is currently running.
[0061] By sending the command "deactive resource plan" to the database, the running database resource execution plan is stopped, assuming that the current database resource execution plan is stopped successfully.
[0062] D4. Clean up resource associations, unbinding resource allocation plans, resources, and user groups associated with resources. Based on the cleanup resource identifier resourceId, obtain the resource association resourceDirective for the current resource.
[0063] By sending the command "drop resource directive" to the database, resource associations are cleared, and resource allocation plans, resources, and user groups of resources are unbound. (Assuming failure).
[0064] Restart the stopped database resource execution plan by sending the command "activeresource plan" to the database to resume its execution.
[0065] D5. Return the resource cleanup results in a RESTful format. The resource management application returned a result indicating that the cleanup of resource associations and the unbinding of resource allocation plans, resources, and user groups for those resources had failed.
[0066] Example 5: Cleaning up default users using resources; unbinding ordinary users from resource user groups failed. E1. Receiving RESTful requests from external applications to obtain cleanup resource parameters. The resource management application sends a RESTful request to the web container via the HTTP protocol. The request includes the identifier of the resource to be cleaned up, the user and password for cleaning up the resource, in the form of http: / / admin:admin@192.168.0.1:8080 / resouseDelete / resourceId.
[0067] When the web container receives an HTTP request, it parses the request content and obtains the request parameters. During the parsing process, it can normally obtain the resourceId identifier for cleaning up resources, the user account for cleaning up resources (admin), and the password (admin).
[0068] E2. Parameter validity verification stage Verify that the passed-in resourceId identifier, the user admin and password admin for cleaning up resources conform to the format requirement that it can only consist of numbers, letters and underscores. Assume that it does.
[0069] The program compares the username and password "admin" with the username and password stored internally. If they do not match, the user does not have resource cleanup privileges; otherwise, it is assumed that the user does.
[0070] Retrieve the list of existing resource identifiers and compare them with the resourceId. Determine if the resourceId to be cleaned exists. If it does, the validity verification is successful.
[0071] E3. Stop the current database resource execution plan phase. Based on the cleanup resource identifier resourceId, obtain the current database resource execution plan resourcePlan and the running status of the resource execution plan. The resource execution plan is currently running.
[0072] By sending the command "deactive resource plan" to the database, the running database resource execution plan is stopped, assuming that the current database resource execution plan is stopped successfully.
[0073] E4. Clean up resource associations, unbinding resource allocation plans, resources, and user groups associated with those resources. Based on the cleanup resource identifier resourceId, obtain the resource association resourceDirective for the current resource.
[0074] By sending the command "drop resource directive" to the database, resource associations are cleared, thereby unbinding resource allocation plans, resources, and user groups of resources. It is assumed that the clearing of resource associations is successful.
[0075] E5. Clean up the default users using the resources, and unbind ordinary users from the user groups of the resources. Based on the cleanup resource identifier resourceId, obtain the default user (defaultUser) for the current resource.
[0076] Based on the resourceId identifier, obtain the user group name (userGroup) of the current resource.
[0077] Retrieves a list of database users bound to the current user group based on the user group name userGroup.
[0078] The user is dropped by default and the user is dropped by the database. Assuming the drop is successful, the drop is dropped.
[0079] By sending the command `alter consumer group` to the database, users bound to the current user group can be unbound, assuming the execution fails.
[0080] The default resource user is recreated by sending the command "create user" to the database.
[0081] By sending the command `create resource directive` to the database, the resource allocation plan, resources, and user groups of the resources are re-bound.
[0082] The database resource execution plan is resumed by sending the command "active resource plan" to the database.
[0083] E6. Return the resource cleanup results in a RESTful format. The resource management application returns the result that the process of unbinding ordinary users from the user groups of the resources failed, indicating that the default users used to clean up the resources had been cleared.
[0084] Example 6: Failed to clean up user groups using resources F1. Receiving RESTful requests from external applications and obtaining cleanup resource parameters. The resource management application sends a RESTful request to the web container via the HTTP protocol. The request includes the identifier of the resource to be cleaned up, the user and password for cleaning up the resource, in the form of http: / / admin:admin@192.168.0.1:8080 / resouseDelete / resourceId.
[0085] When the web container receives an HTTP request, it parses the request content and obtains the request parameters. During the parsing process, it can normally obtain the resourceId identifier for cleaning up resources, the user account for cleaning up resources (admin), and the password (admin).
[0086] F2. Parameter validity verification stage Verify that the passed-in resourceId identifier, the user admin and password admin for cleaning up resources conform to the format requirement that it can only consist of numbers, letters and underscores. Assume that it does.
[0087] The program compares the username and password "admin" with the username and password stored internally. If they do not match, the user does not have resource cleanup privileges; otherwise, it is assumed that the user does.
[0088] Retrieve the list of existing resource identifiers and compare them with the resourceId. Determine if the resourceId to be cleaned exists. If it does, the validity verification is successful.
[0089] F3, Stop the current database resource execution plan phase. Based on the cleanup resource identifier resourceId, obtain the current database resource execution plan resourcePlan and the running status of the resource execution plan. The resource execution plan is currently running.
[0090] By sending the command "deactive resource plan" to the database, the running database resource execution plan is stopped, assuming that the current database resource execution plan is stopped successfully.
[0091] F4. Clean up resource associations, unbinding resource allocation plans, resources, and user groups associated with those resources. Based on the cleanup resource identifier resourceId, obtain the resource association resourceDirective for the current resource.
[0092] By sending the command "drop resource directive" to the database, resource associations are cleared, thereby unbinding resource allocation plans, resources, and user groups of resources. It is assumed that the clearing of resource associations is successful.
[0093] F5: Clean up the default users using the resources, and unbind ordinary users from the resource's user group. Based on the cleanup resource identifier resourceId, obtain the default user (defaultUser) for the current resource.
[0094] Based on the resourceId identifier, obtain the user group name (userGroup) of the current resource.
[0095] Retrieves a list of database users bound to the current user group based on the user group name userGroup.
[0096] The user is dropped by default and the user is dropped by the database. Assuming the drop is successful, the drop is dropped.
[0097] By sending the command `alter consumer group` to the database, users bound to the current user group are unbound, assuming the execution is successful.
[0098] F6, Phase of cleaning up user groups using resources Based on the resourceId identifier, obtain the user group name (userGroup) of the current resource.
[0099] The user group that uses resources is cleaned up by sending the command "drop consumer group" to the database. The execution is assumed to fail.
[0100] By sending the command `alter consumer group` to the database, the user and user group are re-bound.
[0101] The default resource user is recreated by sending the command "create user" to the database.
[0102] By sending the command `create resource directive` to the database, the resource allocation plan, resources, and user groups of the resources are re-bound.
[0103] The database resource execution plan is resumed by sending the command "active resource plan" to the database.
[0104] F7. Return the resource cleanup results in a RESTful format. The resource management application returns a result indicating that the cleanup of user groups using resources failed.
[0105] Example 7: Failed to clean up resources using the resource identifier set in the request parameters G1, Receiving RESTful requests from external applications to obtain cleanup resource parameters. The resource management application sends a RESTful request to the web container via the HTTP protocol. The request includes the identifier of the resource to be cleaned up, the user and password for cleaning up the resource, in the form of http: / / admin:admin@192.168.0.1:8080 / resouseDelete / resourceId.
[0106] When the web container receives an HTTP request, it parses the request content and obtains the request parameters. During the parsing process, it can normally obtain the resourceId identifier for cleaning up resources, the user account for cleaning up resources (admin), and the password (admin).
[0107] G2, Parameter validity verification stage Verify that the passed-in resourceId identifier, the user admin and password admin for cleaning up resources conform to the format requirement that it can only consist of numbers, letters and underscores. Assume that it does.
[0108] The program compares the username and password "admin" with the username and password stored internally. If they do not match, the user does not have resource cleanup privileges; otherwise, it is assumed that the user does.
[0109] Retrieve the list of existing resource identifiers and compare them with the resourceId. Determine if the resourceId to be cleaned exists. If it does, the validity verification is successful.
[0110] G3, Stop the current database resource execution plan phase. Based on the cleanup resource identifier resourceId, obtain the current database resource execution plan resourcePlan and the running status of the resource execution plan. The resource execution plan is currently running.
[0111] By sending the command "deactive resource plan" to the database, the running database resource execution plan is stopped, assuming that the current database resource execution plan is stopped successfully.
[0112] G4. Clean up resource associations, unbinding resource allocation plans, resources, and user groups associated with resources. Based on the cleanup resource identifier resourceId, obtain the resource association resourceDirective for the current resource.
[0113] By sending the command "drop resource directive" to the database, resource associations are cleared, thereby unbinding resource allocation plans, resources, and user groups of resources. It is assumed that the clearing of resource associations is successful.
[0114] G5. Clean up the default users using the resources, and unbind ordinary users from the user groups of the resources. Based on the cleanup resource identifier resourceId, obtain the default user (defaultUser) for the current resource.
[0115] Based on the resourceId identifier, obtain the user group name (userGroup) of the current resource.
[0116] Retrieves a list of database users bound to the current user group based on the user group name userGroup.
[0117] The user is dropped by default and the user is dropped by the database. Assuming the drop is successful, the drop is dropped.
[0118] By sending the command `alter consumer group` to the database, users bound to the current user group are unbound, assuming the execution is successful.
[0119] G6, Phase 6: Cleaning up user groups using resources Based on the resourceId identifier, obtain the user group name (userGroup) of the current resource.
[0120] By sending the command "drop consumer group" to the database, the user group using the resources is cleaned up, assuming the execution is successful.
[0121] G7. Resource cleanup phase using resource identifiers set in request parameters. Resources are cleaned up by sending the command "drop resource pool" to the database, assuming the execution fails.
[0122] The user group is recreated by sending the command "create consumer group" to the database.
[0123] By sending the command `alter consumer group` to the database, the user and user group are re-bound.
[0124] The default resource user is recreated by sending the command "create user" to the database.
[0125] By sending the command `create resource directive` to the database, the resource allocation plan, resources, and user groups of the resources are re-bound.
[0126] The database resource execution plan is resumed by sending the command "active resource plan" to the database.
[0127] 8. Return the resource cleanup results in a RESTful format. Returns a result to the resource management application indicating that cleanup of resources using the resource identifier set in the request parameters failed.
[0128] Example 8: Failed to start database resource allocation plan H1. Receiving RESTful requests from external applications and obtaining cleanup resource parameters. The resource management application sends a RESTful request to the web container via the HTTP protocol. The request includes the identifier of the resource to be cleaned up, the user and password for cleaning up the resource, in the form of http: / / admin:admin@192.168.0.1:8080 / resouseDelete / resourceId.
[0129] When the web container receives an HTTP request, it parses the request content and obtains the request parameters. During the parsing process, it can normally obtain the resourceId identifier for cleaning up resources, the user account for cleaning up resources (admin), and the password (admin).
[0130] H2. Parameter validity verification stage Verify that the passed-in resourceId identifier, the user admin and password admin for cleaning up resources conform to the format requirement that it can only consist of numbers, letters and underscores. Assume that it does.
[0131] The program compares the username and password "admin" with the username and password stored internally. If they do not match, the user does not have resource cleanup privileges; otherwise, it is assumed that the user does.
[0132] Retrieve the list of existing resource identifiers and compare them with the resourceId. Determine if the resourceId to be cleaned exists. If it does, the validity verification is successful.
[0133] H3. Stop the current database resource execution plan phase. Based on the cleanup resource identifier resourceId, obtain the current database resource execution plan resourcePlan and the running status of the resource execution plan. The resource execution plan is currently running.
[0134] By sending the command "deactive resource plan" to the database, the running database resource execution plan is stopped, assuming that the current database resource execution plan is stopped successfully.
[0135] H4. Clean up resource associations, unbinding resource allocation plans, resources, and user groups associated with resources. Based on the cleanup resource identifier resourceId, obtain the resource association resourceDirective for the current resource.
[0136] By sending the command "drop resource directive" to the database, resource associations are cleared, thereby unbinding resource allocation plans, resources, and user groups of resources. It is assumed that the clearing of resource associations is successful.
[0137] H5: Clean up the default users using the resources, and unbind ordinary users from the user groups of the resources. Based on the cleanup resource identifier resourceId, obtain the default user (defaultUser) for the current resource.
[0138] Based on the resourceId identifier, obtain the user group name (userGroup) of the current resource.
[0139] Retrieves a list of database users bound to the current user group based on the user group name userGroup.
[0140] The user is dropped by default and the user is dropped by the database. Assuming the drop is successful, the drop is dropped.
[0141] By sending the command `alter consumer group` to the database, users bound to the current user group are unbound, assuming the execution is successful.
[0142] H6. Phase of cleaning up user groups using resources Based on the resourceId identifier, obtain the user group name (userGroup) of the current resource.
[0143] By sending the command "drop consumer group" to the database, the user group using the resources is cleaned up, assuming the execution is successful.
[0144] H7. Resource cleanup phase using resource identifiers set in request parameters Resources are cleaned up by sending the command "drop resource pool" to the database, assuming the execution is successful.
[0145] H8. Start the database resource allocation plan phase Based on the cleanup resource identifier resourceId, obtain the current database resource execution plan resourcePlan.
[0146] By sending the command "active resource plan" to the database, a database resource allocation plan is initiated. Assuming the execution fails, since the resources to be cleaned up have already been completely removed, the restoration of cleaned-up resources will not be performed.
[0147] H9. Return the resource cleanup results in a RESTful format. The resource management application is returned a result indicating that the database resource allocation plan failed to be launched.
[0148] Example 9: Resource cleanup successful I1. Receiving RESTful requests from external applications and obtaining cleanup resource parameters. The resource management application sends a RESTful request to the web container via the HTTP protocol. The request includes the identifier of the resource to be cleaned up, the user and password for cleaning up the resource, in the form of http: / / admin:admin@192.168.0.1:8080 / resouseDelete / resourceId.
[0149] When the web container receives an HTTP request, it parses the request content and obtains the request parameters. During the parsing process, it can normally obtain the resourceId identifier for cleaning up resources, the user account for cleaning up resources (admin), and the password (admin).
[0150] I2. Parameter validity verification stage Verify that the passed-in resourceId identifier, the user admin and password admin for cleaning up resources conform to the format requirement that it can only consist of numbers, letters and underscores. Assume that it does.
[0151] The program compares the username and password "admin" with the username and password stored internally. If they do not match, the user does not have resource cleanup privileges; otherwise, it is assumed that the user does.
[0152] Retrieve the list of existing resource identifiers and compare them with the resourceId. Determine if the resourceId to be cleaned exists. If it does, the validity verification is successful.
[0153] I3. Stop the current database resource execution plan phase. Based on the cleanup resource identifier resourceId, obtain the current database resource execution plan resourcePlan and the running status of the resource execution plan. The resource execution plan is currently running.
[0154] By sending the command "deactive resource plan" to the database, the running database resource execution plan is stopped, assuming that the current database resource execution plan is stopped successfully.
[0155] I4. Clean up resource associations, unbinding resource allocation plans, resources, and user groups associated with resources. Based on the resourceId identifier, obtain the resourceDirective associated with the current resource.
[0156] By sending the command "drop resource directive" to the database, resource associations are cleared, thereby unbinding resource allocation plans, resources, and user groups of resources. It is assumed that the clearing of resource associations is successful.
[0157] I5. Clean up the default users using the resources, and unbind ordinary users from the user groups of the resources. Based on the cleanup resource identifier resourceId, obtain the default user (defaultUser) for the current resource.
[0158] Based on the resourceId identifier, obtain the user group name (userGroup) of the current resource.
[0159] Retrieves a list of database users bound to the current user group based on the user group name userGroup.
[0160] The user who is using the default resource is cleaned up by sending the command "drop user" to the database. Assume that the cleanup is successful.
[0161] By sending the command `alter consumer group` to the database, users bound to the current user group are unbound, assuming the execution is successful.
[0162] I6. Phase 1: Cleaning up user groups using resources Based on the resourceId identifier, obtain the user group name (userGroup) of the current resource.
[0163] By sending the command "drop consumer group" to the database, the user group using the resources is cleaned up, assuming the execution is successful.
[0164] I7. Resource cleanup phase using resource identifiers set in request parameters Resources are cleaned up by sending the command "drop resource pool" to the database, assuming the execution is successful.
[0165] I8. Start the database resource allocation plan phase Based on the cleanup resource identifier resourceId, obtain the current database resource execution plan resourcePlan.
[0166] The database resource allocation plan is initiated by sending the command "active resource plan" to the database, and it is assumed that the execution is successful.
[0167] I9. Return the resource cleanup results in a RESTful format. Return a successful resource cleanup result to the resource management application.
[0168] Advantages and benefits of this invention: (1) It can provide a RESTful interface for external programs such as resource management applications to clean up resources in accordance with the RESTful specification.
[0169] (2) It can simplify the complexity of external applications cleaning up resources in the GBase8aMPP database.
[0170] (3) It can avoid the security risks caused by the resource management application directly using the advanced database user to operate the database.
[0171] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.
Claims
1. A method for cleaning up 8a database cluster resources through an interface, characterized in that: Includes the following steps: S1. The resource management application sends RESTful requests to the web container via the HTTP protocol; S2. When the Web container receives an HTTP request, it parses the request content and obtains the request parameters. If there is an exception, it executes the exception handling procedure for the failure to obtain parameters; otherwise, it continues to the next step S3. S3. Validate the validity of the request parameters in step S2. If there is an error, execute the exception handling procedure for the failure of parameter validity validation. Otherwise, continue to the next step S4. S4. Based on the request parameters verified in step S3, stop the current database resource execution plan. If there is an exception, execute the exception handling procedure for the failure to stop the current database resource execution plan; otherwise, continue to the next step S5. S5. Based on the request parameters verified in step S3, clean up resource associations and unbind the resource allocation plan, resource, and user group of the resource. If there is an error, execute the exception handling procedure for the failure to clean up resource associations and unbind the resource allocation plan, resource, and user group of the resource. Otherwise, continue to the next step S6. S6. Based on the request parameters verified in step S3, clean up the users using the default resources and unbind ordinary users from the user groups of the resources. If there is an error, execute the exception handling procedure for the failure to clean up the users using the default resources and unbind ordinary users from the user groups of the resources. Otherwise, continue to the next step S7. S7. Based on the request parameters verified in step S3, clean up the user groups using resources. If there is an error, execute the exception handling procedure for the failure to clean up the user groups using resources. Otherwise, continue to the next step S8. S8. Based on the request parameters verified in step S3, clean up the resources using the resource identifier set in the request parameters. If there is an error, execute the exception handling procedure for the failure to clean up the resources using the resource identifier set in the request parameters. Otherwise, continue to the next step S9. S9. Based on the request parameters verified in step S3, start the database resource allocation plan. If there is an exception, execute the exception handling procedure for the failure to start the database resource allocation plan; otherwise, return the result of successful resource cleanup to the resource management application in RESTful form.
2. The method for cleaning up 8a database cluster resources through an interface according to claim 1, characterized in that: In step S2, the request parameters are obtained, including: Obtain the resource identifier, username, and password for cleaning up resources.
3. The method for cleaning up 8a database cluster resources through an interface according to claim 2, characterized in that: Resource identifiers are unique.
4. The method for cleaning up 8a database cluster resources through an interface according to claim 1, characterized in that: In step S2, an exception handling procedure is executed for parameter acquisition failure, including: Return the result of parameter retrieval failure to the resource management application in RESTful format; In step S3, an exception handling procedure is executed for parameter validity verification failure, including: Returns a result indicating parameter validity verification failure to the resource management application in RESTful format; In step S4, an exception handler is executed for the failure to stop the current database resource execution plan, including: Returns a result to the resource management application in RESTful form indicating that the execution plan for stopping the current database resource has failed.
5. The method for cleaning up 8a database cluster resources through an interface according to claim 1, characterized in that: In step S5, an exception handling procedure is executed for the failure to unbind resource allocation plans, resources, and user groups of resources during the cleanup of resource associations, including: S51. Resume the execution plan for database resources; S52. Returns a result to the resource management application in RESTful form, indicating that the cleanup of resource associations and the unbinding of resource allocation plans, resources, and user groups of resources failed.
6. The method for cleaning up 8a database cluster resources through an interface according to claim 1, characterized in that: In step S6, an exception handling procedure is executed for failures in unbinding ordinary users from the user group using the default resource cleanup, including: S61. If the user using the default resource has been cleared, then recreate the default resource user. S62. Rebind the resource allocation plan, resources, and user groups of the resources; S63. Resume the execution plan for database resources; S64. Returns the result to the resource management application in RESTful form: the user group that cleaned up the default resource failed to unbind from the user group of the resource.
7. The method for cleaning up 8a database cluster resources through an interface according to claim 1, characterized in that: In step S7, an exception handling procedure is executed for the failure to clean up user groups using resources, including: S71. Rebind users and user groups; S72. Recreate the default resource user; S73. Rebind the resource allocation plan, resources, and user groups of the resources; S74. Resume the execution plan for database resources; S75. Returns the result of failure to clean up user groups using resources to the resource management application in a RESTful manner.
8. The method for cleaning up 8a database cluster resources through an interface according to claim 1, characterized in that: In step S8, an exception handler is executed for failure to clean up resources using the resource identifier set with the request parameters, including: S81. Recreate the user group; S82. Rebind users and user groups; S83. Recreate the default resource user; S84. Rebind the resource allocation plan, resources, and user groups of the resources; S85. Resume the execution plan for database resources; S86. Returns a result to the resource management application in RESTful form, indicating that cleanup of resources using the resource identifier set in the request parameters failed.
9. The method for cleaning up 8a database cluster resources through an interface according to claim 1, characterized in that: In step S9, an exception handler is executed for the failure to start the database resource allocation plan, including: Returns a result to the resource management application in RESTful form indicating that the database resource allocation plan failed to start.
10. An apparatus for cleaning up 8a database cluster resources via an interface, applied to the method for cleaning up 8a database cluster resources via an interface as described in any one of claims 1-9, characterized in that: Deployed in a web container; A resource cleanup interface is provided, and the web container is interacted with through the resource cleanup interface; The web container interacts with the resource management application via RESTful HTTP, and also interacts with the GBase8aMPP database cluster via JDBC.
Citation Information
Patent Citations
Data processing method and device, electronic equipment and storage medium
CN110427368A
Distributed storage data storage compatible method and system
CN114706919A
Method and device for creating database resources based on restful interface and electronic equipment
CN118410030A
Cluster resource management method and device, computer equipment, readable storage medium and program product
CN119474422A
System and method for policy based migration using mtree replication with data protection applications
US20210182253A1