Method, device and electronic device for creating database resources based on RESTful interface

Creating database resources via RESTful interfaces solves the problem of the lack of RESTful interfaces in the GBase8aMPP database cluster, improves security and ease of operation, and simplifies the resource creation process.

CN118410030BActive Publication Date: 2024-09-03TIANJIN NANKAI UNIV GENERAL DATA TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410864577.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-01
Publication Date
2024-09-03
Estimated Expiration
2044-07-01

AI Technical Summary

Technical Problem

The GBase8aMPP database cluster lacks a RESTful interface, requiring database users to log in directly for resource creation operations, which poses security risks and is complex to operate.

Method used

Create database resources, obtain resource parameters, build user groups and generate resource allocation plans through RESTful interfaces, avoiding direct interaction with the database system and simplifying the operation process.

Benefits of technology

Resource creation via RESTful APIs enhances security and ease of use, while reducing the risk of direct manipulation of the database system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118410030B
    Figure CN118410030B
Patent Text Reader

Abstract

The present invention provides a method, device and electronic device for creating database resources based on a restful interface, including responding to a user's request to create a database resource in a restful form, obtaining a resource creation parameter; determining whether the resource parameter is valid, and if not, sending an invalid result to the user in a restful form; if valid, stopping the first resource allocation plan used by the current database and creating a second resource according to the resource parameter. The present invention discloses a method, device and electronic device for creating a database cluster resource based on a restful interface, which can provide users with a resource creation interface that complies with the restful specification, simplify the complexity of creating resources for external applications in a GBase8aMPP database, and avoid users directly operating the database as advanced database users, effectively reducing database security risks.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of databases, and in particular relates to a method, a device and an electronic device for creating database resources based on a RESTful interface. Background Art

[0002] At present, it is very common to use GBase8aMPP database cluster for data computing and storage. When using GBase8aMPP database cluster, due to the strong service capability of database cluster, it can provide data computing and storage services for multiple applications in many scenarios. In this case, in order to isolate the application resources and avoid competition when multiple applications use database resources, the database needs to provide external resource allocation function to allocate appropriate database resources to each application user.

[0003] In the existing implementation, although the GBase8aMPP database cluster has provided the function of creating database resources, this function requires the database user to directly log in to the database system to operate the database. This has the following problems:

[0004] 1. Many scenarios require the GBase8aMPP database cluster to have a restful interface to provide users with the ability to integrate GBase8aMPP resource creation functions through the restful interface, but the current GBase8aMPP database does not have such an interface.

[0005] 2. The resource creation function provided by the current database needs to be completed by the database user logging into the database system. This operation method requires the resource creator to obtain the database user's account and to be able to connect to the server where the database system is located. This leads to great security risks and other operations may be performed in the database system, causing the database system to be invaded.

[0006] 3. In the process of creating database resources, resource creators need to understand the internal resource objects of the database and the relationships between these objects, and execute multiple SQL statements at the same time. The concepts and relationships of these internal resource objects in the database, as well as the SQL statements that need to be executed, are too professional and cumbersome for ordinary resource creators, resulting in operational difficulties. Summary of the invention

[0007] In view of this, the present invention aims to overcome the defects in the prior art and proposes a method, device and electronic device for creating database resources based on a RESTful interface.

[0008] To achieve the above object, the technical solution of the present invention is achieved as follows:

[0009] In a first aspect, the present invention discloses a method for creating a database resource based on a RESTful interface, the method comprising:

[0010] In response to a user's request to create a database resource in a RESTful form, obtain resource creation parameters; the resource creation parameters include a resource identifier and a resource quota corresponding to the resource identifier;

[0011] Determine whether the resource parameters are valid. If not, send the invalid result to the user in a restful form; if valid, stop the first resource allocation plan used by the current database and create a second resource according to the resource parameters; the second resource includes a resource identifier and a resource quota corresponding to the resource identifier;

[0012] Constructing a second user group capable of using the second resource and setting initial users of the second user group; generating a second resource allocation plan based on the second resource, the second user group and the initial users;

[0013] The database starts the second resource allocation plan and returns the resource creation result to the user in a RESTful form.

[0014] Furthermore, determining whether the resource parameters are valid includes: the resource parameters are valid only if: the user has the authority to create resources, the format of the resource identifier meets the requirements, the resource identifier is not repeated, the format of the resource quota meets the requirements, and the target database of the resource quota exists and works normally.

[0015] Furthermore, the first resource allocation plan includes: a first resource and a first resource user group using the first resource; the first resource includes a resource identifier and a resource quota corresponding to the resource identifier.

[0016] Further, in response to a user's request to create a database resource in a RESTful form, obtaining the resource creation parameters includes: the user sends a RESTful HTTP request to a web container, and the web container parses and obtains the resource creation parameters after receiving the HTTP request.

[0017] Furthermore, the database starts the second resource allocation plan and returns the resource creation result to the user in a RESTful form, including: returning the resource creation result to the web container in a form that complies with the RESTful specification, and the web container returns the resource creation result to the user in an HTTP response.

[0018] Furthermore, the resource quota includes the CPU usage, memory capacity and disk capacity allocated on the database.

[0019] Furthermore, if valid, stopping the first resource allocation plan used by the current database and creating a second resource according to the resource parameters also includes: if stopping the first resource allocation plan used by the current database fails, stopping all subsequent processes and directly returning the resource creation failure result to the user in a restful form.

[0020] Furthermore, if any of the following fails: creating a second resource according to resource parameters, building a second user group that can use the second resource, setting the initial user of the second user group, and generating a second resource allocation plan, all subsequent processes are stopped, the first resource allocation plan is restarted, and the result of resource creation failure is directly returned to the user in a restful form.

[0021] In a second aspect, the present invention discloses a device for creating a database resource based on a restful interface. The device for creating a database resource based on a restful interface includes:

[0022] The acquisition module is used to respond to the user's request to create a database resource in a RESTful form and obtain the creation resource parameters; the creation resource parameters include a resource identifier and a resource quota corresponding to the resource identifier;

[0023] The determination module is used to determine whether the resource parameters are valid. If not, the invalid result is sent to the user in a restful form; if valid, the first resource allocation plan used by the current database is stopped and a second resource is created according to the resource parameters; the second resource includes a resource identifier and a resource quota corresponding to the resource identifier;

[0024] A construction module, used to construct a second user group that can use the second resource and set initial users of the second user group; based on the second resource, the second user group and the initial users, generate a second resource allocation plan;

[0025] The return module is used for the database to start the second resource allocation plan and return the resource creation result to the user in a RESTful form.

[0026] In a third aspect, the present invention discloses an electronic device, comprising: one or more processors; a storage device for storing one or more programs, wherein when the one or more programs are executed by one or more processors, the one or more processors execute the above-mentioned method of creating database resources based on a RESTful interface.

[0027] Compared with the prior art, the present invention has the following advantages:

[0028] First, the present invention discloses a method for creating database resources based on a restful interface, which can meet the user's requirements for creating resources through a restful interface and solve the problem that the GBase8aMPP database cluster does not have a restful interface to create resources.

[0029] Second, the present invention discloses a method for creating database resources based on a restful interface. Users create resources by calling a restful interface. They only need to have the permission to access the restful resource creation interface to create GBase8aMPP database cluster resources. In this process, users do not directly establish operational contact with the database system and can only perform resource creation operations, which largely ensures the security of the GBase8aMPP database system.

[0030] Third, the present invention discloses a method for creating database resources based on a restful interface. Users create resources by calling a restful interface. They only need to apply for resource quotas based on actual needs and send creation requests according to the request parameters defined in the interface. There is no need to pay attention to the resource objects and relationships within the GBase8aMPP database cluster, nor is there any need to understand SQL statements, which greatly simplifies the difficulty of resource creation. BRIEF DESCRIPTION OF THE DRAWINGS

[0031] The accompanying drawings, which constitute a part of the present invention, are used to provide a further understanding of the present invention. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute improper limitations on the present invention.

[0032] In the attached picture:

[0033] Figure 1 This is a schematic diagram of a method for creating database resources based on a restful interface according to an embodiment of the present invention;

[0034] Figure 2 This is a schematic diagram of a second embodiment of a method for creating database resources based on a restful interface according to an embodiment of the present invention;

[0035] Figure 3 This is a schematic diagram of a third embodiment of a method for creating database resources based on a restful interface according to an embodiment of the present invention;

[0036] Figure 4 This is a schematic diagram of a fourth embodiment of a method for creating database resources based on a restful interface according to an embodiment of the present invention;

[0037] Figure 5A schematic diagram of a device for creating database resources based on a RESTful interface according to an embodiment of the present invention;

[0038] Figure 6 A schematic diagram of an electronic device for creating database resources based on a RESTful interface according to an embodiment of the present invention. DETAILED DESCRIPTION

[0039] It should be noted that, in the absence of conflict, the embodiments of the present invention and the features in the embodiments may be combined with each other.

[0040] In the description of the present invention, it should be further explained that the terms "first", "second", etc. are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Thus, a feature defined as "first", "second", etc. may explicitly or implicitly include one or more of the features. In the description of the present invention, unless otherwise specified, "plurality" means two or more.

[0041] The present invention will be described in detail below with reference to the accompanying drawings and in conjunction with embodiments.

[0042] Embodiment 1, as Figure 1 As shown, a method for creating a database resource based on a RESTful interface includes:

[0043] Step S101, in response to a user's request to create a database resource in a restful form, obtaining resource creation parameters; the resource creation parameters include a resource identifier and a resource quota corresponding to the resource identifier;

[0044] Step S102, determining whether the resource parameters are valid, if not valid, sending an invalid result to the user in a restful form; if valid, stopping the first resource allocation plan used by the current database and creating a second resource according to the resource parameters; the second resource includes a resource identifier and a resource quota corresponding to the resource identifier;

[0045] Step S103, constructing a second user group that can use the second resource, and setting initial users of the second user group; generating a second resource allocation plan based on the second resource, the second user group and the initial users;

[0046] Step S104: The database starts the second resource allocation plan and returns the resource creation result to the user in a RESTful form.

[0047] In this embodiment, the first resource allocation plan includes: a first resource and a first resource user group using the first resource; the first resource includes a resource identifier and a resource quota corresponding to the resource identifier.

[0048] Resource ID refers to the unique ID of the resource that needs to be created. In a database, the resource ID is unique.

[0049] A resource includes a resource identifier and a resource quota corresponding to the resource identifier.

[0050] Resource quotas include the CPU usage, memory capacity, and disk capacity allocated to the database.

[0051] A resource user group refers to a database user group that can use the resource quota corresponding to a resource identifier. A resource user group can be associated with a database user. A database user associated with a resource user group can use resources allocated by a resource quota. Database users corresponding to different resources can be created for different applications, thereby isolating the use of database resources by applications.

[0052] The initial user has the permission to create resources. The initial user is created according to the resource identifier and is associated with the resource user group.

[0053] The resource allocation plan is a rule identifier for database resource allocation. After the resource allocation plan is started, the interrelated resource identifiers, resource quotas, resource user groups, and initial users take effect. If you need to change the resource quota, you need to stop the started resource plan first.

[0054] In this embodiment, in step S101, the creation resource parameter may be:

[0055] RESTful interface request path: / {resource identifier}

[0056] RESTful interface request parameters: {“mem”: “memory quota”,

[0057] “cpu” : “cpu quota”,

[0058] "storage" : "disk quota"}

[0059] In this embodiment, in step S104, the resource creation result returned in RESTful form may be:

[0060] The restful interface returns information: {"status": "status code",

[0061] "message": "return message"}

[0062] In this embodiment, the user refers to an application that calls a RESTful resource creation interface, which can be a command line application or a visual application platform. As long as the resource creation interface caller meets the requirements of using the RESTful interface, it is a user.

[0063] Embodiment 2, as Figure 2 As shown, determining whether the resource parameters are valid includes: the resource parameters are valid only if: the user has the authority to create resources 201, the format of the resource identifier meets the requirements 202, the resource identifier is not repeated 203, the format of the resource quota meets the requirements 204, and the target database of the resource quota exists and works normally 205.

[0064] Embodiment three, as Figure 3 As shown, in response to the user's RESTful request to create a database resource, obtaining the creation resource parameters includes: the user 301 sends a RESTful HTTP request to the web container 302, and after the web container 302 receives the HTTP request, it parses and obtains the creation resource parameters, and further creates the resource operation on the GBase8aMPP database 303 resource in the JDBC form.

[0065] like Figure 3 As shown, the database starts the second resource allocation plan and returns the resource creation result to the user in a RESTful form, including: returning the resource creation result to the web container 302 in a form that complies with the RESTful specification, and the web container 302 returns the resource creation result to the user 301 in an HTTP response.

[0066] In this embodiment, the web container 302 may be tomcat, or other web containers supporting the http protocol.

[0067] Embodiment 4, as Figure 4 As shown, if valid, stopping the first resource allocation plan used by the current database and creating a second resource according to the resource parameters also includes: if stopping the first resource allocation plan used by the current database fails, stopping all subsequent processes and directly returning the resource creation failure result to the user in a restful form.

[0068] like Figure 4 As shown, if any of the four steps of creating a second resource according to resource parameters, building a second user group that can use the second resource, setting the initial user of the second user group, and generating a second resource allocation plan fails, all subsequent processes are stopped, the first resource allocation plan is restarted, and the resource creation failure result is directly returned to the user in a restful form.

[0069] Embodiment 5, as Figure 5 As shown, the present invention also discloses a device for creating database resources based on a restful interface, and the device for creating database resources based on a restful interface includes:

[0070] The acquisition module 401 is used to obtain resource creation parameters in response to a user's request to create a database resource in a RESTful form; the resource creation parameters include a resource identifier and a resource quota corresponding to the resource identifier;

[0071] The determination module 402 is used to determine whether the resource parameters are valid. If not, an invalid result is sent to the user in a restful form; if valid, the first resource allocation plan used by the current database is stopped and a second resource is created according to the resource parameters; the second resource includes a resource identifier and a resource quota corresponding to the resource identifier;

[0072] A construction module 403 is used to construct a second user group that can use the second resource and set initial users of the second user group; based on the second resource, the second user group and the initial users, generate a second resource allocation plan;

[0073] The return module 404 is used for the database to start the second resource allocation plan and return the resource creation result to the user in a RESTful form.

[0074] The present invention discloses an electronic device, comprising: one or more processors; a storage device for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors execute the above-mentioned method for creating database resources based on a RESTful interface.

[0075] like Figure 6 As shown, an embodiment is disclosed, which is a block diagram of an electronic device suitable for creating database resources based on a restful interface.

[0076] The electronic device 50 of this embodiment includes a processor 501, which can perform various appropriate actions and processes according to the program stored in the ROM 502 or the program loaded from the storage part 508 to the RAM 503. The processor 501 may include, for example, a general-purpose microprocessor, an instruction set processor and / or a related chipset and / or a dedicated microprocessor, etc. The processor 501 may also include an onboard memory for caching purposes. The processor 501 may include a single processing unit or multiple processing units for performing different actions of the method flow according to the embodiment of the present invention.

[0077] In RAM503, various programs and data required for the operation of electronic device 50 are stored. Processor 501, ROM502 and RAM503 are connected to each other via bus 504, and processor 501 performs various operations of the method flow according to the embodiment of the present invention by executing the program in ROM502 and / or RAM503. It should be noted that the program can also be stored in one or more memories other than ROM502 and RAM503, and processor 501 can also perform various operations of the method flow according to the embodiment of the present invention by executing the program stored in one or more memories.

[0078] According to an embodiment of the present invention, the electronic device 50 may further include an I / O interface 505, which is also connected to the bus 504. The electronic device 50 may further include one or more of the following components connected to the I / O interface 505: an input portion 506 including a keyboard, a mouse, etc.; an output portion 507 including a cathode ray tube, a liquid crystal display, and a speaker; a storage portion 508 including a hard disk, etc.; and a communication portion 509 including a network interface card such as a LAN card, a modem, etc. The communication portion 509 performs communication processing via a network such as the Internet. A drive 5010 is also connected to the I / O interface 505 as needed. A removable medium 5011, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 5010 as needed, so that a computer program read therefrom is installed into the storage portion 508 as needed.

[0079] The embodiments of the present invention are described above. However, these embodiments are only for the purpose of illustration, and are not intended to limit the scope of the present invention. Although each embodiment is described above, it does not mean that the measures in each embodiment cannot be used in combination. The scope of the present invention is defined by the attached claims and their equivalents. Without departing from the scope of the present invention, those skilled in the art may make various substitutions and modifications, which should all fall within the scope of the present invention.

Claims

1. A method for creating database resources based on a restful interface, characterized in that: The method comprises: In response to a user's request to create a database resource in a RESTful form, obtaining resource creation parameters; the resource creation parameters include a resource identifier and a resource quota corresponding to the resource identifier; Determine whether the resource parameters are valid, and if not, send an invalid result to the user in a restful form; if valid, stop the first resource allocation plan currently used by the database and create a second resource according to the resource parameters; the second resource includes the resource identifier and the resource quota corresponding to the resource identifier; Constructing a second user group capable of using the second resource and setting initial users of the second user group; generating a second resource allocation plan based on the second resource, the second user group and the initial users; The database starts the second resource allocation plan and returns the resource creation result to the user in a RESTful form.

2. According to a method for creating database resources based on a RESTful interface according to claim 1, it is characterized in that: Determining whether the resource parameters are valid includes: the resource parameters are valid only if: the user has the authority to create resources, the format of the resource identifier meets the requirements, the resource identifier is not repeated, the format of the resource quota meets the requirements, and the target database of the resource quota exists and works normally.

3. According to a method for creating database resources based on a RESTful interface according to claim 1, it is characterized in that: The first resource allocation plan includes: a first resource and a first resource user group using the first resource; the first resource includes the resource identifier and a resource quota corresponding to the resource identifier.

4. According to a method for creating database resources based on a RESTful interface according to claim 1, it is characterized in that: The obtaining of resource creation parameters in response to a user's RESTful request for creating a database resource comprises: the user sends a RESTful HTTP request to a web container, and the web container parses and obtains the resource creation parameters after receiving the HTTP request.

5. The method for creating database resources based on a RESTful interface according to claim 1, characterized in that: The database starts the second resource allocation plan and returns the resource creation result to the user in a RESTful form, including: returning the resource creation result to the web container in a form that complies with the RESTful specification, and the web container returns the resource creation result to the user in an HTTP response.

6. A method for creating database resources based on a RESTful interface according to claim 1, characterized in that: The resource quota includes the CPU occupancy rate, the memory capacity and the disk capacity allocated on the database.

7. The method for creating database resources based on a RESTful interface according to claim 1, characterized in that: If valid, stopping the first resource allocation plan used by the current database and creating a second resource according to the resource parameters also includes: if stopping the first resource allocation plan used by the current database fails, stopping all subsequent processes and directly returning the resource creation failure result to the user in a restful form.

8. The method for creating database resources based on a RESTful interface according to claim 1, characterized in that: If any of the four steps of creating the second resource according to the resource parameters, building the second user group that can use the second resource, setting the initial user of the second user group, and generating the second resource allocation plan fails, all subsequent processes are stopped, the first resource allocation plan is restarted, and the resource creation failure result is directly returned to the user in a restful form.

9. A device for creating database resources based on a restful interface, characterized in that: The device for creating database resources based on the restful interface includes: An acquisition module, used to obtain resource creation parameters in response to a user's request to create a database resource in a RESTful form; the resource creation parameters include a resource identifier and a resource quota corresponding to the resource identifier; A determination module, used to determine whether the resource parameters are valid, and if not, to send an invalid result to the user in a restful form; if valid, to stop the first resource allocation plan currently used by the database and create a second resource according to the resource parameters; the second resource includes the resource identifier and the resource quota corresponding to the resource identifier; A construction module, configured to construct a second user group capable of using the second resource and set initial users of the second user group; and generate a second resource allocation plan based on the second resource, the second user group and the initial users; The return module is used for the database to start the second resource allocation plan and return the resource creation result to the user in a restful form.

10. An electronic device, characterized in that: include: one or more processors; A storage device for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors are caused to perform the method according to any one of claims 1 to 8.