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 |
null
when the pool is empty. Therefore all requests fail fast until connections are freed.
Definition at line 43 of file FailFastPoolConnectionManager.java.
|
Creates a new
Definition at line 63 of file FailFastPoolConnectionManager.java. 00066 { 00067 super(backendUrl, backendName, login, password, driverPath, 00068 driverClassName, poolSize); 00069 }
|
|
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 }
|
|
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 }
|
|
Gets a connection from the pool. Returns
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 }
|
|
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 }
|
|
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 }
|