Re: Recovery from Network error

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Mon Mar 01 2004 - 12:20:53 EST

  • Next message: Tore Halset: "1.1M3 and pruneMissing"

    > jdbc:apache:commons:dbcp:/datasourcename

    Looks like it should work fine. Didn't know you can do this with
    DBCP... Cool. This indeed makes things very easy.

    Andrus

    On Mar 1, 2004, at 3:57 AM, Vassilis Raxenidis wrote:
    > Hi Andrus,
    >
    > I think I found a solution.
    >
    > I think that the cayenne connection pool does not work in the way we
    > want.
    > I think that the cayenne connection pool does not perform any
    > reinitialization when a network error
    > occures and the pooled connections reamain invalid in the pool.
    > What I have done to solve this problem are the foolowing:
    > 1. Create a db connection pool by using the Jakarta DBCP.
    > 2. Configure a cayenne data source to use the DBCP pooling driver.
    > the configuration for the driver used by cayenne datasource looks
    > like
    > this:
    > <driver project-version="1.0"
    > class="org.apache.commons.dbcp.PoolingDriver">
    > <url value="jdbc:apache:commons:dbcp:/datasourcename"/>
    > </driver>
    > 3. Modified the cayenne DriverDataSourceFactory
    > (org.objectstyle.cayenne.conf.DriverDataSourceFactory)
    > to return instances of org.objectstyle.cayenne.conn.DriverDataSource
    > based
    > on the driver parameters defined above.
    > Then the cayenne.xml file looks like that:
    > <?xml version="1.0" encoding="utf-8"?>
    > <domains project-version="1.0">
    > <domain name="Domain1">
    > <map name="Map1" location="Map1.map.xml"/>
    > <node name="Node1"
    > datasource="Node1.driver.xml"
    > adapter="org.objectstyle.cayenne.dba.sybase.SybaseAdapter"
    > factory="JakartaDBCPDriverDataSourceFactory">
    > <map-ref name="Map1"/>
    > </node>
    > </domain>
    > </domains>
    >
    > JakartaDBCPDriverDataSourceFactory is a sub-class of
    > org.objectstyle.cayenne.conf.DriverDataSourceFactory and the
    > getDataSource
    > method is implemented like this:
    > public DataSource getDataSource(String arg0, Level arg1) throws
    > Exception {
    > load(arg0);
    > return new DriverDataSource(getDriverInfo().getJdbcDriver(),
    > getDriverInfo().getDataSourceUrl());
    > }
    >
    > Then cayenne uses the pooled data source defined by the DBCP and every
    > time
    > that cayenne needs a connection then it is aqcuired from the DBCP
    > pool.
    > Of course the DBCP pool is configured to validate every connection
    > before it
    > is returned from the pool. Moreover every idle connection in the pool
    > is periodocally validated. Every invalid connection is dropped from
    > pool.
    > Then while the network is down the pool does not contain any valid
    > connection (every connection has been dropped). So, when a connection
    > is requested an exception is thrown. As soon as the network is up the
    > pool
    > creates new validated connections which can be returned.
    >
    > What do you think about this solution? I'm testing it and it seems to
    > work
    > properly.
    >
    > Regards,
    >
    > Vassilis Raxenidis



    This archive was generated by hypermail 2.0.0 : Mon Mar 01 2004 - 12:20:58 EST