The present invention relates generally to managing datasources and, more particularly, to managing dynamic configuration-based database connections using a proxy datasource.
A datasource is a collection of information about a database such as the type of database, the location of the database, or credentials that might be associated with the database. A datasource is utilized to configure and access database connections between a server (or an application on the server) and a database. An application container is a controlling element for an application instance that runs within an application container environment. Within an application server/application container environment, datasources are typically configured statically via a deployment descriptor. Such datasources usually include connection information (e.g., database server hostname, port number, database name, etc.), as well as additional properties to control the behavior of database connections served up by the datasource (e.g. read timeout, write timeout, automatic client re-route properties, etc.).
In an aspect of the invention, a computer-implemented method includes: receiving, by a proxy datasource of a computing device, a connection request for a connection to a database from a software application of the computing device, wherein the software application is in an application container environment; obtaining, by the proxy datasource of the computing device, configuration data associated with the connection request; creating, by the proxy datasource of the computing device, a concrete datasource according to the configuration data; and returning, by the proxy datasource of the computing device, the connection to the database to the software application.
The present invention is described in the detailed description which follows, in reference to the noted plurality of drawings by way of non-limiting examples of exemplary embodiments of the present invention.
The present invention relates generally to managing datasources and, more particularly, to managing dynamic configuration-based database connections using a proxy datasource. In embodiments, a proxy datasource implementation is utilized to allow new database connections to be configured for use by an application without the need to restart the application. In implementations, the proxy datasource is defined to the application server/application container environment through the use of a single static datasource definition. This proxy datasource implementation then uses a configuration-based approach for managing any number of concrete datasources. In aspects, an application obtains database connections by using the proxy datasource in much the same way that it would use a static datasource, but also specifies a datasource identifier that acts as a key into the configuration of database connections (e.g., first and second databases).
Since datasources are typically configured statically, the configuration of any new database connections that might be needed by the application would require a restart of the application. This restart requirement can be problematic in situations in which a server-based application needs to be “always on”.
Advantageously, embodiments of the invention provide improvements to a computing device and to the technical field of implementing configuration-based database connections. More specifically, embodiments of the invention provide dynamic configuration-based management of concrete datasources and the proxy's dynamic management of database connections to these non-static datasources, which prevents the need to configure static datasources with the application container environment. Additionally, embodiments of the invention enable eXtended Architecture (XA) transaction recovery functionality, which allows the entire collection of concrete datasources to appear as a single XA datasource to the application container when it triggers XA transaction recovery operations.
The present invention may be a system, a method, and/or a computer program product at any possible technical detail level of integration. The computer program product may include a computer readable storage medium (or media) having computer readable program instructions thereon for causing a processor to carry out aspects of the present invention.
The computer readable storage medium can be a tangible device that can retain and store instructions for use by an instruction execution device. The computer readable storage medium may be, for example, but is not limited to, an electronic storage device, a magnetic storage device, an optical storage device, an electromagnetic storage device, a semiconductor storage device, or any suitable combination of the foregoing. A non-exhaustive list of more specific examples of the computer readable storage medium includes the following: a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or Flash memory), a static random access memory (SRAM), a portable compact disc read-only memory (CD-ROM), a digital versatile disk (DVD), a memory stick, a floppy disk, a mechanically encoded device such as punch-cards or raised structures in a groove having instructions recorded thereon, and any suitable combination of the foregoing. A computer readable storage medium, as used herein, is not to be construed as being transitory signals per se, such as radio waves or other freely propagating electromagnetic waves, electromagnetic waves propagating through a waveguide or other transmission media (e.g., light pulses passing through a fiber-optic cable), or electrical signals transmitted through a wire.
Computer readable program instructions described herein can be downloaded to respective computing/processing devices from a computer readable storage medium or to an external computer or external storage device via a network, for example, the Internet, a local area network, a wide area network and/or a wireless network. The network may comprise copper transmission cables, optical transmission fibers, wireless transmission, routers, firewalls, switches, gateway computers and/or edge servers. A network adapter card or network interface in each computing/processing device receives computer readable program instructions from the network and forwards the computer readable program instructions for storage in a computer readable storage medium within the respective computing/processing device.
Computer readable program instructions for carrying out operations of the present invention may be assembler instructions, instruction-set-architecture (ISA) instructions, machine instructions, machine dependent instructions, microcode, firmware instructions, state-setting data, configuration data for integrated circuitry, or either source code or object code written in any combination of one or more programming languages, including an object oriented programming language such as Smalltalk, C++, or the like, and procedural programming languages, such as the “C” programming language or similar programming languages. The computer readable program instructions may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the latter scenario, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet Service Provider). In some embodiments, electronic circuitry including, for example, programmable logic circuitry, field-programmable gate arrays (FPGA), or programmable logic arrays (PLA) may execute the computer readable program instructions by utilizing state information of the computer readable program instructions to personalize the electronic circuitry, in order to perform aspects of the present invention.
Aspects of the present invention are described herein with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. 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 readable program instructions.
These computer readable program instructions may be provided to a processor of a general purpose computer, special purpose computer, 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/acts specified in the flowchart and/or block diagram block or blocks. These computer readable program instructions may also be stored in a computer readable storage medium that can direct a computer, a programmable data processing apparatus, and/or other devices to function in a particular manner, such that the computer readable storage medium having instructions stored therein comprises an article of manufacture including instructions which implement aspects of the function/act specified in the flowchart and/or block diagram block or blocks.
The computer readable program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other device to cause a series of operational steps to be performed on the computer, other programmable apparatus or other device to produce a computer implemented process, such that the instructions which execute on the computer, other programmable apparatus, or other device implement the functions/acts specified in the flowchart and/or block diagram block or blocks.
The flowchart and block diagrams in the Figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of instructions, which comprises one or more executable instructions for implementing the specified logical function(s). In some alternative implementations, the functions noted in the blocks may occur out of the order noted in the Figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems that perform the specified functions or acts or carry out combinations of special purpose hardware and computer instructions.
Referring now to
In computing infrastructure 10 there is a computer system (or server) 12, which is operational with numerous other general purpose or special purpose computing system environments or configurations. Examples of well-known computing systems, environments, and/or configurations that may be suitable for use with computer system 12 include, but are not limited to, personal computer systems, server computer systems, thin clients, thick clients, hand-held or laptop devices, multiprocessor systems, microprocessor-based systems, set top boxes, programmable consumer electronics, network PCs, minicomputer systems, mainframe computer systems, and distributed cloud computing environments that include any of the above systems or devices, and the like.
Computer system 12 may be described in the general context of computer system executable instructions, such as program modules, being executed by a computer system. Generally, program modules may include routines, programs, objects, components, logic, data structures, and so on that perform particular tasks or implement particular abstract data types. Computer system 12 may be practiced in distributed cloud computing environments where tasks are performed by remote processing devices that are linked through a communications network. In a distributed cloud computing environment, program modules may be located in both local and remote computer system storage media including memory storage devices.
As shown in
Bus 18 represents one or more of any of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, and a processor or local bus using any of a variety of bus architectures. By way of example, and not limitation, such architectures include Industry Standard Architecture (ISA) bus, Micro Channel Architecture (MCA) bus, Enhanced ISA (EISA) bus, Video Electronics Standards Association (VESA) local bus, and Peripheral Component Interconnects (PCI) bus.
Computer system 12 typically includes a variety of computer system readable media. Such media may be any available media that is accessible by computer system 12, and it includes both volatile and non-volatile media, removable and non-removable media.
System memory 28 can include computer system readable media in the form of volatile memory, such as random access memory (RAM) 30 and/or cache memory 32. Computer system 12 may further include other removable/non-removable, volatile/non-volatile computer system storage media. By way of example only, storage system 34 can be provided for reading from and writing to a nonremovable, non-volatile magnetic media (not shown and typically called a “hard drive”). Although not shown, a magnetic disk drive for reading from and writing to a removable, non-volatile magnetic disk (e.g., a “floppy disk”), and an optical disk drive for reading from or writing to a removable, non-volatile optical disk such as a CD-ROM, DVD-ROM or other optical media can be provided. In such instances, each can be connected to bus 18 by one or more data media interfaces. As will be further depicted and described below, memory 28 may include at least one program product having a set (e.g., at least one) of program modules that are configured to carry out the functions of embodiments of the invention.
Program/utility 40, having a set (at least one) of program modules 42, may be stored in memory 28 by way of example, and not limitation, as well as an operating system, one or more application programs, other program modules, and program data. Each of the operating system, one or more application programs, other program modules, and program data or some combination thereof, may include an implementation of a networking environment. Program modules 42 generally carry out the functions and/or methodologies of embodiments of the invention as described herein.
Computer system 12 may also communicate with one or more external devices 14 such as a keyboard, a pointing device, a display 24, etc.; one or more devices that enable a user to interact with computer system 12; and/or any devices (e.g., network card, modem, etc.) that enable computer system 12 to communicate with one or more other computing devices. Such communication can occur via Input/Output (I/O) interfaces 22. Still yet, computer system 12 can communicate with one or more networks such as a local area network (LAN), a general wide area network (WAN), and/or a public network (e.g., the Internet) via network adapter 20. As depicted, network adapter 20 communicates with the other components of computer system 12 via bus 18. It should be understood that although not shown, other hardware and/or software components could be used in conjunction with computer system 12. Examples, include, but are not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data archival storage systems, etc.
As illustrated in
In the example of
Since the datasource 202 is configured statically, the configuration of any new database connections that might be needed by the application 200 would require a restart of the application 200. This restart requirement can be problematic in situations in which the application 200 needs to be “always on” or in which it is undesirable to restart the application 200. For example, if a user of the application 200 needed to introduce a new datasource to connect to an additional database MyDB2 (not depicted), then the static configuration would be updated to include the configuration data 208 for MyDB2. After the application container's static datasource configuration is updated to include the configuration data 208, the application 200 would need to be restarted in order to allow the application 200 to connect to the new database MyDB2.
The network 20 may be any suitable communication network or combination of networks, such as a local area network (LAN), a general wide area network (WAN), and/or a public network (e.g., the Internet). The first and second databases 62 and 63 may be any type of data source configured to provide information to the server 60 or store information from the server 60.
Still referring to
In implementations, the server 60 further comprises a proxy datasource module 76 (hereafter proxy datasource 76), configured to create concrete datasources (e.g., first and second datasources 77 and 78), and act as an intermediary between a software application (e.g., application 74) and the concrete datasources to facilitate the establishment of a connection between the software application and a database (e.g., first database 80 or second database 81). The term proxy datasource as used herein refers to computer software that acts as a proxy to concrete (real) datasources so that the concrete datasources can be managed dynamically as configuration changes are made, without impacting the software application relying on the concrete datasource for a database connection. For example, in the case where a new database is added to the application container environment 72, the configuration information for an existing database (e.g., first database 80) may be changed or removed from stored configuration data. The first and second datasources 77 and 78 are concrete datasources utilized to configure and access database connections between a server or an application on the server (e.g., application 74) and a local or remote database (e.g., local first and second databases 80 and 81 or remote first and second database 62 and 63).
In embodiments, the sever 60 may include additional or fewer components than those shown in
At step 400, the application 74 sends a request to the application container 73 for a handle to the proxy datasource 76. The request is sent based on the desire to connect the application 74 to a first database (e.g., the first database 62 or the first database 80). For the purpose of
At step 401, the application container 73 provides the application 74 with the handle to the proxy datasource 76 in response to the request of step 400. In contrast to the method of
At step 402, the application 74 sends a request to the proxy datasource 76 for a connection to the first database 80 (i.e., a request for a datasource) based on the handle received at step 401. In implementations, the request includes a datasource or database identifier (e.g., “db1”) identifying the first database 80, and configuration data. In aspects, the datasource or database identifier is specified through a specialized use of existing method parameters (e.g., DataSource.getConnection(String, String)), through a thread-local structure, or other method. The manner in which an application specifies the datasource or database identifier to the proxy datasource 76 when obtaining a connection to the first database 80 may vary depending on a particular implementation. In contrast to the method of
At step 403, the proxy datasource 76 instantiates a first datasource 77 (concrete datasource) for the first database 80 as needed (i.e., if the first datasource 77 has not yet been created/cached) in response to the request of step 402. In implementations, the first datasource 77 is created based on the configuration data of the request of step 402.
At step 404, the proxy datasource 76 causes the first datasource 77 to pass the proxy datasource 76 a connection to the first database 80, and the proxy datasource 76 then returns the connection to the application 74. Step 404 may be implemented after creation of the first datasource 77 at step 403, or when the first datasource 77 is already created, in response to the request for connection of step 402. In contrast to the method of
At step 405, the application 74 interacts with the first database 80 via the connection created by the first datasource 77 and returned to the application 74 by the proxy datasource 76. The application 74 may interact with the first database 80 to access or obtain data from the database 80, or to store data in the first database 80.
In embodiments, the application 74 connects to a plurality of databases utilizing the proxy datasource 76. In this way, new database configurations may be implemented within the application container environment 72 without the need for restarting the application 74 or server 60 to instantiate a new datasource for the new database.
In one example at step 406, the application 74 sends a request to the proxy datasource 76 for a connection to the second database 81 (i.e., a request for a datasource) based on the handle received at step 401. In implementations, the request includes a datasource or database identifier (e.g., “db2”) identifying the second database 81, and configuration data.
At step 407, the proxy datasource 76 instantiates (creates) the second datasource 78 for the second database 81 as needed (i.e., if the second datasource 78 has not yet been created/cached) in response to the request of step 406. In implementations, the second datasource 78 is created based on the configuration data of the request of step 406.
At step 408, the proxy datasource 76 causes the second datasource 78 to pass the proxy datasource 76 a connection to the second database 81, and the proxy datasource 76 returns the connection to the application 74. In contrast to the method of
At step 409, the application 74 interacts with the second database 81 via the connection created by the second datasource 78 and returned to the application 74 by the proxy datasource 76. The application 74 may interact with the second database 81 to obtain or access data in the second database 81, or to store data in the second database 81, for example.
In embodiments, once the proxy datasource 76 mechanisms described above is in place, the proxy datasource's configuration is updated dynamically to configure a new concrete datasource. The application 74 then immediately starts to request connections from this new datasource without the need to restart the application 74 or the application server/container environment, since it is the proxy datasource 76 which deals with the underlying datasource configuration and manages the concrete datasource instances, as opposed to the application server/application container 73. Implementations of the proxy datasource 76 enable the server 60 to reload configuration properties as needed on the fly in order to recognize and use any new configuration data. In implementations, a robust implementation of this dynamic configuration feature includes the ability of the proxy datasource 76 to detect changes to existing configuration information and react to those changes by marking any cached concrete datasource instances (affected by the configuration changes) for disposal so that any subsequent connection requests associated with any changed datasource configurations would result in instantiating a new instance of the concrete datasource using the new configuration information.
Accordingly in implementations, at step 410, when the configuration data of the connection request (request of steps 402 or 406) comprises new configuration data, the proxy datasource 76 identifies the change in configuration data and marks cached datasource instances for disposal. Thereafter the proxy datasource 76 instantiates a new datasource based on the new configuration data.
With reference to
In the scenario of
In the exemplary scenario of
Based on the above, implementations of the invention utilize the proxy datasource 76 as a proxy to concrete (real) datasources (e.g., first and second datasources 77 and 78) so that the concrete datasources can be managed dynamically as configuration changes are made, without impacting the application (e.g., application 74) wishing to utilize the datasource. A configuration change may occur, for example when a new database is added, and the configuration information for an existing database is changed or removed from the configuration. In implementations, part of the management of these concrete datasources involves an eXtended Architecture (XA) transaction management façade that is provided by the proxy datasource 76 implementation. The term XA refers to a two-phase commit protocol that is natively supported by many database and transaction monitors. In aspects, the XA transaction management façade appears as a single XA resource to the application container 73 which handles XA recovery steps triggered by a transaction manager 75. In implementations, the present invention provides a mechanism for XA recovery, wherein, during a recovery phase, the proxy datasource 76 provides the transaction manager 75 with a single logical XA resource that supplies recoverable Xids (identifiers that identify each transaction branch in XA transactions) for a multiplicity of XA resources, enabling the transaction manager 75 to agnostically recover transactional operations across multiple distinct datasources. An Xid is comprised of a global transaction identification (ID) that identifies a global transaction that a transaction will be a part of, a global transaction format ID, and a branch qualifier ID that uniquely identifies the transaction branch.
In situations where static datasources are utilized, such as the one depicted in
In XA implementations, the transaction manager 75 commits distributed branches of a global transaction using a two-phase commit protocol. In phase one, the transaction manager 75 directs each resource manager (not shown) to prepare to commit, which is to verify and guarantee it can commit its respective branch of the global transaction. If a resource manager cannot commit its branch, the transaction manager 75 rolls back the entire transaction in phase two. In phase two, the transaction manager 75 either directs each resource manager to commit its branch or, if a resource manager reported it was unable to commit in phase one, rolls back the global transaction. In implementations, when a database is loaded from disk to recover after a failure or unexpected termination, any global transactions that were prepared but not committed are left pending, or in doubt. For recovery, the transaction manager 75 calls recover method of each XA resource.
At step 600, the transaction manager 75 reads a transaction recovery log stored by the server 60. Existing procedures for reading transaction recovery logs may be utilized in implementations of step 600.
At step 601, the transaction manager 75 finds an entry in the recovery log for an in-doubt transaction, wherein the proxy datasource is a participating resource in the in-doubt transaction. In contrast to the embodiment of
At step 602, the transaction manager 75 requests an XA resource from the proxy datasource 76. In this configuration, the XA resource is a proxy XA resource, wherein the proxy datasource 76 provides the transaction manager 75 with the proxy XA resource.
At step 603, the transaction manager 75 queries the proxy XA resource for recoverable
Xids.
At step 604, the proxy XA resource obtains a concrete XA resource from each available concrete datasource (e.g., the first datasource 77 and the second datasource 78).
At step 605, the proxy XA resource requests recoverable Xids from each of the concrete XA resources.
At step 606, the proxy XA resource builds a conglomerate list of recoverable Xids across all concrete XA resources and supplies this list to the transaction manager 75.
At step 607, the transaction manager 75 identifies the Xids for the in-doubt transaction from its entry in the recovery log.
At step 608, the transaction manager 75 matches up each Xid needing recovery with the XA resource that reported the Xid as recoverable.
At step 609, the transaction manager 75 requests, for each Xid needing recovery, the corresponding proxy XA resource to prepare that Xid for commit.
At 610, the corresponding proxy XA resources of step 609 each receive the respective request to prepare the Xid for commit, and use the Xid to identify a respective concrete XA resource.
At step 611, each of the corresponding proxy XA resources of step 610 delegate the prepare operation to the concrete XA resources identified at step 610.
At step 612, the transaction manager 75 requests, for each Xid needing recovery, the corresponding proxy XA resource to commit the transaction branch with the Xid.
At step 613, each of the corresponding proxy XA resources of step 612 receives a respective request to commit the transaction branch with the Xid and uses the Xid to identify the respective concrete XA resource.
At step 614, each of the corresponding XA resources of step 613 delegates the commit operation to the concrete XA resources identified at step 613.
At step 615, the server 60 successfully recovers the transaction. The above method steps are implemented for the commit path in XA resource recovery, however, the above-identified steps may be utilized for the rollback path instead, wherein the rollback operation is substituted for the commit operation.
Thus, embodiments of the invention enable the server 60 to perform eXtended Architecture (XA) recovery during a recovery phase, wherein the proxy datasource provides to a transaction manager of the computing device a single logical XA resource that supplies recoverable Xids for multiple XA resources, enabling the transaction manager to recover transactional operations across the first concrete datasource and a second concrete datasource, wherein the first and second concrete datasources are represented by the proxy datasource. In such embodiments, the concrete datasources are managed by the proxy datasource so that the transaction manager 75 only really knows about the proxy datasource 76 while the concrete datasources (e.g., first datasource 77 and second datasource 78) are largely hidden from the transaction manager 75. In embodiments, in addition to the concrete datasources that are managed by the proxy datasource (and essentially hidden from the transaction manager's view), other transactional resources may be recovered by the transaction manager 75. Thus, apart from the concrete datasources (e.g., first datasource 77 and second datasource 78) being managed by the proxy datasource 76, it is possible that other resources (not related to the proxy datasource or the concrete datasources) can be participants in transactions being recovered. Accordingly, embodiments of the invention enable the server 60 to recover transactional operations across: 1) the two or more concrete datasources which are represented (or managed) by the proxy datasource 76; and 2) any other transactional resources that happen to also be a participant in the transaction being recovered.
In embodiments, a service provider could offer to perform the processes described herein. In this case, the service provider can create, maintain, deploy, support, etc., the computer infrastructure that performs the process steps of the invention for one or more customers. These customers may be, for example, any business that uses technology. In return, the service provider can receive payment from the customer(s) under a subscription and/or fee agreement and/or the service provider can receive payment from the sale of advertising content to one or more third parties.
In still another embodiment, the invention provides a computer-implemented method for implementing dynamic, configuration-based database connection in a server/application container environment. In this case, a computer infrastructure, such as computer system 12 (
One exemplary computer-implemented method includes: receiving, by a proxy datasource, a request from an application for a connection to a specific datasource; reading, by the proxy datasource, configuration data associated with the requested connection; instantiating and configuring, by the proxy datasource, a concrete datasource implementation according to the configuration data; and returning, by the proxy datasource, the requested connection to the application. In implementations, the configuration data is updated dynamically to configure a new concrete datasource without restarting the application server/container environment. In aspects, the method further includes identifying, by the proxy datasource, a change to the configuration data; and marking cached concrete datasource instances affected by the change for disposal, such that new requests for datasources affected by the change result in instantiating a new instance of a concrete datasource.
The descriptions of the various embodiments of the present invention have been presented for purposes of illustration, but are not intended to be exhaustive or limited to the embodiments disclosed. Many modifications and variations will be apparent to those of ordinary skill in the art without departing from the scope and spirit of the described embodiments. The terminology used herein was chosen to best explain the principles of the embodiments, the practical application or technical improvement over technologies found in the marketplace, or to enable others of ordinary skill in the art to understand the embodiments disclosed herein.
Number | Date | Country | |
---|---|---|---|
Parent | 16411873 | May 2019 | US |
Child | 16509770 | US |