-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathDataSourcePool.java
More file actions
118 lines (102 loc) · 2.58 KB
/
DataSourcePool.java
File metadata and controls
118 lines (102 loc) · 2.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
package io.ebean.datasource;
import javax.sql.DataSource;
import java.sql.SQLException;
/**
* DataSource pool API.
*
* <pre>{@code
*
* DataSourcePool pool = DataSourcePool.builder()
* .setName("test")
* .setUrl("jdbc:h2:mem:tests")
* .setUsername("sa")
* .setPassword("")
* .build();
*
* Connection connection = pool.getConnection();
*
* }</pre>
*/
public interface DataSourcePool extends DataSource {
/**
* Return a builder for the DataSourcePool.
*
* <pre>{@code
*
* DataSourcePool pool = DataSourcePool.builder()
* .setName("test")
* .setUrl("jdbc:h2:mem:tests")
* .setUsername("sa")
* .setPassword("")
* .build();
*
* Connection connection = pool.getConnection();
*
* }</pre>
*
*/
static DataSourceBuilder builder() {
return new DataSourceConfig();
}
/**
* Return the dataSource name.
*/
String name();
/**
* Return the current size of the pool. This includes both busy and idle connections.
*/
int size();
/**
* Return true if the pool defaults to using autocommit.
*/
boolean isAutoCommit();
/**
* Return true if the DataSource is online.
* <p>
* Effectively the same as (synonym for) {@link #isDataSourceUp()}.
*/
boolean isOnline();
/**
* Returns false when the dataSource is down.
* <p>
* Effectively the same as (synonym for) {@link #isOnline()}.
*/
boolean isDataSourceUp();
/**
* Bring the DataSource online ensuring min connections and start heart beat checking.
*/
void online() throws SQLException;
/**
* Take the DataSource offline closing all connections and stopping heart beat checking.
*/
void offline();
/**
* Returns a connection for given affinity ID. It is guaranteed, that connection.affinityId in listener etc.
* is the same object.
*/
DataSourceConnection getConnection(Object affinityId) throws SQLException;
/**
* Shutdown the pool.
* <p>
* This is functionally the same as {@link #offline()} but generally we expect to only
* shut down the pool once whereas we can expect to make many calls to offline() and
* online().
*/
void shutdown();
/**
* Return the current status of the connection pool.
* <p>
* With reset true, the counters are reset.
*/
PoolStatus status(boolean reset);
/**
* Returns the reason, why the dataSource is down.
*/
SQLException dataSourceDownReason();
/**
* Set a new maximum size.
* <p>
* The pool will apply the new maximum and not require a restart.
*/
void setMaxSize(int max);
}