Skip to content

Commit 2bc667e

Browse files
committed
Refactor rename methods in PoolStatus with deprecation
Migrate away from getters to accessors
1 parent bdbffb3 commit 2bc667e

5 files changed

Lines changed: 111 additions & 47 deletions

File tree

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

Lines changed: 72 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,40 +8,104 @@ public interface PoolStatus {
88
/**
99
* Return the pools minimum size.
1010
*/
11-
int getMinSize();
11+
int minSize();
12+
13+
/**
14+
* Deprecated migrate to minSize()
15+
*/
16+
@Deprecated
17+
default int getMinSize() {
18+
return minSize();
19+
}
1220

1321
/**
1422
* Return the pools maximum size.
1523
*/
16-
int getMaxSize();
24+
int maxSize();
25+
26+
/**
27+
* Deprecated migrate to maxSize()
28+
*/
29+
@Deprecated
30+
default int getMaxSize() {
31+
return maxSize();
32+
}
1733

1834
/**
1935
* Return number of free connections.
2036
*/
21-
int getFree();
37+
int free();
38+
39+
/**
40+
* Deprecated migrate to free()
41+
*/
42+
@Deprecated
43+
default int getFree() {
44+
return free();
45+
}
2246

2347
/**
2448
* Return number of busy connections.
2549
*/
26-
int getBusy();
50+
int busy();
51+
52+
/**
53+
* Deprecated migrate to busy()
54+
*/
55+
@Deprecated
56+
default int getBusy() {
57+
return busy();
58+
}
2759

2860
/**
2961
* Return the number of threads waiting for connections.
3062
*/
31-
int getWaiting();
63+
int waiting();
64+
65+
/**
66+
* Deprecated migrate to waiting()
67+
*/
68+
@Deprecated
69+
default int getWaiting() {
70+
return waiting();
71+
}
3272

3373
/**
3474
* Return the busy connection high water mark.
3575
*/
36-
int getHighWaterMark();
76+
int highWaterMark();
77+
78+
/**
79+
* Deprecated migrate to waiting()
80+
*/
81+
@Deprecated
82+
default int getHighWaterMark() {
83+
return highWaterMark();
84+
}
3785

3886
/**
3987
* Return the number of times threads had to wait for connections.
4088
*/
41-
int getWaitCount();
89+
int waitCount();
90+
91+
/**
92+
* Deprecated migrate to waitCount()
93+
*/
94+
@Deprecated
95+
default int getWaitCount() {
96+
return waitCount();
97+
}
4298

4399
/**
44100
* Return the hit count against the pool.
45101
*/
46-
int getHitCount();
102+
int hitCount();
103+
104+
/**
105+
* Deprecated migrate to hitCount()
106+
*/
107+
@Deprecated
108+
default int getHitCount() {
109+
return hitCount();
110+
}
47111
}

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -867,55 +867,55 @@ public String toString() {
867867
* Return the min pool size.
868868
*/
869869
@Override
870-
public int getMinSize() {
870+
public int minSize() {
871871
return minSize;
872872
}
873873

874874
/**
875875
* Return the max pool size.
876876
*/
877877
@Override
878-
public int getMaxSize() {
878+
public int maxSize() {
879879
return maxSize;
880880
}
881881

882882
/**
883883
* Return the current number of free connections in the pool.
884884
*/
885885
@Override
886-
public int getFree() {
886+
public int free() {
887887
return free;
888888
}
889889

890890
/**
891891
* Return the current number of busy connections in the pool.
892892
*/
893893
@Override
894-
public int getBusy() {
894+
public int busy() {
895895
return busy;
896896
}
897897

898898
/**
899899
* Return the current number of threads waiting for a connection.
900900
*/
901901
@Override
902-
public int getWaiting() {
902+
public int waiting() {
903903
return waiting;
904904
}
905905

906906
/**
907907
* Return the high water mark of busy connections.
908908
*/
909909
@Override
910-
public int getHighWaterMark() {
910+
public int highWaterMark() {
911911
return highWaterMark;
912912
}
913913

914914
/**
915915
* Return the total number of times a thread had to wait.
916916
*/
917917
@Override
918-
public int getWaitCount() {
918+
public int waitCount() {
919919
return waitCount;
920920
}
921921

@@ -928,7 +928,7 @@ public int getWaitCount() {
928928
* </p>
929929
*/
930930
@Override
931-
public int getHitCount() {
931+
public int hitCount() {
932932
return hitCount;
933933
}
934934

ebean-datasource/src/test/java/io/ebean/datasource/pool/ConnectionPoolOfflineTest.java

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -41,24 +41,24 @@ public void testOffline() throws InterruptedException, SQLException {
4141
log.info("pool created ");
4242

4343
waitFor(() -> {
44-
assertEquals(0, pool.status(false).getFree());
45-
assertEquals(0, pool.status(false).getBusy());
44+
assertEquals(0, pool.status(false).free());
45+
assertEquals(0, pool.status(false).busy());
4646
assertThat(pool.size()).isEqualTo(0);
4747
});
4848

4949
pool.online();
5050
log.info("pool online");
5151
assertThat(pool.isOnline()).isTrue();
52-
assertEquals(2, pool.status(false).getFree());
53-
assertEquals(0, pool.status(false).getBusy());
52+
assertEquals(2, pool.status(false).free());
53+
assertEquals(0, pool.status(false).busy());
5454
assertThat(pool.size()).isEqualTo(2);
5555

5656
pool.offline();
5757
log.info("pool offline");
5858
waitFor(() -> {
5959
assertThat(pool.isOnline()).isFalse();
60-
assertEquals(0, pool.status(false).getFree());
61-
assertEquals(0, pool.status(false).getBusy());
60+
assertEquals(0, pool.status(false).free());
61+
assertEquals(0, pool.status(false).busy());
6262
assertThat(pool.size()).isEqualTo(0);
6363
});
6464

@@ -67,17 +67,17 @@ public void testOffline() throws InterruptedException, SQLException {
6767

6868
waitFor(() -> {
6969
assertThat(pool.isOnline()).isTrue();
70-
assertEquals(2, pool.status(false).getFree());
71-
assertEquals(0, pool.status(false).getBusy());
70+
assertEquals(2, pool.status(false).free());
71+
assertEquals(0, pool.status(false).busy());
7272
assertThat(pool.size()).isEqualTo(2);
7373
});
7474

7575
pool.shutdown();
7676

7777
waitFor(() -> {
7878
assertThat(pool.isOnline()).isFalse();
79-
assertEquals(0, pool.status(false).getFree());
80-
assertEquals(0, pool.status(false).getBusy());
79+
assertEquals(0, pool.status(false).free());
80+
assertEquals(0, pool.status(false).busy());
8181
assertThat(pool.size()).isEqualTo(0);
8282
});
8383
}
@@ -126,19 +126,19 @@ public void offline_whenBusy_allowed() throws SQLException, InterruptedException
126126

127127
Thread.sleep(200);
128128
System.out.println("-- taking pool offline (with a busy connection)");
129-
assertEquals(1, pool.status(false).getBusy());
129+
assertEquals(1, pool.status(false).busy());
130130
assertThat(pool.size()).isEqualTo(2);
131131

132132
pool.offline();
133-
assertEquals(0, pool.status(false).getFree());
134-
assertEquals(1, pool.status(false).getBusy()); // still 1 busy connection
133+
assertEquals(0, pool.status(false).free());
134+
assertEquals(1, pool.status(false).busy()); // still 1 busy connection
135135
assertThat(pool.size()).isEqualTo(1);
136136

137137
// wait to let busy connection finish and close
138138
waitFor(() -> {
139139
// all done now
140-
assertEquals(0, pool.status(false).getFree());
141-
assertEquals(0, pool.status(false).getBusy());
140+
assertEquals(0, pool.status(false).free());
141+
assertEquals(0, pool.status(false).busy());
142142
assertThat(pool.size()).isEqualTo(0);
143143
});
144144
}

ebean-datasource/src/test/java/io/ebean/datasource/pool/ConnectionPoolTest.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,28 +40,28 @@ void getConnection_expect_poolGrowsAboveMin() throws SQLException {
4040
Connection con1 = pool.getConnection();
4141
Connection con2 = pool.getConnection();
4242

43-
assertThat(pool.status(false).getBusy()).isEqualTo(2);
44-
assertThat(pool.status(false).getFree()).isEqualTo(0);
43+
assertThat(pool.status(false).busy()).isEqualTo(2);
44+
assertThat(pool.status(false).free()).isEqualTo(0);
4545
assertThat(pool.size()).isEqualTo(2);
4646

4747
Connection con3 = pool.getConnection();
48-
assertThat(pool.status(false).getBusy()).isEqualTo(3);
49-
assertThat(pool.status(false).getFree()).isEqualTo(0);
48+
assertThat(pool.status(false).busy()).isEqualTo(3);
49+
assertThat(pool.status(false).free()).isEqualTo(0);
5050
assertThat(pool.size()).isEqualTo(3);
5151

5252
con2.close();
53-
assertThat(pool.status(false).getBusy()).isEqualTo(2);
54-
assertThat(pool.status(false).getFree()).isEqualTo(1);
53+
assertThat(pool.status(false).busy()).isEqualTo(2);
54+
assertThat(pool.status(false).free()).isEqualTo(1);
5555
assertThat(pool.size()).isEqualTo(3);
5656

5757
con3.close();
58-
assertThat(pool.status(false).getBusy()).isEqualTo(1);
59-
assertThat(pool.status(false).getFree()).isEqualTo(2);
58+
assertThat(pool.status(false).busy()).isEqualTo(1);
59+
assertThat(pool.status(false).free()).isEqualTo(2);
6060
assertThat(pool.size()).isEqualTo(3);
6161

6262
con1.close();
63-
assertThat(pool.status(false).getBusy()).isEqualTo(0);
64-
assertThat(pool.status(false).getFree()).isEqualTo(3);
63+
assertThat(pool.status(false).busy()).isEqualTo(0);
64+
assertThat(pool.status(false).free()).isEqualTo(3);
6565
assertThat(pool.size()).isEqualTo(3);
6666
}
6767

ebean-datasource/src/test/java/io/ebean/datasource/pool/ConnectionPoolTrimIdleTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ public void test() throws SQLException, InterruptedException {
4545
con3.close();
4646
con4.close();
4747
assertThat(pool.size()).isEqualTo(4);
48-
assertThat(pool.status(false).getFree()).isEqualTo(4);
48+
assertThat(pool.status(false).free()).isEqualTo(4);
4949

5050
waitFor(() -> {
51-
assertThat(pool.status(false).getFree()).isEqualTo(1);
51+
assertThat(pool.status(false).free()).isEqualTo(1);
5252
assertThat(pool.size()).isEqualTo(1);
5353
});
5454
} finally {
@@ -71,28 +71,28 @@ public void test_withDecreasingActivity_expect_trimToActivityLevel() throws SQLE
7171
}
7272

7373
// start at 10 connections
74-
assertThat(pool.status(false).getFree()).isEqualTo(10);
74+
assertThat(pool.status(false).free()).isEqualTo(10);
7575
assertThat(pool.size()).isEqualTo(10);
7676

7777
// keep 4 connections busy
7878
Timer timer0 = createTimer(pool, 4);
7979

8080
waitFor(() -> {
81-
assertThat(pool.status(false).getFree()).isEqualTo(4);
81+
assertThat(pool.status(false).free()).isEqualTo(4);
8282
});
8383
timer0.cancel();
8484

8585
// keep 2 connections busy
8686
Timer timer1 = createTimer(pool, 2);
8787

8888
waitFor(() -> {
89-
assertThat(pool.status(false).getFree()).isEqualTo(2);
89+
assertThat(pool.status(false).free()).isEqualTo(2);
9090
});
9191
timer1.cancel();
9292

9393
// Go Idle
9494
waitFor(() -> {
95-
assertThat(pool.status(false).getFree()).isEqualTo(1);
95+
assertThat(pool.status(false).free()).isEqualTo(1);
9696
assertThat(pool.size()).isEqualTo(1);
9797
});
9898
} finally {

0 commit comments

Comments
 (0)