Skip to content

Commit 7ad50aa

Browse files
committed
OptionsMap - refactor settings that are used multiple times to a variable.
1 parent 20eb381 commit 7ad50aa

File tree

1 file changed

+20
-12
lines changed

1 file changed

+20
-12
lines changed

core/src/main/java/com/datastax/oss/driver/api/core/config/OptionsMap.java

+20-12
Original file line numberDiff line numberDiff line change
@@ -244,11 +244,16 @@ private void readObject(ObjectInputStream stream) throws InvalidObjectException
244244
protected static void fillWithDriverDefaults(OptionsMap map) {
245245
// Sorted by order of appearance in reference.conf:
246246
Duration initQueryTimeout = Duration.ofSeconds(5);
247+
Duration requestTimeout = Duration.ofSeconds(2);
248+
int requestPageSize = 5000;
249+
int maxPages = 0;
250+
int continuousMaxPagesPerSecond = 0;
251+
int continuousMaxEnqueuedPages = 4;
247252

248253
// Skip CONFIG_RELOAD_INTERVAL because the map-based config doesn't need periodic reloading
249-
map.put(TypedDriverOption.REQUEST_TIMEOUT, Duration.ofSeconds(2));
254+
map.put(TypedDriverOption.REQUEST_TIMEOUT, requestTimeout);
250255
map.put(TypedDriverOption.REQUEST_CONSISTENCY, "LOCAL_ONE");
251-
map.put(TypedDriverOption.REQUEST_PAGE_SIZE, 5000);
256+
map.put(TypedDriverOption.REQUEST_PAGE_SIZE, requestPageSize);
252257
map.put(TypedDriverOption.REQUEST_SERIAL_CONSISTENCY, "SERIAL");
253258
map.put(TypedDriverOption.REQUEST_DEFAULT_IDEMPOTENCE, false);
254259
map.put(TypedDriverOption.GRAPH_TRAVERSAL_SOURCE, "g");
@@ -286,15 +291,18 @@ protected static void fillWithDriverDefaults(OptionsMap map) {
286291
map.put(TypedDriverOption.REQUEST_TRACE_CONSISTENCY, "ONE");
287292
map.put(TypedDriverOption.REQUEST_LOG_WARNINGS, true);
288293
map.put(TypedDriverOption.GRAPH_PAGING_ENABLED, "AUTO");
289-
map.put(TypedDriverOption.GRAPH_CONTINUOUS_PAGING_PAGE_SIZE, 5000);
290-
map.put(TypedDriverOption.GRAPH_CONTINUOUS_PAGING_MAX_PAGES, 0);
291-
map.put(TypedDriverOption.GRAPH_CONTINUOUS_PAGING_MAX_PAGES_PER_SECOND, 0);
292-
map.put(TypedDriverOption.GRAPH_CONTINUOUS_PAGING_MAX_ENQUEUED_PAGES, 4);
293-
map.put(TypedDriverOption.CONTINUOUS_PAGING_PAGE_SIZE, 5000);
294+
map.put(TypedDriverOption.GRAPH_CONTINUOUS_PAGING_PAGE_SIZE, requestPageSize);
295+
map.put(TypedDriverOption.GRAPH_CONTINUOUS_PAGING_MAX_PAGES, maxPages);
296+
map.put(
297+
TypedDriverOption.GRAPH_CONTINUOUS_PAGING_MAX_PAGES_PER_SECOND,
298+
continuousMaxPagesPerSecond);
299+
map.put(
300+
TypedDriverOption.GRAPH_CONTINUOUS_PAGING_MAX_ENQUEUED_PAGES, continuousMaxEnqueuedPages);
301+
map.put(TypedDriverOption.CONTINUOUS_PAGING_PAGE_SIZE, requestPageSize);
294302
map.put(TypedDriverOption.CONTINUOUS_PAGING_PAGE_SIZE_BYTES, false);
295-
map.put(TypedDriverOption.CONTINUOUS_PAGING_MAX_PAGES, 0);
296-
map.put(TypedDriverOption.CONTINUOUS_PAGING_MAX_PAGES_PER_SECOND, 0);
297-
map.put(TypedDriverOption.CONTINUOUS_PAGING_MAX_ENQUEUED_PAGES, 4);
303+
map.put(TypedDriverOption.CONTINUOUS_PAGING_MAX_PAGES, maxPages);
304+
map.put(TypedDriverOption.CONTINUOUS_PAGING_MAX_PAGES_PER_SECOND, continuousMaxPagesPerSecond);
305+
map.put(TypedDriverOption.CONTINUOUS_PAGING_MAX_ENQUEUED_PAGES, continuousMaxEnqueuedPages);
298306
map.put(TypedDriverOption.CONTINUOUS_PAGING_TIMEOUT_FIRST_PAGE, Duration.ofSeconds(2));
299307
map.put(TypedDriverOption.CONTINUOUS_PAGING_TIMEOUT_OTHER_PAGES, Duration.ofSeconds(1));
300308
map.put(TypedDriverOption.MONITOR_REPORTING_ENABLED, true);
@@ -328,8 +336,8 @@ protected static void fillWithDriverDefaults(OptionsMap map) {
328336
map.put(TypedDriverOption.METADATA_TOPOLOGY_WINDOW, Duration.ofSeconds(1));
329337
map.put(TypedDriverOption.METADATA_TOPOLOGY_MAX_EVENTS, 20);
330338
map.put(TypedDriverOption.METADATA_SCHEMA_ENABLED, true);
331-
map.put(TypedDriverOption.METADATA_SCHEMA_REQUEST_TIMEOUT, Duration.ofSeconds(2));
332-
map.put(TypedDriverOption.METADATA_SCHEMA_REQUEST_PAGE_SIZE, 5000);
339+
map.put(TypedDriverOption.METADATA_SCHEMA_REQUEST_TIMEOUT, requestTimeout);
340+
map.put(TypedDriverOption.METADATA_SCHEMA_REQUEST_PAGE_SIZE, requestPageSize);
333341
map.put(TypedDriverOption.METADATA_SCHEMA_WINDOW, Duration.ofSeconds(1));
334342
map.put(TypedDriverOption.METADATA_SCHEMA_MAX_EVENTS, 20);
335343
map.put(TypedDriverOption.METADATA_TOKEN_MAP_ENABLED, true);

0 commit comments

Comments
 (0)