[OJB-developers] concurrent broker transactions in single vm mode
Brought to you by:
thma
From: Doug C. <de...@fl...> - 2002-02-02 22:53:26
|
A broker pool is required to implement odmg concurrent transactions effectively. Daniel Fernandez, you have been looking at a broker pool implementation; have you also thought about how to use this pool at the odmg level in single vm mode? Having looked at this a bit, it seems to me that one broker per odmg transaction is a logical way to proceed. Most code that needs to reference a broker is also grabbing a reference to a transaction. Unfortunately a 1-1 relationship between DatabaseImpl and broker in the current code is assumed by OJB.getBroker, but this can be fixed pretty easily I think. Many places that get a broker from OJB either can just as easily get it from the transaction, or don't care what broker they end up with since they are just using it for access to the cache or metadata. For example, sequences such as (e.g., OQLQueryImpl.execute): // retrieve a broker instance PersistenceBroker broker = OJB.getInstance().getBroker(); //obtain current ODMG transaction Transaction tx = OJB.getInstance().currentTransaction(); // we allow queries even if no ODMG transaction is running. // thus we have to provide a pseudo tx if necessary boolean needsCommit = false; if (tx == null) { tx = OJB.getInstance().newTransaction(); } // we allow to work with unopened transactions. // we assume that such a tx is to be closed after performing the query if (!tx.isOpen()) { tx.begin(); needsCommit = true; } would get the trasaction first and become //obtain current ODMG transaction Transaction tx = OJB.getInstance().currentTransaction(); // we allow queries even if no ODMG transaction is running. // thus we have to provide a pseudo tx if necessary boolean needsCommit = false; if (tx == null) { tx = OJB.getInstance().newTransaction(); } // we allow to work with unopened transactions. // we assume that such a tx is to be closed after performing the query if (!tx.isOpen()) { tx.begin(); needsCommit = true; } // retrieve the transactions's broker instance PersistenceBroker broker = tx.getBroker(); // THE CHANGE If you need a hand with this let me know. I am interested in seeing the omdg layer improved with more concurrency for single vm applications. e |