Method for middle-tier optimization in CORBA OTS6973657Abstract To perform a distributed transaction in a CORBA environment, OTS (the CORBA Transaction Service) defines a process called "control object interpositioning". It must be carried out on the server side to ensure transaction integrity. However, for middle-tier servers (servers that do not access a database directly) this process is not necessary. The control object can be simply passed through. However, the two propagation methods of OTS do not provide a good way to take advantage of this fact. The present invention defines a model by which the deployment nature of the server can be specified. Middle-tier or database-tier can be defined in a deployment descriptor file, which is read in deployment time by the server process. The present invention will optimize the middle-tier servers by bypassing the control object interpositioning process and handing the control object directly to the next tier, bringing noticeable performance gains for an n-tiered system. Claims 1. A computer-implemented method for optimizing transactional behavior of a middle-tier server between a client application and a database-tier server, the method comprising: Description CROSS-REFERENCE TO RELATED APPLICATIONS
Users can design their system without even considering transactions initially. By comparison, if using straight OTS, the IDL is one of the following two:
The advantage of using ENCORE's programming model is that the transaction characteristics are completely separated from the IDL interface. The first IDL interface can then be implemented in either Java or C++. When deploying the server, a deployment descriptor needs to be supplied. The following is the deployment descriptor file for the above example:
Another advantage of ENCORE is that its programming model is not restricted by any programming language or environment. This model is maintained consistently in C++ and Java language implementations of ENCORE. Not only can a client written in Java or C++ talk to servers written in C++ or Java in a transactional manner, EJB session beans running ENCORE client side library can act as a client to a C++ server with ENCORE server side library outside the EJB environment. FIG. 1 provides a diagram of the principal components of a distributed transaction accomplished in a CORBA-compliant manner. In the context of this disclosure, CORBA-compliant means compliant and compatible with the relevant specifications for CORBA in general and for CORBA OTS specifically. While the most preferred embodiment is compliant with CORBA 2.1 and OTS97, an embodiment compliant with CORBA 2.1 and CORBA OTS97 is defined as being CORBA-compliant with later embodiments of CORBA and CORBA OTS. In FIG. 1, the client object 10 (also referred to as client application or more simply as client) acts as the transaction originator. To originate the transaction, client 10 sends a command to the Object Transaction Service 20 (also referred to as OTS) to begin the transaction. At the same time, client 10 sends a CORBA call in the form of an IIOP message to both server object 30 and server object 40 (also referred to as server applications or more simply as servers). Server objects 30 & 40 are both transaction participants. The illustration provides two transaction participants to demonstrate the advantage of using a transaction service, where a request may require changes in multiple databases and where if one database is not able to make a change, any other changes may be rolled back to their original state. The server objects 30 & 40 each communicate with supporting databases 50 & 60 respectively, most preferably Oracle databases, but also potentially other relational databases. Each server object communicates CRUD commands (create, read, update, & delete) using SQL language. At the same time, the OTS 20 communicates with each database 50 & 60 to begin a transaction using XA commands compliant with the X/Open standard for two-phase commit protocols. There are potentially, but not necessarily, machine boundaries between any or all of the objects 10, 30, 40, 50, & 60 and OTS 20. After all of the CORBA calls return successfully, client 10 informs OTS 20 to commit the transaction and OTS 20 similarly informs the databases 50 & 60 to commit the transaction. At this point the transaction is complete and OTS 20 steps out of the picture. However, if one of the calls to server objects fail, for example because the database was unavailable, client 10 informs OTS 20 to rollback the transaction and OTS 20 informs any of databases 50 & 60 which have made a change to implement the transaction to rollback the change and return to their original state before the transaction began. In FIG. 2, a more detailed diagram illustrating the connections between client, server, database and OTS is provided. Client 10 provides commands to begin, commit, or rollback to OTS 20. Server Object 30 registers with OTS 20. Client 10 sends its CORBA call by IIOP message including the transaction context to server object 30. OTS 20 sends a start command and later a prepare and commit command or a rollback command to database 50 preferably using the X/Open standard. Server object 30 sends an SQL command to database 50 including a transaction id (or XID). Database 50 will respond to the server object 30's SQL request which is returned to client 10 which informs OTS 20 to commit or rollback the request depending on the response. OTS 20 informs database 50 to commit or rollback and the transaction is completed. In the present invention, this model is accomplished by the use of CORBA interceptors. Whenever the client invokes a CORBA method on the server side, the client side interceptor intercepts the call and puts the "control" object (defined by OTS to represent the transaction context) encapsulated within a "session" object on the service context of the IIOP message. When the server receives the invocation, the interceptor first intercepts it, extracts the "session" object from the service context of the IIOP message, checks the policy, and make the appropriate calls to the OTS. Note that the session object encapsulates the control object and is sometimes referred to in this disclosure as the control object where the control object is the focus of the discussion. Since this programming model is accomplished by using interceptors to propagate the transaction context information without the user's intervention, therefore, the propagation is implicit. Because the transaction context is completely managed by ENCORE's server side library, from the user's perspective the context management is indirect. While implicit and indirect context management are recognized and defined by the OTS specification, the indirect propagation of transaction context through the use of interceptors placing transaction context in a session object on the service context of the IIOP message is not known to the inventors outside of their present invention. FIG. 3 diagrams a preferred embodiment of the events on client side when "initialize" is called. Client 110 calls initialize which is passed to its ENCORE framework 120. ENCORE framework 120 propagates the initialize to both ORB 130 and OTS 140. Interceptor 210 also registers with ORB 130 at initialization. FIG. 4 diagrams a preferred embodiment of the events on client side when "beginTx" is called. Client 110 calls beginTx to ENCORE framework 120 which constructs a session object 220 incorporating a control object 230. Encore framework 120 also initiates a begin command with OTS 140. FIG. 5 diagrams the events which occur when a client call is made from the client side. When the client object 110 invokes a CORBA method on the server side (in this instance Account→Balance), the invocation is passed through ENCORE framework 120 to ORB 150. After the call is initially delivered to ORB 150, the client side interceptor 210 intercepts the call and puts the session object 220 (the object representing the transaction context and incorporating the control object) on the service context of the IIOP message heading to the server and then returns the IIOP message to ORB 150 for delivery. FIG. 6 diagrams the server side events. When the server side receives the invocation through the ORB 150, the server side interceptor 240 first intercepts the invocation, extracts the session object 220 and checks the transaction policy for the server. The transaction policy is read from the deployment descriptor when the server 160 is deployed. If the policy is not transactional, the interceptor 240 bypasses the OTS calls and invokes the user's implementation directly on the server object 160. But if the policy requires transaction, the interceptor code completes the control object interpositioning process, an OTS defined process between the session object 220 and the OTS 140 and then invokes the called method on the server object 160. Both the client object 110 and the server object 160 work in cooperation with separate ENCORE Frameworks 120 and 170 respectively to accomplish the defined process. While the discussion here refers to client side and server side, one skilled in the art will recognize that a given system may function as both a client and a server at various times. When the specification refers to the client side, it is referring to the system or environment on which the client object is resident. Where the specification refers to a system remote from the client object it does not require a separate network or even a separate computer (as objects functioning in a client/server relationship may share a computer) but instead refers to a separate environment where communications between the client side and the server side (i.e., the local and remote system) are exchanged through the CORBA ORB rather than though another local channel. The client object is the object making the request which may or may not require transactional support. The CORBA method being called or invoked is contained within an object. For shorthand, the term CORBA method is defined to include the object which contains the CORBA method. Hence where the statement is made that the CORBA method resides on a system, it is understood that the object containing the CORBA method resides on the system. In the above described example, the server object contains the invoked CORBA method. The User's View ENCORE's Programming interface provides the following interfaces to the client side and the server side:
This interface is very simple, the transaction propagation and management is completely hidden to the user. The deployment descriptor file preferably specifies the policies of all the methods resident on the server, but could specify transaction policies for a set of methods or even for an individual method. It is preferably read when the server process first starts up. The file format is preferably basically name and value pairs separated by "=" sign, but other separators or approaches to provide the information could also be used. The file format typically takes the form of a text file, but other formats understood by those of skill in the art could also be employed. At its heart, the deployment descriptor file is a stored file which lists transaction policies for specific methods. When the deployment descriptor file is "read", the act of creation of the transaction policy actually transforms the data in the text file into a different form, typically but not necessarily tabular, which is preferably stored in a cache on the server. The act of checking the provided method name against the transaction policy comprises comparing the name to the names in the transaction policy and determining the specific policy associated with the name. In its most preferred form, this involves comparing the name against the transaction policy in the cache. However, in an alternative form, checking may involve reading the deployment descriptor file after receiving the method invocation to compare the invoked method name with the contents of the deployment descriptor file more contemporaneously (run-time instead of deployment time). Even this act involves pulling the stored information from the deployment descriptor file into memory (either as a whole or in pieces) and comparing, and such an act is included within the definition of creating a transaction policy. It is just an alternative, more ephemeral, transaction policy created in response to each request, rather than only at the time of deployment. The user must supply the deployment descriptor file in order to deploy the server. While the deployment descriptor file is preferably stored on the system where the server object is resident, (i.e. on the server side), it may alternatively be stored elsewhere so long as the server has access to the file either during deployment or during run-time or both. By having the deployment descriptor file remote from the server, the same deployment descriptor file could be used to define the transaction policies for more than one server. In this manner, a group of servers typically deployed together and similarly situated may have their transaction policies modified by changing a single deployment descriptor file rather than having to change a deployment descriptor file for each server separately. The Session Object (incorporating and sometimes referred to as the Control Object) In the preferred embodiment, the client side ENCORE container creates a session when a transaction is initiated on the client side. The session is identified by a unique id. The resulting session object comprises a string composed of the machine's IP address, the process id, the thread id, and the current time in mili-second. A session represents a transaction. All the information pertaining to a session is propagated to the server side on every method invocation, so that the server knows which transaction that particular call belongs to. The session has a time-out parameter, which specifies how long it is allowed to exist before it gets cleaned up by the garbage collection mechanism of the ENCORE container. The session id gets logged in the server side log file on every call. Middle-Tier Optimization The use of deployment descriptors described above may be modified somewhat to create a very flexible model by which the deployment nature of the server can be specified. Middle-tier or Database-tier can be defined in a deployment descriptor file for each server. It is read in deployment time by the server process. ENCORE will optimize the middle-tier servers by bypassing the control object interpositioning process and handing the control object directly to the next tier. Hence it brings in noticeable performance gains for an n-tiered system. Control Object Interpositioning is an OTS defined process for joining a CORBA call with an existing transaction. The steps can be shown with the following pseudo code:
In the above code, the original control object is used to get the coordinator object, the coordinator is then used to get the context object. The ots—factory is an instance of the OTS factory interface. The context object is passed as argument to the recreate method of OTS factory to create a new control object. Since the implementation of the OTS interfaces such as the factory and the coordinator typically reside in other processes, this process is time consuming because each of the above calls is a network call. There is currently no product known to the present inventors that performs the run-time optimization in the middle-tier servers when using OTS. The present inventors likewise know of no product that offers a flexible model such as ENCORE's to define the middle-tier nature of a server in deployment time and without requiring any code change. In the deployment descriptor file for a given server, the following property needs to be set:
The ENCORE framework for the server will read this file when it starts up and creates the transactional policy for the server. The middle-tier optimization is accomplished by passing the control object directly to the next tier omitting the expensive control object interpositioning process. In effect, an override is created in the transactional policy, where middle-tier servers will not treat a method as transactional (and hence will not go through the control object interpositioning process) regardless of whether the specific method is or is not being treated as transactional otherwise. With the middle-tier optimization, the control object passes right through without any processing. This may be referred to as a negative transaction policy for the server. But if there is no middle-tier optimization, the control object in the middle-tier is processed, and the result is another control object generated by the interpositioning process. The new control object is eventually passed to the next tier. This may be referred to as a positive transaction policy. Middle-tier optimization is accomplished by run-time optimization, that is, to let the control object pass through the middle-tier to the next tier and by the use of deployment descriptor file. The particular convenience of the use of deployment descriptor files to set middle-tier optimization, the most preferred method, is that the same server may be redeployed outside of a middle-tier role (in a database-tier for example) and brought back into transactional status by one change of the deployment descriptor file. There is no need for recoding or recompilation which would otherwise be required. Because the middle-tier optimization is an override, the deployment descriptor file itself may still define correct transactional behaviors for each method which will then come into play when middle-tier optimization is turned off, without even need to create a new deployment descriptor file. FIG. 7 provides a diagram of the simplest set of components in an n-tier transaction. In FIG. 7, the client object 110 (also referred to as client application or more simply as client) acts as the transaction originator. To originate the transaction, client 110 sends a command through its ENCORE Framework 120. The result is the passing of a control object 220 to a middle-tier server 165 through its ENCORE Framework 175. The transaction policy created from the deployment descriptor file is checked, and on finding that the server 165 is defined as a middle-tier server, the control object 220 is passed through middle-tier server 165 and its ENCORE Framework 175 without going through a control object interpositioning process. This continues until control object 220 reaches a database-tier server such as database-tier server 160 within its ENCORE Framework 170. The control object 220 is intercepted and compared with the transactional policy for database-tier server 160 and if the object is invoking a transactional method, then a control object interpositioning process takes place and preferably an X/Open command is sent to the database 180 in an attempt to fulfill the request. Outside of the initial override check for whether the server is a middle-tier server, the process in its preferred embodiment would mirror the above-described processes for evaluating transactional behavior and also preferably for propagating transactional context. Performance Benchmark A benchmark was used in the inventor's lab to test the merits of middle-tier optimization of ENCORE. It can serve as an example to show the advantages of the feature. The benchmark is composed of 3 servers accessing directly to an Oracle database, and one server in the middle aggregating data that is retrieved from the 3 servers. A client is talking to the server in the middle to obtain information. The components are running on 4 different machines. The ENCORE client starts a transaction and then calls a method on the middle-tier server inside the transaction. The middle-tier server turns around and calls one method on each of the 3 database-tier servers to access the database. The client commits the transaction once the method it issues to the middle-tier is returned. The client repeats this operation many times and takes the average time per transaction. With the middle-tier optimization turned on, the above benchmark demonstrated a 29% performance improvement in terms of TPM (transactions per minute) over the same system without the optimization. Computer Systems The method as described above may generally be implemented on a variety of different computer systems. FIG. 8 illustrates a typical, general-purpose computer system suitable for implementing the present invention. The computer system 330 includes a processor 332 (also referred to as a central processing units, or CPU) that is coupled to memory devices including primary storage devices 336 (typically a read only memory, or ROM) and primary storage devices 334 (typically a random access memory, or RAM). As is well known in the art, ROM acts to transfer data and instructions uni-directionally to CPU 332, while RAM is used typically to transfer data and instructions in a bi-directional manner. Both storage devices 334, & 336 may include any suitable computer-readable media. A secondary storage medium 338, which is typically a mass memory device, is also coupled bi-directionally to CPU 332 and provides additional data storage capacity. The mass memory device 338 is a computer-readable medium that may be used to store programs including computer code, data, and the like. Typically, mass memory device 338 is a storage medium such as a non-volatile memory such as a hard disk or a tape which are generally slower than primary storage devices 334, 336. Mass memory storage device 338 may take the form of a magnetic or paper tape reader or some other well-known device. It will be appreciated that the information retained within the mass memory device 338, may, in appropriate cases, be incorporated in standard fashion as part of RAM 334 as virtual memory. A specific primary storage device 334 such as a CD-ROM may also pass data uni-directionally to the CPU 332. CPU 332 are also coupled to one or more input/output devices 340 that may include, but are not limited to, devices such as video monitors, track balls, mice, keyboards, microphones, touch-sensitive displays, transducer card readers, magnetic or paper tape readers, tablets, styluses, voice or handwriting recognizers, or other well-known input devices such as, of course, other computers. Finally, CPU 332 optionally may be coupled to a computer or telecommunications network, e.g., an internet network, or an intranet network, using a network connection as shown generally at 312. With such a network connection, it is contemplated that CPU 332 might receive information from the network, or might output information to the network in the course of performing the above-described method steps. Such information, which is often represented as a sequence of instructions to be executed using CPU 332, may be received from and outputted to the network, for example, in the form of a computer data signal embodied in a carrier wave. The above-described devices and materials will be familiar to those of skill in the computer hardware and software arts. In one embodiment, sequences of instructions may be executed substantially simultaneously on multiple CPUs, as for example a CPU in communication across network connections. Specifically, the above-described method steps may be performed across a computer network. Although only a few embodiments of the present invention have been described, it should be understood that the present invention may be embodied in many other specific forms without departing from the spirit or the scope of the present invention. By way of example, while databases which communicate using SQL and X/Open commands are described, databases which communicate and support transactions using alternative defined protocols could equally be used without departing from the spirit of the present invention. Therefore, the present examples are to be considered as illustrative and not restrictive, and the invention is not to be limited to the details given herein, but may be modified within the scope of the appended claims along with their full scope of equivalents.
|
Same subclass Same class Consider this |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
