63
63
import software .amazon .jdbc .dialect .Dialect ;
64
64
import software .amazon .jdbc .hostavailability .SimpleHostAvailabilityStrategy ;
65
65
import software .amazon .jdbc .targetdriverdialect .TargetDriverDialect ;
66
+ import software .amazon .jdbc .util .connection .ConnectionService ;
67
+ import software .amazon .jdbc .util .monitoring .MonitorService ;
68
+ import software .amazon .jdbc .util .storage .StorageService ;
66
69
import software .amazon .jdbc .util .telemetry .GaugeCallable ;
67
70
import software .amazon .jdbc .util .telemetry .TelemetryContext ;
68
71
import software .amazon .jdbc .util .telemetry .TelemetryCounter ;
@@ -89,7 +92,11 @@ public class PluginBenchmarks {
89
92
private final HostSpec writerHostSpec = new HostSpecBuilder (new SimpleHostAvailabilityStrategy ())
90
93
.host (TEST_HOST ).port (TEST_PORT ).build ();
91
94
95
+ @ Mock private StorageService mockStorageService ;
96
+ @ Mock private MonitorService mockMonitorService ;
97
+ @ Mock private ConnectionService mockConnectionService ;
92
98
@ Mock private PluginService mockPluginService ;
99
+ @ Mock private TargetDriverDialect mockTargetDriverDialect ;
93
100
@ Mock private Dialect mockDialect ;
94
101
@ Mock private ConnectionPluginManager mockConnectionPluginManager ;
95
102
@ Mock private TelemetryFactory mockTelemetryFactory ;
@@ -158,59 +165,48 @@ public void initAndReleaseBaseLine() {
158
165
159
166
@ Benchmark
160
167
public ConnectionWrapper initAndReleaseWithExecutionTimePlugin () throws SQLException {
161
- try (ConnectionWrapper wrapper = new TestConnectionWrapper (
162
- useExecutionTimePlugin (),
163
- CONNECTION_STRING ,
164
- mockConnectionPluginManager ,
165
- mockTelemetryFactory ,
166
- mockPluginService ,
167
- mockHostListProviderService ,
168
- mockPluginManagerService )) {
168
+ try (ConnectionWrapper wrapper = getConnectionWrapper (useExecutionTimePlugin (), CONNECTION_STRING )) {
169
169
wrapper .releaseResources ();
170
170
return wrapper ;
171
171
}
172
172
}
173
173
174
- @ Benchmark
175
- public ConnectionWrapper initAndReleaseWithAuroraHostListPlugin () throws SQLException {
176
- try (ConnectionWrapper wrapper = new TestConnectionWrapper (
177
- useAuroraHostListPlugin (),
178
- CONNECTION_STRING ,
174
+ private ConnectionWrapper getConnectionWrapper (Properties props , String connString ) throws SQLException {
175
+ return new TestConnectionWrapper (
176
+ props ,
177
+ connString ,
178
+ mockConnectionProvider ,
179
+ mockTargetDriverDialect ,
179
180
mockConnectionPluginManager ,
180
181
mockTelemetryFactory ,
181
182
mockPluginService ,
182
183
mockHostListProviderService ,
183
- mockPluginManagerService )) {
184
+ mockPluginManagerService ,
185
+ mockStorageService ,
186
+ mockMonitorService ,
187
+ mockConnectionService );
188
+ }
189
+
190
+ @ Benchmark
191
+ public ConnectionWrapper initAndReleaseWithAuroraHostListPlugin () throws SQLException {
192
+ try (ConnectionWrapper wrapper = getConnectionWrapper (useAuroraHostListPlugin (), CONNECTION_STRING )) {
184
193
wrapper .releaseResources ();
185
194
return wrapper ;
186
195
}
187
196
}
188
197
189
198
@ Benchmark
190
199
public ConnectionWrapper initAndReleaseWithExecutionTimeAndAuroraHostListPlugins () throws SQLException {
191
- try (ConnectionWrapper wrapper = new TestConnectionWrapper (
192
- useExecutionTimeAndAuroraHostListPlugins (),
193
- CONNECTION_STRING ,
194
- mockConnectionPluginManager ,
195
- mockTelemetryFactory ,
196
- mockPluginService ,
197
- mockHostListProviderService ,
198
- mockPluginManagerService )) {
200
+ try (ConnectionWrapper wrapper =
201
+ getConnectionWrapper (useExecutionTimeAndAuroraHostListPlugins (), CONNECTION_STRING )) {
199
202
wrapper .releaseResources ();
200
203
return wrapper ;
201
204
}
202
205
}
203
206
204
207
@ Benchmark
205
208
public ConnectionWrapper initAndReleaseWithReadWriteSplittingPlugin () throws SQLException {
206
- try (ConnectionWrapper wrapper = new TestConnectionWrapper (
207
- useReadWriteSplittingPlugin (),
208
- CONNECTION_STRING ,
209
- mockConnectionPluginManager ,
210
- mockTelemetryFactory ,
211
- mockPluginService ,
212
- mockHostListProviderService ,
213
- mockPluginManagerService )) {
209
+ try (ConnectionWrapper wrapper = getConnectionWrapper (useReadWriteSplittingPlugin (), CONNECTION_STRING )) {
214
210
wrapper .releaseResources ();
215
211
return wrapper ;
216
212
}
@@ -219,14 +215,8 @@ public ConnectionWrapper initAndReleaseWithReadWriteSplittingPlugin() throws SQL
219
215
@ Benchmark
220
216
public ConnectionWrapper initAndReleaseWithAuroraHostListAndReadWriteSplittingPlugin ()
221
217
throws SQLException {
222
- try (ConnectionWrapper wrapper = new TestConnectionWrapper (
223
- useAuroraHostListAndReadWriteSplittingPlugin (),
224
- PG_CONNECTION_STRING ,
225
- mockConnectionPluginManager ,
226
- mockTelemetryFactory ,
227
- mockPluginService ,
228
- mockHostListProviderService ,
229
- mockPluginManagerService )) {
218
+ try (ConnectionWrapper wrapper =
219
+ getConnectionWrapper (useAuroraHostListAndReadWriteSplittingPlugin (), PG_CONNECTION_STRING )) {
230
220
wrapper .releaseResources ();
231
221
return wrapper ;
232
222
}
@@ -237,14 +227,7 @@ public ConnectionWrapper initAndReleaseWithReadWriteSplittingPlugin_internalConn
237
227
HikariPooledConnectionProvider provider =
238
228
new HikariPooledConnectionProvider ((hostSpec , props ) -> new HikariConfig ());
239
229
Driver .setCustomConnectionProvider (provider );
240
- try (ConnectionWrapper wrapper = new TestConnectionWrapper (
241
- useReadWriteSplittingPlugin (),
242
- CONNECTION_STRING ,
243
- mockConnectionPluginManager ,
244
- mockTelemetryFactory ,
245
- mockPluginService ,
246
- mockHostListProviderService ,
247
- mockPluginManagerService )) {
230
+ try (ConnectionWrapper wrapper = getConnectionWrapper (useReadWriteSplittingPlugin (), CONNECTION_STRING )) {
248
231
wrapper .releaseResources ();
249
232
ConnectionProviderManager .releaseResources ();
250
233
Driver .resetCustomConnectionProvider ();
@@ -258,14 +241,8 @@ public ConnectionWrapper initAndReleaseWithAuroraHostListAndReadWriteSplittingPl
258
241
HikariPooledConnectionProvider provider =
259
242
new HikariPooledConnectionProvider ((hostSpec , props ) -> new HikariConfig ());
260
243
Driver .setCustomConnectionProvider (provider );
261
- try (ConnectionWrapper wrapper = new TestConnectionWrapper (
262
- useAuroraHostListAndReadWriteSplittingPlugin (),
263
- PG_CONNECTION_STRING ,
264
- mockConnectionPluginManager ,
265
- mockTelemetryFactory ,
266
- mockPluginService ,
267
- mockHostListProviderService ,
268
- mockPluginManagerService )) {
244
+ try (ConnectionWrapper wrapper = getConnectionWrapper (
245
+ useAuroraHostListAndReadWriteSplittingPlugin (), PG_CONNECTION_STRING )) {
269
246
wrapper .releaseResources ();
270
247
ConnectionProviderManager .releaseResources ();
271
248
Driver .resetCustomConnectionProvider ();
@@ -275,14 +252,7 @@ public ConnectionWrapper initAndReleaseWithAuroraHostListAndReadWriteSplittingPl
275
252
276
253
@ Benchmark
277
254
public Statement executeStatementBaseline () throws SQLException {
278
- try (ConnectionWrapper wrapper = new TestConnectionWrapper (
279
- useExecutionTimePlugin (),
280
- CONNECTION_STRING ,
281
- mockConnectionPluginManager ,
282
- mockTelemetryFactory ,
283
- mockPluginService ,
284
- mockHostListProviderService ,
285
- mockPluginManagerService );
255
+ try (ConnectionWrapper wrapper = getConnectionWrapper (useExecutionTimePlugin (), CONNECTION_STRING );
286
256
Statement statement = wrapper .createStatement ()) {
287
257
return statement ;
288
258
}
@@ -291,14 +261,7 @@ public Statement executeStatementBaseline() throws SQLException {
291
261
@ Benchmark
292
262
public ResultSet executeStatementWithExecutionTimePlugin () throws SQLException {
293
263
try (
294
- ConnectionWrapper wrapper = new TestConnectionWrapper (
295
- useExecutionTimePlugin (),
296
- CONNECTION_STRING ,
297
- mockConnectionPluginManager ,
298
- mockTelemetryFactory ,
299
- mockPluginService ,
300
- mockHostListProviderService ,
301
- mockPluginManagerService );
264
+ ConnectionWrapper wrapper = getConnectionWrapper (useExecutionTimePlugin (), CONNECTION_STRING );
302
265
Statement statement = wrapper .createStatement ();
303
266
ResultSet resultSet = statement .executeQuery ("some sql" )) {
304
267
return resultSet ;
@@ -308,14 +271,7 @@ public ResultSet executeStatementWithExecutionTimePlugin() throws SQLException {
308
271
@ Benchmark
309
272
public ResultSet executeStatementWithTelemetryDisabled () throws SQLException {
310
273
try (
311
- ConnectionWrapper wrapper = new TestConnectionWrapper (
312
- disabledTelemetry (),
313
- CONNECTION_STRING ,
314
- mockConnectionPluginManager ,
315
- mockTelemetryFactory ,
316
- mockPluginService ,
317
- mockHostListProviderService ,
318
- mockPluginManagerService );
274
+ ConnectionWrapper wrapper = getConnectionWrapper (disabledTelemetry (), CONNECTION_STRING );
319
275
Statement statement = wrapper .createStatement ();
320
276
ResultSet resultSet = statement .executeQuery ("some sql" )) {
321
277
return resultSet ;
@@ -325,14 +281,7 @@ public ResultSet executeStatementWithTelemetryDisabled() throws SQLException {
325
281
@ Benchmark
326
282
public ResultSet executeStatementWithTelemetry () throws SQLException {
327
283
try (
328
- ConnectionWrapper wrapper = new TestConnectionWrapper (
329
- useTelemetry (),
330
- CONNECTION_STRING ,
331
- mockConnectionPluginManager ,
332
- mockTelemetryFactory ,
333
- mockPluginService ,
334
- mockHostListProviderService ,
335
- mockPluginManagerService );
284
+ ConnectionWrapper wrapper = getConnectionWrapper (useTelemetry (), CONNECTION_STRING );
336
285
Statement statement = wrapper .createStatement ();
337
286
ResultSet resultSet = statement .executeQuery ("some sql" )) {
338
287
return resultSet ;
0 commit comments