Skip to content

Commit c6f37dc

Browse files
authored
Merge pull request #100 from ebean-orm/feature/lambda-detect
Remove ability to modify minConnections at runtime
2 parents 88a092c + 00a6d34 commit c6f37dc

File tree

3 files changed

+13
-39
lines changed

3 files changed

+13
-39
lines changed

ebean-datasource-api/src/main/java/io/ebean/datasource/DataSourcePool.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ static DataSourceBuilder builder() {
4848
String name();
4949

5050
/**
51-
* Deprecated migrate to name().
51+
* @deprecated migrate to {@link #name()}.
5252
*/
5353
@Deprecated
5454
default String getName() {
@@ -106,7 +106,7 @@ default String getName() {
106106
PoolStatus status(boolean reset);
107107

108108
/**
109-
* Deprecated migrate to status().
109+
* @deprecated migrate to {@link #status(boolean)}.
110110
*/
111111
@Deprecated
112112
default PoolStatus getStatus(boolean reset) {
@@ -119,7 +119,7 @@ default PoolStatus getStatus(boolean reset) {
119119
SQLException dataSourceDownReason();
120120

121121
/**
122-
* Deprecated migrate to dataSourceDownReason().
122+
* @deprecated migrate to {@link #dataSourceDownReason()}
123123
*/
124124
@Deprecated
125125
default SQLException getDataSourceDownReason() {
@@ -140,7 +140,7 @@ default SQLException getDataSourceDownReason() {
140140
* and not require a restart. We may want to increase the maxConnections if the
141141
* pool gets large and hits the warning levels.
142142
*/
143-
@Deprecated
143+
@Deprecated(forRemoval = true)
144144
void setWarningSize(int warningSize);
145145

146146
/**
@@ -149,7 +149,7 @@ default SQLException getDataSourceDownReason() {
149149
* Return the warning size. When the pool hits this size it can send a
150150
* warning message to an administrator.
151151
*/
152-
@Deprecated
152+
@Deprecated(forRemoval = true)
153153
int getWarningSize();
154154

155155
}

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

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ final class ConnectionPool implements DataSourcePool {
7171
private final AtomicBoolean dataSourceUp = new AtomicBoolean(false);
7272
private SQLException dataSourceDownReason;
7373
private final AtomicBoolean inWarningMode = new AtomicBoolean();
74-
private int minConnections;
74+
private final int minConnections;
7575
private int maxConnections;
7676
private int warningSize;
7777
private final int waitTimeoutMillis;
@@ -197,8 +197,8 @@ private void initialiseConnections() throws SQLException {
197197
}
198198

199199
final var ro = readOnly ? "readOnly[true] " : "";
200-
Log.info("DataSource [{0}] {1}autoCommit[{2}] transIsolation[{3}] min[{4}] max[{5}] in[{6}ms]",
201-
name, ro, autoCommit, description(transactionIsolation), minConnections, maxConnections, (System.currentTimeMillis() - start));
200+
Log.info("DataSource [{0}] {1}autoCommit[{2}] [{3}] min[{4}] max[{5}] in[{6}ms]",
201+
name, ro, autoCommit, description(transactionIsolation), minConnections, maxConnections, (System.currentTimeMillis() - start), validateOnHeartbeat);
202202
}
203203

204204
/**
@@ -440,25 +440,11 @@ public void setMaxSize(int max) {
440440
this.maxConnections = max;
441441
}
442442

443-
/**
444-
* Return the max size this pool can grow to.
445-
*/
446-
public int getMaxSize() {
443+
int maxSize() {
447444
return maxConnections;
448445
}
449446

450-
/**
451-
* Set the min size this pool should maintain.
452-
*/
453-
public void setMinSize(int min) {
454-
queue.setMinSize(min);
455-
this.minConnections = min;
456-
}
457-
458-
/**
459-
* Return the min size this pool should maintain.
460-
*/
461-
public int getMinSize() {
447+
int minSize() {
462448
return minConnections;
463449
}
464450

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

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ final class PooledConnectionQueue {
3737
private final long waitTimeoutMillis;
3838
private final long leakTimeMinutes;
3939
private final long maxAgeMillis;
40+
private final int minSize;
4041
private int warningSize;
4142
private int maxSize;
42-
private int minSize;
4343
/**
4444
* Number of threads in the wait queue.
4545
*/
@@ -70,8 +70,8 @@ final class PooledConnectionQueue {
7070
PooledConnectionQueue(ConnectionPool pool) {
7171
this.pool = pool;
7272
this.name = pool.name();
73-
this.minSize = pool.getMinSize();
74-
this.maxSize = pool.getMaxSize();
73+
this.minSize = pool.minSize();
74+
this.maxSize = pool.maxSize();
7575
this.warningSize = pool.getWarningSize();
7676
this.waitTimeoutMillis = pool.waitTimeoutMillis();
7777
this.leakTimeMinutes = pool.leakTimeMinutes();
@@ -115,18 +115,6 @@ PoolStatus status(boolean reset) {
115115
}
116116
}
117117

118-
void setMinSize(int minSize) {
119-
lock.lock();
120-
try {
121-
if (minSize > this.maxSize) {
122-
throw new IllegalArgumentException("minSize " + minSize + " > maxSize " + this.maxSize);
123-
}
124-
this.minSize = minSize;
125-
} finally {
126-
lock.unlock();
127-
}
128-
}
129-
130118
void setMaxSize(int maxSize) {
131119
lock.lock();
132120
try {

0 commit comments

Comments
 (0)