Method and device for cleaning database cluster resources through an interface
Patent Information
- Application Number
- CN202511869992.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-12
- Publication Date
- 2026-02-27
- Estimated Expiration
- 2045-12-12
AI Technical Summary
[0004]在现有的实现方式中,GBase8aMPP数据库集群虽然已经提供了清理数据库资源的功能,但是该功能操作需要直接操作数据库,而不是通过restful接口方式,且操作步骤复杂,导致无法对接专门用于资源管控的应用,从而在部署时遇到障碍
[0053] (1) An external program such as a resource management application can be provided with a resource cleaning interface conforming to a restful specification.
Smart Images

Figure CN121301467B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of GBase8aMPP database cluster resource cleanup, and in particular relates to a method and apparatus for cleanup 8a database cluster resources through an interface. Background Technology
[0002] Currently, the use of GBase8aMPP database clusters for data computation and storage is very common. When using GBase8aMPP database clusters, due to their strong service capabilities, they can provide data computation and storage services to multiple applications in many scenarios. In this case, to isolate the resources used by applications and avoid contention for database resources among multiple applications, the database needs to provide resource allocation functionality. This allocates database cluster resources to each application, limiting the available CPU, memory, and other resource quotas. Simultaneously, when resources are no longer in use, the database also needs to provide resource cleanup functionality. Resource cleanup is generally implemented through a resource management platform. Since resource management platforms often operate on multiple databases, they do not directly manipulate the database but instead use RESTful interfaces provided by the database. This requires the database to provide RESTful interfaces to support database resource cleanup.
[0003] Problems with existing technology:
[0004] In the existing implementation, although the GBase8aMPP database cluster has provided the function of cleaning up database resources, this function requires direct operation of the database instead of through a RESTful interface, and the operation steps are complicated, making it impossible to connect with applications specifically used for resource management, thus encountering obstacles during deployment. Summary of the Invention
[0005] In view of this, the present invention aims to propose a method and apparatus for cleaning up 8a database cluster resources through an interface, so as to solve the problems existing in the prior art.
[0006] To achieve the above objectives, the technical solution of the present invention is implemented as follows:
[0007] In a first aspect, the present invention provides a method for cleaning up 8a database cluster resources through an interface, comprising the following steps:
[0008] S1. The resource management application sends RESTful requests to the web container via the HTTP protocol;
[0009] S2, the Web container receives the http request, parses the request content, obtains the request parameter, if abnormal, executes the exception handling program for parameter acquisition failure, otherwise, continues to execute the next step S3;
[0010] S3, the request parameter of step S2 is verified for validity, if abnormal, executes the exception handling program for parameter validity verification failure, otherwise, continues to execute the next step S4;
[0011] S4, based on the request parameter verified in step S3, stop the current database resource execution plan, if abnormal, execute the exception handling program for stopping the current database resource execution plan failure, otherwise, continue to execute the next step S5;
[0012] S5, based on the request parameter verified in step S3, clean up the resource association, unbind the resource allocation plan, resource, and user group of the resource, if abnormal, execute the exception handling program for cleaning up the resource association, unbind the resource allocation plan, resource, and user group of the resource failure, otherwise, continue to execute the next step S6;
[0013] S6, based on the request parameter verified in step S3, clean up the user of the default resource, unbind the ordinary user and the user group of the resource, if abnormal, execute the exception handling program for cleaning up the user of the default resource, unbind the ordinary user and the user group of the resource failure, otherwise, continue to execute the next step S7;
[0014] S7, based on the request parameter verified in step S3, clean up the user group using the resource, if abnormal, execute the exception handling program for cleaning up the user group using the resource failure, otherwise, continue to execute the next step S8;
[0015] S8, based on the request parameter verified in step S3, use the resource identifier set by the request parameter to clean up the resource, if abnormal, execute the exception handling program for using the resource identifier set by the request parameter to clean up the resource failure, otherwise, continue to execute the next step S9;
[0016] S9, based on the request parameter verified in step S3, start the database resource allocation plan, if abnormal, execute the exception handling program for starting the database resource allocation plan failure, otherwise, return the result of cleaning up the resource successfully to the resource management application in the form of restful.
[0017] Further, in step S2, the request parameter is obtained, including:
[0018] The resource identifier, username and password for cleaning up the resource are obtained.
[0019] Further, the resource identifier is unique.
[0020] Further, in step S2, an exception handling procedure for parameter acquisition failure is executed, including:
[0021] returning the result of parameter acquisition failure to the resource management application in the form of restful;
[0022] In step S3, an exception handling procedure for parameter validity verification failure is executed, including:
[0023] returning the result of parameter validity verification failure to the resource management application in the form of restful;
[0024] In step S4, an exception handling procedure for stopping the current database resource execution plan failure is executed, including:
[0025] returning the result of stopping the current database resource execution plan failure to the resource management application in the form of restful.
[0026] Further, in step S5, an exception handling procedure for cleaning resource association, unbinding resource allocation plan, resource, and user group of the resource is executed, including:
[0027] S51, resuming the running of the database resource execution plan;
[0028] S52, returning the result of cleaning resource association, unbinding resource allocation plan, resource, and user group of the resource to the resource management application in the form of restful.
[0029] Further, in step S6, an exception handling procedure for cleaning the user of default resource usage, unbinding ordinary user and user group of the resource is executed, including:
[0030] S61, if the user of default resource usage has been cleaned, re-creating the default resource user;
[0031] S62, re-binding resource allocation plan, resource, and user group of the resource;
[0032] S63, resuming the running of the database resource execution plan;
[0033] S64, returning the result of cleaning the user of default resource usage, unbinding ordinary user and user group of the resource to the resource management application in the form of restful.
[0034] Further, in step S7, an exception handling procedure for cleaning the user group of resource usage failure is executed, including:
[0035] S71, rebind the user and the user group;
[0036] S72, re-create the default resource user;
[0037] S73, rebind the resource allocation plan, the resource, and the user group of the resource;
[0038] S74, restore the operation of the database resource execution plan;
[0039] S75, return the result of the failure of the cleaning of the user group using the resource to the resource management application in the form of restful.
[0040] Further, in step S8, an exception handling program for cleaning the resource of the resource identifier set by the use request parameter is executed, including:
[0041] S81, re-create the user group;
[0042] S82, rebind the user and the user group;
[0043] S83, re-create the default resource user;
[0044] S84, rebind the resource allocation plan, the resource, and the user group of the resource;
[0045] S85, restore the operation of the database resource execution plan;
[0046] S86, return the result of the failure of the cleaning of the resource of the resource identifier set by the use request parameter to the resource management application in the form of restful.
[0047] Further, in step S9, an exception handling program for starting the database resource allocation plan is executed, including:
[0048] Return the result of the failure of starting the database resource allocation plan to the resource management application in the form of restful.
[0049] In a second aspect, based on the same aspect, the application further provides an apparatus for cleaning the resources of a database cluster 8a through an interface, which is deployed in a web container;
[0050] The resource cleaning interface is provided, and the web container interacts with the resource management application through the resource cleaning interface;
[0051] The web container interacts with the resource management application through http in the form of restful, and the web container interacts with the GBase8aMPP database cluster through JDBC.
[0052] Compared with the prior art, the method and device for cleaning up 8a database cluster resources through an interface have the following beneficial effects:
[0053] (1) An external program such as a resource management application can be provided with a resource cleaning interface conforming to a restful specification.
[0054] (2) The complexity of an external application in cleaning up resources of a GBase 8a MPP database can be simplified.
[0055] (3) A resource management application can be prevented from directly using a high-level database user to operate a database, thereby avoiding security risks. BRIEF DESCRIPTION OF DRAWINGS
[0056] The accompanying drawings, which form a part of the present application, are intended to provide further understanding of the present application, and are used to interpret the specific embodiments of the present application and their descriptions, and do not constitute improper limitations on the present application. In the drawings:
[0057] Figure 1 The device for cleaning up 8a database cluster resources through an interface according to the embodiment of the present application is schematically shown in the figure;
[0058] Figure 2 The method flowchart for cleaning up 8a database cluster resources through an interface according to the embodiment of the present application is schematically shown in the figure. DETAILED DESCRIPTION
[0059] It should be noted that the embodiments in the present application and the features in the embodiments can be combined with each other without conflict.
[0060] In the description of the present application, it should be understood that the terms "center", "longitudinal", "transverse", "upper", "lower", "front", "rear", "left", "right", "vertical", "horizontal", "top", "bottom", "inner", "outer", and the like indicate the orientation or positional relationship shown in the drawings, and are only used to facilitate the description of the present application and simplify the description, and do not indicate or imply that the device or element referred to must have a particular orientation, be constructed and operated in a particular orientation, and therefore cannot be understood as a limitation on the present application. In addition, the terms "first", "second", and the like are only used for descriptive purposes, and cannot be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Therefore, the features limited by "first", "second", and the like can explicitly or implicitly include one or more features. In the description of the present application, unless otherwise stated, the meaning of "a plurality of" is two or more.
[0061] The present application will be described in detail below with reference to the accompanying drawings and in conjunction with the embodiments.
[0062] AsFigures 1 to 2 As shown, a method and apparatus for cleaning up 8a database cluster resources through an interface are described below:
[0063] 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.
[0064] 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.
[0065] The specific explanation is as follows:
[0066] 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.
[0067] 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.
[0068] 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.
[0069] 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.
[0070] The user group of the resource refers to a database user group corresponding to a resource quota of the resource. The user group of the resource can be associated with a database user. The database user associated with the user group of the resource can use the resource allocated by the resource quota when logging into the database. The database user corresponding to different resources can be created for different applications. The database is logged in by using these users, so as to realize the isolation of the database resources. When the resources are cleaned up, the user group of the resources needs to be cleaned up according to the resource identifier.
[0071] The default resource user refers to an initial user using the resource. The user has the right to create the resource. When the resource is cleaned up, the default resource user needs to be unbound from the user group of the resource, and the default user is deleted according to the resource identifier.
[0072] The resource association refers to an association relationship of associating the resource allocation plan, the resource, and the user group of the resource together. When the resource is cleaned up, the resource association is cleaned up according to the resource identifier, and the resource allocation plan, the resource, and the user group of the resource are unbound.
[0073] The resource allocation plan is started, and the previously cleaned resource, the user group of the resource, and the default resource user are validated.
[0074] The cleaning result is assembled into a return result in a manner conforming to the restful specification, and is returned to the web container. The web container returns the response result to the request initiator in the form of an http response.
[0075] The exception handling refers to that when an exception occurs in the processing process, the previously executed steps can be rolled back, and the return result can be assembled in a manner conforming to the restful specification, and is returned to the web container. The web container returns the response result to the request initiator in the form of an http response.
[0076] The operation on the database is linked to the database by using the jdbc mode, and a SQL statement is executed to complete the operation, so as to ensure the safety of the database.
[0077] The application program is an application program running on various operating system platforms, linking to the database by using the jdbc mode, and storing and operating data by executing a SQL statement.
[0078] The resource management and control application program is an application program running on various operating system platforms, linking to the restful interface provided by each database by using the restful form of http protocol request, and calling the interface to complete the management and control operation on the resource of the database.
[0079] As Figure 1As shown, an apparatus for cleaning 8a database cluster resources through an interface, which is deployed in a web container in a web application manner, and provides a resource cleaning interface service in the form of restful to the outside. An external resource management and control application sends a restful form of http protocol request to the web container. The web container parses the parameters in the http request and passes them to the apparatus for resource cleaning. After the resource cleaning is completed, the apparatus can assemble the return result in a manner consistent with 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.
[0080] Embodiment 1: Failure to obtain cleaning resource parameters
[0081] A1, receiving an external application restful form request, obtaining cleaning resource parameters stage
[0082] The resource management and control application sends a restful form of request to the Web container through the http protocol. The request contains the identification of the resource to be cleaned, the user and password of the cleaned resource, and the form is like http: / / admin: admin@192.168.0.1:8080 / resouseDelete / resourceId.
[0083] The Web container receives the http request, parses the request content, and obtains the request parameters. In the parsing process, it is assumed that the request parameters are not included, and the parameter acquisition fails.
[0084] A2, return the cleaning resource result in the form of restful stage
[0085] The resource management and control application returns the parameter acquisition failure result.
[0086] Embodiment 2: Parameter validity verification failure
[0087] B1, receiving an external application restful form request, obtaining cleaning resource parameters stage
[0088] The resource management and control application sends a restful form of request to the Web container through the http protocol. The request contains the identification of the resource to be cleaned, the user and password of the cleaned resource, and the form is like http: / / admin: admin@192.168.0.1:8080 / resouseDelete / resourceId.
[0089] The web container receives the HTTP request, parses the request content, and obtains the request parameters. In the parsing process, the identifier of the resource to be cleaned (resourceId), the user of the resource to be cleaned (admin), and the password of the resource to be cleaned (admin) can be normally obtained.
[0090] B2, validity verification stage of parameters
[0091] The identifier of the resource to be cleaned (resourceId), the user of the resource to be cleaned (admin), and the password of the resource to be cleaned (admin) are verified to see whether they meet the format requirement of being composed of numbers, letters, and underscores. It is assumed that they meet the requirement.
[0092] The user (admin) and the password (admin) are compared with the username and password saved in the program to see whether they are consistent. If they are not consistent, the user does not have the resource cleaning authority. It is assumed that they are consistent.
[0093] The existing resource identifier list is obtained, and the resource to be cleaned (resourceId) is compared with the existing resource identifier list to determine whether the resource to be cleaned (resourceId) exists. It is assumed that the resource to be cleaned (resourceId) does not exist, and the validity verification fails.
[0094] B3, return the result of cleaning the resource in the form of restful
[0095] The result of the parameter validity verification failure is returned to the resource management and control application.
[0096] Embodiment 3: failure of stopping the current database resource execution plan
[0097] C1, receiving an external application restful form request to obtain resource cleaning parameters
[0098] The resource management and control application sends a restful form request to the web container through the HTTP protocol. The request includes the identifier of the resource to be cleaned, the user of the resource to be cleaned, and the password of the resource to be cleaned. The form is as follows: http: / / admin:admin@192.168.0.1:8080 / resouseDelete / resourceId.
[0099] The web container receives the HTTP request, parses the request content, and obtains the request parameters. In the parsing process, the identifier of the resource to be cleaned (resourceId), the user of the resource to be cleaned (admin), and the password of the resource to be cleaned (admin) can be normally obtained.
[0100] C2, validity verification stage of parameters
[0101] Verify the passed-in cleaning resource identifier resourceId, the user admin and the password admin, whether they meet the format requirement of consisting of only digits, letters and underscores, and assume that they do.
[0102] Compare the user admin and the password admin with the username and password saved internally by the program, and if they are inconsistent, the user does not have the resource cleaning right, and assume that the user has the right.
[0103] Get the list of existing resource identifiers, compare it with resourceId, and determine whether the resource identifier to be cleaned, resourceId, exists, and assume that it exists, which means that the validity verification is successful.
[0104] C3, stop the current database resource execution plan phase
[0105] According to the cleaning resource identifier resourceId, get the running state of the current database resource execution plan, if the resource execution plan is running, continue the following steps.
[0106] Stop the running database resource execution plan by sending the command deactive resource plan to the database, and assume that the execution of the command fails, which means that the stopping of the current database resource execution plan fails.
[0107] C4, return the cleaning resource result in the form of restful phase
[0108] Return the result of stopping the current database resource execution plan failure to the resource management and control application.
[0109] Embodiment 4: cleaning resource association, resource allocation plan, resource, and user group of resource are unbundled
[0110] D1, receive external application restful form request, get cleaning resource parameter phase
[0111] The resource management and control application sends a restful form request to the Web container through the http protocol, the request contains the identifier of the resource to be cleaned, the user and the password of the cleaning resource, the form is like http: / / admin:admin@192.168.0.1:8080 / resouseDelete / resourceId.
[0112] The Web container receives the http request, parses the request content, and obtains the request parameters, and can normally obtain the request parameters cleaning resource identifier resourceId, cleaning resource user admin and password admin in the parsing process.
[0113] D2, validity verification phase of parameters
[0114] Verify the format of the passed-in cleaning resource identifier resourceId, the user admin and the password admin, which must consist of digits, letters and underscores. Assume that the format is correct.
[0115] Compare the user admin and the password admin with the username and password saved in the program. If they are not consistent, the user does not have the resource cleaning authority. Assume that the user has the authority.
[0116] Get the list of existing resource identifiers and compare it with the resource identifier resourceId to determine whether the resource identifier resourceId to be cleaned exists. Assume that the resource identifier exists, and the validity verification is successful.
[0117] D3, stop current database resource execution plan phase
[0118] According to the cleaning resource identifier resourceId, get the current database resource execution plan resourcePlan and the running state of the resource execution plan. The resource execution plan is running.
[0119] Stop the running database resource execution plan by sending the command deactive resource plan to the database. Assume that the current database resource execution plan is stopped successfully.
[0120] D4, clean resource association, and unbind resource allocation plan, resource, and resource user group phase
[0121] According to the cleaning resource identifier resourceId, get the current resource association resourceDirective.
[0122] Clean the resource association by sending the command drop resource directive to the database to unbind the resource allocation plan, resource, and resource user group. Assume that the operation fails.
[0123] Start the already stopped database resource execution plan by sending the command active resource plan to the database to restore the running of the database resource execution plan.
[0124] D5, return the cleaning resource result in the form of restful phase
[0125] Return the result of the failure of cleaning the resource association, unbinding the resource allocation plan, resource, and resource user group to the resource management and control application.
[0126] Example 5: Clean up the default resource usage of the user, the common user and the user group of the resource are failed to be unbound
[0127] E1, receive external application restful form request, obtain cleaning resource parameter stage
[0128] The resource management application sends a restful form request to the Web container through the http protocol, and the request contains the identification of the resource to be cleaned, the user and password of the resource to be cleaned, and the form is as follows: http: / / admin: admin@192.168.0.1:8080 / resouseDelete / resourceId.
[0129] The Web container receives the http request, parses the request content, obtains the request parameters, and can normally obtain the request parameters of the resource to be cleaned, the user and password of the resource to be cleaned.
[0130] E2, parameter validity verification stage
[0131] Verify whether the passed-in resource to be cleaned identification resourceId, the user and password of the resource to be cleaned admin conform to the format requirement that only numbers, letters and underscores are allowed, and assume that it is consistent.
[0132] Compare the user admin and the password admin with the username and password saved in the program, if they are inconsistent, the user does not have the resource cleaning right, and assume that it has.
[0133] Get the list of existing resource identifications, compare with resourceId, and judge whether the resource identification to be cleaned resourceId exists, and assume that it exists, then the validity verification is successful.
[0134] E3, stop the current database resource execution plan stage
[0135] According to the resource to be cleaned identification resourceId, obtain the current database resource execution plan resourcePlan and the running state of the resource execution plan, and the resource execution plan is running.
[0136] Stop the running database resource execution plan by sending the command deactive resource plan to the database, and assume that the current database resource execution plan is stopped successfully.
[0137] E4, clean up the resource association, unbind the resource allocation plan, resource and user group of the resource stage
[0138] According to the cleaning resource identifier resourceId, the resource association resourceDirective of the current resource is obtained.
[0139] By sending the command drop resource directive to the database, the resource association is cleaned up, and the resource allocation plan, resource, and user group of the resource are unbound. It is assumed that the execution of cleaning the resource association is successful.
[0140] E5, clean the user of the default resource usage, unbind the user group of the resource and the ordinary user
[0141] According to the cleaning resource identifier resourceId, the default resource usage user defaultUser of the current resource is obtained.
[0142] According to the cleaning resource identifier resourceId, the user group name userGroup of the current resource is obtained.
[0143] According to the user group name userGroup, the database user list bound to the current user group is obtained.
[0144] By sending the command drop user to the database, the user of the default resource usage is cleaned up, and it is assumed that the cleaning is successful.
[0145] By sending the command alter consumer group to the database, the user bound to the current user group is unbound, and it is assumed that the execution fails.
[0146] By sending the command create user to the database, the default resource user is recreated.
[0147] By sending the command create resource directive to the database, the user group of the resource allocation plan, resource, and resource is bound again.
[0148] By sending the command active resource plan to the database, the running of the database resource execution plan is restored.
[0149] E6, return the cleaning resource result in the form of restful
[0150] The result of unbinding the user group of the resource and the ordinary user and the user of the default resource usage that fails is returned to the resource management application.
[0151] Embodiment 6: cleaning the user group of the resource fails
[0152] F1, receiving external application restful form request, obtaining cleaning resource parameter stage
[0153] The resource management application sends a restful form request to the Web container through the http protocol. The request contains the identification of the resource to be cleaned, the user and password of the resource to be cleaned, and the form is as follows: http: / / admin:admin@192.168.0.1:8080 / resouseDelete / resourceId.
[0154] The Web container receives the http request, parses the request content, and obtains the request parameters. In the parsing process, the request parameter cleaning resource identification resourceId, cleaning resource user admin and password admin can be normally obtained.
[0155] F2, parameter validity verification stage
[0156] Verify whether the passed cleaning resource identification resourceId, cleaning resource user admin and password admin meet the format requirement of consisting of only numbers, letters and underscores. It is assumed to be consistent.
[0157] Compare the user admin and the password admin with the username and password saved in the program. If they are inconsistent, the user does not have the resource cleaning permission. It is assumed to be consistent.
[0158] Get the list of existing resource identifiers and compare it with resourceId to determine whether the resource identifier to be cleaned exists. It is assumed to exist, so the validity verification is successful.
[0159] F3, stop current database resource execution plan stage
[0160] According to the cleaning resource identification resourceId, obtain the current database resource execution plan resourcePlan and the running state of the resource execution plan. The resource execution plan is running.
[0161] Stop the running database resource execution plan by sending the command deactive resource plan to the database. It is assumed that stopping the current database resource execution plan is successful.
[0162] F4, clean resource association, and unbind resource allocation plan, resource, and resource user group stage
[0163] According to the cleaning resource identification resourceId, obtain the current resource resource association resourceDirective.
[0164] By sending the command drop resource directive to the database, the resource association is cleaned up, the resource allocation plan, the resource, and the user group of the resource are unbound, and it is assumed that the execution of cleaning up the resource association is successful.
[0165] F5, cleaning up the user used by the default resource, and unbinding the user group of the resource from the ordinary user
[0166] According to the cleaning resource identifier resourceId, the default resource user defaultUser of the current resource is obtained.
[0167] According to the cleaning resource identifier resourceId, the user group name userGroup of the current resource is obtained.
[0168] According to the user group name userGroup, the database user list bound with the current user group is obtained.
[0169] By sending the command drop user to the database, the user used by the default resource is cleaned up, and it is assumed that the cleaning is successful.
[0170] By sending the command alter consumer group to the database, the user bound with the current user group is unbound, and it is assumed that the execution is successful.
[0171] F6, cleaning up the user group using the resource stage
[0172] According to the cleaning resource identifier resourceId, the user group name userGroup of the current resource is obtained.
[0173] By sending the command drop consumer group to the database, the user group using the resource is cleaned up, and it is assumed that the execution fails.
[0174] By sending the command alter consumer group to the database, the user and the user group are re-bound.
[0175] By sending the command create user to the database, the default resource user is re-created.
[0176] By sending the command create resource directive to the database, the resource allocation plan, the resource, and the user group of the resource are re-bound.
[0177] By sending the command active resource plan to the database, the running of the database resource execution plan is restored.
[0178] F7, return the result of cleaning up resources in the form of restful
[0179] Return the result of cleaning up the user group that uses the resources to the resource management application.
[0180] Embodiment 7: Clean up the resources using the resource identifier set by the request parameter
[0181] G1, receive the request in the form of restful from the external application, and obtain the parameters for cleaning up the resources
[0182] The resource management application sends a request in the form of restful to the Web container through the http protocol, and the request contains the identifier of the resource to be cleaned up, the user and the password for cleaning up the resource, and the form is as follows: http: / / admin:admin@192.168.0.1:8080 / resouseDelete / resourceId.
[0183] The Web container receives the http request, parses the request content, and obtains the request parameters. In the parsing process, the request parameters, the identifier of the resource to be cleaned up (resourceId), the user (admin), and the password (admin) can be normally obtained.
[0184] G2, verify the validity of the parameters
[0185] Verify whether the identifier of the resource to be cleaned up (resourceId), the user (admin), and the password (admin) passed in meet the format requirement that only numbers, letters, and underscores are allowed. It is assumed that they meet the requirement.
[0186] Compare the user (admin) and the password (admin) with the username and password saved in the program. If they are not consistent, the user does not have the right to clean up the resources. It is assumed that they are consistent.
[0187] Obtain the list of existing resource identifiers, compare them with resourceId, and determine whether the resource identifier to be cleaned up (resourceId) exists. It is assumed that it exists, and the validity verification is successful.
[0188] G3, stop the current database resource execution plan
[0189] According to the identifier of the resource to be cleaned up (resourceId), obtain the current database resource execution plan (resourcePlan) and the running state of the resource execution plan. The resource execution plan is running.
[0190] By sending the command deactive resource plan to the database, the running database resource execution plan is stopped, assuming that stopping the current database resource execution plan is successful.
[0191] G4, cleaning up resource association, disassociating the resource allocation plan, resources, and user groups of resources
[0192] According to the cleaning resource identifier resourceId, the resource association resourceDirective of the current resource is obtained.
[0193] By sending the command drop resource directive to the database, the resource association is cleaned up, and the resource allocation plan, resources, and user groups of resources are disassociated, assuming that the cleaning of resource association is successful.
[0194] G5, cleaning up the default resource usage users, disassociating ordinary users and user groups of resources
[0195] According to the cleaning resource identifier resourceId, the default resource usage user defaultUser of the current resource is obtained.
[0196] According to the cleaning resource identifier resourceId, the user group name userGroup of the current resource is obtained.
[0197] According to the user group name userGroup, the database user list bound to the current user group is obtained.
[0198] By sending the command drop user to the database, the default resource usage users are cleaned up, assuming that the cleaning is successful.
[0199] By sending the command alter consumer group to the database, the users bound to the current user group are disassociated, assuming that the execution is successful.
[0200] G6, cleaning up the user groups using resources
[0201] According to the cleaning resource identifier resourceId, the user group name userGroup of the current resource is obtained.
[0202] By sending the command drop consumer group to the database, the user groups using resources are cleaned up, assuming that the execution is successful.
[0203] G7, cleaning up resources using the resource identifier set by the request parameters
[0204] By sending the command drop resource pool to the database, the resources are cleaned up, and it is assumed that the execution fails.
[0205] By sending the command create consumer group to the database, the user group is recreated.
[0206] By sending the command alter consumer group to the database, the user and the user group are re-bound.
[0207] By sending the command create user to the database, the default resource user is recreated.
[0208] By sending the command create resource directive to the database, the resource allocation plan, the resource, and the user group of the resource are bound.
[0209] By sending the command active resource plan to the database, the execution of the database resource execution plan is resumed.
[0210] 8. The result of cleaning up the resources is returned in the form of restful.
[0211] The resource management application returns the result of cleaning up the resources to the resource management application using the resource identifier set by the request parameters.
[0212] Embodiment 8: Failure to start the database resource allocation plan
[0213] H1, receive external application restful form request, get clean up resource parameters stage
[0214] The resource management application sends a restful form request to the Web container through the http protocol, and the request includes the identifier of the resource to be cleaned up, the user to clean up the resource, and the password. The form is as follows: http: / / admin:admin@192.168.0.1:8080 / resouseDelete / resourceId.
[0215] The Web container receives the http request, parses the request content, and obtains the request parameters. In the parsing process, the request parameters can be normally obtained, including the identifier of the resource to be cleaned up, the user to clean up the resource, and the password.
[0216] H2, parameter validity verification stage
[0217] Verify the passed-in cleaning resource identifier resourceId, the user admin and the password admin of the cleaning resource, whether it meets the format requirement of only consisting of digital letters and underscores, and assume that it meets the requirement.
[0218] Compare the user admin and the password admin with the username and password saved internally by the program, and if they are inconsistent, the user does not have the resource cleaning permission, and assume that the user has the permission.
[0219] Get the list of existing resource identifiers, compare it with resourceId, and determine whether the resource identifier to be cleaned, resourceId, exists, and assume that it exists, which means that the validity verification is successful.
[0220] H3, stop the current database resource execution plan phase
[0221] According to the cleaning resource identifier resourceId, get the current database resource execution plan resourcePlan and the running state of the resource execution plan, and assume that the resource execution plan is running.
[0222] Stop the running database resource execution plan by sending the command deactive resource plan to the database, and assume that stopping the current database resource execution plan is successful.
[0223] H4, clean up resource association, and unbind resource allocation plan, resource, and user group of the resource phase
[0224] According to the cleaning resource identifier resourceId, get the resource association resourceDirective of the current resource.
[0225] Clean up the resource association by sending the command drop resource directive to the database, and unbind the resource allocation plan, resource, and user group of the resource, and assume that cleaning up the resource association is successful.
[0226] H5, clean up the default resource usage user, and unbind the user group of the resource phase
[0227] According to the cleaning resource identifier resourceId, get the default resource usage user defaultUser of the current resource.
[0228] According to the cleaning resource identifier resourceId, get the user group name userGroup of the current resource.
[0229] Get the database user list bound to the current user group according to the user group name userGroup.
[0230] Clean up the user using the default resource by sending the command drop user to the database, assuming that the clean up is successful.
[0231] Unbind the user bound to the current user group by sending the command alter consumer group to the database, assuming that the execution is successful.
[0232] H6, clean up the user group using the resource stage
[0233] According to the resource identifier resourceId, the user group name userGroup of the current resource is obtained.
[0234] Clean up the user group using the resource by sending the command drop consumer group to the database, assuming that the execution is successful.
[0235] H7, clean up the resource using the resource identifier set by the request parameter stage
[0236] Clean up the resource by sending the command drop resource pool to the database, assuming that the execution is successful.
[0237] H8, start the database resource allocation plan stage
[0238] According to the resource identifier resourceId, the current database resource execution plan resourcePlan is obtained.
[0239] Start the database resource allocation plan by sending the command active resource plan to the database, assuming that the execution fails, at this time, since the resource to be cleaned up has been completely cleaned up, so no longer restore the cleaned up resource.
[0240] H9, return the cleaned up resource result in the form of restful stage
[0241] Return the result of starting the database resource allocation plan to the resource management and control application.
[0242] Embodiment 9: clean up the resource successfully
[0243] I1, receive the external application restful form request, obtain the clean up resource parameter stage
[0244] The resource management application sends a request in the form of RESTful via HTTP protocol to the Web container, the request contains the identification of the resource to be cleaned, the user and password for cleaning the resource, in the form of http: / / admin:admin@192.168.0.1:8080 / resouseDelete / resourceId.
[0245] The Web container receives the HTTP request, parses the request content, and obtains the request parameters. In the parsing process, the request parameters, the identification of the resource to be cleaned (resourceId), the user (admin) and the password (admin) for cleaning the resource can be normally obtained.
[0246] I2, parameter validity verification stage
[0247] Verify whether the identification of the resource to be cleaned (resourceId), the user (admin) and the password (admin) for cleaning the resource passed in meet the format requirement of consisting of only numbers, letters and underscores, and assume that they meet the requirement.
[0248] Compare whether the user (admin) and the password (admin) are consistent with the user name and password saved in the program internally, if not consistent, the user does not have the resource cleaning authority, and assume that the user has the authority.
[0249] Obtain the list of existing resource identifiers, compare with the resource identifier (resourceId), and judge whether the resource identifier (resourceId) to be cleaned exists, and assume that it exists, then the validity verification is successful.
[0250] I3, stop current database resource execution plan stage
[0251] According to the identification of the resource to be cleaned (resourceId), obtain the current database resource execution plan (resourcePlan) and the running state of the resource execution plan, and assume that the resource execution plan is running.
[0252] Stop the running database resource execution plan by sending the command deactive resource plan to the database, and assume that the current database resource execution plan is stopped successfully.
[0253] I4, clean resource association, and detach the resource allocation plan, resource and user group stage
[0254] According to the identification of the resource to be cleaned (resourceId), obtain the current resource association (resourceDirective).
[0255] I1, cleaning up the resource allocation plan stage
[0256] I5, cleaning up the user group stage
[0257] According to the cleaning up resource identifier resourceId, the default resource use user of the current resource defaultUser is obtained.
[0258] According to the cleaning up resource identifier resourceId, the user group name userGroup of the current resource is obtained.
[0259] According to the user group name userGroup, the database user list bound with the current user group is obtained.
[0260] By sending the command drop user to the database, the user using the default resource is cleaned up, and it is assumed that the cleaning is successful.
[0261] By sending the command alter consumer group to the database, the user bound with the current user group is unbound, and it is assumed that the execution is successful.
[0262] I6, cleaning up the user group stage
[0263] According to the cleaning up resource identifier resourceId, the user group name userGroup of the current resource is obtained.
[0264] By sending the command drop consumer group to the database, the user group using the resource is cleaned up, and it is assumed that the execution is successful.
[0265] I7, cleaning up the resource stage using the resource identifier set by the request parameter
[0266] By sending the command drop resource pool to the database, the resource is cleaned up, and it is assumed that the execution is successful.
[0267] I8, starting the database resource allocation plan stage
[0268] According to the cleaning up resource identifier resourceId, the current database resource execution plan resourcePlan is obtained.
[0269] By sending the command active resource plan to the database, the database resource allocation plan is started, and it is assumed that the execution is successful.
[0270] I9. Return the resource cleanup results in a RESTful format.
[0271] Return a successful resource cleanup result to the resource management application.
[0272] Advantages and beneficial effects of the present invention:
[0273] (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.
[0274] (2) It can simplify the complexity of external applications cleaning up resources in the GBase8aMPP database.
[0275] (3) It can avoid the security risks caused by the resource management application directly using the advanced database user to operate the database.
[0276] 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 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.
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