Guide  Reference  Contents  Previous  Next  Index
You can improve performance in certain Objectivity for Java applications by using an in-process lock server.
Before you can use an in-process lock server, you must purchase and install Objectivity/DB In-Process Lock Server Option (Objectivity/IPLS).
When multiple applications access a federated database, the access rights for those applications are coordinated by a lock server that runs as a separate process. If, however, all or most lock requests originate from a single, multithreaded application, the application can improve its runtime speed by starting an in-process lock server. An application that starts an in-process lock server is called an IPLS application.
An in-process lock server is just like a standard lock server, except that it runs in the IPLS application process. This enables the IPLS application to request locks through simple method calls without having to send these requests to an external process.
When an in-process lock server is started, the IPLS application becomes the lock-server process for the workstation on which it is running. Consequently, if a federated database names this workstation as its lock server host, all applications accessing that federated database will send their lock requests to the application running the in-process lock server. The in-process lock server creates a separate listener thread to service requests from external applications.
A large number of lock requests from external applications could reduce the performance of the IPLS application; normally an in-process lock server is consulted only by the application that started it.
Just as you cannot run two lock-server processes on the same host, you cannot run two IPLS applications on the same host; an in-process lock server cannot be started if any lock-server process or IPLS application is already running on the same host.
You start an in-process lock server after creating a session object and before starting the first transaction:
An in-process lock server can be started only if no other lock-server process or IPLS application is currently running on the same host. You can check whether a lock server (external or in-process) is running on your host by calling the checkLS method of the connection object.
You stop an in-process lock server by calling the stopInternalLS method of the connection object at the end of the IPLS application, and after committing or aborting all transactions in all sessions.
The stopInternalLS method safely shuts down an in-process lock server so that you can terminate the IPLS application without harming any external applications that may be using the in-process lock server. By default, this method waits indefinitely for other applications to terminate their transactions, stopping the in-process lock server when all active transactions are finished. You can optionally specify a finite wait period, after which stopInternalLS returns, even if transactions are not terminated. If active transactions do not finish and the wait period expires, the method optionally stops the in-process lock server or allows it to continue running so you can try again later.
This example shows a simple outline for an IPLS application. The static method main of the IPLSInit class opens a connection to the federated database and creates the first session object, then starts the in-process lock server after checking whether any other lock server is running on the current host. The application creates other sessions and performs its Objectivity/DB operations. After all transactions have ended, it stops the in-process lock server before closing the connection to the federated database.
import com.objy.db.*; //Import Objectivity for Java exceptions import com.objy.db.app.*; //Import Objectivity for Java classes ... public class IPLSInit { public static void main(String args[]) { Connection connection; Session session1; ... // Open a connection to a federated database try { connection = Connection.open("myFD", oo.openReadWrite); } catch (DatabaseNotFoundException e1) { System.out.println( "\nFederated database not found."); return; // Create first session session1 = new Session(); // Find out whether another lock server is running // on the current host if (connection.checkLS("myHost")) { ... // Advise user that another lock server is running ... // Proceed or not according to user choice } // Start the lock server if (connection.startInternalLS()) { ... // Create other sessions, if desired ... // Perform Objectivity/DB operations in transactions // After all transactions have ended, wait for 5 minutes // (300 seconds) to allow the in-process lock server to // finish servicing any transactions of external // applications; then stop the in-process lock server connection.stopInternalLS(300, true); } // Close the connection try { connection.close(); } catch (DatabaseClosedException e3) { System.out.println("\nConnection already closed."); return; } } // End main ... } // End class IPLSInit
Guide  Reference  Contents  Previous  Next  Index