View source | View content page | Page history | Printable version   
Toolbox
Main Page
Upload file
What links here
Recent changes
Help

PDF Books
Show collection (0 pages)
Collections help

Search

Projects:Read Only Pool/Specs

Contents

Functional Requirements

The main functional goal is to provide the ability to configure a second database that will be used by the Openbravo reports to retrieve their data. A new read-only pool will be available to provide the connections required during report generation.

Read-Only Pool Configuration

To read-only pool configuration will be done through the Openbravo.properties file.

In Openbravo.properties for each bbdd.* and db.pool.* it will be possible to add new bbdd.readonly.* and db.readonly.pool.* properties to configure the read-only database connection and specific pool properties for it.

If those new properties are set, a new connection pool will be created to be used from the code that explicitly decides to. In case they are not set, no new pool will be created and the code marked to use the read-only pool, will use the standard one.

The only required property to use the read-only pool is bbdd.readonly.url which is used to define the read-only database url. The rest of properties for the read-only pool are optional, if not set, read-only pool will take the definition from the standard one.

Known Limitations

Technical Requirements

Multi-Pool

The infrastructure designed for this project will allow to have two pools at most (standard and read-only), but it is designed also to make it easy to extend in the future to provide more pools.

The read-only pool is intended to retrieve connections from a secondary (backup) database which only allow read operations.

Read only pool.png


The JdbcExternalConnectionPool class manages all the functionality of the Apache JDBC Connection Pool. This is the class in charge to retrieve the configuration from the Openbravo.properties file and together with the standard pool, generate the read-only pool (if defined).

Along with the above, the SessionHandler keeps the Hibernate Session and Transaction in a ThreadLocal and it is in charge to make it available throughout the application. When the Apache JDBC Connection Pool is enabled, this class will retrieve the connections from the pool explicitly requested by the SessionHandler class.

All the connections retrieved from the read-only pool will be marked as read-only. This means that the connection will be put in read-only mode as a hint to the JDBC driver to enable database optimizations.

New API

This new feature works both for DAL and SQLC queries, to make use of the read-only pool both the OBDal and DalConnectionProvider classes has been adapted accordingly.

To access to the read-only database (pool) with DAL, the following method will be available:

 
OBDal.getReadOnlyInstance()

For SQLC queries that want to use the read-only pool, the connection provider must be defined as follows:

 
ConnectionProvider cp = DalConnectionProvider.getReadOnlyConnectionProvider();

Any query performed in OBDal/ConnectionProvider obtained in these ways, will be executed in read-only mode.

Standard Report Implementation

As part of this project, the standard reports must be configured to use the read-only pool by default. Thus:

Other reports, for example those that provide their own datasource (not using a query in the jrxml template) must be reviewed and updated in order to retrieve their data with the new API.

Future Implementations

The read-only pool could be especially suitable to retrieve static information from the database, i.e., information that usually does not change along the normal usage of the application. For example, it could be used to retrieve information from the Application Dictionary.

Retrieved from "http://wiki.openbravo.com/wiki/Projects:Read_Only_Pool/Specs"

This page has been accessed 401 times. This page was last modified on 19 January 2017, at 18:23. Content is available under Creative Commons Attribution-ShareAlike 2.5 Spain License.