Main Page | Packages | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages

org.objectweb.cjdbc.controller.connection.FailFastPoolConnectionManager Class Reference

Inheritance diagram for org.objectweb.cjdbc.controller.connection.FailFastPoolConnectionManager:

Inheritance graph
[legend]
Collaboration diagram for org.objectweb.cjdbc.controller.connection.FailFastPoolConnectionManager:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 FailFastPoolConnectionManager (String backendUrl, String backendName, String login, String password, String driverPath, String driverClassName, int poolSize)
Connection getConnection () throws UnreachableBackendException
synchronized void releaseConnection (Connection c)
synchronized void deleteConnection (Connection c)
String getXmlImpl ()

Protected Member Functions

Object clone () throws CloneNotSupportedException

Detailed Description

This connection manager returns null when the pool is empty. Therefore all requests fail fast until connections are freed.

Author:
Emmanuel Cecchet

Nicolas Modrzyk

Version:
1.0

Definition at line 43 of file FailFastPoolConnectionManager.java.


Constructor & Destructor Documentation

org.objectweb.cjdbc.controller.connection.FailFastPoolConnectionManager.FailFastPoolConnectionManager String  backendUrl,
String  backendName,
String  login,
String  password,
String  driverPath,
String  driverClassName,
int  poolSize
 

Creates a new FailFastPoolConnectionManager instance.

Parameters:
backendUrl URL of the DatabaseBackend owning this connection manager
backendName name of the DatabaseBackend owning this connection manager
login backend connection login to be used by this connection manager
password backend connection password to be used by this connection manager
driverPath path for driver
driverClassName class name for driver
poolSize size of the connection pool

Definition at line 63 of file FailFastPoolConnectionManager.java.

00066   {
00067     super(backendUrl, backendName, login, password, driverPath,
00068         driverClassName, poolSize);
00069   }


Member Function Documentation

Object org.objectweb.cjdbc.controller.connection.FailFastPoolConnectionManager.clone  )  throws CloneNotSupportedException [protected, virtual]
 

See also:
java.lang.Object#clone()

Implements org.objectweb.cjdbc.controller.connection.AbstractConnectionManager.

Definition at line 196 of file FailFastPoolConnectionManager.java.

00197   {
00198     return new FailFastPoolConnectionManager(backendUrl, backendName, rLogin,
00199         rPassword, driverPath, driverClassName, poolSize);
00200   }

synchronized void org.objectweb.cjdbc.controller.connection.FailFastPoolConnectionManager.deleteConnection Connection  c  )  [virtual]
 

See also:
org.objectweb.cjdbc.controller.connection.AbstractPoolConnectionManager.deleteConnection(Connection)

Implements org.objectweb.cjdbc.controller.connection.AbstractConnectionManager.

Definition at line 155 of file FailFastPoolConnectionManager.java.

References org.objectweb.cjdbc.common.log.Trace.debug(), and org.objectweb.cjdbc.common.log.Trace.error().

00156   {
00157     if (!initialized)
00158       return; // We probably have been disabled
00159 
00160     if (activeConnections.remove(c))
00161     {
00162       Connection newConnection = getConnectionFromDriver();
00163       if (newConnection == null)
00164       {
00165         if (logger.isDebugEnabled())
00166           logger.error(Translate
00167               .get("connection.replaced.failed", c.toString()));
00168       }
00169       else
00170       {
00171         freeConnections.push(newConnection);
00172         if (logger.isDebugEnabled())
00173           logger.debug(Translate.get("connection.replaced.success", c
00174               .toString()));
00175       }
00176     }
00177     else
00178       logger.error(Translate.get("connection.replaced.failed.exception", c
00179           .toString()));
00180   }

Connection org.objectweb.cjdbc.controller.connection.FailFastPoolConnectionManager.getConnection  )  throws UnreachableBackendException [virtual]
 

Gets a connection from the pool. Returns null if the pool is empty.

Returns:
a connection from the pool or null if the pool is exhausted
Exceptions:
UnreachableBackendException if the backend must be disabled
See also:
org.objectweb.cjdbc.controller.connection.AbstractConnectionManager.getConnection()

Implements org.objectweb.cjdbc.controller.connection.AbstractConnectionManager.

Definition at line 80 of file FailFastPoolConnectionManager.java.

References org.objectweb.cjdbc.common.log.Trace.error(), org.objectweb.cjdbc.controller.connection.AbstractConnectionManager.getConnectionFromDriver(), org.objectweb.cjdbc.common.log.Trace.info(), org.objectweb.cjdbc.common.log.Trace.isWarnEnabled(), and org.objectweb.cjdbc.common.log.Trace.warn().

00081   {
00082     if (!initialized)
00083     {
00084       logger.error(Translate.get("connection.request.not.initialized"));
00085       return null;
00086     }
00087 
00088     try
00089     { // Both freeConnections and activeConnections are synchronized
00090       Connection c = (Connection) freeConnections.pop();
00091       activeConnections.add(c);
00092       return c;
00093     }
00094     catch (EmptyStackException e)
00095     {
00096       synchronized (this)
00097       {
00098         int missing = poolSize
00099             - (activeConnections.size() + freeConnections.size());
00100         if (missing > 0)
00101         { // Re-allocate missing connections
00102           logger.info(Translate.get("connection.reallocate.missing", missing));
00103           Connection connectionToBeReturned = null;
00104           while (missing > 0)
00105           {
00106             Connection c = getConnectionFromDriver();
00107             if (c == null)
00108             {
00109               if (missing == poolSize)
00110               {
00111                 logger.error(Translate.get("connection.backend.unreachable",
00112                     backendName));
00113                 throw new UnreachableBackendException();
00114               }
00115               logger.warn(Translate
00116                   .get("connection.reallocate.failed", missing));
00117               break;
00118             }
00119             else
00120             {
00121               if (connectionToBeReturned == null)
00122                 connectionToBeReturned = c;
00123               else
00124                 freeConnections.add(c);
00125             }
00126             missing--;
00127           }
00128           return connectionToBeReturned;
00129         }
00130       }
00131       if (logger.isWarnEnabled())
00132         logger.warn(Translate.get("connection.backend.out.of.connections",
00133             new String[]{backendName, String.valueOf(poolSize)}));
00134       return null;
00135     }
00136   }

String org.objectweb.cjdbc.controller.connection.FailFastPoolConnectionManager.getXmlImpl  )  [virtual]
 

See also:
org.objectweb.cjdbc.controller.connection.AbstractConnectionManager.getXmlImpl()

Implements org.objectweb.cjdbc.controller.connection.AbstractConnectionManager.

Definition at line 185 of file FailFastPoolConnectionManager.java.

00186   {
00187     StringBuffer info = new StringBuffer();
00188     info.append("<" + DatabasesXmlTags.ELT_FailFastPoolConnectionManager + " "
00189         + DatabasesXmlTags.ATT_poolSize + "=\"" + poolSize / 1000 + "\"/>");
00190     return info.toString();
00191   }

synchronized void org.objectweb.cjdbc.controller.connection.FailFastPoolConnectionManager.releaseConnection Connection  c  )  [virtual]
 

See also:
org.objectweb.cjdbc.controller.connection.AbstractPoolConnectionManager.releaseConnection(Connection)

Implements org.objectweb.cjdbc.controller.connection.AbstractConnectionManager.

Definition at line 141 of file FailFastPoolConnectionManager.java.

References org.objectweb.cjdbc.common.log.Trace.error().

00142   {
00143     if (!initialized)
00144       return; // We probably have been disabled
00145 
00146     if (activeConnections.remove(c))
00147       freeConnections.push(c);
00148     else
00149       logger.error(Translate.get("connection.release.failed", c.toString()));
00150   }


The documentation for this class was generated from the following file:
Generated on Mon Apr 11 22:03:40 2005 for C-JDBC by  doxygen 1.3.9.1