A data source hot switching method and system applied to a multi-tenant management system

By establishing long-lived connections in the multi-tenant management system and periodically refreshing data source and routing rule information, the re-encoding problem during data source switching is solved, improving switching efficiency and convenience.

CN114880705BActive Publication Date: 2025-12-19SHANGHAI GANGYIN TECH DEV CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202210486162.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-05-06
Publication Date
2025-12-19
Estimated Expiration
2042-05-06

AI Technical Summary

Technical Problem

In a multi-tenant management system, switching data sources requires recoding or modifying file configurations, which makes client updates inconvenient.

Method used

When the client starts, it reads the application's dependent data source configuration, establishes a long connection with the dynamic database sharding routing component, and performs hot switching of data sources by periodically refreshing and loading data source connection and routing rule information, avoiding recoding or modifying file configurations.

Benefits of technology

It improves the efficiency of data source switching, reduces client data refresh latency, and increases the ease of switching.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114880705B_ABST
    Figure CN114880705B_ABST
Patent Text Reader

Abstract

The application relates to a data source hot switching method and system applied to a multi-tenant management system, which comprises the following steps: reading an application dependent data source configuration when a client is started; establishing a long connection with a dynamic database routing component according to the data source configuration, and performing data source hot switching; performing business operation based on the switched data source, so as to perform data source routing switching; and accessing a corresponding database based on the switched data source routing. The application has the effect of increasing switching efficiency by establishing a long connection, so as to avoid re-coding or modifying a file configuration when data source switching is performed in a multi-tenant management system.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the field of multi-tenant management systems, and in particular to a data source hot switching method and system applied to a multi-tenant management system. BACKGROUND

[0002] With the rapid development of e-commerce, more and more merchants realize the convenience of online transactions, and due to the huge market potential of online transactions, more traditional large commodity transactions are gradually transferred to the online. Due to the online of large commodity transactions, the corresponding application program and operation environment need to be designed for the application of huge data between different enterprise users, so in the prior art, a multi-tenant management system is used to isolate the program environment and data of different users, so as to achieve strong data security between different users.

[0003] In the multi-tenant management system, when the user needs to call different database information on the client, the system publishes new routing configuration information according to different needs, and updates the information to the client, and the client recompiles and packages according to the update information, and the data source routing updates according to the new routing configuration information, so that different users can change the permission of calling the database.

[0004] When the multi-tenant management system does multi-data source switching, it needs to re-code or modify the file configuration, go through the program code compilation and release process, and after online updating the configuration, the corresponding client needs to be updated. SUMMARY

[0005] In order to avoid the need for the user end to update when the data source is switched, the present application provides a data source hot switching method and system applied to a multi-tenant management system.

[0006] The data source hot switching method and system applied to a multi-tenant management system provided by the present application adopt the following technical solutions:

[0007] A data source hot switching method applied to a multi-tenant management system, comprising:

[0008] reading application dependent data source configuration when the client is started;

[0009] establishing a long connection with a dynamic database routing component according to the data source configuration to perform data source hot switching;

[0010] performing business operation based on the switched data source to perform data source routing switching;

[0011] accessing the corresponding database based on the switched data source routing.

[0012] By adopting the technical scheme, when a tenant needs to query data information on a data source through a client, application dependent data source configuration is read when the client is started, a long connection with a dynamic database routing component is established according to the data source configuration, data source hot switching is performed, and when the multi-tenant management system performs data source switching, re-coding or file configuration modification is avoided as much as possible, and switching efficiency is improved.

[0013] Optionally, the establishing of the long connection with the dynamic database routing component according to the data source configuration and the data source hot switching include:

[0014] periodically refreshing and loading data source connection information from the dynamic database routing component within a first refreshing time;

[0015] initializing a dynamic data source connection based on the data source connection information;

[0016] periodically refreshing and loading dependent data source routing rules from the dynamic database routing component within a second refreshing time.

[0017] By adopting the technical scheme, the data source connection information is refreshed and loaded within the first refreshing time, the dynamic data source connection is initialized, the dependent data source routing rules are loaded within the second refreshing time, and the long connection with the dynamic database routing component can be established, so that the data source hot switching is facilitated.

[0018] Optionally, the first refreshing time is a time for periodically receiving data source connection information transmitted from the dynamic database routing component, and the periodically refreshing and loading of the data source connection information within the first refreshing time include:

[0019] acquiring the first refreshing time;

[0020] querying, by the dynamic database routing component, a routing rule version from a data source routing configuration component;

[0021] judging whether the routing rule is expired in a local version of the client within a preset cycle time;

[0022] when the routing rule is expired, periodically refreshing data source connection information within the first refreshing time based on the routing rule.

[0023] By adopting the technical scheme, the data source connection information can be refreshed and loaded within the first refreshing time.

[0024] Optionally, the querying of the routing rule version from the data source routing configuration component by the dynamic database routing component includes:

[0025] judging, by the data source routing configuration component, whether an application routing rule is added or modified;

[0026] When the judgment result is yes, the route rule version information is applied based on the demand change;

[0027] The route rule version is obtained by the dynamic database routing component querying the changed route rule version information in the data source routing component.

[0028] By adopting the technical solution, the route rule version can be queried in the data source routing configuration component, and it is determined whether the route rule version on the data source routing configuration component changes.

[0029] Optionally, the periodically refreshing the data source connection information at the first refresh time based on the route rule comprises:

[0030] The component name of the data source routing configuration component is obtained based on the route rule at the first refresh time.

[0031] The related data source connection information is obtained based on the component name.

[0032] By adopting the technical solution, the related data source connection information can be obtained in the data source routing configuration component.

[0033] Optionally, the second refresh time is a time for periodically receiving the route information transmitted from the dynamic database routing component, and the periodically refreshing and loading the dependent data source routing rule from the dynamic database routing component at the second refresh time based on the route rule comprises:

[0034] The second refresh time is obtained.

[0035] The route rule version is queried in the data source routing configuration component by the dynamic database routing component.

[0036] It is determined whether the local version of the route rule on the client is expired at a preset cycle time.

[0037] When it is expired, the data source routing rule is periodically refreshed at the second refresh time based on the route rule.

[0038] By adopting the technical solution, the data source routing rule can be refreshed and loaded at the second refresh time.

[0039] Optionally, the periodically refreshing the data source routing rule at the second refresh time based on the route rule further comprises:

[0040] The data source name of the data source routing is obtained based on the route rule at the second refresh time.

[0041] The data source routing rule is obtained based on the data source name.

[0042] By adopting the technical scheme, the data source connection information can be obtained by the data source routing configuration component.

[0043] Optionally, the application also adopts a data source hot switching system applied to a multi-tenant management system, comprising:

[0044] The configuration reading module is configured to read the application dependent data source configuration when the client is started.

[0045] The data source hot switching module is configured to establish a long connection with the dynamic database routing component according to the data source configuration, and perform data source hot switching.

[0046] The data source routing switching module is configured to perform business operation based on the switched data source, so as to perform data source routing switching.

[0047] The database access module is configured to access the corresponding database based on the switched data source routing.

[0048] By adopting the technical scheme, the configuration reading module reads the application dependent data source configuration when the client is started, the data source hot switching module establishes a long connection with the dynamic database routing component according to the data source configuration, and performs data source hot switching, the data source routing switching module performs business operation based on the switched data source, so as to perform data source routing switching, and the database access module accesses the corresponding database based on the switched data source routing. When the data source is switched in the multi-tenant management system, the long connection is established, and the re-coding or file configuration modification is avoided as much as possible, so as to increase the switching efficiency.

[0049] In summary, the application has the following beneficial technical effects:

[0050] By establishing a long connection, the re-coding or file configuration modification is avoided as much as possible when the data source is switched in the multi-tenant management system, so as to increase the switching efficiency. BRIEF DESCRIPTION OF DRAWINGS

[0051] Figure 1 is a flow chart of one embodiment of the application applied to a data source hot switching method of a multi-tenant management system;

[0052] Figure 2 is a flow chart of step S120 in one embodiment of the application applied to a data source hot switching method of a multi-tenant management system;

[0053] Figure 3 is a flow chart of step S210 in one embodiment of the application applied to a data source hot switching method of a multi-tenant management system;

[0054] Figure 4is a flow chart of step S320 in one embodiment of the data source hot switching method applied to the multi-tenant management system of the application;

[0055] Figure 5 is a flow chart of step S340 in one embodiment of the data source hot switching method applied to the multi-tenant management system of the application;

[0056] Figure 6 is a flow chart of step S230 in one embodiment of the data source hot switching method applied to the multi-tenant management system of the application;

[0057] Figure 7 is a flow chart of step S640 in one embodiment of the data source hot switching method applied to the multi-tenant management system of the application;

[0058] Figure 8 is a relationship diagram of the client, dynamic database routing component and data source routing configuration component in the multi-tenant management system according to another embodiment of the application. DETAILED DESCRIPTION

[0059] The application will be further described in detail below with reference to the accompanying drawings.

[0060] When a new member is added or the data source of an old member is migrated in the multi-tenant system, the routing configuration of the tenant needs to be changed. In the traditional multi-tenant system, the multi-data source switching needs to be re-coded or the file configuration needs to be modified, the program code compilation and release process needs to be performed, and the corresponding client needs to be updated after the online configuration is updated, which is relatively inconvenient.

[0061] In order to solve the problem that the client needs to be updated, with reference to Figure 1 The application discloses a data source hot switching method applied to a multi-tenant management system, which comprises the following steps:

[0062] S110, reading the application dependent data source configuration when the client is started.

[0063] The client is an operation terminal for operating the tenant, the tenant can switch the data source and obtain the data information of different data sources through the client. The data source is a database or a database server used by the database application program, and the dependent data source configuration mainly configures the mutual constraint relationship of the data in the data source, is the state of the data processed before the program structure causes the data reference, and enables the reading of the relationship configuration between the client and the data source when the client is started last time by reading the configured application dependent data source.

[0064] S120, establishing a long connection with the dynamic database routing component according to the data source configuration, and performing data source hot switching.

[0065] The connection includes a long connection and a short connection, the short connection refers to that when the two parties of communication have data interaction, the connection is established, and when the data interaction is completed, the connection is disconnected, that is, each connection only completes the sending of one service. The long connection refers to that multiple data packets can be sent on one connection, if there is no data packet sent in the connection maintaining device, link detection packets need to be sent by both parties. The long connection is mainly used for frequent operation and point-to-point communication, and is applied to the multi-tenant management system in the embodiment of the application. In order to establish the connection between the tenant and the data source, so that the data source and the dynamic database routing component can maintain the connection, the long connection is usually established.

[0066] S130, performing service operation based on the switched data source to perform data source routing switching.

[0067] The service operation is an operation of accessing the data source by the tenant when using the corresponding service on the client. When the corresponding service is not in the corresponding data source, the data source routing needs to be switched to achieve the purpose of switching the data source. When the tenant adds a new member, the corresponding new data source needs to be established, and the client does not need to be restarted, and the routing configuration is refreshed through the data source routing switching. Or when the data source of the old member is migrated, the client does not need to be restarted, and the new routing configuration of the member can be updated online directly.

[0068] S140, accessing the corresponding database based on the switched data source routing.

[0069] The implementation principle of the data source hot switching method applied to the multi-tenant management system in the embodiment of the application is as follows: when the tenant needs to query the data information on the data source through the client, the application dependent data source configuration is read when the client is started, and the long connection with the dynamic database routing component is established according to the data source configuration to perform data source hot switching. Through the establishment of the long connection, when the data source is switched in the multi-tenant management system, re-coding or file configuration modification is avoided as much as possible, the delay of client data refreshing is reduced, and the switching efficiency is increased.

[0070] Referring to Figure 2 The long connection with the dynamic database routing component is established according to the data source configuration to perform data source hot switching, including:

[0071] S210, periodically refreshing and loading the data source connection information from the dynamic database routing component within a first refreshing time.

[0072] The data source connection information includes information about how the new data source connects with the client, and the dynamic database routing component is a server component that sends the new data source connection information to the client.

[0073] S220, initializing the dynamic data source connection based on the data source connection information.

[0074] When the data source connection information is loaded, the dynamic data source connection is initialized to cover the original data source connection information, so as to facilitate loading of new data source connection information when the connected data source needs to be changed.

[0075] S230, periodically refreshing and loading the dependent data source routing rules from the dynamic database routing component within the second refreshing time.

[0076] Referring to Figure 3 The first refreshing time is a time for periodically receiving the data source connection information transmitted from the dynamic database routing component, and the periodically refreshing and loading of the data source connection information within the first refreshing time comprises:

[0077] S310, obtaining the first refreshing time.

[0078] The first refreshing time can be set according to requirements, for example, when the first refreshing time is set to 1 min, the dynamic database routing component refreshes and loads the data source connection information with a period of 1 min.

[0079] S320, querying a routing rule version by the dynamic database routing component on a data source routing configuration component.

[0080] The data source routing configuration component can configure a new version of the data source routing rule according to requirements, for example, the requirement can be that when a tenant originally configures a data source as a database A, with the change of the tenant business, the data source needs to be switched to a database B, at this time, the data source routing version needs to be reconfigured. When the requirement changes, whether the routing rule version changes can be queried by the dynamic database routing component on the data source routing configuration component.

[0081] S330, judging whether a local version of the routing rule on a client is expired within a preset cycle time.

[0082] The judgment of whether the local version of the routing rule on the client is expired is performed by the dynamic database routing component, and the dynamic database routing component stores the local version of the routing rule. The routing rule version on the client is a default version, and the default version points to a default data source. When whether the routing rule version changes is judged, whether the routing rule version changes can be queried on the data source routing configuration component. The preset cycle time can be freely set, for example, the preset cycle time can be set to be the same as the first refreshing time.

[0083] S340, when the local version of the routing rule on the client is expired, periodically refreshing the data source connection information based on the routing rule within the first refreshing time.

[0084] When it is judged that the routing rule is expired in the local version of the routing client, it indicates that the user demand has changed, and the data source connection information is periodically refreshed based on the routing rule at the first refresh time. The new routing rule can be transmitted to the client within the first refresh time.

[0085] When it is not changed, it indicates that the version of the routing rule in the client is the currently used version, and no change occurs.

[0086] Referring to Figure 4 The routing rule version is queried by the dynamic database routing component in the data source routing configuration component, including:

[0087] S410, whether the application routing rule is newly added or modified is judged by the data source routing configuration component.

[0088] When the user demand changes, for example, the data source needs to be changed, the data source routing configuration component judges that the routing rule needs to be newly added, and when it is not changed, it is judged that the routing rule does not need to be newly added.

[0089] S420, when the judgment result is yes, the routing rule version information is applied based on the demand change.

[0090] The data source routing configuration component and the dynamic database routing component are arranged in the same server, the data source routing configuration component configures the corresponding routing rule version information based on the demand, when the new routing rule version information is newly configured, the version number of the routing rule is increased, that is, the version number of the routing rule on the client is smaller than the version number of the newly added routing rule version.

[0091] S430, the changed routing rule version information is queried by the dynamic database routing component in the data source routing component, and the new routing rule version is obtained.

[0092] The routing rule version is mainly queried by the routing rule version information.

[0093] Referring to Figure 5 The data source connection information is periodically refreshed based on the routing rule at the first refresh time, including:

[0094] S510, the component name of the data source routing configuration component is obtained based on the routing rule within the first refresh time.

[0095] Each tenant has a corresponding component name of the data source routing configuration component, and the routing rule in the data source routing configuration component is queried by the component name.

[0096] S520, the related data source connection information is obtained based on the component name query.

[0097] The data source connection information is provided with the pointing information of the client accessing the corresponding database, and whether the accessed database is changed can be queried through the data source connection information.

[0098] Referring to Figure 6 The second refresh time is a time for periodically receiving the routing information transmitted from the dynamic database routing component, and the dependent data source routing rule of the dynamic database routing component is periodically refreshed and loaded within the second refresh time, and the dependent data source routing rule includes:

[0099] S610, acquiring a second refresh time.

[0100] The second refresh time and the first refresh time can be set as the same refresh time, that is, the second refresh time can also be set according to requirements.

[0101] S620, querying the routing rule version in the data source routing configuration component through the dynamic database routing component.

[0102] S630, judging whether the local version of the routing rule in the client is expired within a preset cycle time.

[0103] S640, when expired, periodically refreshing the data source routing rule based on the routing rule within the second refresh time.

[0104] Referring to Figure 7 Periodically refreshing the data source routing rule based on the routing rule within the second refresh time further includes:

[0105] S710, acquiring a data source name of the data source routing based on the routing rule within the second refresh time.

[0106] S720, querying and acquiring the data source routing rule based on the data source name.

[0107] The application also discloses a data source hot switching system applied to a multi-tenant management system, which includes:

[0108] The configuration reading module 1 is configured to read the application dependent data source configuration when the client is started.

[0109] The data source hot switching module 2 is configured to establish a long connection with the dynamic database routing component according to the data source configuration, and perform data source hot switching.

[0110] The data source routing switching module 3 is configured to perform business operation based on the switched data source, so as to perform data source routing switching.

[0111] The database access module 4 is configured to access the corresponding database based on the switched data source routing.

[0112] The data source hot switching module 2 includes:

[0113] The data source loading unit 21 is configured to periodically refresh and load the data source connection information from the dynamic sharded routing component within a first refresh time;

[0114] The initialization connection unit 22 is configured to initialize the dynamic data source connection based on the data source connection information;

[0115] The routing rule loading unit 23 is configured to periodically refresh and load the dependent data source routing rule from the dynamic sharded routing component within a second refresh time.

[0116] The relationship among the client, the dynamic sharded routing component, and the data source routing configuration component is shown in Figure 8 .

[0117] The application embodiment of the data source hot switching system applied to the multi-tenant management system is configured to read the application dependent data source configuration when the client is started by the configuration reading module 1, the data source hot switching module 2 establishes the long connection with the dynamic sharded routing component according to the data source configuration, performs the data source hot switching, the data source routing switching module 3 performs the business operation based on the switched data source to perform the data source routing switching, and the database access module 4 accesses the corresponding database based on the switched data source routing, so that the long connection is established, the re-coding or the file configuration modification is avoided as much as possible when the data source is switched in the multi-tenant management system, and the switching efficiency is increased.

[0118] The above are the preferred embodiments of the application, and are not intended to limit the protection scope of the application, so that: any equivalent changes made according to the structure, shape, principle of the application should be covered within the protection scope of the application.

Claims

1. A method for applying to multi-tenant management system data source hot switchover, characterized in that, The application comprises the following steps: reading application dependency data source configuration at client startup; establishing a long connection with a dynamic database routing component according to the data source configuration to perform data source hot switching; performing business operations based on the switched data source to perform data source routing switching; accessing the corresponding database based on the switched data source routing; wherein the step of establishing a long connection with a dynamic database routing component according to the data source configuration to perform data source hot switching comprises the following steps: periodically refreshing and loading data source connection information from the dynamic database routing component within a first refresh time; initializing a dynamic data source connection based on the data source connection information; periodically refreshing and loading dependency data source routing rules from the dynamic database routing component within a second refresh time; establishing a long connection with a dynamic database routing component to receive updated data source configuration information through the long connection when the data source configuration changes, so that the client can complete data source hot switching without restarting; wherein the first refresh time is the time for periodically receiving data source connection information transmitted from the dynamic database routing component, and the step of periodically refreshing and loading data source connection information within the first refresh time comprises the following steps: obtaining the first refresh time; querying the routing rule version from the data source routing configuration component through the dynamic database routing component; determining whether the local version of the routing rule is expired within a preset cycle time; when expired, periodically refreshing the data source connection information based on the routing rule within the first refresh time; wherein the step of querying the routing rule version from the data source routing configuration component through the dynamic database routing component comprises the following steps: determining whether the application routing rule is added or modified through the data source routing configuration component; when the determination result is yes, updating the routing rule version information based on the requirement change; querying the changed routing rule version information from the data source routing component through the dynamic database routing component to obtain the new routing rule version; wherein the second refresh time is the time for periodically receiving routing information transmitted from the dynamic database routing component, and the step of periodically refreshing and loading dependency data source routing rules from the dynamic database routing component within the second refresh time comprises the following steps: obtaining the second refresh time; querying the routing rule version from the data source routing configuration component through the dynamic database routing component; determining whether the local version of the routing rule is expired within a preset cycle time; when expired, periodically refreshing the data source routing rule based on the routing rule within the second refresh time; wherein the step of periodically refreshing the data source routing rule based on the routing rule within the second refresh time further comprises the following steps: obtaining the data source name of the data source routing based on the routing rule within the second refresh time; querying and obtaining the data source routing rule based on the data source name.

2. The method of claim 1, wherein, the step of periodically refreshing the data source connection information based on the routing rule within the first refresh time comprises the following steps: obtaining the component name of the data source routing configuration component based on the routing rule within the first refresh time; querying and obtaining the relevant data source connection information based on the component name.

3. A system for applying to a multi-tenant management system data source hot switchover system, characterized in that, The method of any one of claims 1-2, comprising: configuring a reading module for reading application dependent data source configuration when the client starts; a data source hot switching module for establishing a long connection with a dynamic database routing component according to the data source configuration to perform data source hot switching; a data source routing switching module for performing business operations based on the switched data source to perform data source routing switching; a database access module for accessing a corresponding database based on the switched data source routing; wherein the data source hot switching module comprises: a data source loading unit for periodically refreshing and loading data source connection information from the dynamic database routing component within a first refresh time; an initialization connection unit for initializing a dynamic data source connection based on the data source connection information; a routing rule loading unit for periodically refreshing and loading dependent data source routing rules from the dynamic database routing component within a second refresh time; establishing a long connection with a dynamic database routing component to receive updated data source configuration information through the long connection when the data source configuration changes, so that the client can complete data source hot switching without restarting; wherein the first refresh time is the time for periodically receiving data source connection information transmitted from the dynamic database routing component, and the periodically refreshing and loading data source connection information within the first refresh time comprises: obtaining a first refresh time; querying a routing rule version from a data source routing configuration component through the dynamic database routing component; determining whether the local version of the routing rule is expired within a preset cycle time; when expired, periodically refreshing the data source connection information based on the routing rule within the first refresh time; wherein the querying a routing rule version from a data source routing configuration component through the dynamic database routing component comprises: determining whether an application routing rule is added or modified through the data source routing configuration component; when the determination result is yes, applying routing rule version information based on demand changes; querying the changed routing rule version information from the data source routing component through the dynamic database routing component to obtain a new routing rule version; wherein the second refresh time is the time for periodically receiving routing information transmitted from the dynamic database routing component, and the periodically refreshing and loading dependent data source routing rules from the dynamic database routing component within the second refresh time comprises: obtaining a second refresh time; querying a routing rule version from a data source routing configuration component through the dynamic database routing component; determining whether the local version of the routing rule is expired within a preset cycle time; when expired, periodically refreshing the data source routing rule based on the routing rule within the second refresh time; wherein the periodically refreshing the data source routing rule based on the routing rule within the second refresh time further comprises: obtaining a data source name of the data source routing based on the routing rule within the second refresh time; querying and obtaining a data source routing rule based on the data source name.

Citation Information

Patent Citations

  • Data processing method and device and electronic equipment

    CN110532243A

  • Method and system for accessing multiple data sources

    CN111414391A

  • Data source routing method and device

    CN112306984A