CN117827940A - Multi-tenant data processing method and device, electronic equipment and storage medium - Google Patents

Multi-tenant data processing method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN117827940A
CN117827940A CN202211203236.6A CN202211203236A CN117827940A CN 117827940 A CN117827940 A CN 117827940A CN 202211203236 A CN202211203236 A CN 202211203236A CN 117827940 A CN117827940 A CN 117827940A
Authority
CN
China
Prior art keywords
data
thread
processed
tenant
dyeing
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202211203236.6A
Other languages
Chinese (zh)
Inventor
邓鹏鑫
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN202211203236.6A priority Critical patent/CN117827940A/en
Publication of CN117827940A publication Critical patent/CN117827940A/en
Pending legal-status Critical Current

Links

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention discloses a multi-tenant data processing method, a device, electronic equipment and a storage medium, wherein the method comprises the following steps: in response to a first service request corresponding to a first tenant, determining a dyeing identifier and first data to be processed, wherein the dyeing identifier is used for uniquely identifying the first tenant, setting the dyeing identifier in a shared parameter of a first thread, wherein the first thread is a thread to be operated to process the first data to be processed, acquiring the dyeing identifier from the shared parameter of the first thread when the operated first thread performs data storage on the first data to be processed, and sending the first data to a database instance corresponding to the dyeing identifier, wherein a database corresponding to the database instance is a database only storing the data of the first tenant. According to the embodiment of the application, the data of the tenants with data isolation requirements can be transmitted between services through the full-link dyeing identification based on the shared service, and the physical isolation of the data storage is realized on the basis of reducing the cost of the tenants.

Description

Multi-tenant data processing method and device, electronic equipment and storage medium
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a method and apparatus for processing multi-tenant data, an electronic device, and a storage medium.
Background
With the development of internet technology, private domain traffic is gradually rising, and the requirements of tenants on data security are higher and higher, so that part of tenants cannot accept to store own data and other data in the same database.
In the prior art, different tenants are deployed in different clusters through different applications, and deployment cluster isolation is fully adopted. This has a problem in that although data security is secured, the cost of the tenant is high, and many tenants do not pay for the servers providing different applications.
Disclosure of Invention
In order to solve the problems in the prior art, the embodiment of the invention provides a multi-tenant data processing method, a device, electronic equipment and a storage medium. The technical proposal is as follows:
in one aspect, a multi-tenant data processing method is provided, the method including:
determining a dyeing identifier and first data to be processed in response to a first service request corresponding to a first tenant; the staining identifier is used for uniquely identifying the first tenant;
Setting the dyeing identification in the sharing parameter of the first thread; the first thread is a thread to be run to process first data to be processed;
when the first thread running performs data storage on the first data to be processed, a dyeing identifier is obtained from the shared parameter of the first thread;
the first data to be processed is sent to a database instance corresponding to the dyeing identification; the database corresponding to the database instance is a database only storing the data of the first tenant.
In another aspect, there is provided a multi-tenant data processing apparatus, the apparatus comprising:
the determining module is used for responding to a first service request corresponding to a first tenant and determining a dyeing identifier and first data to be processed; the staining identifier is used for uniquely identifying the first tenant;
the mark setting module is used for setting the dyeing mark in the shared parameter of the first thread; the first thread is a thread to be run to process first data to be processed;
the identification acquisition module is used for acquiring a dyeing identification from the shared parameter of the first thread when the first thread running performs data storage on the first data to be processed;
the processing module is used for sending the first data to be processed to a database instance corresponding to the dyeing identifier; the database corresponding to the database instance is a database only storing the data of the first tenant.
In some of the possible embodiments of the present invention,
a determining module for:
receiving a second service request; the second service request includes an identification of the first tenant;
under the condition that a dyeing identifier corresponding to the identifier of the first tenant exists, setting the dyeing identifier in a request head of the second service request to obtain the first service request;
when the first service request is transmitted to the service middleware, responding to the first service request, analyzing the first service request to obtain a dyeing identification and first data to be processed.
In some of the possible embodiments of the present invention,
a determining module for:
triggering a first service request for generating a timing task at a preset moment; the first service request comprises task parameters of a timing task;
analyzing the task parameters to obtain a dyeing mark;
first data to be processed corresponding to the timing task is determined based on the first service request.
In some of the possible embodiments of the present invention,
the processing performed by the first thread on the first data to be processed includes two steps;
the identification acquisition module is used for:
when a first thread running carries out first step processing on first data to be processed, calling a function corresponding to the first step to process the first data to be processed to obtain first data;
And when the running first thread processes the first data in the second step, if the function corresponding to the second step is called to process the first data into data storage, acquiring the dyeing identification from the sharing parameter of the first thread.
In some of the possible embodiments of the present invention,
the device also comprises a delivery message delivery module and a delivery message detection module:
the delivery message delivery module is used for setting the dyeing identifier in the first data to be processed to obtain a delivery message when the first service request indicates that the requested service is a message queue service; sending a delivery message to a shared message queue server;
the delivery message detection module is used for acquiring the delivery message from the shared message queue server when detecting that the shared message queue server has the delivery message;
the determining module is used for analyzing the delivery message to obtain a dyeing identifier and first data to be processed;
the mark setting module is used for setting the dyeing mark in the shared parameter of the first thread;
the identification acquisition module is used for acquiring a dyeing identification from the shared parameter of the first thread when the first thread running performs data storage on the first data to be processed;
And the processing module is used for sending the first data to be processed to the database instance corresponding to the dyeing identifier.
In some of the possible embodiments of the present invention,
the apparatus further comprises a cross-application service module for:
generating a third service request based on the first data to be processed when the processing of the first data to be processed is cross-application processing;
setting the dyeing mark in a request head of the third service request to obtain a fourth service request;
and sending a fourth service request to the device corresponding to the cross-application processing.
In some of the possible embodiments of the present invention,
the apparatus further comprises a cross-thread service module for:
copying the dyeing identification from the shared parameter of the first thread to the shared parameter of the second thread; the second thread is a thread which is operated to process the first data to be processed in the operation process of the first thread; the first thread is a main thread, and the second thread is a sub thread in the main thread;
and running the second thread to process the first data to be processed based on the dyeing identification in the shared parameter of the second thread. In some of the possible embodiments of the present invention,
the apparatus further includes a sub-thread processing module configured to:
caching the dyeing identification from the shared parameter of the first thread to the shared parameter of the execution unit of the target thread pool; the target thread pool comprises threads which are operated to process first data to be processed in the operation process of the first thread; the target thread pool comprises a plurality of second threads;
Determining a second thread to be run in the target thread pool;
setting a dyeing identifier in the shared parameter of the execution unit in the shared parameter of the second thread;
running the second thread to process the first data to be processed based on the dyeing identification in the shared parameter of the second thread;
and after the second thread is operated, setting the dyeing identification in the shared parameter of the second thread in the shared parameter of the execution unit.
In some of the possible embodiments of the present invention,
the determining module is used for receiving a fifth service request, wherein the fifth service request comprises an identification of a second tenant; transmitting a fifth service request to the service middleware under the condition that a staining identifier corresponding to the identifier of the second tenant exists; the dyeing identifier corresponding to the identifier of the second tenant is a public dyeing identifier; responding to the fifth service request, and analyzing the fifth service request to obtain second to-be-processed data;
the processing module is used for sending the second data to be processed to the shared database instance when the third thread running performs data storage on the second data to be processed; the shared database corresponding to the shared database instance is a database for providing data storage for a plurality of tenants; the plurality of tenants includes a second tenant.
In some of the possible embodiments of the present invention,
the database associated with the staining identification corresponding to the identification of the first tenant and the shared database are databases which are physically isolated in one database cluster in a plurality of database clusters.
In another aspect, an electronic device is provided, including a processor and a memory, where at least one instruction or at least one program is stored, where the at least one instruction or at least one program is loaded and executed by the processor to implement the multi-tenant data processing method described above.
In another aspect, a computer readable storage medium is provided, in which at least one instruction or at least one program is stored, the at least one instruction or the at least one program being loaded and executed by a processor to implement a multi-tenant data processing method as described above.
In another aspect, a computer program product or computer program is provided, the computer program product or computer program comprising computer instructions stored in a computer readable storage medium. The processor of the computer device reads the computer instructions from the computer readable storage medium, and the processor executes the computer instructions, so that the computer device performs the multi-tenant data processing method described above.
In the embodiment of the invention, the dyeing identifier and the first data to be processed are determined by responding to the first service request corresponding to the first tenant, the dyeing identifier is used for uniquely identifying the first tenant, the dyeing identifier is arranged in the shared parameter of the first thread, the first thread is a thread to be operated to process the first data to be processed, when the operated first thread processes the first data to be processed into data storage, the dyeing identifier is acquired from the shared parameter of the first thread, the first data to be processed is sent to the database instance corresponding to the dyeing identifier, and the database corresponding to the database instance is a database only storing the data of the first tenant. According to the embodiment of the application, the data of the tenants with data isolation requirements can be transmitted between services through the full-link dyeing identification based on the shared service, and the physical isolation of the data storage is realized on the basis of reducing the cost of the tenants.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for the description of the embodiments will be briefly described below, and it is apparent that the drawings in the following description are only some embodiments of the present invention, and other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a schematic illustration of an implementation environment provided by an embodiment of the present invention;
fig. 2 is a flow chart of a multi-tenant data processing method according to an embodiment of the present invention;
fig. 3 is a flow chart of a multi-tenant data processing method according to an embodiment of the present invention;
fig. 4 is a schematic flow structure diagram of a multi-tenant data processing method according to an embodiment of the present invention;
fig. 5 is a flow chart of a multi-tenant data processing method according to an embodiment of the present invention;
fig. 6 is a flow chart of a multi-tenant data processing method according to an embodiment of the present invention;
fig. 7 is a flow chart of a multi-tenant data processing method according to an embodiment of the present invention;
fig. 8 is a schematic flow structure diagram of a multi-tenant data processing method according to an embodiment of the present invention;
fig. 9 is a flow chart of a multi-tenant data processing method according to an embodiment of the present invention;
FIG. 10 is a block diagram illustrating a multi-tenant data processing apparatus according to an embodiment of the present invention;
fig. 11 is a block diagram of a hardware structure of an electronic device according to an embodiment of the present invention.
Detailed Description
The following description of the embodiments of the present invention will be made clearly and completely with reference to the accompanying drawings, in which it is apparent that the embodiments described are only some embodiments of the present invention, but not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
It should be noted that the terms "first," "second," and the like in the description and the claims of the present invention and the above figures are used for distinguishing between similar objects and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used may be interchanged where appropriate such that the embodiments of the invention described herein may be implemented in sequences other than those illustrated or otherwise described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or server that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed or inherent to such process, method, article, or apparatus, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
It will be appreciated that in the specific embodiments of the present application, related data such as user data is referred to, and when the above embodiments of the present application are applied to specific products or technologies, user permissions or consents need to be obtained, and the collection, use and processing of related data need to comply with related laws and regulations and standards of related countries and regions.
In order to facilitate understanding of the technical solutions described in the embodiments of the present disclosure and the technical effects thereof, the terms involved in the embodiments of the present disclosure are briefly described:
cloud technology (Cloud technology) refers to a hosting technology that unifies serial resources such as hardware, software, networks and the like in a wide area network or a local area network to realize calculation, storage, processing and sharing of data. Cloud technology (Cloud technology) is based on the general terms of network technology, data technology, integration technology, management platform technology, application technology and the like applied by Cloud computing business models, and can form a resource pool, so that the Cloud computing business model is flexible and convenient as required. Cloud computing technology will become an important support. Background services of technical networking systems require a large amount of computing, storage resources, such as video websites, picture-like websites, and more portals. Along with the high development and application of the internet industry, each article possibly has an own identification mark in the future, the identification mark needs to be transmitted to a background system for logic processing, data with different levels can be processed separately, and various industry data needs strong system rear shield support and can be realized only through cloud computing.
Cloud storage (cloud storage) is a new concept that extends and develops in the concept of cloud computing, and a distributed cloud storage system (hereinafter referred to as a storage system for short) refers to a storage system that integrates a large number of storage devices (storage devices are also referred to as storage nodes) of various types in a network to work cooperatively through application software or application interfaces through functions such as cluster application, grid technology, and a distributed storage file system, so as to provide data storage and service access functions for the outside. At present, the storage method of the storage system is as follows: when creating logical volumes, each logical volume is allocated a physical storage space, which may be a disk composition of a certain storage device or of several storage devices. The client stores data on a certain logical volume, that is, the data is stored on a file system, the file system divides the data into a plurality of parts, each part is an object, the object not only contains the data but also contains additional data such as a data Identification (ID), the file system writes each object into a physical storage space of the logical volume, and the file system records storage location data of each object, so that when the client requests to access the data, the file system can enable the client to access the data according to the storage location data of each object. The process of allocating physical storage space for the logical volume by the storage system specifically includes: physical storage space is divided into stripes in advance according to the set of capacity measures for objects stored on a logical volume (which measures tend to have a large margin with respect to the capacity of the object actually to be stored) and redundant array of independent disks (RAID, redundant array of Independent Disk), and a logical volume can be understood as a stripe, whereby physical storage space is allocated for the logical volume.
The Database (Database), which can be considered as an electronic filing cabinet, is a place for storing electronic files, and users can perform operations such as adding, inquiring, updating, deleting and the like on the data in the files. A "database" is a collection of data stored together in a manner that can be shared with multiple users, with as little redundancy as possible, independent of the application.
Referring to fig. 1, a schematic diagram of an implementation environment provided by an embodiment of the present invention is shown, where the implementation environment may include a client 110, a server 120, and a database 130.
Wherein, connection communication between the client 110 and the server 120 and between the server 120 and the database 130 may be performed through a network.
Wherein the client 110 includes, but is not limited to, a cell phone, a computer, an intelligent voice interaction device, an intelligent home appliance, a vehicle client, an aircraft, etc. The client 110 has an application program having a man-machine interaction function running therein,
the server 120 may determine, in response to a first service request corresponding to the first tenant, a staining identifier and first data to be processed, where the staining identifier is used to uniquely identify the first tenant, set the staining identifier in a shared parameter of a first thread, where the first thread is a thread to be run to process the first data to be processed, and obtain, when a process implemented by the running first thread on the first data to be processed is data storage, the staining identifier from the shared parameter of the first thread, send the first data to be processed to a database instance corresponding to the staining identifier, where a database corresponding to the database instance is a database that stores only data of the first tenant. According to the embodiment of the application, the data of the tenants with data isolation requirements can be transmitted between services through the full-link dyeing identification based on the shared service, and the physical isolation of the data storage is realized on the basis of reducing the cost of the tenants.
The database 130 may include a memory database and a relational database, and it should be noted that, in the embodiment of the present invention, the server, the database, the node, etc. may be independent physical servers, may be a server cluster or a distributed system formed by a plurality of physical servers, or may be a cloud server that provides cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN (Content Delivery Network ), and basic cloud computing services such as big data and an artificial intelligent platform.
In an exemplary embodiment, the client 110, the server 120, and the database 130 may be node devices in a blockchain system, and may be capable of sharing acquired and generated data to other node devices in the blockchain system, so as to implement data sharing between multiple node devices. The plurality of node devices in the blockchain system can be configured with the same blockchain, the blockchain consists of a plurality of blocks, and the blocks adjacent to each other in front and back have an association relationship, so that the data in any block can be detected through the next block when being tampered, thereby avoiding the data in the blockchain from being tampered, and ensuring the safety and reliability of the data in the blockchain.
Referring to fig. 2, a flowchart of a multi-tenant data processing method according to an embodiment of the present invention is shown, and the method may be applied to the implementation environment shown in fig. 1, where an execution body of the method may be a server or a server cluster for executing multi-tenant data processing in fig. 1, or may be a client or other server nodes for executing multi-tenant data processing. It is noted that the present specification provides method operational steps as described in the examples or flowcharts, but may include more or fewer operational steps based on conventional or non-inventive labor. The order of steps recited in the embodiments is merely one way of performing the order of steps and does not represent a unique order of execution. In actual system or product execution, the methods illustrated in the embodiments or figures may be performed sequentially or in parallel (e.g., in a parallel processor or multi-threaded processing environment). As shown in fig. 2, the method may include:
s201, determining a dyeing identifier and first data to be processed in response to a first service request corresponding to a first tenant; the stain identity is used to uniquely identify the first tenant.
The aim to be achieved by the embodiment of the application is that: the tenant with data isolation requirement can realize the objective of tenant data isolation through lower cost. Based on the dyeing identification, the routing distribution of the database is performed, so that data of different tenants can be stored in different databases with physical isolation.
In this embodiment of the present application, before determining the dyeing identifier and the first data to be processed in response to the first service request corresponding to the first tenant, the server may further set a unique dyeing identifier for the tenant having a data isolation requirement, and store a mapping table of the dyeing identifiers corresponding to the tenant and the tenant.
For clarity of explanation of the embodiment of the present application, in the embodiment of the present application, it is assumed that the first tenant is a tenant with a data isolation requirement, and the second tenant is a tenant without a data isolation requirement. Based on this, the server may add the mapping relationship between the first tenant and the dyeing identifier corresponding to the first tenant in the mapping table of the dyeing identifier corresponding to the tenant, for example, the first tenant may be represented by "000001", and the dyeing identifier corresponding to the first tenant may be represented by "a".
Optionally, the second tenant does not have a corresponding staining identifier in the mapping table of the staining identifiers corresponding to the tenant and the tenant. Optionally, the second tenant may have a corresponding dyeing identifier in the mapping table of the tenant and the dyeing identifier corresponding to the tenant, but multiple second tenants may share one dyeing identifier. For example, the first second tenant is denoted by "100001", and the dyeing identifier corresponding to the first second tenant may be denoted by "N"; the second tenant is denoted by '100002', and the dyeing identifier corresponding to the second tenant can be denoted by 'N'; the third second tenant is denoted by "100003", and the dyeing identifier corresponding to the third second tenant may be denoted by "N" … …, that is, the dyeing identifier "N" is a public dyeing identifier, and corresponds to a shared database corresponding to a shared database instance.
In this embodiment, providing data storage for the tenant may be one of services that may be provided by a server, where the server may provide different services for the tenant's data through different service middleware, such as storing, transmitting, modifying, transmitting, distributing, and ordering the data according to a certain arrangement rule.
Alternatively, the data store may be the last service provided by the server for data of one tenant under different service requirements of different tenants. Alternatively, the data store may be an intermediate service provided by the server for data of one tenant, after which the server may also provide other services for the data.
Alternatively, the service of the data of one tenant may be initiated by the terminal of the tenant, for example, the terminal of the tenant sends a service request to the server, and the server processes the data of the tenant based on the service request. Alternatively, the service of data for one tenant may be server-originated, such as a server-triggered timed task itself.
In an embodiment in which the staining identity and the first data to be processed are determined in response to a first service request corresponding to the first tenant, the terminal of the tenant may be a source of the data of the tenant. Referring to fig. 3, a flow chart of a multi-tenant data processing method according to an embodiment of the invention is shown, including:
in S301, a second service request is received; the second service request includes an identification of the first tenant.
Optionally, the server receives a second service request from the terminal of the tenant, wherein the second service request includes an identification of the first tenant, such as "000001".
In S303, when there is a coloring identifier corresponding to the identifier of the first tenant, the coloring identifier is set in the request header of the second service request, so as to obtain the first service request.
Based on the above continuing explanation, since the server adds the mapping relationship between the first tenant and the dyeing identifier corresponding to the first tenant in the mapping table of the tenant and the dyeing identifier corresponding to the tenant, there is the dyeing identifier corresponding to the identifier of the first tenant, and the dyeing identifier corresponding to the identifier of the first tenant is used for uniquely identifying the first tenant.
In an optional embodiment, in the case that there is a coloring identifier corresponding to the identifier of the first tenant, the server may set the coloring identifier in a request body of the second service request, to obtain the first service request.
However, although the dyeing identifier is set in the request body of the request, the dyeing identifier is transmitted in the server as a general protocol, and the realization is simpler. However, first, the data processing industry uses a lot of services, and because of the need to unify the specifications of the request body, the transformation area that may be involved is relatively wide, and the intrusion into the business is relatively large. Secondly, some requests have larger request bodies, and when the requests are transmitted in the server, the frequent analysis request bodies acquire dyeing identifications, so that the loss of the performance of the server is larger. Third, the request parameters are different between different methods of the same thread or between different threads, so that the dyeing identifier arranged in the request body is difficult to transfer, and the application range is small.
Based on this, in another alternative embodiment, based on consideration of server performance, application scope, and business invasiveness, in the case that there is a coloring identifier corresponding to the identifier of the first tenant, the server may set the coloring identifier in the request header of the second service request, to obtain the first service request.
In S305, when the first service request is transmitted to the service middleware, the first service request is parsed in response to the first service request, to obtain the dyeing identifier and the first data to be processed.
In this embodiment of the present application, when the first service request is transmitted to the service middleware, the server may parse the first service request in response to the first service request, to obtain the dyeing identifier and the first data to be processed.
In particular, the server may include a service middleware module that includes different service middleware. After the service customization layer sets the dyeing identifier in the request header of the second service request to obtain the first service request, the first service request can be sent to the service middleware module, so that the server can analyze the first service request by utilizing the service middleware module to obtain the dyeing identifier and the first data to be processed.
Fig. 4 is a schematic flow chart of a multi-tenant data processing method according to an embodiment of the invention. Optionally, the server receives the second service request, transmits the second service request to a service customization layer of the server, and determines, through the customization layer of the service customization layer, that the identity of the tenant carried by the second service request is the identity of the first tenant. And then, the service customization layer can acquire the dyeing identifier corresponding to the identifier of the first tenant from the tenant and the mapping table of the dyeing identifier corresponding to the tenant stored in the configuration center, and set the dyeing identifier in the request header of the second service request to obtain the first service request.
Alternatively, the configuration center may be located in the service customization layer.
If the framework where the server is located is a remote procedure call protocol (Remote Procedure Call Protocol, RPC) framework, the service customization layer may send the second service request and the dyeing identifier to the service middleware module (may also be referred to as a middle platform) after acquiring the dyeing identifier corresponding to the identifier of the first tenant from the mapping table of the dyeing identifiers corresponding to the tenants and tenants stored in the configuration center. In the process of sending to the service middleware module, the RPC interceptor at the service customization layer can intercept the second service request and the dyeing identifier, and set the dyeing identifier in the request header of the second service request to obtain the first service request. And then, the first service request is sent to the service middleware module, so that the server can analyze the first service request by utilizing the service middleware module to obtain the dyeing identification and the first data to be processed.
In another embodiment, in which the staining identity and the first data to be processed are determined in response to a first service request corresponding to the first tenant, the server is the source of the data. Referring to fig. 5, a flow chart of a multi-tenant data processing method according to an embodiment of the present invention is shown, including:
s501, triggering a first service request for generating a timing task at a preset time; the first service request includes task parameters for the timed task.
In the embodiment of the application, the timing task is set in advance in the server. Taking setting a timing task for a first tenant as an example, if 3 service containers pod exist in the server, when the timing task is started, the server may inject a dyeing identifier corresponding to the identifier of the first tenant into a task parameter of the timing task. Optionally, the task parameters of the timed task may include a task name parameter, such as job=test_a, where "a" is a staining label corresponding to the identity of the first tenant.
When the server executes the timing task at the preset moment, a first service request for generating the timing task can be triggered, wherein the first service request comprises a task name parameter of the timing task.
In S503, the task parameters are analyzed to obtain the dyeing mark.
Then, the server may parse the task parameter, such as the task name parameter, to obtain a dyeing identifier corresponding to the identifier of the first tenant, so as to prepare for subsequent cross-thread or cross-process transfer of the dyeing identifier.
In S505, first data to be processed corresponding to the timing task is determined based on the first service request.
Optionally, the server may determine, based on the first service request, first to-be-processed data corresponding to the timing task, for example, take out data of a previous week from a database of the first tenant.
The present application can explain whether the source of the request is at the terminal or the server through the above two examples, and in order to logically isolate the data of a specific tenant (for example, the first tenant), the precondition of performing full-link dyeing is to set a dyeing label for the data in the first step of the server.
S203, setting the dyeing identification in the sharing parameter of the first thread; the first thread is a thread to be run to process first data to be processed.
Continuing to describe based on fig. 4, in the embodiment of the present application, continuing to describe based on the RPC framework, after the first service request is sent from the service customization layer of the server to the service middleware module, the RPC interceptor in the service middleware module may intercept the first service request, and extract the dyeing identifier from the request header of the first service request. At this time, the first service request is restored to the original second service request because the dyeing identifier is not available. Then, the server sets the dyeing identifier in the shared parameter linear of the first thread through an RPC interceptor in the service middleware module, and sends the second service request to the service middleware processing the second service request.
S205, when the first thread running performs data storage on the first data to be processed, the dyeing identification is obtained from the sharing parameters of the first thread.
Continuing to describe based on fig. 4, in this embodiment of the present application, when the service middleware that processes the second service request runs the first thread to process the first data to be processed, if the process implemented on the first data to be processed is data storage, the second service request may be sent to the data routing plug-in that distributes the data, so that when the server obtains the second service request (such as the data storage request) through the data routing plug-in, the dyeing identifier may be obtained from the shared parameter of the first thread, so as to prepare for the subsequent data storage.
S207, the first data to be processed is sent to a database instance corresponding to the dyeing identifier; the database corresponding to the database instance is a database only storing the data of the first tenant.
In the embodiment of the application, the server may send the first data to be processed to a database instance corresponding to the dyeing identifier; the database corresponding to the database instance is a database only storing the data of the first tenant.
The database instance refers to a series of processes in the operating system and memory blocks allocated for the processes. An example database is a program, which is a layer of data management software located between a user and an operating system. A database instance is a channel that accesses a database. The user performs any operation on the data in the database, including data definition, data query, data maintenance, database operation control and the like, under the database instance, and the application program can only make a channel with the database through the database instance. Typically one database instance corresponds to one database.
Databases refer to a collection of physical operating system files or disk data blocks, such as data files, index files, and structure files.
Continuing with the description of fig. 4, after obtaining the second service request (such as the data storage request) in the server, the data routing plug-in may determine the database based on the dyeing identifier obtained in the shared parameter of the first thread, for example, determine that the database stored in the first data to be processed is the a database. Then, the data routing plug-in may send the second service request to the database instance corresponding to the a database, and the database instance obtains the first data to be processed in the second service request, and stores the first data to be processed in the a database corresponding to the first tenant separately. The database A only stores the data of the first tenant, so that service sharing provided by the server is realized, but the data are stored in the independent corresponding database, and the data security of the first tenant is further ensured.
In this embodiment of the present application, the customization layer in the service customization layer may provide some services for the first to-be-processed data in the second service request by using the thread provision, in addition to determining the identifier of the first tenant from the second service request and transmitting the dyed identifier corresponding to the identifier of the second service request and the identifier of the first tenant to the service middleware module. When a thread is utilized to provide certain services, the customization layer can set the dyeing identification corresponding to the identification of the first tenant in the sharing parameter of the thread, so that the thread can acquire the dyeing identification corresponding to the identification of the first tenant from the sharing parameter when processing the first data to be processed.
In an alternative embodiment, the processing of the first data to be processed by the first thread may comprise a plurality of steps, i.e. on a rather complex function, the function may be split into several tens of steps when split, each step being implemented in a single way. The following description is made by that the first thread includes two steps for processing the first data to be processed, and the first thread includes more steps for processing the first data to be processed may be implemented with reference to the two steps, which are described herein in detail.
Fig. 6 is a schematic flow chart of a multi-tenant data processing method according to an embodiment of the present invention, including:
in S2051, when the running first thread performs the first step processing on the first data to be processed, a function corresponding to the first step is called to process the first data to be processed, so as to obtain the first data.
In this embodiment of the present application, in a server, when a first thread is running to perform a first step processing on first data to be processed, a service middleware that processes a second service request may call a function (method) corresponding to the first step to process the first data to be processed, so as to obtain the first data. Wherein the first step process may be one or more of deleting, modifying, adding, arranging, etc. data processes.
In S2053, when the running first thread performs the second step processing on the first data, if the processing performed on the first data by calling the function corresponding to the second step is data storage, the dyeing identifier is obtained from the shared parameter of the first thread.
In this embodiment of the present application, in a server, when a service middleware that processes a second service request executes a second step of processing on first data by running a first thread, if a function (method) corresponding to the second step is called to execute processing on the first data to store the data, the service middleware that processes the second service request obtains a dyeing identifier from a shared parameter of the first thread.
The first thread comprising two methods is an optional implementation manner of the present application, and in a practical application process, the first thread comprising more methods may be included, and multiple methods may all need to use the dyeing identifier. Based on this, the embodiment of the application may set the dyeing identifier in the shared parameter of the first thread, so that each method in the dyeing identifier is convenient to acquire, and service execution efficiency may be improved.
As mentioned above, the data store of the tenant may be one of the services provided by the server, which may provide different services for the tenant's data through different service middleware in the service middleware module. The application also provides a message queue service. Alternatively, the message queue service may be located in front of the data storage service. Fig. 7 is a schematic flow chart of a multi-tenant data processing method according to an embodiment of the present invention, including:
In S701, when the first service request indicates that the requested service is a message queue service, a dyeing identifier is set in the first data to be processed, so as to obtain a delivery message.
In this embodiment of the present application, when the first service request indicates that the requested service is a message queue service, the server may set the dyeing identifier in the first data to be processed through the message queue service middleware in the service middleware module, where the first data to be processed may also be referred to as a message, and further obtain a delivery message.
Fig. 8 is a schematic flow chart of a multi-tenant data processing method according to an embodiment of the present invention, specifically, a server may intercept next data to be processed by a queuing interceptor and set a dyeing identifier in the first data to be processed in a process that a message queue service middleware (service middleware 1 in fig. 8) in a service middleware module sends the first data to be processed to a shared message queue server, so as to obtain a delivery message.
In S703, a delivery message is sent to the shared message queue server.
In the embodiment of the application, the server can send the delivery message to the shared message queue server through the message queue service middleware. As described in connection with fig. 8, after the queue interceptor intercepts the next data to be processed and sets the dyeing identifier in the first data to be processed, and further obtains the delivery message, the delivery message may be sent to the shared message queue server.
In S705, when it is detected that the shared message queue server has a posted message, the posted message is acquired from the shared message queue server.
In this embodiment, the server may obtain the delivery message from the shared message queue server by detecting that the shared message queue server has the delivery message through the consuming component (the service middleware 2 in fig. 8).
In S707, the delivery message is parsed to obtain the dyeing identifier and the first data to be processed.
In an alternative embodiment, the server may store the delivery message to a pre-set database via the consumption component based on the needs of the service.
In the embodiment of the application, the server can analyze the delivery message through the consumption component to obtain the dyeing identification and the first data to be processed.
In S709, the staining flag is set in the shared parameter of the first thread.
In the embodiment of the application, the server may set the dyeing identifier in the shared parameter threaded of the first thread through the consumption component. As described in detail in connection with fig. 8, if, after the consumption component obtains the delivery information, independent storage of the first data to be processed in the delivery message based on the data of the first tenant is required, the delivery information may be sent to a service middleware (such as a storage middleware) that processes the service. In the process of sending the delivery information to the storage middleware for processing the service, the queue interceptor can intercept the delivery information and extract the dyeing identification from the delivery information. At this time, the delivery message is restored to the original first data to be processed due to the absence of the dyeing identifier. Then, the server sets the dyeing flag in the shared parameter threaded of the first thread through the queue interceptor, and sends the first data to be processed to the service middleware (storage middleware) that processes the service.
In S711, when the first thread running performs the data storage on the first data to be processed, the dyeing identifier is obtained from the shared parameter of the first thread.
In the embodiment of the present application, when the server runs the first thread to process the first data to be processed through the storage middleware, if the process of the first data to be processed is data storage, the first data to be processed may be sent to the data routing plug-in for distributing the data, so that the server may obtain the dyeing identifier from the shared parameter of the first thread when obtaining the first data to be processed through the data routing plug-in, so as to prepare for the subsequent data storage.
In S713, the first data to be processed is sent to the database instance corresponding to the dyeing identifier.
In the embodiment of the application, the server may send the first data to be processed to a database instance corresponding to the dyeing identifier; the database corresponding to the database instance is a database only storing the data of the first tenant.
Specifically, after the data routing plug-in the server obtains the first data to be processed, the database stored in the first data to be processed can be determined to be the database a based on the dyeing identifier obtained in the sharing parameter of the first thread. Then, the data routing plug-in may send the first data to be processed to the database instance corresponding to the a database, and the database instance stores the first data to be processed to the a database corresponding to the first tenant alone. The database A only stores the data of the first tenant, so that service sharing provided by the server is realized, but the data is stored in the independent corresponding database, and the data security of the first tenant is ensured.
Therefore, the server sets the dyeing mark into the message entity through the interceptor of the message queue of the producer when sending the message, and then sets the dyeing mark into the sharing parameter of the thread through the interceptor of the message queue of the consumer when consuming, thereby completing the transmission of the dyeing mark of the message queue and ensuring the data dyeing of the whole link.
The message queuing service and the data storage service in the above may be services in one application. In one embodiment, after the delivery message is parsed to obtain the dye identifier and the first data to be processed, a third service request is generated based on the first data to be processed when the processing of the first data to be processed is cross-application processing. And setting the dyeing identifier in a request header of the third service request to obtain a fourth service request, and sending the fourth service request to the device corresponding to the cross-application processing.
In particular, a consuming component in the server may generate a third service request based on the first data to be processed, the third server request including the request header. When the third service request is sent to the device corresponding to the cross-application processing by the server, the RPC interceptor in the device corresponding to the cross-application processing can intercept the third service request, and set the dyeing identifier to the request header of the third server to obtain a fourth service request. Then, the service middleware in the device corresponding to the application processing processes the first data to be processed based on the fourth service request.
Therefore, the server sets the dyeing mark into the message entity through the interceptor of the message queue of the producer when sending the message, and then sets the dyeing mark into the request head through the interceptor of the message queue of the consumer when consuming, thereby realizing the transmission of the dyeing mark in the middle of the cross-application and ensuring the data dyeing of the full link.
In an alternative embodiment, if there are other tasks (the tasks are time-consuming) in the process of performing tasks by the first thread, for example, in the process of sending a large amount of first data to be processed to the database instance corresponding to the dyeing identifier, the second thread may be created in the first thread to complete the other tasks, and the dyeing identifier may be copied from the shared parameter of the first thread to the shared parameter of the second thread, and based on the dyeing identifier in the shared parameter of the second thread, the second thread is operated to process the first data to be processed.
The first thread can be a main thread, the second thread can be a sub thread in the main thread, and the second thread is a thread which is operated to process first data to be processed in the operation process of the first thread.
Therefore, the embodiment of the application can realize cross-thread (main thread and sub-thread) calling of the dyeing mark, and ensures data dyeing of the whole link.
In another alternative embodiment, if during the task execution of the first thread, for example, during the process of sending a large amount of first to-be-processed data to the database instance corresponding to the dyeing identifier, it is desired to asynchronously execute other tasks, for example, after a few seconds, the first to-be-processed data is to be subjected to an integrated process, so as to avoid that in the above embodiment, the sub-threads of the main thread are created to execute the task, which causes an increase of server overhead, the task may be executed by using the thread pool. Based on this, please refer to fig. 7, which is a flow chart of a multi-tenant data processing method according to an embodiment of the present invention, including:
in S901, caching the dyeing identifier from the shared parameter of the first thread to the shared parameter of the execution unit of the target thread pool; the target thread pool comprises threads which are operated to process first data to be processed in the operation process of the first thread; the target thread pool includes a plurality of second threads.
The server may cache the staining identity from the shared parameter of the first thread to the shared parameter TransmitableThreadLocal of the execution unit Runneable of the target thread pool. In order to better transfer the dyeing identification, the target thread pool is a thread pool with a transfer function, and the execution unit Runneable is an execution unit with the transfer function.
The target thread pool comprises threads which are operated to process first data to be processed in the operation process of the first thread.
Alternatively, the target thread pool may comprise a plurality of second threads.
In S903, a second thread in the target thread pool to be run is determined.
Optionally, the server may determine a second thread to be run in the target thread pool, where the second sub-thread may be a thread that does not currently execute a task, or may be a thread that is idle after executing a previous task in the target thread pool.
In S905, the dyeing flag in the shared parameter of the execution unit is set in the shared parameter of the second thread.
Alternatively, the server may set the dyeing identifier in the shared parameter of the execution unit in the shared parameter of the second thread.
In S907, the second thread is run to process the first data to be processed based on the dyeing identifier in the shared parameter of the second thread.
Optionally, the server may run the second thread to process the first data to be processed based on the dyeing identifier in the shared parameter of the second thread.
In S909, after the second thread is run, the dyeing flag in the shared parameter of the second thread is set in the shared parameter of the execution unit.
Optionally, after the second thread runs, the server may set the dyeing identifier in the shared parameter of the second thread in the shared parameter of the execution unit.
In the above, the second tenant is a tenant without data isolation requirement, so the server may receive a fifth service request, where the fifth service request includes an identifier of the second tenant, and if there is no coloring identifier corresponding to the identifier of the second tenant, the fifth service request may be transmitted to the service middleware, and in response to the fifth service request, the fifth service request is parsed to obtain second to-be-processed data, and when the process implemented by the third thread running on the second to-be-processed data is data storage, the second to-be-processed data is sent to the shared database instance, where the shared database corresponding to the shared database instance is a database for providing data storage for multiple tenants, where the multiple tenants include the second tenant.
The server may receive a fifth service request, where the fifth service request includes an identifier of the second tenant, and when there is a coloring identifier corresponding to the identifier of the second tenant, and the coloring identifier corresponding to the identifier of the second tenant is the public coloring identifier above, the server may transmit the fifth service request to the service middleware. In response to the fifth service request, the server may parse the fifth service request to obtain second to-be-processed data. And when the processing of the third thread to the second data to be processed is data storage, the second data to be processed is sent to a shared database instance, wherein the shared database corresponding to the shared database instance is a database for providing data storage for a plurality of tenants, and the plurality of tenants comprises the second tenant.
Therefore, the service can be carried out on different types of tenants through the same server, data of different tenants are stored in independent databases or shared data, service sharing is completed, but the stored databases are not shared, and data storage cost is reduced.
In this embodiment, the database associated with the staining identifier corresponding to the identifier of the first tenant and the shared database are databases that are physically isolated in one database cluster among the plurality of database clusters.
Optionally, the database associated with the staining identifier corresponding to the identifier of the first tenant and the shared database are two databases in a database cluster corresponding to one server. However, as the number of tenants increases, another database cluster may be split, where another database cluster may also include an independent database and a shared database, and the database cluster may also have another server to provide a shared service.
Referring to fig. 10, a schematic structural diagram of a multi-tenant data processing apparatus according to an embodiment of the present invention is shown, where the apparatus has a function of implementing the multi-tenant data processing method in the foregoing method embodiment, and the function may be implemented by hardware or implemented by executing corresponding software by hardware. As shown in fig. 10, the multi-tenant data processing apparatus 1000 may include:
A determining module 1001, configured to determine a staining identifier and first data to be processed in response to a first service request corresponding to a first tenant; the staining identifier is used for uniquely identifying the first tenant;
an identifier setting module 1002, configured to set a dyeing identifier in a shared parameter of the first thread; the first thread is a thread to be run to process first data to be processed;
the identifier obtaining module 1003 is configured to obtain, when the process implemented by the running first thread on the first data to be processed is data storage, a dyeing identifier from the shared parameter of the first thread;
the processing module 1004 is configured to send the first data to be processed to a database instance corresponding to the dyeing identifier; the database corresponding to the database instance is a database only storing the data of the first tenant.
In some of the possible embodiments of the present invention,
a determining module for:
receiving a second service request; the second service request includes an identification of the first tenant;
under the condition that a dyeing identifier corresponding to the identifier of the first tenant exists, setting the dyeing identifier in a request head of the second service request to obtain the first service request;
when the first service request is transmitted to the service middleware, responding to the first service request, analyzing the first service request to obtain a dyeing identification and first data to be processed.
In some of the possible embodiments of the present invention,
a determining module for:
triggering a first service request for generating a timing task at a preset moment; the first service request comprises task parameters of a timing task;
analyzing the task parameters to obtain a dyeing mark;
first data to be processed corresponding to the timing task is determined based on the first service request.
In some of the possible embodiments of the present invention,
the processing performed by the first thread on the first data to be processed includes two steps;
the identification acquisition module is used for:
when a first thread running carries out first step processing on first data to be processed, calling a function corresponding to the first step to process the first data to be processed to obtain first data;
and when the running first thread processes the first data in the second step, if the function corresponding to the second step is called to process the first data into data storage, acquiring the dyeing identification from the sharing parameter of the first thread.
In some of the possible embodiments of the present invention,
the device also comprises a delivery message delivery module and a delivery message detection module:
the delivery message delivery module is used for setting the dyeing identifier in the first data to be processed to obtain a delivery message when the first service request indicates that the requested service is a message queue service; sending a delivery message to a shared message queue server;
The delivery message detection module is used for acquiring the delivery message from the shared message queue server when detecting that the shared message queue server has the delivery message;
the determining module is used for analyzing the delivery message to obtain a dyeing identifier and first data to be processed;
the mark setting module is used for setting the dyeing mark in the shared parameter of the first thread;
the identification acquisition module is used for acquiring a dyeing identification from the shared parameter of the first thread when the first thread running performs data storage on the first data to be processed;
and the processing module is used for sending the first data to be processed to the database instance corresponding to the dyeing identifier.
In some of the possible embodiments of the present invention,
the apparatus further comprises a cross-application service module for:
generating a third service request based on the first data to be processed when the processing of the first data to be processed is cross-application processing;
setting the dyeing mark in a request head of the third service request to obtain a fourth service request;
and sending a fourth service request to the device corresponding to the cross-application processing.
In some of the possible embodiments of the present invention,
the apparatus further comprises a cross-thread service module for:
copying the dyeing identification from the shared parameter of the first thread to the shared parameter of the second thread; the second thread is a thread which is operated to process the first data to be processed in the operation process of the first thread; the first thread is a main thread, and the second thread is a sub thread in the main thread;
And running the second thread to process the first data to be processed based on the dyeing identification in the shared parameter of the second thread. In some of the possible embodiments of the present invention,
the apparatus further includes a sub-thread processing module configured to:
caching the dyeing identification from the shared parameter of the first thread to the shared parameter of the execution unit of the target thread pool; the target thread pool comprises threads which are operated to process first data to be processed in the operation process of the first thread; the target thread pool comprises a plurality of second threads;
determining a second thread to be run in the target thread pool;
setting a dyeing identifier in the shared parameter of the execution unit in the shared parameter of the second thread;
running the second thread to process the first data to be processed based on the dyeing identification in the shared parameter of the second thread;
and after the second thread is operated, setting the dyeing identification in the shared parameter of the second thread in the shared parameter of the execution unit.
In some of the possible embodiments of the present invention,
the determining module is used for receiving a fifth service request, wherein the fifth service request comprises an identification of a second tenant; transmitting a fifth service request to the service middleware under the condition that a staining identifier corresponding to the identifier of the second tenant exists; the dyeing identifier corresponding to the identifier of the second tenant is a public dyeing identifier; responding to the fifth service request, and analyzing the fifth service request to obtain second to-be-processed data;
The processing module is used for sending the second data to be processed to the shared database instance when the third thread running performs data storage on the second data to be processed; the shared database corresponding to the shared database instance is a database for providing data storage for a plurality of tenants; the plurality of tenants includes a second tenant.
In some of the possible embodiments of the present invention,
the database associated with the staining identification corresponding to the identification of the first tenant and the shared database are databases which are physically isolated in one database cluster in a plurality of database clusters.
It should be noted that, in the apparatus provided in the foregoing embodiment, when implementing the functions thereof, only the division of the foregoing functional modules is used as an example, in practical application, the foregoing functional allocation may be implemented by different functional modules, that is, the internal structure of the device is divided into different functional modules, so as to implement all or part of the functions described above. In addition, the apparatus and the method embodiments provided in the foregoing embodiments belong to the same concept, and specific implementation processes of the apparatus and the method embodiments are detailed in the method embodiments and are not repeated herein.
The embodiment of the invention provides electronic equipment, which comprises a processor and a memory, wherein at least one instruction or at least one section of program is stored in the memory, and the at least one instruction or the at least one section of program is loaded and executed by the processor to realize the multi-tenant data processing method provided by the embodiment of the method.
The memory may be used to store software programs and modules that the processor executes to perform various functional applications and multi-tenant data processing by running the software programs and modules stored in the memory. The memory may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, application programs required for functions, and the like; the storage data area may store data created according to the use of the device, etc. In addition, the memory may include high-speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other volatile solid-state storage device. Accordingly, the memory may also include a memory controller to provide access to the memory by the processor.
The method embodiments provided by the embodiments of the present invention may be executed in a computer terminal, a server, or similar computing device. Taking the example of running on a server, fig. 11 is a block diagram of a hardware structure of a server running a multi-tenant data processing method according to an embodiment of the present invention, as shown in fig. 11, the server 2000 may generate relatively large differences according to configuration or performance, and may include one or more central processing units (Central Processing Units, CPU) 2010 (the processor 2010 may include, but is not limited to, a microprocessor MCU or a processing device such as a programmable logic device FPGA), a memory 2030 for storing data, and one or more storage media 2020 (e.g., one or more mass storage devices) storing application 2023 or data 2022. Wherein the memory 2030 and the storage medium 2020 may be transitory or persistent. The program stored on the storage medium 2020 may include one or more modules, each of which may include a series of instruction operations on a server. Still further, the central processor 2010 may be configured to communicate with a storage medium 2020, executing a series of instruction operations in the storage medium 2020 on the server 2000. The server 2000 may also include one or more power supplies 2060, one or more wired or wireless network interfaces 2050, one or more input/output interfaces 2040, and/or one or more operating systems 2021, such as Windows Server, mac OS XTM, unixTM, linuxTM, freeBSDTM, and the like.
The input-output interface 2040 may be used to receive or transmit data via a network. The specific example of the network described above may include a wireless network provided by a communication provider of the server 2000. In one example, the input-output interface 2040 includes a network adapter (Network Interface Controller, NIC) that can connect to other network devices through a base station to communicate with the internet. In one example, the input/output interface 2040 may be a Radio Frequency (RF) module for communicating with the internet wirelessly.
It will be appreciated by those of ordinary skill in the art that the configuration shown in fig. 11 is merely illustrative and is not intended to limit the configuration of the electronic device described above. For example, the server 2000 may also include more or fewer components than shown in fig. 11, or have a different configuration than shown in fig. 11.
Embodiments of the present invention also provide a computer readable storage medium that may be disposed in an electronic device to store at least one instruction or at least one program related to implementing a multi-tenant data processing method, where the at least one instruction or the at least one program is loaded and executed by the processor to implement the multi-tenant data processing method provided in the above method embodiments.
Alternatively, in the present embodiment, the storage medium may include, but is not limited to: a U-disk, a Read-Only Memory (ROM), a random access Memory (RAM, random access Memory), a removable hard disk, a magnetic disk, or an optical disk, or other various media capable of storing program codes.
It should be noted that: the sequence of the embodiments of the present invention is only for description, and does not represent the advantages and disadvantages of the embodiments. And the foregoing description has been directed to specific embodiments of this specification. Other embodiments are within the scope of the following claims. In some cases, the actions or steps recited in the claims can be performed in a different order than in the embodiments and still achieve desirable results. In addition, the processes depicted in the accompanying figures do not necessarily require the particular order shown, or sequential order, to achieve desirable results. In some embodiments, multi-service processing and parallel processing are also possible or may be advantageous.
Embodiments of the present invention also provide a computer program product or computer program comprising computer instructions stored in a computer readable storage medium. The processor of the computer device reads the computer instructions from the computer readable storage medium, and the processor executes the computer instructions, so that the computer device performs the multi-tenant data processing method described above.
In this specification, each embodiment is described in a progressive manner, and identical and similar parts of each embodiment are all referred to each other, and each embodiment mainly describes differences from other embodiments. In particular, for the device embodiments, since they are substantially similar to the method embodiments, the description is relatively simple, and reference is made to the description of the method embodiments in part.
It will be understood by those skilled in the art that all or part of the steps for implementing the above embodiments may be implemented by hardware, or may be implemented by a program for instructing relevant hardware, where the program may be stored in a computer readable storage medium, and the storage medium may be a read-only memory, a magnetic disk or an optical disk, etc.
The foregoing description of the preferred embodiments of the invention is not intended to limit the invention to the precise form disclosed, and any such modifications, equivalents, and alternatives falling within the spirit and scope of the invention are intended to be included within the scope of the invention.

Claims (14)

1. A method of multi-tenant data processing, the method comprising:
determining a dyeing identifier and first data to be processed in response to a first service request corresponding to a first tenant; the staining identity is used for uniquely identifying the first tenant;
Setting the dyeing identification in a shared parameter of a first thread; the first thread is a thread to be run to process the first data to be processed;
when the first thread running performs data storage on the first data to be processed, acquiring the dyeing identification from the shared parameters of the first thread;
the first data to be processed is sent to a database instance corresponding to the dyeing identifier; the database corresponding to the database instance is a database only storing the data of the first tenant.
2. The multi-tenant data processing method of claim 1, wherein determining the coloring identification and the first data to be processed in response to the first service request corresponding to the first tenant comprises:
receiving a second service request; the second service request includes an identification of the first tenant;
setting the dyeing identifier in a request header of the second service request under the condition that the dyeing identifier corresponding to the identifier of the first tenant exists, so as to obtain the first service request;
and when the first service request is transmitted to a service middleware, responding to the first service request, and analyzing the first service request to obtain the dyeing identification and the first data to be processed.
3. The multi-tenant data processing method of claim 1, wherein determining the coloring identification and the first data to be processed in response to the first service request corresponding to the first tenant comprises:
triggering a first service request for generating a timing task at a preset moment; the first service request comprises task parameters of the timing task;
analyzing the task parameters to obtain the dyeing identification;
and determining first to-be-processed data corresponding to the timing task based on the first service request.
4. A multi-tenant data processing method according to any one of claims 1-3, wherein the processing performed by the first thread on the first data to be processed comprises two steps;
and when the running first thread performs data storage on the first data to be processed, acquiring the dyeing identifier from the shared parameter of the first thread, including:
when the running first thread processes the first data to be processed in a first step, calling a function corresponding to the first step to process the first data to be processed, and obtaining first data;
and when the running first thread processes the first data in the second step, if the process of calling a function corresponding to the second step to process the first data is data storage, acquiring the dyeing identification from the shared parameter of the first thread.
5. A multi-tenant data processing method according to any one of claims 1 to 3, wherein the setting the dyeing identifier in a shared parameter of a first thread, when the running first thread performs a data storage on the first to-be-processed data, acquiring the dyeing identifier from the shared parameter of the first thread, and sending the first to-be-processed data to a database instance corresponding to the dyeing identifier, includes:
setting the dyeing identifier in the first data to be processed to obtain a delivery message under the condition that the first service request indicates that the requested service is a message queue service;
sending the delivery message to a shared message queue server;
acquiring the delivery message from the shared message queue server when the existence of the delivery message in the shared message queue server is detected;
analyzing the delivery message to obtain the dyeing identifier and the first data to be processed;
setting the dyeing identification in a shared parameter of the first thread;
when the first thread running performs data storage on the first data to be processed, acquiring the dyeing identification from the shared parameters of the first thread;
And sending the first data to be processed to a database instance corresponding to the dyeing identifier.
6. The multi-tenant data processing method of claim 5, wherein after parsing the delivery message to obtain the dye identifier and the first data to be processed, further comprising:
generating a third service request based on the first data to be processed when the processing of the first data to be processed is cross-application processing;
setting the dyeing mark in a request head of the third service request to obtain a fourth service request;
and sending the fourth service request to the device corresponding to the cross-application processing.
7. The multi-tenant data processing method of claim 1, wherein after the sending the first data to be processed to the database instance corresponding to the staining identity, further comprises:
copying the dyeing identification from the shared parameter of the first thread to the shared parameter of a second thread; the second thread is a thread which is operated to process the first data to be processed in the operation process of the first thread; the first thread is a main thread, and the second thread is a sub thread in the main thread;
And running the second thread to process the first data to be processed based on the dyeing identification in the shared parameter of the second thread.
8. The multi-tenant data processing method of claim 2, wherein after the sending the first data to be processed to the database instance corresponding to the staining identity, further comprises:
caching the dyeing identification into the shared parameters of the execution units of the target thread pool by the shared parameters of the first thread; the target thread pool comprises threads which are operated to process the first data to be processed in the operation process of the first thread; the target thread pool comprises a plurality of second threads;
determining a second thread to be run in the target thread pool;
setting the dyeing identifier in the shared parameters of the execution unit in the shared parameters of the second thread;
running the second thread to process the first data to be processed based on the dyeing identification in the shared parameter of the second thread;
and after the second thread is operated, setting the dyeing identification in the shared parameter of the second thread in the shared parameter of the execution unit.
9. The multi-tenant data processing method of any one of claims 1-8, further comprising:
receiving a fifth service request, the fifth service request including an identification of a second tenant;
transmitting the fifth service request to a service middleware under the condition that a staining identifier corresponding to the identifier of the second tenant exists; the dyeing identifier corresponding to the identifier of the second tenant is a public dyeing identifier;
responding to the fifth service request, and analyzing the fifth service request to obtain second data to be processed;
when the processing implemented by the running third thread on the second data to be processed is data storage, the second data to be processed is sent to a shared database instance; the shared database corresponding to the shared database instance is a database for providing data storage for a plurality of tenants; the plurality of tenants includes the second tenant.
10. The multi-tenant data processing method of claim 9, wherein,
the database associated with the staining identification corresponding to the identification of the first tenant and the shared database are databases which are physically isolated in one database cluster in a plurality of database clusters.
11. A multi-tenant data processing apparatus, the apparatus comprising:
the determining module is used for responding to a first service request corresponding to a first tenant and determining a dyeing identifier and first data to be processed; the staining identity is used for uniquely identifying the first tenant;
the mark setting module is used for setting the dyeing mark in the shared parameter of the first thread; the first thread is a thread to be run to process the first data to be processed;
the identification acquisition module is used for acquiring the dyeing identification from the shared parameter of the first thread when the running first thread performs data storage on the first data to be processed;
the processing module is used for sending the first data to be processed to a database instance corresponding to the dyeing identifier; the database corresponding to the database instance is a database only storing the data of the first tenant.
12. An electronic device comprising a processor and a memory, wherein the memory has stored therein at least one instruction or at least one program that is loaded and executed by the processor to implement the multi-tenant data processing method of any one of claims 1 to 10.
13. A computer readable storage medium having stored therein at least one instruction or at least one program, the at least one instruction or the at least one program being loaded and executed by a processor to implement the multi-tenant data processing method of any one of claims 1 to 10.
14. A computer program product comprising at least one instruction or at least one program, the at least one instruction or the at least one program being loaded and executed by a processor to implement the multi-tenant data processing method of any one of claims 1 to 10.
CN202211203236.6A 2022-09-29 2022-09-29 Multi-tenant data processing method and device, electronic equipment and storage medium Pending CN117827940A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211203236.6A CN117827940A (en) 2022-09-29 2022-09-29 Multi-tenant data processing method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211203236.6A CN117827940A (en) 2022-09-29 2022-09-29 Multi-tenant data processing method and device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN117827940A true CN117827940A (en) 2024-04-05

Family

ID=90512038

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211203236.6A Pending CN117827940A (en) 2022-09-29 2022-09-29 Multi-tenant data processing method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN117827940A (en)

Similar Documents

Publication Publication Date Title
US10999353B2 (en) Beacon-based distributed data processing platform
CN110310034B (en) Service arrangement and business flow processing method and device applied to SaaS
US9465641B2 (en) Selecting cloud computing resource based on fault tolerance and network efficiency
CN110009201B (en) Electric power data link system and method based on block chain technology
US11646939B2 (en) Network function NF management method and NF management device
CN111258627B (en) Interface document generation method and device
CN114244717B (en) Configuration method and device of virtual network card resources, computer equipment and medium
CN112995273B (en) Network call-through scheme generation method and device, computer equipment and storage medium
US11297105B2 (en) Dynamically determining a trust level of an end-to-end link
US20150006459A1 (en) Alarm Correlation Analysis Method, Apparatus and System
CN113037891B (en) Access method and device for stateful application in edge computing system and electronic equipment
WO2022267175A1 (en) Information processing method and apparatus, and computer device and storage medium
CN112698952A (en) Unified management method and device for computing resources, computer equipment and storage medium
CN115086330A (en) Cross-cluster load balancing system
CN106547790B (en) Relational database service system
CN111984505A (en) Operation and maintenance data acquisition engine and acquisition method
CN116805946A (en) Message request processing method and device, electronic equipment and storage medium
CN111435329A (en) Automatic testing method and device
CN108347465B (en) Method and device for selecting network data center
CN109005071B (en) Decision deployment method and scheduling equipment
CN106936643B (en) Equipment linkage method and terminal equipment
CN117827940A (en) Multi-tenant data processing method and device, electronic equipment and storage medium
CN110347718A (en) A kind of REDIS sharding method, device, computer equipment and storage medium
CN114745377A (en) Edge cloud cluster service system and implementation method
CN114070889A (en) Configuration method, traffic forwarding method, device, storage medium, and program product

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination