Background technology
The fast development of Internet technology makes traditional database face huge challenge when tackling mass data, distributed key-value Key-Value database arises at the historic moment, Key-Value database comprise increase income non-relational distributed data base HBase, non-relational database Cassandra, non-relational the no SQL of database etc.The distributed architecture of Key-Value database, relative traditional Relational DataBase has and can store mass data, and a table can have more than one hundred million row; Store towards row, towards storage and the control of authority of row (race), the independent retrieval of row (race); Sparse storage, for the row of sky, does not take storage space, and that table can be designed is very sparse.
Many tenants technology is mainly used in multiple tenant and shares hardware resource, the public Application Instance of multiple tenant.In prior art, many tenants technology mainly comprises following three kinds of schemes in data storage:
1. each tenant has self contained data base
For different tenant provides separate database, such data isolation is best, and owing to can be the independent design data library structure of different user, contributes to the design of reduced data library structure, breaks down and recovers also relatively simple.But set up self contained data base for each tenant, different tenant not really share hardware resource, acquisition cost and maintenance cost high, general operator cannot accept.
2. tenant's shared data bank, but have independent storehouse table
All tenants share a database, but different tenant has independently storehouse table.Provide isolation between certain data, the trouble relatively but expansion is got up, be not easy to expansion, cost is also higher, difficult across tenant data statistics.
3. tenant's shared data bank, shared data bank table
All tenant's shared data banks, shared library table, this method cost is minimum, and sharing degree is the highest, allows the tenant supported also maximum, but differs due to the business demand between different tenant, therefore needs well-designed database for this situation.When adopting traditional Relational DataBase, when tenant needs to add custom field, need to add row in a database, for certain tenant, the row that other tenants add are useless row to this tenant, but need to exist in a database, but when tenant's quantity is larger, need to increase a large amount of row in a database, this just causes there is a large amount of null values in database, very wasting space.
Summary of the invention
Embodiments provide a kind of many tenants extended method based on key-Value Data storehouse, effectively reduce operation cost and the maintenance cost of multi-tenant database, increase the extendability of multi-tenant database, reduce the customization cost of tenant and shorten the customization cycle.
Embodiments provide a kind of many tenants extended method based on key-Value Data storehouse, described method comprises:
Obtain initial service entity metadata;
In the customization stage, attribute that described initial service entity metadata is activated business, to described service attribute definition Business Entity and display label, generates the specific transactions entity metadata meeting many tenants demand;
Generate the example stage, according to described specific transactions entity metadata, create key-value Key-Value database;
The example operation phase, the Business Entity data of Key-Value database are inserted into using tenant identification as RowKey prefix, the query context inquiry business solid data of RowKey is generated by described tenant identification, from described Key-Value database, Business Entity data are taken out in described query context, interactive interface is generated, so that by described Business Entity data display according to described specific transactions entity metadata.
Preferably, described initial service entity metadata and described specific transactions entity metadata all at least comprise: the index column mark of the attribute column name of the table name of Business Entity, the display label of Business Entity, Business Entity, the data type of Business Entity, Business Entity and the attribute display label of Business Entity.
Preferably, in the described generation example stage, described method also comprises:
All tenants share a described Key-Value database, and what described initial service entity metadata was corresponding be classified as, and all tenants share.
Preferably, in the described generation example stage, described method also comprises:
Described attribute of activating business for meeting the different business demand of described tenant, and generates the extension columns corresponding with newly-increased service attribute simultaneously, and described extension columns is only visible to described tenant.
Preferably, the described Business Entity data being inserted into Key-Value database using tenant identification as RowKey prefix specifically also comprise: adopt the table name of the mark of described tenant+described Business Entity as the RowKey prefix of described Business Entity data.
Preferably, the described query context inquiry business solid data by described tenant identification generation RowKey specifically comprises: inquire about described Key-Value database, according to the mark of described tenant and the table name setting query context of described Business Entity, in the query context of described setting, carry out inquiry according to the querying condition of user's setting and obtain described Business Entity data.
Preferably, describedly generate interactive interface according to described specific transactions entity metadata and specifically comprise:
The specific transactions entity metadata of described tenant is obtained according to the mark of described tenant;
According to index column information and the data type generated query item of the specific transactions entity metadata of described tenant;
According to the display label in the specific transactions entity metadata of described tenant and Business Entity data display Query Result;
The New any of the newly-built page is generated according to the data type of the display label of the Business Entity of the specific transactions entity metadata of described tenant, the attribute display label of Business Entity and Business Entity.
The many tenants extended method based on key-Value Data storehouse that the present invention proposes, can produce positive beneficial effect, specific as follows: support to generate by customization the application meeting tenant's individual demand, the business similar for operation flow can avoid overlapping development; Adopt the Key-Value database shared conveniently to realize expansion, cut operating costs, along with the growth of newly-increased tenant, along with tenant userbase growth, the RowKey prefix of the present invention using tenant identification as all Business Entity data, conveniently realizes expansion, cuts operating costs.
Embodiment
For making the object, technical solutions and advantages of the present invention clearly, below in conjunction with accompanying drawing, the specific embodiment of the invention is described in further detail.
Embodiment one
Below for the many tenants extended method based on key-Value Data storehouse that Fig. 1 detailed description embodiment of the present invention one provides, the many tenants extended method process flow diagram based on key-Value Data storehouse that Fig. 1 provides for the embodiment of the present invention, subject of implementation can be operation supporting platform in embodiments of the present invention.Fig. 2 shows the theory diagram of the many tenants extended method based on key-Value Data storehouse that the embodiment of the present invention proposes.As shown in Figure 2, in the many tenants extended method based on key-Value Data storehouse that the present invention proposes, adopt the operation supporting platform of the definable many tenants of easily extensible, this platform adopts distributed Key-Value database purchase business information.Shown in composition graphs 1 and Fig. 2, the method comprises the steps:
Step 101, acquisition initial service entity metadata;
Initial service entity metadata at least comprises: the index column mark of the attribute column name of the table name of Business Entity, the display label of Business Entity, Business Entity, the data type of Business Entity, Business Entity and the attribute display label of Business Entity.
Step 102, customization stage, attribute that described initial service entity metadata is activated business, to described service attribute definition Business Entity and display label, generates the specific transactions entity metadata meeting many tenants demand.
Described initial service entity metadata and described specific transactions entity metadata all at least comprise: the index column mark of the attribute column name of the table name of Business Entity, the display label of Business Entity, Business Entity, the data type of Business Entity, Business Entity and the attribute display label of Business Entity.
Particularly, operation supporting platform formulates each module initial service entity metadata according to each modular service demand before disposing, and creates Key-Value data Kuku table according to initial service metadata, and such as, wherein service metadata structure is mainly as shown in table 1:
Table 1 service metadata structural table
As shown in table 2 according to template establishment database table CRM structure:
Table 2 database table CRM structural table
Step 103, generation example stage, according to described specific transactions entity metadata, create key-value Key-Value database.
In the described generation example stage, described method also comprises:
All tenants share a described Key-Value database, and what described initial service entity metadata was corresponding be classified as, and all tenants share.
Particularly, in the customization stage, tenant, on initial service entity metadata basis, customizes initial service entity metadata according to domain knowledge, by amendment initial column information, increases self-defined column information and generates tenant's specific transactions entity metadata.
Tenant 1 is certain educational institution, according to business demand, entity title corresponding for CRM is changed into " student "; Attribute tags in initial service entity metadata corresponding to " USER_NAME " row changes into " student name ", and " USER_ID " corresponding attribute tags changes into " student number "; For Business Entity " student " increases attribute " grade ", and define corresponding self-defined row, by above customization, it is as shown in table 3 that tenant 1 generates self-defined Business Entity metadata:
The self-defined Business Entity metadata that table 3 tenant 1 generates
Tenant 2 is certain corporate user, according to business demand, entity title corresponding for CRM is changed into " employee "; Attribute tags in initial service entity metadata corresponding to " USER_NAME " row changes into " employee name ", and " USER_ID " corresponding attribute tags changes into " employee number "; For Business Entity " employee " increases attribute " department ", and define corresponding self-defined row, by above customization, it is as shown in table 4 that tenant 2 generates self-defined Business Entity metadata:
The self-defined Business Entity metadata that table 4 tenant 2 generates
According to the self-defined Business Entity metadata that tenant 1 and tenant 2 generate, we can define several similar self-defined Business Entity metadata, we suppose that tenant N is certain enterprise management level personnel equally, according to business demand, entity title corresponding for CRM are changed into " manager "; Attribute tags in initial service entity metadata corresponding to " USER_NAME " row changes into " keeper ", and " USER_ID " corresponding attribute tags changes into " keeper number "; For Business Entity " employee " increases attribute " department ", and define corresponding self-defined row, by above customization, it is as shown in table 5 that tenant N generates self-defined Business Entity metadata:
The self-defined Business Entity metadata that table 5 tenant N generates
In the described generation example stage, described method also comprises:
Described attribute of activating business for meeting the different business demand of described tenant, and generates the extension columns corresponding with newly-increased service attribute simultaneously, and described extension columns is only visible to described tenant.
Different tenant generates example after adopting identical initial service entity metadata to expand and shares same database table, and what initial service entity metadata was corresponding be classified as all tenants shares; Meanwhile, the Custom Attributes of specific transactions entity generated according to tenant is self-defined extension columns for tenant adds, and self-defined extension columns is from this tenant.After certain tenant adds self-defined row, only have this tenant to add data at these row, due to the sparse row storage characteristics of Key-Value database, there are not the data of the self-defined row of this tenant in other tenants, does not take any redundant space yet.Now tenant 1 Business Entity " student ", tenant 2 Business Entity " employee " the Key-Value database table CRM structure automatic expansion shared with tenant N Business Entity " keeper " becomes table 6:
Table 6Key-Value database table CRM structure extension table
Step 104, example operation phase, the Business Entity data of Key-Value database are inserted into using tenant identification as RowKey prefix, the query context inquiry business solid data of RowKey is generated by described tenant identification, from described Key-Value database, Business Entity data are taken out in described query context, interactive interface is generated, so that by described Business Entity data display according to described specific transactions entity metadata.
The described query context inquiry business solid data by described tenant identification generation RowKey specifically comprises: inquire about described Key-Value database, according to the mark of described tenant and the table name setting query context of described Business Entity, in the query context of described setting, carry out inquiry according to the querying condition of user's setting and obtain described Business Entity data.
In the example operation phase, Key-Value database is inserted using tenant identification as the RowKey prefix of all Business Entity data, generate RowKey query context by described tenant identification and take out Business Entity data from Key-Value database, generate interactive interface according to the described specific transactions entity metadata after customization.
Describedly generate interactive interface according to described specific transactions entity metadata and specifically comprise:
The specific transactions entity metadata of described tenant is obtained according to the mark of described tenant;
According to index column information and the data type generated query item of the specific transactions entity metadata of described tenant;
According to the display label in the specific transactions entity metadata of described tenant and Business Entity data display Query Result;
The New any of the newly-built page is generated according to the data type of the display label of the Business Entity of the specific transactions entity metadata of described tenant, the attribute display label of Business Entity and Business Entity.
The described Business Entity data being inserted into Key-Value database using tenant identification as RowKey prefix specifically also comprise: adopt the table name of the mark of described tenant+described Business Entity as the RowKey prefix of described Business Entity data.
Obtain Business Entity " student " metadata by tenant identification " Tenant001 ", generated content and the pattern thereof of the newly-built or amendment page by the Business Entity attribute display label of this metadata and data type.Fill in whole user information, data insert Key-Value database.During data inserting, adopt " tenant identification+storehouse table name claims " as the prefix of this data RowKey, as " Tenant001CRMStudent001 ".In like manner, represent that " Tenant002 " obtains Business Entity " employee " and generate the newly-built or amendment page afterwards by tenant 2, insert employee " Tenant002CRMEmployee001 ", tenant N is like this too simultaneously.Data now in the table of CRM storehouse are as shown in table 7, and wherein BASE represents initial service metadata structure table, and CUSTOM represents metadata structure table of activating business:
Table 7CRM storehouse table data
RowKey |
Row |
Tenant001CRMStudent001 |
BASE:USER_ID:Student001 |
Tenant001CRMStudent001 |
BASE:USER_NAME: a king young waiter in a wineshop or an inn |
Tenant001CRMStudent001 |
BASE:USER_EMAIL:wangxe@stu.com |
Tenant001CRMStudent001 |
CUSTOM:STUDENT_LEVEL:1 |
Tenant002CRMEmployee001 |
BASE:USER_ID:Employee001 |
Tenant002CRMEmployee001 |
BASE:USER_NAME: Li Du |
Tenant002CRMEmployee001 |
BASE:USER_EMAIL:lid@company.com |
Tenant002CRMEmployee001 |
CUSTOM:DEPARTMENT: research and development |
When entering query page, utilize tenant 1 to identify " Tenant001 " and obtain Business Entity " student " metadata, obtain all index entry generated query pages in the metadata, index entry display label comprises " student name ", " mailbox ", " grade ".Query Result shows self-defined Business Entity all properties, comprises " student number ", " student name ", " mailbox ", " grade ".In like manner, utilize tenant 2 to identify " Tenant002 " and obtain Business Entity " employee " metadata, obtain all index entry generated query pages in the metadata, index entry display label comprises " employee name ", " mailbox ", " department ".Query Result shows self-defined Business Entity all properties, comprises " employee number ", " employee name ", " mailbox ", " department ".When inquiring about certain tenant Ku Biao data, claim to set query context according to tenant identification and storehouse table name, within the scope of this, carry out inquiry according to the querying condition of user's setting obtain data, specifically, adopt " tenant identification+storehouse table name claims " to be set as StartRow, StartRow is added one and is set as EndRow, all data of this tenant in the table of storehouse are namely within the scope of this, make the inquiry velocity of tenant only relevant with the data volume of this tenant oneself like this, and have nothing to do with other tenant data amounts.In this case, during inquiry tenant 1 Business Entity " student " data, set StartRow as " Tenant001CRM ", EndRow is " Tenant 001CRN ", after setting range, inquiry tenant 1 data only need within the scope of this matching inquiry condition, and do not need to scan whole database table.
Particularly, in the example operation phase, when tenant 1 business demand changes, as needs for Business Entity " student " increases attribute " specialty ", then only need increase the information of this attribute and self-defined row name in database template, not need do the exploitation of any additional customized or dispose.When operator tenant increase causes server capacity inadequate, being only required to be distributed Key-Value database increases server, does not need to do extra Data Migration.
In sum, the present invention proposes a kind of many tenants extended method based on key-Value Data storehouse, the method is in the customization stage, to activate business entity according to domain knowledge in initial metadata basis, and define the display label of Business Entity and attribute thereof, generate the certain metadata meeting tenant's different business demand; In the generation example stage, according to the Business Entity metadata of user's expansion, for tenant creates Key-Value database; In the example operation phase, when tenant is to database Insert service data, with " tenant identification+storehouse table name claims " for prefix generates business datum RowKey, generate interactive interface by the specific transactions entity metadata obtaining tenant, set query context by RowKey and take out business datum showing from database.Support of the present invention generates the application meeting tenant's individual demand by customization, the business similar for operation flow can avoid overlapping development, adopts shared Key-Value database conveniently to realize expansion simultaneously, cuts operating costs.
Professional should recognize further, in conjunction with unit and the algorithm steps of each example of embodiment disclosed herein description, can realize with electronic hardware, computer software or the combination of the two, in order to the interchangeability of hardware and software is clearly described, generally describe composition and the step of each example in the above description according to function.These functions perform with hardware or software mode actually, depend on application-specific and the design constraint of technical scheme.Professional and technical personnel can use distinct methods to realize described function to each specifically should being used for, but this realization should not think the scope exceeding the embodiment of the present invention.
The software module that the method described in conjunction with embodiment disclosed herein or the step of algorithm can use hardware, processor to perform, or the combination of the two is implemented.Software module can be placed in the storage medium of other form any known in random access memory (RAM), internal memory, ROM (read-only memory) (ROM), electrically programmable ROM, electrically erasable ROM, register, hard disk, moveable magnetic disc, CD-ROM or technical field.
Above-described embodiment; to the embodiment of the present invention, technical scheme and beneficial effect further describe; be understood that; the foregoing is only the embodiment of the embodiment of the present invention; be not intended to limit the present invention the protection domain of embodiment; within all spirit in the embodiment of the present invention and principle, any amendment made, equivalent replacement, improvement etc., within the protection domain that all should be included in the embodiment of the present invention.