Method, model and database system for constructing multi-source isomorphic database and medium

By functionally grouping and configuring static SQL resource packages for multi-source homogeneous databases, combined with extended Mapper interfaces and organization number access, the development and maintenance difficulties of multi-source homogeneous databases, as well as data pollution and blocking issues, are resolved, achieving efficient database access and maintenance.

CN117056305BActive Publication Date: 2026-02-17CHINA MOBILE INFORMATION TECHNOLOGY CO LTD +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310987601.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-08-07
Publication Date
2026-02-17
Estimated Expiration
2043-08-07

AI Technical Summary

Technical Problem

The development and maintenance of multi-source homogeneous databases in the existing technology are difficult, mainly due to the large workload of development and operation caused by repeated SQL configuration and non-switching data source access methods, as well as data pollution and blocking problems.

Method used

By grouping the functions of multi-source homogeneous databases, configuring static SQL resource packages and public Mapper interfaces, and using the organization number to configure extended Mapper interfaces, duplicate SQL configurations are avoided. When accessing the database, the extended Mapper interface and the organization number are used to access the database, avoiding data source sharing and achieving data consistency and blocking solutions.

Benefits of technology

It reduces the development and maintenance difficulty caused by repeated SQL configurations between multiple homogeneous databases, avoids data pollution and blocking issues, and improves the robustness and development efficiency of the system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117056305B_ABST
    Figure CN117056305B_ABST
Patent Text Reader

Abstract

The present application relates to the technical field of database, especially to a multi-source database construction method, model, database system and storage medium.The method comprises the following steps: grouping the functions of multi-source isomorphic databases according to business classification to obtain function groups, and configuring a static SQL resource package corresponding to each function group; configuring a public Mapper interface of each static SQL resource package, and associating the public Mapper interface with each static SQL resource package under the same function group through a namespace class identifier; and configuring an extended Mapper interface corresponding to the public Mapper interface according to the agency number associated with each multi-source isomorphic database. All multi-source isomorphic databases share the same static SQL resource package, thereby reducing the development difficulty caused by repeated SQL configuration among each multi-source isomorphic database, and the difficulty of later database maintenance.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of database, in particular to a multi-source database construction method, model, database system and storage medium. BACKGROUND

[0002] At present, the database architecture adopted by large enterprises with large business volume in China is mainly a decentralized distributed architecture. For enterprises whose business involves the whole country, the multi-source isomorphic databases deployed between each province involved in the business volume usually adopt a data architecture of isomorphic database and table separation. This data architecture has the characteristics of high availability, high reliability and high data throughput, and can realize stable and efficient multi-data source transaction design of the database.

[0003] In the related technical solutions, the multi-data source access mode of the database usually adopts a non-switching data source access mode. The non-switching data source access mode is characterized in that the same SQL (Structured Query Language) file needs to be configured between each multi-source isomorphic database, the same set of Mapper interface objects needs to be created, and the same set of general services needs to be designed.

[0004] However, the non-switching data source access mode has the defect of large development and operation and maintenance workload due to repeated SQL configuration, repeated provincial service layer, etc.

[0005] The above content is only used to assist in understanding the technical solutions of the present application and does not represent the acknowledgement of the above content as prior art. SUMMARY

[0006] The main purpose of the present application is to provide a multi-source isomorphic database construction method, which aims to solve the problem of how to reduce the development and maintenance difficulty of multi-source isomorphic databases.

[0007] To achieve the above purpose, the present application provides a multi-source isomorphic database construction method, which comprises:

[0008] grouping the functions of the multi-source isomorphic databases according to business classification to obtain function groups, and configuring a static SQL resource package corresponding to each function group;

[0009] configuring a public Mapper interface for each static SQL resource package, and associating the public Mapper interface with each static SQL resource package under the same function group through a namespace class identifier;

[0010] configuring an extended Mapper interface corresponding to the public Mapper interface according to the agency number associated with each multi-source isomorphic database.

[0011] Optionally, after the step of configuring the extended Mapper interface corresponding to the public Mapper interface according to the institution number associated with each multi-source isomorphic database and naming the transaction manager of the multi-source isomorphic database based on the institution number, the method further comprises:

[0012] When the multi-source isomorphic database receives an access request, determining a business processing type of a target access object in the access request;

[0013] If the business processing type is a service control type, accessing the target access object in the multi-source isomorphic database through the extended Mapper interface;

[0014] If the business processing type is a transaction control type, obtaining an institution number in the access request, calling an extended Mapper interface corresponding to the institution number, and accessing the target access object in the multi-source isomorphic database through the extended Mapper interface.

[0015] Optionally, after the step of accessing the target access object in the multi-source isomorphic database through the extended Mapper interface, the method further comprises:

[0016] passing the target access object into a service method to perform a transaction control operation through the service method, the transaction control operation including at least one of starting a transaction, data access, committing a transaction, and rolling back a transaction.

[0017] Optionally, after the step of configuring the extended Mapper interface corresponding to the public Mapper interface according to the institution number associated with each multi-source isomorphic database, the method further comprises:

[0018] obtaining a current resource usage degree of a target service node associated with the multi-source isomorphic database, adjusting an acceptable number of access requests of the target service node in a same time period according to the current resource usage degree and a preset single-point vertical capacity expansion strategy; or

[0019] obtaining a current resource usage total degree of a service node cluster associated with the multi-source isomorphic database, adjusting an acceptable number of access requests of the service node cluster in a same time period according to the current resource usage total degree and a preset multi-point horizontal capacity expansion strategy.

[0020] Optionally, the step of adjusting the acceptable number of access requests of the target service node in the same time period according to the current resource usage degree and the preset single-point vertical capacity expansion strategy comprises:

[0021] determining whether the current resource usage degree is less than or equal to a preset usage degree threshold;

[0022] If yes, at least one XML configuration file is sent to the target service node to increase the number of acceptable access requests of the target service node in the same period;

[0023] Otherwise, configuration file reduction instructions are sent to the target service node to reduce the number of XML configuration files in the target service node, thereby reducing the number of acceptable access requests of the target service node.

[0024] Optionally, the step of adjusting the number of acceptable access requests of the service node cluster in the same period according to the current resource usage total degree and a preset multi-point horizontal capacity expansion strategy comprises:

[0025] determining whether the current resource usage total degree is less than or equal to a preset usage total degree threshold;

[0026] If yes, at least one target service node in the service node cluster is determined, and at least one XML configuration file is sent to each target service node to increase the number of acceptable access requests of the service node cluster in the same period;

[0027] Otherwise, at least one target service node in the service node cluster is determined, and configuration file reduction instructions are sent to each target service node to reduce the number of XML configuration files in the target service node, thereby reducing the number of acceptable access requests of the service node cluster.

[0028] Optionally, after or at the same time as the step of configuring the extended Mapper interface corresponding to the public Mapper interface according to the agency number associated with each multi-source isomorphic database, the method further comprises:

[0029] naming the transaction manager of the multi-source isomorphic database based on the agency number.

[0030] In addition, to achieve the above-mentioned purposes, the application also provides a multi-source isomorphic database construction model, which comprises:

[0031] a static SQL resource package establishment module, configured to group the functions of the multi-source isomorphic database according to business classification to obtain function groups, and configure a static SQL resource package corresponding to each function group;

[0032] an interface binding module, configured to configure a public Mapper interface of each static SQL resource package, and associate the public Mapper interface with each static SQL resource package under the same function group through a namespace class identifier;

[0033] A public Mapper interface extension module configures an extension Mapper interface corresponding to the public Mapper interface according to the agency number associated with each multi-source isomorphic database.

[0034] In addition, to achieve the above object, the present application also provides a database system, characterized in that the database system comprises a memory, a processor and a multi-source isomorphic database construction program stored in the memory and executable on the processor, and the multi-source isomorphic database construction program implements the steps of the multi-source isomorphic database construction method when executed by the processor.

[0035] In addition, to achieve the above object, the present application also provides a computer readable storage medium, which stores a multi-source isomorphic database construction program, and the multi-source isomorphic database construction program implements the steps of the multi-source isomorphic database construction method when executed by a processor.

[0036] The embodiments of the present application provide a multi-source database construction method, model, database system and storage medium, by implementing that all multi-source isomorphic databases share the same static SQL resource package, to reduce the development difficulty caused by SQL repeated configuration between each multi-source isomorphic database, and the database maintenance difficulty in later period. Moreover, the present application extracts an extension Mapper interface which inherits one or more public Mapper interfaces on the basis of the public Mapper interface, and according to the agency number of each extension Mapper interface and the multi-source isomorphic database, to access the object in the database when accessing the database, to avoid sharing the data source with other requests, and fundamentally solve the problem of data pollution and blocking. BRIEF DESCRIPTION OF DRAWINGS

[0037] Figure 1 The figure is a schematic diagram of the hardware running environment of the database system related to the embodiments of the present application;

[0038] Figure 2 The figure is a flowchart of the first embodiment of the multi-source isomorphic database construction method of the present application;

[0039] Figure 3 The figure is a schematic diagram of the multi-source isomorphic database related to the embodiments of the present application;

[0040] Figure 4 The figure is a flowchart of the second embodiment of the multi-source isomorphic database construction method of the present application;

[0041] Figure 5 The figure is a schematic diagram of the service transaction separation related to the embodiments of the present application;

[0042] Figure 6A flowchart of a third embodiment of the method for constructing a multi-source isomorphic database of the application is shown in the figure.

[0043] Figure 7 A schematic diagram of the architecture of the construction model of the multi-source isomorphic database.

[0044] The implementation, functional features and advantages of the application will be further described with reference to the embodiments and the accompanying drawings. DETAILED DESCRIPTION

[0045] For the non-switching data source mode, there is a problem of static SQL repeated configuration between each multi-source isomorphic database. The application configures the same static SQL resource package for the same function grouping between each multi-source isomorphic database, then configures the same public Mapper interface for the static SQL resource package, and associates and binds the public Mapper interface with each static SQL file, and finally configures an extended Mapper interface as a sub-interface of the public Mapper interface based on the public Mapper interface through the pre-associated agency number of each multi-source isomorphic database.

[0046] By implementing all multi-source isomorphic databases sharing the same static SQL resource package, the development difficulty caused by SQL repeated configuration between each multi-source isomorphic database and the difficulty of later database maintenance are reduced. Moreover, the application extracts an extended Mapper interface inheriting one or more public Mapper interfaces based on the public Mapper interface, and accesses the object in the database according to each extended Mapper interface and the agency number of the multi-source isomorphic database when accessing the database, thereby avoiding sharing the data source with other requests, and fundamentally solving the problems of data pollution and blocking.

[0047] In order to better understand the above technical solutions, the exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments described herein. On the contrary, these embodiments are provided to enable a more thorough understanding of the present disclosure and to fully convey the scope of the present disclosure to those skilled in the art.

[0048] As an implementation scheme, Figure 1 A schematic diagram of the hardware operating environment of the database system involved in the embodiment scheme of the application is shown in the figure.

[0049] As Figure 1As shown, the database system can include a processor 1001, such as a CPU, a memory 1005, a user interface 1003, a network interface 1004, and a communication bus 1002. The communication bus 1002 is used to realize the connection communication between the components. The user interface 1003 can include a display, an input unit such as a keyboard, and the optional user interface 1003 can further include a standard wired interface, a wireless interface. The network interface 1004 can optionally include a standard wired interface, a wireless interface (such as a WI-FI interface). The memory 1005 can be a high-speed RAM memory, or a stable memory (non-volatile memory) such as a disk memory. The memory 1005 can also be a storage device independent of the aforementioned processor 1001.

[0050] Those skilled in the art can understand that, Figure 1 The database system architecture shown in the figure does not constitute a limitation on the database system, and can include more or fewer components than shown, or combine certain components, or different component arrangements.

[0051] As Figure 1 As shown, the memory 1005 as a storage medium can include an operating system, a network communication module, a user interface module, and a multi-source isomorphic database construction program. The operating system is a program that manages and controls the hardware and software resources of the database system, and the multi-source isomorphic database construction program and the running of other software or programs.

[0052] In Figure 1 In the database system shown, the user interface 1003 is mainly used to connect the terminal and communicate data with the terminal; the network interface 1004 is mainly used for the background server and communicates data with the background server; and the processor 1001 can be used to call the multi-source isomorphic database construction program stored in the memory 1005.

[0053] In this embodiment, the database system includes a memory 1005, a processor 1001, and a multi-source isomorphic database construction program stored on the memory and executable on the processor, wherein:

[0054] When the processor 1001 calls the multi-source isomorphic database construction program stored in the memory 1005, the following operations are performed:

[0055] According to the business classification, the functions of the multi-source isomorphic database are grouped to obtain a function group, and a static SQL resource package corresponding to each function group is configured;

[0056] configure a common Mapper interface for each of the static SQL resource packages, and associate the common Mapper interface with each of the static SQL resource packages under the same functional group through a namespace class identifier;

[0057] configure an extended Mapper interface corresponding to the common Mapper interface according to the agency number associated with each of the multi-source isomorphic databases.

[0058] When the processor 1001 invokes the construction program of the multi-source isomorphic database stored in the memory 1005, the following operations are performed:

[0059] When the multi-source isomorphic database receives an access request, determine the business processing type of the target access object in the access request;

[0060] If the business processing type is a service control type, access the target access object in the multi-source isomorphic database through the extended Mapper interface;

[0061] If the business processing type is a transaction control type, obtain the agency number in the access request, invoke the extended Mapper interface corresponding to the agency number, and access the target access object in the multi-source isomorphic database through the extended Mapper interface.

[0062] When the processor 1001 invokes the construction program of the multi-source isomorphic database stored in the memory 1005, the following operations are performed:

[0063] Pass the target access object into a service method to perform a transaction control operation through the service method, the transaction control operation including at least one of starting a transaction, data access, committing a transaction, and rolling back a transaction.

[0064] When the processor 1001 invokes the construction program of the multi-source isomorphic database stored in the memory 1005, the following operations are performed:

[0065] Obtain the current resource usage degree of the target service node associated with the multi-source isomorphic database, and adjust the number of acceptable access requests of the target service node within the same time period according to the current resource usage degree and a preset single-point vertical capacity expansion strategy; or,

[0066] Obtain the current resource usage total degree of the service node cluster associated with the multi-source isomorphic database, and adjust the number of acceptable access requests of the service node cluster within the same time period according to the current resource usage total degree and a preset multi-point horizontal capacity expansion strategy.

[0067] When the processor 1001 invokes the construction program of the multi-source isomorphic database stored in the memory 1005, the following operations are performed:

[0068] determining whether the current resource usage degree is less than or equal to a preset usage degree threshold value;

[0069] If yes, sending at least one XML configuration file to the target service node to increase the number of acceptable access requests of the target service node in the same period;

[0070] Otherwise, sending a configuration file reduction instruction to the target service node to reduce the number of XML configuration files in the target service node, so as to reduce the number of acceptable access requests of the target service node.

[0071] When the processor 1001 invokes the construction program of the multi-source isomorphic database stored in the memory 1005, the following operations are performed:

[0072] determining whether the current resource usage total degree is less than or equal to a preset usage total degree threshold value;

[0073] If yes, determining at least one target service node in the service node cluster, and sending at least one XML configuration file to each target service node to increase the number of acceptable access requests of the service node cluster in the same period;

[0074] Otherwise, determining at least one target service node in the service node cluster, and sending a configuration file reduction instruction to each target service node to reduce the number of XML configuration files in the target service node, so as to reduce the number of acceptable access requests of the service node cluster.

[0075] When the processor 1001 invokes the construction program of the multi-source isomorphic database stored in the memory 1005, the following operations are performed:

[0076] naming the transaction manager of the multi-source isomorphic database based on the agency number.

[0077] Based on the hardware architecture of the above-mentioned database system based on database technology, embodiments of the construction method of the multi-source isomorphic database are proposed.

[0078] At present, the commonly used framework for Java micro-service development database is MyBatis framework. MyBatis is an excellent persistence layer framework that supports ordinary SQL queries, stored procedures and advanced mapping. MyBatis eliminates almost all Jdbc code and manual settings of parameters and retrieval of result sets. MyBatis uses simple Xml or annotations for configuration and original mapping, and maps interfaces and Java POJOs (Plain Ordinary Java Objects) into records in the database.

[0079] Database transaction processing usually adopts Spring AOP-based declarative transaction, which enables transaction support by using the @Transactional annotation at the service and method level.

[0080] The existing MyBatis-based Spring AOP declarative transaction processing nationwide province-isomorphic sub-library table data architecture, the transaction design method of multi-data source mainly includes non-switching data source and switching data source two ways:

[0081] The traditional non-switching data source method mainly includes: SQL statement resources are packaged according to provinces, and the static SQL statement files of each province are stored in the package of each province. Create a Mapper interface package according to the province, declare the Mapper interface object of each province, and bind the SQL static statement of the corresponding province in the provincial resource package. Design a set of general services, and the service method uses a generic parameter to pass in the mapping Mapper object of MyBatis to execute database access. Add the @Transactional annotation on the provincial service database access method, pass in the provincial Mapper object and parameters in the method, and access the corresponding provincial database data. The @Transactional annotation of the provincial service specifies the corresponding provincial transaction processor, and the provincial service layer binds the provincial database transaction manager, thereby realizing the control of the transaction of the province. According to the specified provincial organization number, switch the current provincial processing service object.

[0082] The traditional switching data source method configures a SQL static file for all provinces; first, create a set of Mapper interface objects for all provinces, and bind the static SQL statement. Then design a set of general services, add the @Transactional annotation on the database access method, and the @Transactional annotation specifies the dynamic data source object to access the provincial database according to the currently switched provincial data source. Create a DynamicDataSource object, inherit AbstractRoutingDataSource, initialize all provincial data sources, and dynamically switch the data source according to the provincial organization number in operation.

[0083] However, for the traditional non-switching data source mode, due to the limitation of the Mybatis framework, the namespace attribute in the SQL statement configuration XML file can only bind one interface object. Based on the nationwide multi-provincial database and table business scenario, it is necessary to configure the Mapper object by province and bind the SQL configuration xml file of the province. Therefore, the same SQL configuration file needs to be repeatedly configured multiple times. This causes great difficulty in development and maintenance, and is prone to cause differences and abnormalities in data access due to maintenance errors. Moreover, because the spring framework declarative transaction needs to apply the @Transactional annotation to the service layer, based on the nationwide multi-provincial data source scenario, it is necessary to write a set of provincial services for each province to specify the provincial database transaction processing object. Similarly, multiple copies of the same code are generated, except that the database transaction object is different, but the other processing is basically the same. The development and operation workload is huge. In addition, due to the need of the system to dynamically switch the current service object through the routing service according to the provincial organization number, the request blocking problem may occur due to the switching of the locking object in the high-concurrency scenario.

[0084] For the traditional switching data source mode, in a high-concurrency scenario, when a transaction is still being executed, but the current working data source is switched to another province, when the transaction is submitted, the data of the province will be submitted to another province, thereby causing data pollution. The DynamicDataSource object dynamically switches the current working data source through the organization number. In a high-concurrency scenario, the request blocking problem may occur due to the switching of the locking object. When the data source switching occurs abnormally, the target data source is still the data source of the last business access, and the data will be polluted to the province data of the last business.

[0085] In view of the defects existing in the above two modes, the concept of the embodiment is derived:

[0086] I. In view of the data pollution and access blocking problem caused by data source switching, the embodiment adopts a non-data source switching mode. For each business processing, the current data source is selected according to the provincial organization number information; the data source is no longer shared with other requests, thereby fundamentally solving the data pollution and blocking problem.

[0087] II. In view of the problem of repeated provincial static SQL in the non-switching data source mode, the embodiment shares one copy of the static SQL resource for all provinces, thereby effectively avoiding the problems of great difficulty in development synchronization, easy maintenance errors, and great workload caused by the existence of multiple copies of the same SQL. The efficiency of program development is greatly improved, the consistency of database access is maintained, and the robustness of the system is improved.

[0088] Reference Figure 2 In the first embodiment, the construction method of the multi-source isomorphic database comprises the following steps:

[0089] Step S10, grouping the functions of the multi-source isomorphic database according to the business classification, obtaining a function grouping, and configuring a static SQL resource package corresponding to each function grouping;

[0090] In the embodiment, the multi-source isomorphic database is characterized by having multiple data sources and allowing seamless migration, interaction and expansion between different computer architectures and operating systems.

[0091] Common business classifications of databases include, but are not limited to, transaction processing business, decision support business, data warehouse business, data mining business, online analytical processing business, document storage and retrieval business, and graphic data processing business. Different databases have different business classifications configured during development, and the business classification can be classified based on the function of the database. In the embodiment, one business classification corresponds to one function grouping of the database.

[0092] In the embodiment, during the data access interface design stage, the system functions are grouped according to the business classification, and a static SQL file is designed for each function grouping. All static SQL files are stored in a static SQL resource package, and the corresponding SQL resource package is configured according to the function grouping.

[0093] Step S20, configuring a public Mapper interface for each static SQL resource package, and associating the public Mapper interface with each static SQL file under the same function grouping through a namespace class identifier;

[0094] In the embodiment, after configuring the static SQL resource package corresponding to each function grouping, the public Mapper interface of each static SQL resource package is configured, and the public Mapper interface is associated and bound with each static SQL file through a namespace class identifier.

[0095] The Namespace class identifier is an identifier that defines a namespace. In the embodiment, the Namespace class identifier is used to create different namespaces in the system to allocate storage space for the public Mapper interface and each static SQL file for associated storage and binding.

[0096] It should be noted that each multi-source isomorphic database has the same business classification, and the same public Mapper interface and static SQL resource package are configured. For example, the data mining business of the A province database and the data mining business of the B province database use the same public Mapper interface and static SQL resource package; the transaction processing business of the A province database and the transaction processing business of the B province database use another same public Mapper interface and static SQL resource package.

[0097] In step S30, the extended Mapper interface corresponding to the public Mapper interface is configured according to the agency number associated with each multi-source isomorphic database.

[0098] In the embodiment, after the public Mapper interface and the static SQL resource package are associated through the namespace class identifier, the extended Mapper interface corresponding to the public Mapper interface is configured according to the agency number associated with each multi-source isomorphic database, so that the access request is accessed through the extended Mapper interface.

[0099] In the embodiment, the agency number is a unique identification of each multi-source isomorphic database, that is, the agency numbers of each multi-source isomorphic database are different.

[0100] Optionally, if the arrangement architecture of the multi-source isomorphic database is that one multi-source isomorphic database is arranged in each province of the country, the agency number can be the provincial agency number of each province.

[0101] As an optional implementation, when the extended Mapper interface is configured, the resource package naming rule + the agency number is used as the naming of the resource package to create a directory, and then the extended Mapper interface is created under the directory. Optionally, the extended manner of the extended Mapper interface can be one-to-one extension or one-to-many extension.

[0102] It should be noted that in the embodiment, the static SQL resource binds the public basic Mapper interface, but the extended Mapper interface is actually used when the system accesses the database. The extended Mapper interface in the embodiment is all extended from the public Mapper interface, and therefore, when the Mapper interface actually used by the MyBatis static SQL resource is selected, the object-oriented Liskov Substituition Principle is used to provide the Mapper interface of the provincial MyBatis to the static SQL resource. That is, the static SQL resource binds the public Mapper parent interface, but the system provides the child interface extended from the parent interface to actually access the database when running.

[0103] The Liskov substitution principle is that a subclass must be able to replace a base class, otherwise it should not be designed as a subclass of the base class, that is, the subclass can only extend the base class, but not hide or override the base class.

[0104] In addition, for example, see Figure 3 , Figure 3 The architecture diagram of the completed multi-source isomorphic database, the static SQL shared management module configures a static SQL file for each business group of the database, the static SQL file corresponds to the basic mapper interface (i.e. Mapper public interface), and on the basic mapper interface, the province extension mapper interface corresponding to the basic mapper interface is extended in units of provinces.

[0105] For example, the following uses the DAO (Data Access Object) interface (in this embodiment, the DAO interface is equivalent to the Mapper interface) to illustrate the construction process of the multi-source isomorphic database in this embodiment:

[0106] I. According to the business grouping, the following public interfaces are planned:

[0107] The public report DAO interface is PubRepInterface.

[0108] The public configuration processing DAO interface is PubConfigInterface.

[0109] The public cache DAO interface is PubCacheInterface.

[0110] The public log DAO interface is PubLogInterface.

[0111] The public data update DAO interface is PubUpdateInterface.

[0112] The public data query DAO interface is PubQueryInterface.

[0113] The public data modification DAO interface is PubModifyInterface.

[0114] The public data deletion DAO interface is PubDeleteInterface.

[0115] The public extension DAO interface is PubExtendInterface.

[0116] II. Create a public DAO interface java package and a public SQL resource storage directory:

[0117] The public DAO interface package is named pubinterface.

[0118] The public SQL resource storage directory is named pubSQL.

[0119] The public SQL resource file corresponds to the public interface one by one, and is named the same as the public interface, for example: pubRepInterface.xml, pubConfigInterface.xml, etc.

[0120] Three, according to the list of provincial agency numbers, create a provincial DAO package;

[0121] The naming rule of the provincial DAO package is DAO+provincial agency number, for example:

[0122] DAO110000, DAO120000,..., DAO850000

[0123] Four, create a provincial sub-DAO interface;

[0124] Create A city extension DAO interface under DAO110000 directory, and the extension mode can be one-to-one extension mode and one-to-many extension mode.

[0125] If one-to-one extension mode is adopted:

[0126] DAORepInterface110000 Extends PubRepInterface;

[0127] DAOConfigInterface110000 Extends PubConfigInterface;

[0128] DAOCacheInterface110000 Extends PubCacheInterface;

[0129] DAOLogInterface110000 Extends PubLogInterface;

[0130] DAOUpdateInterface110000 Extends PubUpdateInterface;

[0131] DAOQueryInterface110000 Extends PubQueryInterface;

[0132] DAO Modify Interface 110000 Extends Pub Modify Interface

[0133] DAO Delete Interface 110000 Extends Pub Delete Interface

[0134] DAO Extend Interface 110000 Extends Pub Extend Interface

[0135] If a one-to-many extension mode is adopted:

[0136] DAO Com Interface 110000

[0137] Extends Pub Rep Interface, Pub Config Interface, Pub Cache Interface, Pub Log Interface, Pub Update Interface, Pub Query Interface, Pub Modify Interface, Pub Delete Interface, Pub Extend Interface.

[0138] It should be noted that the extended DAO interface does not need to write any business code, and only needs to be extended to declare, which can greatly reduce the amount of code required for development.

[0139] In the technical scheme provided in the embodiment, all multi-source isomorphic databases share the same static SQL resource package, which reduces the development difficulty caused by repeated SQL configuration between the multi-source isomorphic databases and the difficulty of database maintenance in the later period. Moreover, the application extracts an extended Mapper interface which inherits one or more public Mapper interfaces on the basis of the public Mapper interface, and accesses the object in the database according to the extended Mapper interface and the institution number of the multi-source isomorphic database when accessing the database, so as to avoid sharing the data source with other requests, and achieve the effect of avoiding data pollution and blocking.

[0140] Further, in the embodiment, the step S30 is followed or accompanied by:

[0141] In step S40, the transaction manager of the multi-source isomorphic database is named based on the institution number.

[0142] Optionally, in the embodiment, the institution number is also used to name the transaction manager of the multi-source isomorphic database, which is a component used to manage database transactions and is responsible for ensuring that a set of operations performed in a transaction either all succeed or all fail to maintain the consistency and integrity of the database.

[0143] Optionally, the transaction manager naming rule can be: transaction manager name+ institution number.

[0144] For example, the transaction manager is named in the mode of TransactionManager+ institution number, such as TransactionManager110000, TransactionManager120000, etc.

[0145] In the technical solution provided in the embodiment, the transaction manager is named by the institution number, and when transaction control is performed, the transaction manager is called by the institution number to access the access object of the transaction control type, so as to build a multi-source isomorphic database sharing the same static SQL resource package, and further reduce the development difficulty caused by SQL repeated configuration between the multi-source isomorphic databases, and the difficulty of later database maintenance.

[0146] Reference Figure 4 In the second embodiment, based on the first embodiment, after the step S30, the method further comprises:

[0147] Step S50, when the multi-source isomorphic database receives an access request, determining the business processing type of the target access object in the access request;

[0148] Step S60, if the business processing type is a service control type, accessing the target access object in the multi-source isomorphic database through the extended Mapper interface;

[0149] Step S70, if the business processing type is a transaction control type, obtaining the institution number in the access request, calling the extended Mapper interface corresponding to the institution number, and accessing the target access object in the multi-source isomorphic database through the extended Mapper interface.

[0150] As an optional embodiment, in the embodiment, after the multi-source isomorphic database is constructed, in order to avoid the problem that the traditional @Transactional annotation is deeply bound with the service layer in the non-switching data source mode, and a large amount of repeated service layer code is difficult to maintain in the multi-data source non-switching business scenario, the service transaction business in the database originally under the same type of business is split into service control and transaction control in the embodiment.

[0151] In the embodiment, when the multi-source isomorphic database receives an access request, first, the business processing type of the target access object which the access request needs to access is determined. Specifically, a transaction control object is programmed by manual programming, and the naming manner of the transaction control object is distinguished from the service control object, so as to separate the transaction control object from the service layer.

[0152] Optionally, the transaction control object is programmed by a public Util class, and the naming rule of the transaction control object is defined as: a preset naming field + an organization number. The business control object does not contain the organization number. When the organization number exists in the access request, it is judged that the target access type is the transaction control object, otherwise, it is judged that the target access type is the service control object.

[0153] In the embodiment, the business processing type of the object which the request sending end needs to access is contained in the access request, and the way of accessing the object is different according to the different business processing types. If it is determined that the business processing type is the service control type, the access object can be directly accessed through the extended Mapper interface of the multi-source isomorphic database.

[0154] If it is determined that the business processing type is the transaction control object, the extended Mapper interface corresponding to the organization number is called according to the organization number obtained by analyzing the access request, and the target access object in the multi-source isomorphic database is accessed through the extended Mapper interface.

[0155] Further, in the embodiment, after the step S70, the method further includes:

[0156] In step S80, the target access object is transmitted into a service method, so that the service method performs a transaction control operation. The transaction control operation includes at least one of starting a transaction, data access, committing a transaction and rolling back a transaction.

[0157] Optionally, in the embodiment, the target access object with the business processing type of the transaction control type is transmitted into the service method to perform the transaction control operation. The transaction control operation includes at least one of starting a transaction, data access, committing a transaction and rolling back a transaction.

[0158] Exemplarily, with reference to Figure 5 , Figure 5 A service transaction separation architecture schematic diagram is shown. The service transaction separation management module is arranged in the database. The service transaction separation management module separates the transaction and the service. The transaction control object is accessed through the ApplicationContext object, and the transaction control object is transmitted into the service method as a parameter to perform a corresponding operation. For the service control object, the service control object is directly transmitted into the service method to perform a corresponding operation.

[0159] In the technical scheme provided in the embodiment, in order to avoid that, in a non-switching data source mode, a traditional @Transactional annotation is deeply bound with a service layer, and thus a large amount of repeated and difficult-to-maintain code appears in the service layer in the face of a multi-data source non-switching business scenario, in the embodiment, service transaction businesses in a database that are originally under the same type of business are split into service control and transaction control in two different dimensions for processing, so as to further reduce the development difficulty and the later database maintenance difficulty caused by SQL repeated configuration among various multi-source isomorphic databases.

[0160] With reference to Figure 6 In the third embodiment, based on any embodiment, after the step S30, the method further includes:

[0161] In step S901, a current resource usage degree of a target service node associated with the multi-source isomorphic database is acquired, and according to the current resource usage degree and a preset single-point vertical capacity expansion strategy, the number of acceptable access requests of the target service node in the same time period is adjusted.

[0162] Or, in step S902, a current resource usage total degree of a service node cluster associated with the multi-source isomorphic database is acquired, and according to the current resource usage total degree and a preset multi-point horizontal capacity expansion strategy, the number of acceptable access requests of the service node cluster in the same time period is adjusted.

[0163] As an optional embodiment, in a traditional scheme, the data processing capacity is basically fixed, and if the data processing capacity needs to be expanded, the code needs to be modified. In the embodiment, based on the constructed multi-source isomorphic database, all processing capacities are regarded as a resource list, and without modification on the code side, the resource list can be used to dynamically increase or decrease according to a loading configuration file of the multi-source isomorphic database, so as to realize dynamic capacity adjustment of a system data source.

[0164] In the embodiment, the multi-source isomorphic database is associated with a service node cluster, the service node cluster includes a plurality of service nodes, and the multi-source isomorphic database sends a heartbeat data packet to each node in the service node cluster at a regular time to acquire a current resource usage degree of a target service node.

[0165] The current resource usage degree represents a quantitative value of a current load state of the service node.

[0166] In the embodiment, the following two capacity expansion modes are provided:

[0167] One, single point longitudinal capacity expansion. For a node in the server cluster, the node is dynamically adjusted, thereby adjusting the number of acceptable access requests of the node in the same period, wherein the adjustment can be increasing the number of acceptable access requests in the same period, or reducing the number of acceptable access requests in the same period.

[0168] Two, multi-point horizontal capacity expansion. For multiple service nodes in the entire server cluster, a batch of nodes are dynamically adjusted, and the processing capacity of the batch of nodes is increased or reduced.

[0169] In the technical scheme provided in the embodiment, through the design of dynamic data processing capacity expansion of the multi-source homogeneous database, the processing capacity of the service node can be dynamically and flexibly increased or reduced according to the load of the service node, and the expansion capacity of the multi-source homogeneous database is improved. Since the system code does not need to be modified, the development difficulty of the multi-source homogeneous database and the difficulty of the database maintenance in the later stage are further reduced.

[0170] Further, in the embodiment, the step S901 includes:

[0171] Step S9011, determining whether the current resource usage degree is less than or equal to a preset usage threshold;

[0172] Step S9012, if yes, at least one XML configuration file is sent to the target service node to increase the number of acceptable access requests of the target service node in the same period;

[0173] Step S9013, otherwise, a configuration file reduction instruction is sent to the target service node to reduce the number of XML configuration files in the target service node, thereby reducing the number of acceptable access requests of the target service node.

[0174] Optionally, in the embodiment, for how to execute the single point longitudinal capacity expansion strategy, when it is determined that the current resource usage degree of a service node is less than or equal to a preset usage threshold, it means that the resource usage degree of the current state service node is low, and at least one XML configuration file is sent to the target service node, so as to allocate more data access requests to the current service node, thereby increasing the acceptable access request capacity of the service node in the same period.

[0175] If the current resource usage degree of the service node is greater than the preset usage threshold, it means that the resource usage degree of the current state service node is high, and a configuration file reduction instruction is sent to the target service node to reduce the number of XML configuration files in the target service node, thereby reducing the number of acceptable access requests of the target service node, so as to avoid that the number of acceptable access requests of the service node is too much and causes the service node to be overloaded.

[0176] Further, in the embodiment, the step S902 comprises:

[0177] Step S9021, determining whether the current resource usage total degree of the service node cluster associated with the database is less than or equal to a preset usage total degree threshold value;

[0178] Step S9022, if yes, determining at least one target service node in the service node cluster, and sending at least one XML configuration file to each of the target service nodes to increase the acceptable access request number of the service node cluster in the same period;

[0179] Step S9023, otherwise, determining at least one target service node in the service node cluster, and sending a configuration file reduction instruction to each of the target service nodes to reduce the number of XML configuration files in the target service nodes, so as to reduce the acceptable access request number of the service node cluster.

[0180] Optionally, in the embodiment, when the current resource usage total degree is less than or equal to the preset usage total degree threshold value, it means that the resource usage degree of the current service cluster is low, and at least one target service node in the service node cluster is determined, and at least one XML configuration file is sent to each of the target service nodes to increase the acceptable access request number of the service cluster in the same period.

[0181] Optionally, the same number of XML configuration files can be sent to each target service node, for example, if there are 3 target service nodes, 2 XML configuration files (a total of 6) are sent to each target service node at the same time. Different numbers of XML configuration files can also be sent to each target service node, for example, 1 XML configuration file is sent to target service node A, and 3 XML configuration files are sent to target service node B.

[0182] In the embodiment, if the current resource usage total degree of the service cluster is greater than the preset usage total degree threshold value, it means that the resource usage degree of the current service cluster is high, at least one target service node is selected from the service cluster, and a configuration file reduction instruction is sent to the target service node to reduce the number of XML configuration files in the target service node, so as to reduce the acceptable access request number of the entire service cluster, and avoid that the acceptable access request number of the service cluster is too large to cause the service node to be overloaded.

[0183] In addition, with reference to Figure 7 The embodiment also provides a multi-source isomorphic database construction model, which comprises:

[0184] The static SQL resource package establishment module 100 is configured to group functions of the multi-source isomorphic database according to business classification, obtain a function group, and configure a static SQL resource package corresponding to each function group.

[0185] The interface binding module 200 is configured to configure a public Mapper interface of each static SQL resource package, and associate the public Mapper interface with each static SQL file under the same function group through a namespace class identifier.

[0186] The public Mapper interface expansion module 300 is configured to configure an expansion Mapper interface corresponding to the public Mapper interface according to an agency number associated with each multi-source isomorphic database.

[0187] In addition, those skilled in the art can understand that all or part of the processes in the method for implementing the above embodiments can be completed by a computer program instructing related hardware. The computer program includes program instructions, and the computer program can be stored in a storage medium, which is a computer readable storage medium. The program instructions are executed by at least one processor in the database system to implement the process steps of the above method embodiments.

[0188] Therefore, the application further provides a computer readable storage medium storing a multi-source isomorphic database construction program, and the multi-source isomorphic database construction program is executed by a processor to implement each step of the multi-source isomorphic database construction method according to the above embodiments.

[0189] The computer readable storage medium can be a U disk, a mobile hard disk, a read-only memory (ROM), a magnetic disk or an optical disk, and various computer readable storage media that can store program codes.

[0190] It should be noted that the storage medium provided by the embodiments of the application is a storage medium used to implement the method of the embodiments of the application. Therefore, based on the method introduced in the embodiments of the application, those skilled in the art can understand the specific structure and modification of the storage medium, and therefore it is not repeated here. Any storage medium used in the method of the embodiments of the application belongs to the scope of protection of the application.

[0191] Those skilled in the art will appreciate that embodiments of the present application can be readily used as a method, a system or a computer program product. Accordingly, the present application can take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application can take the form of a computer program product on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROMs, optical storage devices, etc.) embodying computer readable program code thereon.

[0192] The present application is described in reference to the flowchart illustrations and / or block diagrams of the methods, apparatus (systems) and computer program products according to embodiments of the application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general purpose computer, special purpose computer, embedded processor or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart illustrations and / or block diagrams block or blocks. Figure 1 one or more functions specified in the flowchart illustrations and / or block diagrams block or blocks. Figure 1 one or more functions specified in the flowchart illustrations and / or block diagrams block or blocks.

[0193] These computer program instructions can also be stored in a computer- readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instructions which implement the function specified in the flowchart illustrations and / or block diagrams block or blocks. Figure 1 one or more functions specified in the flowchart illustrations and / or block diagrams block or blocks. Figure 1 one or more functions specified in the flowchart illustrations and / or block diagrams block or blocks.

[0194] These computer program instructions can also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart illustrations and / or block diagrams block or blocks. Figure 1 one or more functions specified in the flowchart illustrations and / or block diagrams block or blocks. Figure 1 one or more functions specified in the flowchart illustrations and / or block diagrams block or blocks.

[0195] It should be noted that the word "comprising" does not exclude the presence of elements or steps other than those listed in a claim. The word "a" or "an" preceding the citation of elements does not exclude the presence of a plurality of such elements. It is further noted that the claims can be drafted to exclude any optional element. A combination of claims does not require every element of one claim to be included in the combination for the combination to be within the scope of the disclosure. The word "first", "second", "third" etc. does not necessarily indicate any order, quantity, or position but is used to indicate different categories. The use of the terms "first", "second", "third" etc. does not require the presence of three elements but can be used to distinguish between elements.

[0196] Although the preferred embodiments of the application have been described, those skilled in the art will recognize that many modifications and variations of the preferred embodiments could be made without departing from the spirit or scope of the application. Accordingly, it is intended that there be included within the scope of the application, all such modifications and variations as can be reasonably inferred from the disclosure herein.

[0197] It will be apparent to those skilled in the art that various modifications and variations can be made in the present application without departing from the spirit or scope of the application. Thus, it is intended that the present application cover modifications and variations of this application provided they come within the scope of the appended claims and their equivalents.

Claims

1. A method for constructing a multi-source isomorphic database, characterized in that, The method for constructing the multi-source isomorphic database comprises the following steps: grouping functions of the multi-source isomorphic database according to business categories to obtain function groups, and configuring a static SQL resource package corresponding to each function group; configuring a public Mapper interface of each static SQL resource package, and associating the public Mapper interface with each static SQL resource package under the same function group through a namespace class identifier; configuring an extended Mapper interface corresponding to the public Mapper interface according to an agency number associated with each multi-source isomorphic database, and naming a transaction manager of the multi-source isomorphic database based on the agency number; when the multi-source isomorphic database receives an access request, determining a business processing type of a target access object in the access request; if the business processing type is a service control type, accessing the target access object in the multi-source isomorphic database through the extended Mapper interface; if the business processing type is a transaction control type, obtaining an agency number in the access request, calling an extended Mapper interface corresponding to the agency number, and accessing the target access object in the multi-source isomorphic database through the extended Mapper interface.

2. The method of claim 1, wherein, After the step of accessing the target access object in the multi-source isomorphic database through the extended Mapper interface, the method further comprises: passing the target access object into a service method to perform a transaction control operation through the service method, wherein the transaction control operation comprises at least one of starting a transaction, data access, committing a transaction, and rolling back a transaction.

3. The method of claim 1, wherein, After the step of configuring an extended Mapper interface corresponding to the public Mapper interface according to an agency number associated with each multi-source isomorphic database, the method further comprises: obtaining a current resource usage degree of a target service node associated with the multi-source isomorphic database, adjusting an acceptable access request number of the target service node in the same time period according to the current resource usage degree and a preset single-point vertical capacity expansion strategy; or obtaining a current resource usage total degree of a service node cluster associated with the multi-source isomorphic database, and adjusting an acceptable access request number of the service node cluster in the same time period according to the current resource usage total degree and a preset multi-point horizontal capacity expansion strategy.

4. The method of claim 3, wherein, The step of adjusting the acceptable access request number of the target service node in the same time period according to the current resource usage degree and a preset single-point vertical capacity expansion strategy comprises: determining whether the current resource usage degree is less than or equal to a preset usage degree threshold; if yes, sending at least one XML configuration file to the target service node to increase the acceptable access request number of the target service node in the same time period; otherwise, sending a configuration file reduction instruction to the target service node to reduce the number of XML configuration files in the target service node, thereby reducing the acceptable access request number of the target service node.

5. The method of claim 3, wherein, The step of adjusting the acceptable access request number of the service node cluster in the same period according to the current resource usage total degree and a preset multi-point horizontal capacity expansion strategy comprises: determining whether the current resource usage total degree is less than or equal to a preset usage total degree threshold value; if yes, determining at least one target service node in the service node cluster, and sending at least one XML configuration file to each target service node to increase the acceptable access request number of the service node cluster in the same period; otherwise, determining at least one target service node in the service node cluster, and sending a configuration file reduction instruction to each target service node to reduce the number of XML configuration files in the target service node, thereby reducing the acceptable access request number of the service node cluster.

6. The method of claim 1, wherein, After or at the same time as the step of configuring the extended Mapper interface corresponding to the public Mapper interface according to the agency number associated with each multi-source isomorphic database, the method further comprises: naming the transaction manager of the multi-source isomorphic database based on the agency number.

7. A construction model of a multi-source isomorphic database, characterized in that, The construction model of the multi-source isomorphic database comprises: a static SQL resource package establishment module configured to group the functions of the multi-source isomorphic database according to business classification, obtain a function group, and configure a static SQL resource package corresponding to each function group; an interface binding module configured to configure a public Mapper interface of each static SQL resource package, and associate the public Mapper interface with each static SQL resource package under the same function group through a namespace class identifier; a public Mapper interface extension module configured to configure an extended Mapper interface corresponding to the public Mapper interface according to the agency number associated with each multi-source isomorphic database, and name the transaction manager of the multi-source isomorphic database based on the agency number, determine the business processing type of a target access object in an access request when the multi-source isomorphic database receives the access request, access the target access object in the multi-source isomorphic database through the extended Mapper interface if the business processing type is a service control type, and access the target access object in the multi-source isomorphic database through the extended Mapper interface corresponding to the agency number if the business processing type is a transaction control type.

8. A database system, characterized by The database system comprises a memory, a processor, and a multi-source isomorphic database construction program stored on the memory and executable on the processor, and the multi-source isomorphic database construction program implements the steps of the multi-source isomorphic database construction method according to any one of claims 1 to 6 when executed by the processor.

9. A computer-readable storage medium, characterized in that, The computer readable storage medium stores a multi-source isomorphic database construction program, and the multi-source isomorphic database construction program implements the steps of the multi-source isomorphic database construction method according to any one of claims 1 to 6 when executed by the processor.

Citation Information

Patent Citations

  • Method and system for judging network security inspection compliance of electric power information system and equipment

    CN113886367A

  • Potential affected group positioning method based on heterogeneous information network

    CN115242438A