Skip to content

Commit 5d0a0fb

Browse files
committed
Small improvement to logging
1 parent b10985e commit 5d0a0fb

File tree

4 files changed

+15
-18
lines changed

4 files changed

+15
-18
lines changed

ebean-datasource/src/main/java/io/ebean/datasource/pool/BusyConnectionBuffer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ void closeBusyConnections(long leakTimeMinutes) {
106106

107107
private void closeBusyConnection(PooledConnection pc) {
108108
try {
109-
Log.warn("DataSourcePool closing busy connection? {0}", pc.fullDescription());
109+
Log.warn("DataSource closing busy connection? {0}", pc.fullDescription());
110110
System.out.println("CLOSING busy connection: " + pc.fullDescription());
111111
pc.closeConnectionFully(false);
112112
} catch (Exception ex) {

ebean-datasource/src/main/java/io/ebean/datasource/pool/ConnectionPool.java

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
import java.util.concurrent.atomic.LongAdder;
1212
import java.util.concurrent.locks.ReentrantLock;
1313

14+
import static io.ebean.datasource.pool.TransactionIsolation.description;
15+
1416
/**
1517
* A robust DataSource implementation.
1618
* <ul>
@@ -225,13 +227,8 @@ private void initialiseConnections() throws SQLException {
225227
tryEnsureMinimumConnections();
226228
}
227229
startHeartBeatIfStopped();
228-
String msg = "DataSourcePool [" + name +
229-
"] autoCommit[" + autoCommit +
230-
"] transIsolation[" + TransactionIsolation.getDescription(transactionIsolation) +
231-
"] min[" + minConnections +
232-
"] max[" + maxConnections +
233-
"] in[" + (System.currentTimeMillis() - start) + "ms]";
234-
Log.info(msg);
230+
Log.info("DataSource [{0}] autoCommit[{1}] transIsolation[{2}] min[{3}] max[{4}] in[{5}ms]",
231+
name, autoCommit, description(transactionIsolation), minConnections, maxConnections, (System.currentTimeMillis() - start));
235232
}
236233

237234
/**
@@ -336,7 +333,7 @@ private void notifyDown(SQLException reason) {
336333
// check and set false immediately so that we only alert once
337334
dataSourceUp.set(false);
338335
dataSourceDownReason = reason;
339-
Log.error("FATAL: DataSourcePool [" + name + "] is down or has network error!!!", reason);
336+
Log.error("FATAL: DataSource [" + name + "] is down or has network error!!!", reason);
340337
if (notify != null) {
341338
notify.dataSourceDown(this, reason);
342339
}
@@ -361,12 +358,12 @@ private void notifyUp() {
361358
dataSourceUp.set(true);
362359
startHeartBeatIfStopped();
363360
dataSourceDownReason = null;
364-
Log.error("RESOLVED FATAL: DataSourcePool [" + name + "] is back up!");
361+
Log.error("RESOLVED FATAL: DataSource [" + name + "] is back up!");
365362
if (notify != null) {
366363
notify.dataSourceUp(this);
367364
}
368365
} else {
369-
Log.info("DataSourcePool [{0}] is back up!", name);
366+
Log.info("DataSource [{0}] is back up!", name);
370367
}
371368
} finally {
372369
notifyLock.unlock();
@@ -620,7 +617,7 @@ private void returnTheConnection(PooledConnection pooledConnection, boolean forc
620617

621618
void returnConnectionReset(PooledConnection pooledConnection) {
622619
queue.returnPooledConnection(pooledConnection, true);
623-
Log.warn("Resetting DataSourcePool on read-only failure [{0}]", name);
620+
Log.warn("Resetting DataSource on read-only failure [{0}]", name);
624621
reset();
625622
}
626623

@@ -701,7 +698,7 @@ public void offline() {
701698
private void shutdownPool(boolean closeBusyConnections) {
702699
stopHeartBeatIfRunning();
703700
PoolStatus status = queue.shutdown(closeBusyConnections);
704-
Log.info("DataSourcePool [{0}] shutdown {1} psc[hit:{2} miss:{3} put:{4} rem:{5}]", name, status, pscHit, pscMiss, pscPut, pscRem);
701+
Log.info("DataSource [{0}] shutdown {1} psc[hit:{2} miss:{3} put:{4} rem:{5}]", name, status, pscHit, pscMiss, pscPut, pscRem);
705702
dataSourceUp.set(false);
706703
}
707704

ebean-datasource/src/main/java/io/ebean/datasource/pool/PooledConnectionQueue.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ private PooledConnection _obtainConnection() throws InterruptedException, SQLExc
234234
PooledConnection c = pool.createConnectionForQueue(connectionId++);
235235
int busySize = registerBusyConnection(c);
236236
if (Log.isLoggable(Level.DEBUG)) {
237-
Log.debug("DataSourcePool [{0}] grow; id[{1}] busy[{2}] max[{3}]", name, c.name(), busySize, maxSize);
237+
Log.debug("DataSource [{0}] grow; id[{1}] busy[{2}] max[{3}]", name, c.name(), busySize, maxSize);
238238
}
239239
checkForWarningSize();
240240
return c;
@@ -318,7 +318,7 @@ void reset(long leakTimeMinutes) {
318318
lock.lock();
319319
try {
320320
PoolStatus status = createStatus();
321-
Log.info("Resetting DataSourcePool [{0}] {1}", name, status);
321+
Log.info("Resetting DataSource [{0}] {1}", name, status);
322322
lastResetTime = System.currentTimeMillis();
323323

324324
closeFreeConnections(false);
@@ -358,7 +358,7 @@ private int trimInactiveConnections(long maxInactiveMillis, long maxAgeMillis) {
358358

359359
int trimmedCount = freeList.trim(usedSince, createdSince);
360360
if (trimmedCount > 0) {
361-
Log.debug("DataSourcePool [{0}] trimmed [{1}] inactive connections. New size[{2}]", name, trimmedCount, totalConnections());
361+
Log.debug("DataSource [{0}] trimmed [{1}] inactive connections. New size[{2}]", name, trimmedCount, totalConnections());
362362
}
363363
return trimmedCount;
364364
}
@@ -407,7 +407,7 @@ private void checkForWarningSize() {
407407
int availableGrowth = (maxSize - totalConnections());
408408
if (availableGrowth < warningSize) {
409409
closeBusyConnections(leakTimeMinutes);
410-
pool.notifyWarning("DataSourcePool [" + name + "] is [" + availableGrowth + "] connections from its maximum size.");
410+
pool.notifyWarning("DataSource [" + name + "] is [" + availableGrowth + "] connections from its maximum size.");
411411
}
412412
}
413413

ebean-datasource/src/main/java/io/ebean/datasource/pool/TransactionIsolation.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ final class TransactionIsolation {
1010
/**
1111
* Return the string description of the transaction isolation level specified.
1212
*/
13-
static String getDescription(int level) {
13+
static String description(int level) {
1414
switch (level) {
1515
case Connection.TRANSACTION_NONE:
1616
return "NONE";

0 commit comments

Comments
 (0)