99import io .ebean .datasource .InitDatabase ;
1010import io .ebean .datasource .PoolStatus ;
1111import org .slf4j .Logger ;
12- import org .slf4j .LoggerFactory ;
1312
1413import java .io .PrintWriter ;
1514import java .sql .Connection ;
4241 */
4342public final class ConnectionPool implements DataSourcePool {
4443
45- private static final Logger logger = LoggerFactory . getLogger ( ConnectionPool . class ) ;
44+ private static final Logger log = Log . log ;
4645
4746 private final ReentrantLock heartbeatLock = new ReentrantLock (false );
4847 private final ReentrantLock notifyLock = new ReentrantLock (false );
@@ -200,12 +199,12 @@ private void initialiseConnections() throws SQLException {
200199 "] min[" + minConnections +
201200 "] max[" + maxConnections +
202201 "] in[" + (System .currentTimeMillis () - start ) + "ms]" ;
203- logger .info (msg );
202+ log .info (msg );
204203 } catch (SQLException e ) {
205204 if (failOnStart ) {
206205 throw e ;
207206 }
208- logger .error ("Error trying to ensure minimum connections, maybe db server is down - message:" + e .getMessage (), e );
207+ log .error ("Error trying to ensure minimum connections, maybe db server is down - message:" + e .getMessage (), e );
209208 }
210209 }
211210
@@ -219,7 +218,7 @@ private void initialiseDatabase() throws SQLException {
219218 // successfully obtained a connection so skip initDatabase
220219 connection .clearWarnings ();
221220 } catch (SQLException e ) {
222- logger .info ("Obtaining connection using ownerUsername:{} to initialise database" , config .getOwnerUsername ());
221+ log .info ("Obtaining connection using ownerUsername:{} to initialise database" , config .getOwnerUsername ());
223222 // expected when user does not exist, obtain a connection using owner credentials
224223 try (Connection ownerConnection = createUnpooledConnection (config .getOwnerUsername (), config .getOwnerPassword ())) {
225224 // initialise the DB (typically create the user/role using the owner credentials etc)
@@ -304,7 +303,7 @@ public SQLException getDataSourceDownReason() {
304303 void notifyWarning (String msg ) {
305304 if (inWarningMode .compareAndSet (false , true )) {
306305 // send an Error to the event log...
307- logger .warn (msg );
306+ log .warn (msg );
308307 if (notify != null ) {
309308 notify .dataSourceWarning (this , msg );
310309 }
@@ -325,7 +324,7 @@ private void notifyDown(SQLException reason) {
325324 // check and set false immediately so that we only alert once
326325 dataSourceUp .set (false );
327326 dataSourceDownReason = reason ;
328- logger .error ("FATAL: DataSourcePool [" + name + "] is down or has network error!!!" , reason );
327+ log .error ("FATAL: DataSourcePool [" + name + "] is down or has network error!!!" , reason );
329328 if (notify != null ) {
330329 notify .dataSourceDown (this , reason );
331330 }
@@ -350,12 +349,12 @@ private void notifyUp() {
350349 dataSourceUp .set (true );
351350 startHeartBeatIfStopped ();
352351 dataSourceDownReason = null ;
353- logger .error ("RESOLVED FATAL: DataSourcePool [" + name + "] is back up!" );
352+ log .error ("RESOLVED FATAL: DataSourcePool [" + name + "] is back up!" );
354353 if (notify != null ) {
355354 notify .dataSourceUp (this );
356355 }
357356 } else {
358- logger .info ("DataSourcePool [" + name + " ] is back up!" );
357+ log .info ("DataSourcePool [{} ] is back up!" , name );
359358 }
360359 } finally {
361360 notifyLock .unlock ();
@@ -371,7 +370,7 @@ private void trimIdleConnections() {
371370 queue .trim (maxInactiveMillis , maxAgeMillis );
372371 lastTrimTime = System .currentTimeMillis ();
373372 } catch (Exception e ) {
374- logger .error ("Error trying to trim idle connections - message:" + e .getMessage (), e );
373+ log .error ("Error trying to trim idle connections - message:" + e .getMessage (), e );
375374 }
376375 }
377376 }
@@ -401,7 +400,7 @@ private void checkDataSource() {
401400 conn .close ();
402401 }
403402 } catch (SQLException ex ) {
404- logger .warn ("Can't close connection in checkDataSource!" );
403+ log .warn ("Can't close connection in checkDataSource!" );
405404 }
406405 }
407406 }
@@ -556,14 +555,14 @@ private boolean testConnection(Connection conn) throws SQLException {
556555 rset .close ();
557556 }
558557 } catch (SQLException e ) {
559- logger .error ("Error closing resultSet" , e );
558+ log .error ("Error closing resultSet" , e );
560559 }
561560 try {
562561 if (stmt != null ) {
563562 stmt .close ();
564563 }
565564 } catch (SQLException e ) {
566- logger .error ("Error closing statement" , e );
565+ log .error ("Error closing statement" , e );
567566 }
568567 }
569568 }
@@ -575,7 +574,7 @@ boolean validateConnection(PooledConnection conn) {
575574 try {
576575 return testConnection (conn );
577576 } catch (Exception e ) {
578- logger .warn ("heartbeatsql test failed on connection:" + conn .getName () + " message:" + e .getMessage ());
577+ log .warn ("Heartbeat test failed on connection:" + conn .getName () + " message:" + e .getMessage ());
579578 return false ;
580579 }
581580 }
@@ -617,7 +616,7 @@ private void returnTheConnection(PooledConnection pooledConnection, boolean forc
617616
618617 void returnConnectionReset (PooledConnection pooledConnection ) {
619618 queue .returnPooledConnection (pooledConnection , true );
620- logger .warn ("Resetting DataSourcePool on read-only failure [{}]" , name );
619+ log .warn ("Resetting DataSourcePool on read-only failure [{}]" , name );
621620 reset ();
622621 }
623622
@@ -739,7 +738,7 @@ public void offline() {
739738 private void shutdownPool (boolean closeBusyConnections ) {
740739 stopHeartBeatIfRunning ();
741740 PoolStatus status = queue .shutdown (closeBusyConnections );
742- logger .info ("DataSourcePool [{}] shutdown {} psc[hit:{} miss:{} put:{} rem:{}]" , name , status , pscHit , pscMiss , pscPut , pscRem );
741+ log .info ("DataSourcePool [{}] shutdown {} psc[hit:{} miss:{} put:{} rem:{}]" , name , status , pscHit , pscMiss , pscPut , pscRem );
743742 dataSourceUp .set (false );
744743 }
745744
0 commit comments