Data processing method and device, electronic equipment and storage medium
The method enhances data isolation in multi-tenant cloud platforms by using tenant identifiers to process data within dedicated spaces, addressing the limitations of existing methods and improving security and efficiency.
Patent Information
- Application Number
- CN202310637134.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-05-31
- Publication Date
- 2024-12-03
AI Technical Summary
Existing multi-tenant architectures in cloud platforms face challenges in effectively isolating tenant data, with current methods either being lightweight but offering low isolation levels or requiring complex containerization technologies with high operational costs.
A data processing method that utilizes a tenant identifier to determine tenant information, calls relevant microservices, and performs data processing on a dedicated tenant space within a database, enhancing data isolation without altering the existing microservice framework.
This approach improves data isolation in multi-tenant scenarios, reducing operational costs and maintaining framework integrity while ensuring secure and efficient data management across tenants.
Smart Images

Figure CN119066635A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the fields of database, cloud platform and microservice technology, and in particular to a data processing method, device, electronic device and storage medium. Background Art
[0002] Multi-tenancy is an architectural design method, that is, a SaaS system running on one or a group of servers can provide services for multiple tenants. The purpose is to allow multiple tenants to use the same set of programs in an Internet environment and ensure data isolation between tenants. The focus of multi-tenant architecture is the isolation of multiple tenant data under the same set of programs. Since tenant data is stored centrally, to achieve data security, it depends on whether the tenant data can be isolated to prevent tenant data from being accidentally or maliciously obtained and tampered with by others. Summary of the invention
[0003] The present disclosure provides a data processing method, device, electronic device and storage medium.
[0004] According to one aspect of the present disclosure, a data processing method is provided, including: receiving a service request from a first tenant, wherein the service request carries a tenant identifier; based on the tenant identifier, determining first tenant information of the first tenant from a tenant table, wherein the tenant table is located in a public space of a database; using the first tenant information to call at least one first microservice related to the first tenant; and in response to obtaining a data change instruction, performing data processing on a data table in a first tenant space associated with the first tenant in the database based on the first tenant information and the data change instruction, wherein the data change instruction is generated during the calling process of the at least one first microservice.
[0005] According to another aspect of the present disclosure, a data processing device is provided, including: a receiving module, used to receive a service request from a first tenant, wherein the service request carries a tenant identifier; a first determination module, used to determine the first tenant information of the first tenant from a tenant table based on the tenant identifier, wherein the tenant table is located in a public space of a database; a calling module, used to call at least one first microservice related to the first tenant using the first tenant information; and a processing module, used to perform data processing on a data table in a first tenant space associated with the first tenant in the database based on the first tenant information and the data change instruction in response to obtaining a data change instruction, wherein the data change instruction is generated during the calling process of the at least one first microservice.
[0006] According to another aspect of the present disclosure, an electronic device is provided, including a memory and a processor, wherein instructions executable by the processor are stored in the memory, and when the instructions are executed by the processor, the processor executes the method as described above.
[0007] According to another aspect of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to enable a computer to execute and implement the method described above.
[0008] According to another aspect of the present disclosure, a computer program product is provided, including a computer program, and when the computer program is executed by a processor, the computer program implements the method as described above.
[0009] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0010] The accompanying drawings are used to better understand the present solution and do not constitute a limitation of the present disclosure.
[0011] Figure 1 An exemplary system architecture to which the data processing method and apparatus according to an embodiment of the present disclosure can be applied is schematically shown.
[0012] Figure 2 The flowchart of the data processing method according to the embodiment of the present disclosure is schematically shown.
[0013] Figure 3 A schematic diagram of a microservice framework in a multi-tenant scenario according to an embodiment of the present disclosure is schematically shown.
[0014] Figure 4 The following is a schematic diagram of a tenant creation process according to an embodiment of the present disclosure.
[0015] Figure 5 A schematic diagram schematically shows a user access process of a first tenant according to an embodiment of the present disclosure.
[0016] Figure 6 A schematic diagram schematically shows a user access process of a first tenant according to another embodiment of the present disclosure.
[0017] Figure 7 The block diagram schematically shows a data processing device according to an embodiment of the present disclosure.
[0018] Figure 8 A block diagram of an electronic device suitable for implementing a video data processing method according to an embodiment of the present disclosure is schematically shown. DETAILED DESCRIPTION
[0019] Hereinafter, embodiments of the present disclosure will be described with reference to the accompanying drawings. However, it should be understood that these descriptions are exemplary only and are not intended to limit the scope of the present disclosure. In the following detailed description, for ease of explanation, many specific details are set forth to provide a comprehensive understanding of the embodiments of the present disclosure. However, it is apparent that one or more embodiments may also be implemented without these specific details. In addition, in the following description, descriptions of known structures and technologies are omitted to avoid unnecessary confusion of the concepts of the present disclosure.
[0020] The terms used herein are only for describing specific embodiments and are not intended to limit the present disclosure. The terms "comprise", "include", etc. used herein indicate the existence of the features, steps, operations and / or components, but do not exclude the existence or addition of one or more other features, steps, operations or components.
[0021] All terms (including technical and scientific terms) used herein have the meanings commonly understood by those skilled in the art, unless otherwise defined. It should be noted that the terms used herein should be interpreted as having a meaning consistent with the context of this specification, and should not be interpreted in an idealized or overly rigid manner.
[0022] In the case of using expressions such as "at least one of A, B, and C, etc.", it should generally be interpreted in accordance with the meaning of the expression generally understood by those skilled in the art (for example, "a system having at least one of A, B, and C" should include but is not limited to a system having A alone, B alone, C alone, A and B, A and C, B and C, and / or A, B, C, etc.). In the case of using expressions such as "at least one of A, B, or C, etc.", it should generally be interpreted in accordance with the meaning of the expression generally understood by those skilled in the art (for example, "a system having at least one of A, B, or C" should include but is not limited to a system having A alone, B alone, C alone, A and B, A and C, B and C, and / or A, B, C, etc.).
[0023] In the technical solution of the present disclosure, the collection, storage, use, processing, transmission, provision, disclosure and application of the data involved (including but not limited to user personal information) comply with the provisions of relevant laws and regulations, take necessary confidentiality measures, and do not violate public order and good morals.
[0024] In the technical solution of the present disclosure, the user's authorization or consent is obtained before obtaining or collecting the user's personal information.
[0025] It should be noted that, unless it is explicitly stated that there is a sequence of execution between different operations shown in the flowchart in the embodiments of the present disclosure, or there is a sequence of execution between different operations in technical implementation, otherwise, the execution order of multiple operations may not be prioritized, and multiple operations may also be executed simultaneously.
[0026] In the related art, when implementing multi-tenant data isolation, a redundant field can be added to each data record, such as the tenant ID. When adding, deleting, modifying, and checking data records, the data records that need to be processed can be filtered according to the tenant ID. This type of method is relatively lightweight and simple in technical implementation, but the amount of changes at the code level is large, and the data of different tenants are not physically or logically isolated, and the isolation level is low. Alternatively, based on containerization technologies such as docker and k8s, the data of each tenant can be stored in a separate container. This type of method requires relevant technical personnel to have a certain understanding and familiarity with docker and k8s. It is an implementation solution with the highest technical feasibility, the highest isolation level, and the highest operation and maintenance cost.
[0027] The embodiments of the present disclosure provide a data processing method, device, electronic device and storage medium, which can realize multi-tenant management services in a microservice scenario without affecting the existing microservice framework. The data processing method includes: receiving a service request from a first tenant, wherein the service request carries a tenant identifier; based on the tenant identifier, determining the first tenant information of the first tenant from a tenant table, wherein the tenant table is located in the public space of the database; using the first tenant information to call at least one first microservice related to the first tenant; and in response to obtaining a data change instruction, based on the first tenant information and the data change instruction, performing data processing on a data table in the first tenant space associated with the first tenant in the database, wherein the data change instruction is generated during the calling process of at least one first microservice.
[0028] Figure 1 The exemplary system architecture to which the data processing method and device according to the embodiment of the present disclosure can be applied is schematically shown. It should be noted that: Figure 1 What is shown is merely an example of a system architecture to which the embodiments of the present disclosure can be applied, in order to help those skilled in the art understand the technical content of the present disclosure, but it does not mean that the embodiments of the present disclosure cannot be used in other devices, systems, environments or scenarios.
[0029] like Figure 1 As shown, the system architecture 100 according to this embodiment may include terminal devices 101 , 102 , 103 , a network 104 and a server 105 .
[0030] The terminal devices 101 , 102 , and 103 may be various electronic devices with display screens, including but not limited to smart phones, tablet computers, laptop computers, and desktop computers.
[0031] The network 104 may be used for data communication between the terminal devices 101, 102, 103, or between the terminal devices 101, 102, 103 and the server 105. The network 104 may include various connection types, such as wired and / or wireless communication links.
[0032] The server 102 may be any type of server that provides various services. For example, the server may be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services (Virtual Private Server, VPS). The server may also be an edge server. The server may also be a server in a distributed system.
[0033] It should be noted that the data processing method provided in the embodiment of the present disclosure can generally be executed by the server 105. Accordingly, the data processing device provided in the embodiment of the present disclosure can also be set in the server 105.
[0034] For example, a user can access the tenant service provided by the server 105 through a browser application on any one of the terminal devices 101, 102, and 103 (for example, the terminal device 101). By accessing the tenant service, the user can call the microservice corresponding to the tenant. In the process of the user calling the microservice, the user's input operation on the terminal device 101 can be sent to the server 105 through the network 104. The server 105 can intercept the data change operation in the input operation, rewrite the SQL statement contained in the data change operation, and then execute the SQL statement to perform data change processing on the data table under the tenant space of the corresponding tenant in the database.
[0035] It should be understood that Figure 1 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.
[0036] Figure 2 The flowchart of the data processing method according to the embodiment of the present disclosure is schematically shown.
[0037] like Figure 2 As shown, the data processing method may include operations S210 to S240.
[0038] In operation S210, a service request from a first tenant is received, wherein the service request carries a tenant identifier.
[0039] In operation S220 , first tenant information of the first tenant is determined from a tenant table based on the tenant identifier, wherein the tenant table is located in a public space of a database.
[0040] In operation S230, at least one first microservice related to the first tenant is called using the first tenant information.
[0041] In operation S240, in response to obtaining the data change instruction, data processing is performed on a data table in a first tenant space associated with the first tenant in the database based on the first tenant information and the data change instruction, wherein the data change instruction is generated during the calling process of at least one first microservice.
[0042] According to an embodiment of the present disclosure, a tenant can be represented as a set of accessible resources in each service. The resource set can be used by multiple users, and users can access computing management resources through tenants. The first tenant can be any tenant in the microservice framework. Through the first tenant, the user can use one or more microservices in the microservice framework.
[0043] According to an embodiment of the present disclosure, the service request may be an access request initiated by a user of the first tenant, that is, after logging in through the first tenant, the user may initiate a service request to the resource service to access the tenant data of the first tenant.
[0044] According to an embodiment of the present disclosure, the tenant identifier of the first tenant may be a string of information uniquely indicating the first tenant. The tenant identifier may be a random number consisting of at least one of numbers, uppercase letters, and lowercase letters. The tenant identifier may have a fixed length.
[0045] According to an embodiment of the present disclosure, the tenant table may be a data table storing information such as tenant identification, tenant name, tenant creation time, etc. of each tenant. The data result of the tenant table may be as shown in Table 1, and the tenant table may record information such as the field name, data type, length, default value, description, etc. of each information item such as tenant identification, tenant name, tenant creation time, etc.
[0046] Table 1
[0047] Field Name Data Types length default value describe id int8 Tenant ID tenant_name varchar 60 Tenant Name db_schema varchar 60 Tenant data space create_time timestamp 29 Creation time update_time timestamp 29 Update time update_by varchar 32 "::chara Update User
[0048] According to an embodiment of the present disclosure, the first tenant information may include at least information about a tenant data space associated with the first tenant, for example, the name of the tenant data space.
[0049] According to an embodiment of the present disclosure, the public space of the database may be a schema named public in the database.
[0050] According to an embodiment of the present disclosure, different tenants can use different microservices. At least one first microservice related to a first tenant may include a microservice that a user can call through the first tenant. At least one first microservice related to a first tenant may be configured in a tenant table when creating or updating the first tenant.
[0051] According to an embodiment of the present disclosure, the first tenant and the first microservice may communicate through a gateway server. An interceptor for the first tenant may be provided in the gateway server. When the first tenant makes data changes, the interceptor may intercept and obtain the data change instruction.
[0052] According to an embodiment of the present disclosure, the data change instruction may be generated by the user in the process of calling at least one first microservice related to the first tenant. The data change instruction may include a structured query statement generated based on the user operation, that is, an SQL statement.
[0053] According to an embodiment of the present disclosure, the first tenant space associated with the first tenant may be a schema related to the first tenant in a database, and the schema may be named using the tenant identifier of the first tenant or the tenant name of the first tenant, which is not limited here.
[0054] According to an embodiment of the present disclosure, performing data processing on a data table in the first tenant space may be updating data on the data table in the first tenant space based on an SQL statement included in the data change instruction.
[0055] According to the embodiments of the present disclosure, a user can initiate a service request through the first tenant. After receiving the service request, the gateway server can determine the first tenant information of the first tenant from the tenant table, and use the first tenant information to call at least one first microservice related to the first tenant. For the data change instruction generated in the process of the user calling the first microservice, the first tenant information can be used to modify the data change instruction, and the modified data change instruction can be used to process the data table in the first tenant space. Through the above technical means, data isolation processing in a multi-tenant scenario based on a microservice framework can be achieved, which improves the data isolation effect.
[0056] Reference below Figure 3 to Figure 6 , combined with specific embodiments Figure 2 The data processing method shown is further explained.
[0057] Figure 3A schematic diagram of a microservice framework in a multi-tenant scenario according to an embodiment of the present disclosure is schematically shown.
[0058] like Figure 3 As shown, the microservice framework can be based on Liquibase and the database PostgreSQL.
[0059] According to an embodiment of the present disclosure, the microservice framework may include an infrastructure layer, a middleware layer, a microservice layer, a gateway layer, and multiple tenants from the bottom up. The infrastructure layer may include infrastructure such as servers, storage, and networks. The middleware layer may include middleware such as caches and message queues. The microservice layer may include various microservices that can provide services externally. The gateway layer may provide access control, information forwarding, reverse proxy, and other access.
[0060] According to an embodiment of the present disclosure, each tenant can support multiple users to register and access. For example, both user 1 and user 2 can access the microservice framework through tenant A.
[0061] According to an embodiment of the present disclosure, each tenant may have the permission to call one or more of the multiple microservices. Each tenant service may correspond to a database instance in the database PostgreSQL, that is, a database space in the database PostgreSQL. The name of the database space of the database PostgreSQL may be used as the tenant identifier of the corresponding tenant. The database PostgreSQL may include a public space, and the data tables in the database spaces corresponding to each tenant may have the same library table results as the data tables in the public space.
[0062] According to an embodiment of the present disclosure, the multiple tenants may include at least one default tenant, and the default tenant may correspond to a user called a tenant administrator, who may perform management such as creation and deletion of tenants.
[0063] Figure 4 The following is a schematic diagram of a tenant creation process according to an embodiment of the present disclosure.
[0064] like Figure 4 As shown, when creating a tenant, for example, when creating a second tenant, the tenant administrator can submit basic information of the tenant to be created through the tenant service. Specifically, the tenant administrator can initiate a tenant creation request to the gateway server based on the second tenant information.
[0065] According to an embodiment of the present disclosure, the gateway server may create a second tenant space in the database based on the second tenant information carried in the tenant creation request in response to the tenant creation request for the second tenant.
[0066] According to an embodiment of the present disclosure, specifically, the gateway server can generate a random string of preset length in response to a tenant creation request. The random string can be a string containing numbers, uppercase and lowercase English letters, and can avoid conflicts with Chinese characters and special characters such as slashes and underscores.
[0067] According to an embodiment of the present disclosure, the gateway server may generate an initial tenant space in the database using a random string as a pattern space name, that is, create a tenant's schema in the database PostgreSQL.
[0068] According to an embodiment of the present disclosure, the gateway server may create a plurality of initial data tables, that is, initialize the table structure, in the initial tenant space based on the second tenant information.
[0069] According to an embodiment of the present disclosure, the table structure can be initialized using the microservices and data required by the tenant as an isolation strategy. Specifically, at least one second microservice related to the second tenant can be determined based on the second tenant information. Based on the data tables related to the at least one second microservice, multiple initial data tables are created in the initial tenant space.
[0070] According to the embodiments of the present disclosure, by using the microservices and their data required by the tenants as isolation strategies to initialize the table structure, different tenants can have different microservices and different database spaces to isolate the generated data, thereby realizing data isolation under the microservice framework. At the same time, when creating tenants, on-demand creation can be achieved based on the tenants' needs for microservices, which can reduce the use of database server resources and speed up the initialization operation of the database table structure in the tenant space.
[0071] According to an embodiment of the present disclosure, a plurality of initial data tables are initialized using a plurality of data tables included in a public space of a database to obtain a second tenant space, namely, initialization table data.
[0072] According to an embodiment of the present disclosure, when initializing table data, multiple target data tables can be determined from multiple data tables included in the public space of the database based on multiple initial data tables. The target data tables can correspond to the initial data tables. Multiple target data tables can be used to perform data synchronization processing on multiple initial data tables to initialize the multiple initial data tables and obtain a second tenant space.
[0073] According to the embodiments of the present disclosure, the operations of initializing the table structure and initializing the table data can be implemented by Liquibase, which will not be described in detail here. Alternatively, the process of initializing the table structure can also be implemented using any data table generation method, which is not limited here. The process of initializing the table data can also be implemented using any data synchronization method, which is not limited here.
[0074] According to the embodiments of the present disclosure, in a microservice scenario, data isolation is a very important link. The scalability and hot deployment between microservices all involve data isolation at the bottom layer. Therefore, for tenants, the services used by different tenants may be different. When creating a tenant, it is not necessary to create all services for the tenant. That is, on-demand and dynamic creation can reduce the use of database server resources and speed up the initialization operation of the tenant schema database table structure, so as to achieve fast response of tenant services in microservice scenarios and improve user experience.
[0075] According to an embodiment of the present disclosure, when receiving a service request from the first tenant, access authentication may also be performed on the service request to determine the access rights of the user.
[0076] According to an embodiment of the present disclosure, the service request initiated by the user through the first tenant may carry user credential information, such as the user's login account name, password, and other information.
[0077] Figure 5 A schematic diagram schematically shows a user access process of a first tenant according to an embodiment of the present disclosure.
[0078] like Figure 5 As shown, a user belonging to the first tenant can enter a tenant identifier and user credential information in the front-end browser, so that the front-end browser initiates a service request to the gateway server based on the tenant identifier and user credential information.
[0079] According to an embodiment of the present disclosure, the gateway server can perform access authentication on the user credential information in response to receiving the service request and obtain an authentication result. Specifically, the gateway server can call the authentication service to obtain an information list of users who have registered with the first tenant, and can use the user credential information to match the information included in the information list to determine whether the user credential information exists in the information list, thereby obtaining an authentication result of whether the user has passed the authentication.
[0080] According to an embodiment of the present disclosure, when the authentication result indicates that the authentication is passed, the gateway server can determine the first tenant information of the first tenant from the tenant table based on the tenant identifier. Specifically, the gateway server can call the tenant service to authenticate the first tenant based on the tenant identifier, and after determining that the first tenant has passed the authentication, use the tenant service to obtain the tenant space information table. Authenticating the first tenant can be to verify whether the first tenant has been created in the microservice framework. A tenant information table can be maintained in the tenant service, and the tenant identifier can be matched with multiple identification information included in the tenant information table. Based on the matching result, the first tenant can be obtained. Authentication result. The tenant space information table may include the tenant space related to each tenant, that is, the tenant schema.
[0081] According to an embodiment of the present disclosure, after obtaining the first tenant information of the first tenant, the gateway server may call the user service to call at least one first microservice related to the first tenant. Specifically, the gateway server may determine the access path of the at least one first microservice based on the first tenant information. Based on the access path of the at least one first microservice, the service request is forwarded to the at least one first microservice to call the at least one first microservice.
[0082] According to the embodiments of the present disclosure, the same microservice can provide different access paths when providing services to different tenants. Different access paths can point to the same address after decoding. For example, the access path provided by microservice A to tenant 1 is A1.com, and the access path provided by microservice A to tenant 2 is A2.com. The two access paths can point to the same address A.com, that is, when tenant 1 uses A1.com to call microservice A, and when tenant 2 uses A2.com to call microservice A, both ultimately point to address A.com.
[0083] According to an embodiment of the present disclosure, user credential information may also include other information that can verify the user's access behavior, such as a login token, etc. After the user logs in for the first time and passes the verification, the login token can be obtained based on the user's login account name, password and other information, so that the login token can be used to complete the authentication of the user and the tenant when accessing the microservice in the future.
[0084] Figure 6 A schematic diagram schematically shows a user access process of a first tenant according to another embodiment of the present disclosure.
[0085] like Figure 6 As shown, the user access process of the first tenant may include a login process and an access process.
[0086] According to an embodiment of the present disclosure, in the login process, the user can enter the tenant identification and login account name, password and other user information in the front-end browser, so that the front-end browser can initiate a user login request to the gateway server based on the tenant identification and login account name, password and other information.
[0087] According to an embodiment of the present disclosure, the gateway server may, in response to receiving a user login request from the first tenant, perform login verification on the user information carried in the user login request to obtain a verification result. Specifically, the gateway server may call an authentication service and use the authentication service to verify user information such as a login account name and password to obtain a verification result indicating whether the login verification is passed.
[0088] According to an embodiment of the present disclosure, when the verification result indicates that the login verification is passed, the tenant service can generate user credential information based on the user information. Specifically, the data table related to the user information maintained in the tenant service can be preset with user credential information related to the user information, that is, a login token. The tenant service can obtain the corresponding login token from the data table based on the user information and return it to the gateway server.
[0089] According to an embodiment of the present disclosure, the gateway server may return user credential information to the first tenant, that is, return the login token to the front-end browser.
[0090] According to an embodiment of the present disclosure, as an optional implementation, during the login process, the gateway server may also call the tenant service to determine the first tenant information of the first tenant from the tenant table by means of the tenant identifier.
[0091] According to an embodiment of the present disclosure, in the access process, the user can directly click the quick access button of the front-end browser, and the front-end browser can generate a service request based on the tenant identifier and login token, and send the service request to the gateway service.
[0092] According to an embodiment of the present disclosure, when a service request calls a tenant service or an authentication service to authenticate a tenant or a user, the authentication process can be completed based on a login token, and after the authentication is passed, the first microservice can be called based on the tenant identifier, which will not be repeated here.
[0093] According to an embodiment of the present disclosure, when a user completes the call of a microservice through a first tenant, an interceptor for the tenant space of the first tenant may be generated in the gateway server. The interceptor may be used to intercept and obtain data change instructions when data changes occur. In response to obtaining the data change instruction, the gateway server may splice the first tenant information with the data change instruction to obtain the target data change instruction. Based on the space name included in the first tenant information, the first tenant space is determined from the database. The target data change instruction is executed to perform data processing on the data table in the first tenant space. Data processing may include, but is not limited to, data addition, deletion, and modification processing.
[0094] For example, you can connect to obtain each SQL statement to be executed, parse the SQL statement into a Java object, add the tenant's schema information, that is, the first tenant information, to the table name signature in the SQL statement, and then continue to execute the modified SQL statement to perform data changes on the data table in the first tenant space.
[0095] According to the embodiments of the present disclosure, when executing SQL queries, standard SQL statements are intercepted by interceptors. In order to improve the query efficiency of SQL, tenant information and user information can be cached first to ensure that users can quickly and stably obtain the required information during the access process. At the same time, since in a microservice environment, the process from the user initiating a request to the end of the response involves associated communications between multiple services, the tenant information can be updated in real time in the cache and then synchronized to the database through asynchronous refresh. In order to facilitate the interceptor to quickly process SQL, the backend developers can avoid using complex, difficult to maintain and update SQL such as multi-table associations and nested queries in the process of developing microservices, which reduces the maintenance cost of developers and enables rapid development.
[0096] According to an embodiment of the present disclosure, in a microservice scenario, for database table management operations such as updating and adding microservices, corresponding version information records can be retained in liquibase to facilitate rollback operations when the system is abnormal.
[0097] Figure 7 The block diagram schematically shows a data processing device according to an embodiment of the present disclosure.
[0098] like Figure 7 As shown, the data processing device 700 may include a receiving module 710 , a first determining module 720 , a calling module 730 and a processing module 740 .
[0099] The receiving module 710 is configured to receive a service request from a first tenant, wherein the service request carries a tenant identifier.
[0100] The first determining module 720 is configured to determine first tenant information of a first tenant from a tenant table based on the tenant identifier, wherein the tenant table is located in a public space of a database.
[0101] The calling module 730 is configured to call at least one first microservice related to the first tenant by using the first tenant information.
[0102] The processing module 740 is used to process data on a data table in a first tenant space associated with the first tenant in the database based on the first tenant information and the data change instruction in response to obtaining the data change instruction, wherein the data change instruction is generated during the calling process of at least one first microservice.
[0103] According to an embodiment of the present disclosure, the processing module 740 includes a first processing unit, a second processing unit, and a third processing unit.
[0104] The first processing unit is used for, in response to obtaining the data change instruction, splicing the first tenant information with the data change instruction to obtain a target data change instruction.
[0105] The second processing unit is configured to determine the first tenant space from the database based on the space name included in the first tenant information.
[0106] The third processing unit is used to execute the target data change instruction to perform data processing on the data table in the first tenant space.
[0107] According to an embodiment of the present disclosure, the calling module 730 includes a first calling unit and a second calling unit.
[0108] The first calling unit is used to determine an access path of at least one first microservice based on the first tenant information.
[0109] The second calling unit is used to forward the service request to the at least one first microservice based on the respective access path of the at least one first microservice, so as to call the at least one first microservice.
[0110] According to an embodiment of the present disclosure, the service request also carries user credential information.
[0111] According to an embodiment of the present disclosure, the data processing device 700 further includes an authentication module and a second determination module.
[0112] The authentication module is used to perform access authentication on the user credential information in response to receiving the service request and obtain an authentication result.
[0113] The second determining module is configured to determine the first tenant information of the first tenant from the tenant table based on the tenant identifier when the authentication result indicates that the authentication is passed.
[0114] According to an embodiment of the present disclosure, the data processing device 700 further includes a verification module, a generation module and a sending module.
[0115] The verification module is used to, in response to receiving a user login request from the first tenant, perform login verification on the user information carried in the user login request to obtain a verification result.
[0116] The generation module is used to generate user credential information based on the user information when the verification result indicates that the login verification is passed.
[0117] The sending module is used to return the user credential information to the first tenant.
[0118] According to an embodiment of the present disclosure, the data processing device 700 further includes a creation module.
[0119] The creation module is used to create a second tenant space in the database in response to a tenant creation request for the second tenant and based on the second tenant information carried in the tenant creation request.
[0120] According to an embodiment of the present disclosure, the creation module includes a first creation unit, a second creation unit, a third creation unit, and a fourth creation unit.
[0121] The first creation unit is used to generate a random character string of a preset length in response to a tenant creation request.
[0122] The second creation unit is used to generate an initial tenant space in the database using a random character string as a pattern space name.
[0123] The third creating unit is used to create a plurality of initial data tables in the initial tenant space based on the second tenant information.
[0124] The fourth creation unit is used to initialize the multiple initial data tables using the multiple data tables included in the public space of the database to obtain the second tenant space.
[0125] According to an embodiment of the present disclosure, the third creation unit includes a first creation subunit and a second creation subunit.
[0126] The first creation subunit is used to determine at least one second microservice related to the second tenant based on the second tenant information.
[0127] The second creation subunit is used to create multiple initial data tables in the initial tenant space based on the data tables respectively related to at least one second microservice.
[0128] According to an embodiment of the present disclosure, the fourth creation unit includes a third creation sub-unit and a fourth creation sub-unit.
[0129] The third creation subunit is used to determine a plurality of target data tables from a plurality of data tables included in the public space of the database based on the plurality of initial data tables, wherein the target data tables correspond to the initial data tables.
[0130] The fourth creation subunit is used to perform data synchronization processing on the multiple initial data tables by using the multiple target data tables, so as to initialize the multiple initial data tables and obtain the second tenant space.
[0131] According to the embodiments of the present invention, any one or more of the modules, submodules, units, and subunits, or at least part of the functions of any one of them can be implemented in one module. According to the embodiments of the present invention, any one or more of the modules, submodules, units, and subunits can be split into multiple modules for implementation. According to the embodiments of the present invention, any one or more of the modules, submodules, units, and subunits can be at least partially implemented as hardware circuits, such as field programmable gate arrays (Field Programmable Gate Array, FPGA), programmable logic arrays (Programmable Logic Arrays, PLA), systems on chips, systems on substrates, systems on packages, application specific integrated circuits (Application Specific Integrated Circuit, ASIC), or can be implemented by hardware or firmware of any other reasonable way of integrating or packaging the circuit, or by any one of the three implementation methods of software, hardware, and firmware or by a suitable combination of any of them. Alternatively, according to the embodiments of the present invention, one or more of the modules, submodules, units, and subunits can be at least partially implemented as computer program modules, and when the computer program modules are run, the corresponding functions can be performed.
[0132] For example, any multiple of the receiving module 710, the first determining module 720, the calling module 730 and the processing module 740 can be combined in one module / unit / sub-unit for implementation, or any one of the modules / units / sub-units can be split into multiple modules / units / sub-units. Alternatively, at least part of the functions of one or more modules / units / sub-units in these modules / units / sub-units can be combined with at least part of the functions of other modules / units / sub-units and implemented in one module / unit / sub-unit. According to an embodiment of the present disclosure, at least one of the receiving module 710, the first determining module 720, the calling module 730 and the processing module 740 can be at least partially implemented as a hardware circuit, such as a field programmable gate array (FPGA), a programmable logic array (PLA), a system on a chip, a system on a substrate, a system on a package, an application specific integrated circuit (ASIC), or can be implemented by hardware or firmware such as any other reasonable way of integrating or packaging the circuit, or by any one of the three implementation methods of software, hardware and firmware or by a suitable combination of any of them. Alternatively, at least one of the receiving module 710 , the first determining module 720 , the calling module 730 and the processing module 740 may be at least partially implemented as a computer program module, and when the computer program module is executed, a corresponding function may be performed.
[0133] It should be noted that the data processing device part in the embodiments of the present disclosure corresponds to the data processing method part in the embodiments of the present disclosure. The description of the data processing device part specifically refers to the data processing method part, which will not be repeated here.
[0134] Figure 8 A block diagram of an electronic device suitable for implementing a video data processing method according to an embodiment of the present disclosure is schematically shown. Figure 8 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.
[0135] like Figure 8 As shown, the electronic device 800 according to an embodiment of the present disclosure includes a processor 801, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 802 or a program loaded from a storage part 808 to a random access memory (RAM) 803. The processor 801 may include, for example, a general-purpose microprocessor (e.g., a CPU), an instruction set processor and / or a related chipset and / or a special-purpose microprocessor (e.g., an application-specific integrated circuit (ASIC)), etc. The processor 801 may also include an onboard memory for caching purposes. The processor 801 may include a single processing unit or multiple processing units for performing different actions of the method flow according to an embodiment of the present disclosure.
[0136] In RAM 803, various programs and data required for the operation of electronic device 800 are stored. Processor 801, ROM 802 and RAM 803 are connected to each other via bus 804. Processor 801 performs various operations of the method flow according to the embodiment of the present disclosure by executing the program in ROM 802 and / or RAM 803. It should be noted that the program can also be stored in one or more memories other than ROM 802 and RAM 803. Processor 801 can also perform various operations of the method flow according to the embodiment of the present disclosure by executing the program stored in one or more memories.
[0137] According to an embodiment of the present disclosure, the electronic device 800 may further include an input / output (I / O) interface 805, which is also connected to the bus 804. The electronic device 800 may further include one or more of the following components connected to the input / output (I / O) interface 805: an input portion 806 including a keyboard, a mouse, etc.; an output portion 807 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage portion 808 including a hard disk, etc.; and a communication portion 809 including a network interface card such as a LAN card, a modem, etc. The communication portion 809 performs communication processing via a network such as the Internet. A drive 810 is also connected to the input / output (I / O) interface 805 as needed. A removable medium 811, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 810 as needed, so that a computer program read therefrom is installed into the storage portion 808 as needed.
[0138] The present disclosure also provides a non-transient computer-readable storage medium, which may be included in the device / apparatus / system described in the above embodiments; or may exist independently without being assembled into the device / apparatus / system. The above computer-readable storage medium carries one or more programs, and when the above one or more programs are executed, the method according to the embodiment of the present disclosure is implemented.
[0139] According to an embodiment of the present disclosure, the computer-readable storage medium may be a non-volatile computer-readable storage medium, for example, may include but is not limited to: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program, which may be used by or in combination with an instruction execution system, an apparatus or a device. For example, according to an embodiment of the present disclosure, a computer-readable storage medium may include the ROM 802 and / or RAM 803 described above and / or one or more memories other than ROM 802 and RAM 803.
[0140] The embodiment of the present disclosure also includes a computer program product, which includes a computer program, and the computer program contains program code for executing the method shown in the flowchart. When the computer program product is run in a computer system, the program code is used to enable the computer system to implement the method provided by the embodiment of the present disclosure.
[0141] The above functions defined in the system / device of the embodiment of the present disclosure are executed when the computer program is executed by the processor 801. According to the embodiment of the present disclosure, the system, device, module, unit, etc. described above can be implemented by a computer program module.
[0142] In one embodiment, the computer program may rely on tangible storage media such as optical storage devices, magnetic storage devices, etc. In another embodiment, the computer program may also be transmitted and distributed in the form of signals on a network medium, and downloaded and installed through the communication part 809, and / or installed from a removable medium 811. The program code contained in the computer program may be transmitted using any appropriate network medium, including but not limited to: wireless, wired, etc., or any suitable combination of the above.
[0143] In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 809, and / or installed from the removable medium 811. When the computer program is executed by the processor 801, the above functions defined in the system of the embodiment of the present disclosure are performed. According to the embodiment of the present disclosure, the system, device, means, module, unit, etc. described above can be implemented by a computer program module.
[0144] According to an embodiment of the present disclosure, the program code for executing the computer program provided by the embodiment of the present disclosure can be written in any combination of one or more programming languages. Specifically, these computing programs can be implemented using high-level process and / or object-oriented programming languages, and / or assembly / machine languages. Programming languages include, but are not limited to, Java, C++, python, "C" language or similar programming languages. The program code can be executed entirely on the user computing device, partially on the user device, partially on the remote computing device, or entirely on the remote computing device or server. In the case of a remote computing device, the remote computing device can be connected to the user computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computing device (for example, using an Internet service provider to connect through the Internet).
[0145] The flow charts and block diagrams in the accompanying drawings illustrate the possible architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0146] It will be appreciated by those skilled in the art that the features described in the various embodiments and / or claims of the present disclosure may be combined and / or combined in a variety of ways, even if such combinations and / or combinations are not explicitly described in the present disclosure. In particular, the features described in the various embodiments and / or claims of the present disclosure may be combined and / or combined in a variety of ways without departing from the spirit and teachings of the present disclosure. All of these combinations and / or combinations fall within the scope of the present disclosure.
[0147] The embodiments of the present disclosure are described above. However, these embodiments are only for illustrative purposes and are not intended to limit the scope of the present disclosure. Although the embodiments are described above separately, this does not mean that the measures in the various embodiments cannot be used in combination to advantage. The scope of the present disclosure is defined by the attached claims and their equivalents. Without departing from the scope of the present disclosure, those skilled in the art may make a variety of substitutions and modifications, which should all fall within the scope of the present disclosure.
Claims
1. A data processing method, comprising: Receiving a service request from a first tenant, wherein the service request carries a tenant identifier; Based on the tenant identifier, determining first tenant information of the first tenant from a tenant table, wherein the tenant table is located in a public space of a database; Using the first tenant information to call at least one first microservice related to the first tenant; and In response to obtaining a data change instruction, data processing is performed on a data table in a first tenant space associated with the first tenant in the database based on the first tenant information and the data change instruction, wherein the data change instruction is generated during the calling process of the at least one first microservice.
2. The method according to claim 1, wherein: In response to obtaining the data change instruction, based on the first tenant information and the data change instruction, performing data processing on a data table in the first tenant space associated with the first tenant in the database includes: In response to obtaining the data change instruction, concatenating the first tenant information with the data change instruction to obtain a target data change instruction; Determining the first tenant space from the database based on the space name included in the first tenant information; and The target data change instruction is executed to perform data processing on the data table in the first tenant space.
3. The method according to claim 1, wherein: The using the first tenant information to call at least one first microservice related to the first tenant includes: Based on the first tenant information, determining an access path for each of the at least one first microservice; and Based on the respective access paths of the at least one first microservice, the service request is forwarded to the at least one first microservice respectively to call the at least one first microservice.
4. The method according to claim 1, wherein: The service request also carries user credential information; The method further comprises: In response to receiving the service request, performing access authentication on the user credential information to obtain an authentication result; and When the authentication result indicates that the authentication is successful, first tenant information of the first tenant is determined from the tenant table based on the tenant identifier.
5. The method according to claim 4, further comprising: In response to receiving a user login request from the first tenant, performing login verification on the user information carried in the user login request to obtain a verification result; If the verification result indicates that the login verification is passed, generating the user credential information based on the user information; and The user credential information is returned to the first tenant.
6. The method according to claim 1, further comprising: In response to a tenant creation request for the second tenant, a second tenant space is created in the database based on the second tenant information carried in the tenant creation request.
7. The method according to claim 6, wherein: The step of creating, in response to a tenant creation request for a second tenant and based on the second tenant information carried in the tenant creation request, a second tenant space in the database includes: In response to the tenant creation request, generating a random string of a preset length; Using the random string as a pattern space name, generating an initial tenant space in the database; Based on the second tenant information, creating a plurality of initial data tables in the initial tenant space; and The plurality of initial data tables are initialized using the plurality of data tables included in the public space of the database to obtain the second tenant space.
8. The method according to claim 7, wherein: The creating a plurality of initial data tables in the initial tenant space based on the second tenant information includes: Based on the second tenant information, determining at least one second microservice related to the second tenant; and Based on the data tables respectively related to the at least one second microservice, the multiple initial data tables are created in the initial tenant space.
9. The method according to claim 7, wherein: The initializing the multiple initial data tables using the multiple data tables included in the public space of the database to obtain the second tenant space includes: Based on the multiple initial data tables, determining multiple target data tables from multiple data tables included in the public space of the database, wherein the target data tables correspond to the initial data tables; and The multiple target data tables are used to perform data synchronization processing on the multiple initial data tables, so as to initialize the multiple initial data tables and obtain the second tenant space.
10. A data processing device, comprising: A receiving module, configured to receive a service request from a first tenant, wherein the service request carries a tenant identifier; A first determining module, configured to determine first tenant information of the first tenant from a tenant table based on the tenant identifier, wherein the tenant table is located in a public space of a database; a calling module, configured to call at least one first microservice related to the first tenant by using the first tenant information; and A processing module is used to, in response to obtaining a data change instruction, perform data processing on a data table in a first tenant space associated with the first tenant in the database based on the first tenant information and the data change instruction, wherein the data change instruction is generated during the calling process of the at least one first microservice.
11. An electronic device comprising a memory and a processor, wherein the memory stores instructions executable by the processor, and when the instructions are executed by the processor, the processor executes the method according to any one of claims 1 to 9.
12. A non-transitory computer-readable storage medium storing computer instructions, wherein: The computer instructions are used to cause the computer to execute the method according to any one of claims 1 to 9.
13. A computer program product comprising a computer program, which, when executed by a processor, implements the method according to any one of claims 1 to 9.
Citation Information
Cited By
Multi-tenant hybrid deployment method, device, equipment, medium and product
CN121125488A
