geronimo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Jencks <david_jen...@yahoo.com>
Subject Re: How to configure a datasource to use OracleDataSource for Datasource pooling
Date Thu, 14 Jun 2007 16:52:47 GMT

On Jun 14, 2007, at 9:03 AM, Piers Geyman wrote:

>
> Hi David,
>
> More background info:
> I can connect to RAC successfully using the oracle tranQL Resource  
> Adapter,
> but this method does not allow the ability to use the more powerful  
> features
> of the RAC environment, namely Fast Connection Failover (FCF). With  
> FCF the
> Oracle Datasource Connection pool  
> (oracle.jdbc.pool.OracleDataSourceFactory)
> is used to obtain and manage DataSources. The  
> OracleDataSourceFactory uses
> the Oracle Notification Service (ONS) to subscribe to RAC notification
> events to help it manage its pool of connections. When a RAC node  
> goes down
> the RAC will send a notification via ONS to any subscribers to let  
> them know
> that the Node is no longer available. The OracleDataSourceFactory will
> receive this event and then remove any of the connections to that  
> Node in
> its pool instantly, so that any new connections requested will be  
> valid.
> This means that the application will get valid connections if a  
> node goes
> down, rather than getting connections that are invalid and having  
> handle the
> event - hence Fast Connection Failover.
>
> The following document describes most of this:
> http://www.oracle.com/technology/products/database/clustering/pdf/ 
> twpracwkldmgmt.pdf
>
> We have some projects that do not use JTA, do you have any examples  
> of how
> to create this gbean?
> Newer projects we are working on do require jta though, so a "proper"
> solution would be better.
>

I'm somewhat mystified why Oracle doesn't expose or advertise how to  
use this stuff in app servers other than their own.  You might poke  
around in their jars to see if they actually have a  
ManagedConnectionFactory or ResourceAdapter hidden in there.

I think that the main functions hidden in the driver can be exposed  
through a j2ca resource adapter pretty easily:

-- adapter has to track all the connections itself and keep track of  
which ones go to which oracle cluster member.  This should probably  
be done in a ResourceAdapter instance, since ManagedConnectionFactory  
instances might be created over and over.
-- on notification that a node is down, adapter sends a  
ConnectionErrorOccurred notification to all the connections attached  
to that cluster member.  This causes the app server's connection  
manager to remove them from the pool and destroy them right away.   
It's likely to confuse applications that are currently using these  
connections, but they would have gotten equally confused when the  
connection stopped working anyway.
-- the service level information needs to get fed into the  
ManagedConnectionFactory so when the ConnectionManager attempts to  
match connections the MCF can select one from a low-load cluster member.

The only missing part I see compared to the advertised features is  
automatic creation of idle connections to a low-load cluster member.

So I think it should be possible to extend the tranql oracle adapter  
to deal with all these RAC features.

--------------------

My memories are slowly coming back to me.... when Jeremy Boynes  
originally implemented the tranql oracle adapter we ran into this  
"oracle wants to do the pooling" feature and added a no-pooling  
option to our connection manager to support it.  I'm not sure if/when  
anyone has tried it recently but specifying pooling with <no-pool/>  
should make our connection manager not have a pool, letting oracle  
deal with pooling however it wants.  I don't know if the tranql  
adapter is using the correct oracle class to get the RAC-aware  
datasources you need, but if not it should be a simple change.  Again  
I don't understand the configuration involved but if you need to set  
up different config-properties this is pretty easy to do.

I think that at least short term this is the best option.  I don't  
know how you'd get xa access with  this approach, but if you can  
locate an XADataSource or XAConnection in the oracle classes this too  
should be fairly simple.

--------------------

Finally if using the tranql connector with no pooling doesn't work I  
think you can write a gbean something like this:

public class OracleFoo implements ConnectionFactorySource {

    private Object ds;

     public OracleFoo() {
     //create the oracle datasource
         ds = ???;
     }

     public Object $getResource() {
         return ds;
     }

    public static final GBeanInfo GBEAN_INFO;
     static {
         GBeanInfoFactory infoFactory = GBeanInfoFactory.createStatic 
(OracleFoo.class, "JCAManagedConnectionFactory");
         GBEAN_INFO = infoFactory.createGBeanInfo();
     }
     public static GBeanInfo getGBeanInfo() {
         return GBEAN_INFO;
     }
}

The important parts are "implements ConnectionFactorySource" and  
"JCAManagedConnectionFactory"  which is also available as  
NameFactory.JCA_MANAGED_CONNECTION_FACTORY

Hope this helps
david jencks


>
>
> Regards
>
> Piers
>
>
> djencks wrote:
>>
>>
>> On Jun 14, 2007, at 7:29 AM, Piers Geyman wrote:
>>
>>>
>>> Hi,
>>>
>>> I can get a connection running to Oracle just using the tranql
>>> connector
>>> that uses the tranQL/geronimo connection pooling, but I need to use
>>> the
>>> Oracle Connection Pooling as I am using Oracle RAC and oracle  
>>> needs to
>>> manage the connections in the pool based on information it receives
>>> from the
>>> Oracle RAC.
>>>
>>> Do I need to develop my own Resource Adapter to be able to have
>>> database
>>> connection served by the Oracle Connection Factory Pool
>>> (oracle.jdbc.pool.OracleDataSourceFactory), or am I missing some
>>> obvious
>>> configuration of geronimo/tranQL that would allow me to specify the
>>> Oracle
>>> class (oracle.jdbc.pool.OracleDataSourceFactory) as my connection
>>> pool?
>>>
>>
>> At the moment there's no way to have oracle manage a connection pool,
>> and it doesn't fit into the idea of the connector architecture.  I
>> looked for some RAC documentation and it looks like there's a way for
>> weblogic to do the pooling at least for oracle 10g
>> (bestpracticesforxaandrac.pdf, p.6).  That makes me suspect that
>> there is some way to use RAC through a resource adapter.  For
>> instance, does oracle supply an XADataSource?
>>
>> Do you know what the oracle connection pooling does?  Why is this
>> something that would be difficult for the connection manager to do?
>>
>> If there's really no way to avoid Oracle managing the connections it
>> should still be fairly easy to write a modified ConnectionManager
>> that doesn't do pooling but delegates to oracle.  If you don't need
>> jta transactions at all there's probably an even simpler way to do
>> this by writing a gbean that creates the datasource, and has a method
>> called $getResource that returns it.  If you then name this gbean
>> correctly it should fit into our jndi lookup mechanism.
>>
>> Is there publicly available documentation on how to use RAC in a java
>> enterprise environment, e.g. javadoc or some indication of what
>> classes are available and for what purposes?
>>
>> thanks
>> david jencks
>>
>>> Thanks and regards
>>>
>>> Piers
>>>
>>>
>>>
>>> Lin Sun-2 wrote:
>>>>
>>>> Hi, I tried this with Geronimo 1.1 w/ daytrader.  Basically I  
>>>> need to
>>>> copy the oracle tranql rar file and the oracle jar file into my
>>>> repository, and specify the dependency of the oracle jar file
>>>> somewhere
>>>> in the plan -
>>>>
>>>>
>>>>        <dep:dependency>
>>>>          <dep:groupId>oracle</dep:groupId>
>>>>          <dep:artifactId>classes12</dep:artifactId>
>>>>          <dep:version>10g</dep:version>
>>>>          <dep:type>jar</dep:type>
>>>>        </dep:dependency>
>>>>
>>>>
>>>> and develop a resource adapter plan like below  (below is an
>>>> application
>>>> scoped connection pool plan, but it can also be a server wide  
>>>> plan).
>>>>
>>>>    <ext-module>
>>>>      <connector>TradeDataSource</connector>
>>>>
>>>> <external-path>tranql/tranql-connector-oracle-xa/1.1/rar</external-
>>>> path>
>>>>      <connector
>>>> xmlns="http://geronimo.apache.org/xml/ns/j2ee/connector-1.1">
>>>>        <resourceadapter>
>>>>          <outbound-resourceadapter>
>>>>            <connection-definition>
>>>>
>>>> <connectionfactory-interface>javax.sql.DataSource</
>>>> connectionfactory-interface>
>>>>              <connectiondefinition-instance>
>>>>                <name>jdbc/TradeDataSource</name>
>>>>                <config-property-setting
>>>> name="UserName">trade</config-property-setting>
>>>>                <config-property-setting
>>>> name="Password">trade</config-property-setting>
>>>>                <config-property-setting
>>>> name="DatabaseName">tradedb</config-property-setting>
>>>>                <config-property-setting
>>>> name="DataSourceName">TradeDataSource</config-property-setting>
>>>>                <config-property-setting
>>>> name="ServerName">linsun2</config-property-setting>
>>>>                <config-property-setting
>>>> name="PortNumber">1521</config-property-setting>
>>>>                <config-property-setting
>>>> name="DriverType">thin</config-property-setting>
>>>>                <connectionmanager>
>>>>                  <xa-transaction>
>>>>                    <transaction-caching/>
>>>>                  </xa-transaction>
>>>>                  <single-pool>
>>>>                    <max-size>10</max-size>
>>>>                    <min-size>0</min-size>
>>>>
>>>> <blocking-timeout-milliseconds>5000</blocking-timeout-milliseconds>
>>>>                    <idle-timeout-minutes>30</idle-timeout-minutes>
>>>>                    <match-one/>
>>>>                  </single-pool>
>>>>                </connectionmanager>
>>>>              </connectiondefinition-instance>
>>>>            </connection-definition>
>>>>          </outbound-resourceadapter>
>>>>        </resourceadapter>
>>>>      </connector>
>>>>    </ext-module>
>>>>
>>>> The oracle tranql rar file isn't in the geronimo assembly,
>>>> unfortunatelly.  So you'll have to get it from the Tranql project
>>>> (http://tranql.codehaus.org/Download).  You can download the binary
>>>> (that is a bit old than what I used) or build it yourself.  The
>>>> ra.xml
>>>> inside of the rar file contains what configuration parameters  
>>>> you can
>>>> specify in the connection pool plan.
>>>>
>>>> HTH, Lin
>>>>
>>>> Piers Geyman wrote:
>>>>> Hi,
>>>>>
>>>>> I am trying to migrate from tomcat to geronimo and I am having
>>>>> trouble
>>>>> being
>>>>> able to configure my Oracle RAC datasource in geronimo to use the
>>>>> Oracle
>>>>> Driver's connection pooling rather than the default geonimo  
>>>>> pooling.
>>>>>
>>>>> In tomcat I configured my datasource as follows, which used the
>>>>> Oracle
>>>>> Datasource connection pool rather than DBCP, but I cannot see how
>>>>> I can
>>>>> do
>>>>> the same in Geronimo.
>>>>>
>>>>>
>>>>>         <Resource
>>>>>                 auth="Container"
>>>>>                 description="My Oracle Datasource"
>>>>>                 name="jdbc/myOracleDataSource"
>>>>>                 type="oracle.jdbc.pool.OracleDataSource"
>>>>>                 factory="oracle.jdbc.pool.OracleDataSourceFactory"
>>>>>                 driverClassName="oracle.jdbc.OracleDriver"
>>>>> 			
>>>>> url="jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)
>>>>> (HOST=oraclehost1)(PORT=1529))(ADDRESS=(PROTOCOL=TCP)
>>>>> (HOST=oraclehost2)(PORT=1529))(LOAD_BALANCE=yes)(CONNECT_DATA=
>>>>> (SERVER=DEDICATED)(SERVICE_NAME=TESTDB)))"
>>>>>                 user="devapp"
>>>>>                 password="devapp"
>>>>>                 maxIdle="20"
>>>>>                 minIdle="10"
>>>>>                 maxWait="5000"
>>>>>                 maxActive="100"
>>>>>                 connectionCachingEnabled="true"
>>>>>                 fastConnectionFailoverEnabled="true"
>>>>>                 connectionCacheName="myOracleDatasourceCache"
>>>>>
>>>>> onsConfigStr="nodes=oraclehost1:6200,oraclehost2:6200"
>>>>>
>>>>> connectionProperties="oracle.jdbc.ReadTimeout=30000"/>
>>>>>
>>>>>
>>>>>
>>>>> I see that other connection pools to the databases seem to use
>>>>> tranQL,
>>>>> but
>>>>> there seems to be no documentation for this product.
>>>>>
>>>>> Any help would be appreciated.
>>>>>
>>>>> Thanks and regards
>>>>>
>>>>> Piers
>>>>
>>>>
>>>>
>>>
>>> -- 
>>> View this message in context: http://www.nabble.com/How-to-
>>> configure-a-datasource-to-use-OracleDataSource-for-Datasource-
>>> pooling-tf3921766s134.html#a11121302
>>> Sent from the Apache Geronimo - Users mailing list archive at
>>> Nabble.com.
>>>
>>
>>
>>
>
> -- 
> View this message in context: http://www.nabble.com/How-to- 
> configure-a-datasource-to-use-OracleDataSource-for-Datasource- 
> pooling-tf3921766s134.html#a11123189
> Sent from the Apache Geronimo - Users mailing list archive at  
> Nabble.com.
>


Mime
View raw message