Skip to content

Commit 60852aa

Browse files
committed
Zwischencommit
1 parent 6c13ccd commit 60852aa

8 files changed

Lines changed: 400 additions & 11 deletions

File tree

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -879,6 +879,11 @@ interface Settings extends DataSourceBuilder {
879879
*/
880880
Driver driver();
881881

882+
/**
883+
* Returns the name of the pool.
884+
*/
885+
String name();
886+
882887
/**
883888
* Return the driver class to use (if an instance is not provided).
884889
*/

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public class DataSourceConfig implements DataSourceBuilder.Settings {
8585
private boolean shutdownOnJvmExit;
8686
private boolean validateOnHeartbeat = !System.getenv().containsKey("LAMBDA_TASK_ROOT");
8787
private boolean enforceCleanClose;
88-
private int affinitySize = 257;
88+
private int affinitySize = 0;
8989
private Supplier<Object> affinityProvider;
9090

9191
@Override
@@ -225,6 +225,11 @@ public DataSourceConfig setName(String name) {
225225
return this;
226226
}
227227

228+
@Override
229+
public String name() {
230+
return name;
231+
}
232+
228233
@Override
229234
public DataSource dataSource() {
230235
return dataSource;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public interface DataSourcePoolListener {
1818
/**
1919
* allows interception in the init phase.
2020
*/
21-
default Connection initConnection(DataSourcePool pool, Connection conn) {
21+
default Connection initConnection(DataSourcePool pool, Connection conn) throws SQLException {
2222
return conn;
2323
}
2424

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,12 +127,11 @@ final class ConnectionPool implements DataSourcePool {
127127
this.applicationName = params.getApplicationName();
128128
this.clientInfo = params.getClientInfo();
129129
if (params.getAffinityProvider() == null) {
130-
this.affinitySize = 0;
131130
this.affinityProvider = () -> null; // dummy
132131
} else {
133132
this.affinityProvider = params.getAffinityProvider();
134-
this.affinitySize = params.getAffinitySize();
135133
}
134+
this.affinitySize = params.getAffinitySize();
136135
this.queue = new PooledConnectionQueue(this);
137136
this.schema = params.getSchema();
138137
this.catalog = params.catalog();
@@ -190,7 +189,12 @@ private void tryEnsureMinimumConnections() {
190189
notify.dataSourceUp(this);
191190
}
192191
} catch (SQLException e) {
192+
dataSourceUp.set(false);
193+
dataSourceDownReason = e;
193194
Log.error("Error trying to ensure minimum connections, maybe db server is down - message:" + e.getMessage(), e);
195+
if (notify != null) {
196+
notify.dataSourceDown(this, e);
197+
}
194198
} finally {
195199
notifyLock.unlock();
196200
}

0 commit comments

Comments
 (0)