-
Notifications
You must be signed in to change notification settings - Fork 2.1k
/
VertxOptions.java
753 lines (679 loc) · 26.9 KB
/
VertxOptions.java
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
/*
* Copyright (c) 2011-2019 Contributors to the Eclipse Foundation
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
* which is available at https://www.apache.org/licenses/LICENSE-2.0.
*
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
*/
package io.vertx.core;
import io.vertx.codegen.annotations.DataObject;
import io.vertx.codegen.json.annotations.JsonGen;
import io.vertx.core.dns.AddressResolverOptions;
import io.vertx.core.eventbus.EventBusOptions;
import io.vertx.core.file.FileSystemOptions;
import io.vertx.core.impl.cpu.CpuCoreSensor;
import io.vertx.core.json.JsonObject;
import io.vertx.core.metrics.MetricsOptions;
import io.vertx.core.spi.cluster.ClusterManager;
import io.vertx.core.tracing.TracingOptions;
import java.util.Objects;
import java.util.concurrent.TimeUnit;
/**
* Instances of this class are used to configure {@link io.vertx.core.Vertx} instances.
*
* @author <a href="http://tfox.org">Tim Fox</a>
*/
@DataObject
@JsonGen(publicConverter = false)
public class VertxOptions {
/**
* @deprecated instead use {@link VertxOptions#setDisableTCCL(boolean)}, removed in vertx 5
*/
@Deprecated
private static final String DISABLE_TCCL_PROP_NAME = "vertx.disableTCCL";
/**
* The default number of event loop threads to be used = 2 * number of cores on the machine
*/
public static final int DEFAULT_EVENT_LOOP_POOL_SIZE = 2 * CpuCoreSensor.availableProcessors();
/**
* The default number of threads in the worker pool = 20
*/
public static final int DEFAULT_WORKER_POOL_SIZE = 20;
/**
* The default number of threads in the internal blocking pool (used by some internal operations) = 20
*/
public static final int DEFAULT_INTERNAL_BLOCKING_POOL_SIZE = 20;
/**
* The default value of blocked thread check interval = 1000 ms.
*/
public static final long DEFAULT_BLOCKED_THREAD_CHECK_INTERVAL = TimeUnit.SECONDS.toMillis(1);
/**
* The default value of blocked thread check interval unit = {@link TimeUnit#MILLISECONDS}
*/
public static final TimeUnit DEFAULT_BLOCKED_THREAD_CHECK_INTERVAL_UNIT = TimeUnit.MILLISECONDS;
/**
* The default value of max event loop execute time = 2000000000 ns (2 seconds)
*/
public static final long DEFAULT_MAX_EVENT_LOOP_EXECUTE_TIME = TimeUnit.SECONDS.toNanos(2);
/**
* The default value of max event loop execute time unit = {@link TimeUnit#NANOSECONDS}
*/
public static final TimeUnit DEFAULT_MAX_EVENT_LOOP_EXECUTE_TIME_UNIT = TimeUnit.NANOSECONDS;
/**
* The default value of max worker execute time = 60000000000 ns (60 seconds)
*/
public static final long DEFAULT_MAX_WORKER_EXECUTE_TIME = TimeUnit.SECONDS.toNanos(60);
/**
* The default value of max worker execute time unit = {@link TimeUnit#NANOSECONDS}
*/
public static final TimeUnit DEFAULT_MAX_WORKER_EXECUTE_TIME_UNIT = TimeUnit.NANOSECONDS;
/**
* The default value of quorum size = 1
*/
public static final int DEFAULT_QUORUM_SIZE = 1;
/**
* The default value of Ha group is "__DEFAULT__"
*/
public static final String DEFAULT_HA_GROUP = "__DEFAULT__";
/**
* The default value of HA enabled = false
*/
public static final boolean DEFAULT_HA_ENABLED = false;
/**
* The default value for preferring native transport = false
*/
public static final boolean DEFAULT_PREFER_NATIVE_TRANSPORT = false;
/**
* The default value of warning exception time 5000000000 ns (5 seconds)
* If a thread is blocked longer than this threshold, the warning log
* contains a stack trace
*/
private static final long DEFAULT_WARNING_EXCEPTION_TIME = TimeUnit.SECONDS.toNanos(5);
/**
* The default value of warning exception time unit = {@link TimeUnit#NANOSECONDS}
*/
public static final TimeUnit DEFAULT_WARNING_EXCEPTION_TIME_UNIT = TimeUnit.NANOSECONDS;
public static final boolean DEFAULT_DISABLE_TCCL = Boolean.getBoolean(DISABLE_TCCL_PROP_NAME);
/**
* Set default value to false for aligning with the old behavior
* By default, Vert.x threads are NOT daemons - we want them to prevent JVM exit so embedded user
* doesn't have to explicitly prevent JVM from exiting.
*/
public static final boolean DEFAULT_USE_DAEMON_THREAD = false;
private int eventLoopPoolSize = DEFAULT_EVENT_LOOP_POOL_SIZE;
private int workerPoolSize = DEFAULT_WORKER_POOL_SIZE;
private int internalBlockingPoolSize = DEFAULT_INTERNAL_BLOCKING_POOL_SIZE;
private long blockedThreadCheckInterval = DEFAULT_BLOCKED_THREAD_CHECK_INTERVAL;
private long maxEventLoopExecuteTime = DEFAULT_MAX_EVENT_LOOP_EXECUTE_TIME;
private long maxWorkerExecuteTime = DEFAULT_MAX_WORKER_EXECUTE_TIME;
private ClusterManager clusterManager;
private boolean haEnabled = DEFAULT_HA_ENABLED;
private int quorumSize = DEFAULT_QUORUM_SIZE;
private String haGroup = DEFAULT_HA_GROUP;
private MetricsOptions metricsOptions = new MetricsOptions();
private TracingOptions tracingOptions;
private FileSystemOptions fileSystemOptions = new FileSystemOptions();
private long warningExceptionTime = DEFAULT_WARNING_EXCEPTION_TIME;
private EventBusOptions eventBusOptions = new EventBusOptions();
private AddressResolverOptions addressResolverOptions = new AddressResolverOptions();
private boolean preferNativeTransport = DEFAULT_PREFER_NATIVE_TRANSPORT;
private TimeUnit maxEventLoopExecuteTimeUnit = DEFAULT_MAX_EVENT_LOOP_EXECUTE_TIME_UNIT;
private TimeUnit maxWorkerExecuteTimeUnit = DEFAULT_MAX_WORKER_EXECUTE_TIME_UNIT;
private TimeUnit warningExceptionTimeUnit = DEFAULT_WARNING_EXCEPTION_TIME_UNIT;
private TimeUnit blockedThreadCheckIntervalUnit = DEFAULT_BLOCKED_THREAD_CHECK_INTERVAL_UNIT;
private boolean disableTCCL = DEFAULT_DISABLE_TCCL;
private Boolean useDaemonThread = DEFAULT_USE_DAEMON_THREAD;
/**
* Default constructor
*/
public VertxOptions() {
}
/**
* Copy constructor
*
* @param other The other {@code VertxOptions} to copy when creating this
*/
public VertxOptions(VertxOptions other) {
this.eventLoopPoolSize = other.getEventLoopPoolSize();
this.workerPoolSize = other.getWorkerPoolSize();
this.blockedThreadCheckInterval = other.getBlockedThreadCheckInterval();
this.maxEventLoopExecuteTime = other.getMaxEventLoopExecuteTime();
this.maxWorkerExecuteTime = other.getMaxWorkerExecuteTime();
this.internalBlockingPoolSize = other.getInternalBlockingPoolSize();
this.clusterManager = other.getClusterManager();
this.haEnabled = other.isHAEnabled();
this.quorumSize = other.getQuorumSize();
this.haGroup = other.getHAGroup();
this.metricsOptions = other.getMetricsOptions() != null ? new MetricsOptions(other.getMetricsOptions()) : null;
this.fileSystemOptions = other.getFileSystemOptions() != null ? new FileSystemOptions(other.getFileSystemOptions()) : null;
this.warningExceptionTime = other.warningExceptionTime;
this.eventBusOptions = new EventBusOptions(other.eventBusOptions);
this.addressResolverOptions = other.addressResolverOptions != null ? new AddressResolverOptions(other.getAddressResolverOptions()) : null;
this.preferNativeTransport = other.preferNativeTransport;
this.maxEventLoopExecuteTimeUnit = other.maxEventLoopExecuteTimeUnit;
this.maxWorkerExecuteTimeUnit = other.maxWorkerExecuteTimeUnit;
this.warningExceptionTimeUnit = other.warningExceptionTimeUnit;
this.blockedThreadCheckIntervalUnit = other.blockedThreadCheckIntervalUnit;
this.tracingOptions = other.tracingOptions != null ? other.tracingOptions.copy() : null;
this.disableTCCL = other.disableTCCL;
this.useDaemonThread = other.useDaemonThread;
}
/**
* Create an instance from a {@link io.vertx.core.json.JsonObject}
*
* @param json the JsonObject to create it from
*/
public VertxOptions(JsonObject json) {
this();
VertxOptionsConverter.fromJson(json, this);
}
/**
* Get the number of event loop threads to be used by the Vert.x instance.
*
* @return the number of threads
*/
public int getEventLoopPoolSize() {
return eventLoopPoolSize;
}
/**
* Set the number of event loop threads to be used by the Vert.x instance.
*
* @param eventLoopPoolSize the number of threads
* @return a reference to this, so the API can be used fluently
*/
public VertxOptions setEventLoopPoolSize(int eventLoopPoolSize) {
if (eventLoopPoolSize < 1) {
throw new IllegalArgumentException("eventLoopPoolSize must be > 0");
}
this.eventLoopPoolSize = eventLoopPoolSize;
return this;
}
/**
* Get the maximum number of worker threads to be used by the Vert.x instance.
* <p>
* Worker threads are used for running blocking code and worker verticles.
*
* @return the maximum number of worker threads
*/
public int getWorkerPoolSize() {
return workerPoolSize;
}
/**
* Set the maximum number of worker threads to be used by the Vert.x instance.
*
* @param workerPoolSize the number of threads
* @return a reference to this, so the API can be used fluently
*/
public VertxOptions setWorkerPoolSize(int workerPoolSize) {
if (workerPoolSize < 1) {
throw new IllegalArgumentException("workerPoolSize must be > 0");
}
this.workerPoolSize = workerPoolSize;
return this;
}
/**
* Get the value of blocked thread check period, in {@link VertxOptions#setBlockedThreadCheckIntervalUnit blockedThreadCheckIntervalUnit}.
* <p>
* This setting determines how often Vert.x will check whether event loop threads are executing for too long.
* <p>
* The default value of {@link VertxOptions#setBlockedThreadCheckIntervalUnit blockedThreadCheckIntervalUnit} is {@link TimeUnit#MILLISECONDS}.
*
* @return the value of blocked thread check period, in {@link VertxOptions#setBlockedThreadCheckIntervalUnit blockedThreadCheckIntervalUnit}.
*/
public long getBlockedThreadCheckInterval() {
return blockedThreadCheckInterval;
}
/**
* Sets the value of blocked thread check period, in {@link VertxOptions#setBlockedThreadCheckIntervalUnit blockedThreadCheckIntervalUnit}.
* <p>
* The default value of {@link VertxOptions#setBlockedThreadCheckIntervalUnit blockedThreadCheckIntervalUnit} is {@link TimeUnit#MILLISECONDS}
*
* @param blockedThreadCheckInterval the value of blocked thread check period, in {@link VertxOptions#setBlockedThreadCheckIntervalUnit blockedThreadCheckIntervalUnit}.
* @return a reference to this, so the API can be used fluently
*/
public VertxOptions setBlockedThreadCheckInterval(long blockedThreadCheckInterval) {
if (blockedThreadCheckInterval < 1) {
throw new IllegalArgumentException("blockedThreadCheckInterval must be > 0");
}
this.blockedThreadCheckInterval = blockedThreadCheckInterval;
return this;
}
/**
* Get the value of max event loop execute time, in {@link VertxOptions#setMaxEventLoopExecuteTimeUnit maxEventLoopExecuteTimeUnit}.
* <p>
* Vert.x will automatically log a warning if it detects that event loop threads haven't returned within this time.
* <p>
* This can be used to detect where the user is blocking an event loop thread, contrary to the Golden Rule of the
* holy Event Loop.
* <p>
* The default value of {@link VertxOptions#setMaxEventLoopExecuteTimeUnit maxEventLoopExecuteTimeUnit} is {@link TimeUnit#NANOSECONDS}
*
* @return the value of max event loop execute time, in {@link VertxOptions#setMaxEventLoopExecuteTimeUnit maxEventLoopExecuteTimeUnit}.
*/
public long getMaxEventLoopExecuteTime() {
return maxEventLoopExecuteTime;
}
/**
* Sets the value of max event loop execute time, in {@link VertxOptions#setMaxEventLoopExecuteTimeUnit maxEventLoopExecuteTimeUnit}.
* <p>
* The default value of {@link VertxOptions#setMaxEventLoopExecuteTimeUnit maxEventLoopExecuteTimeUnit}is {@link TimeUnit#NANOSECONDS}
*
* @param maxEventLoopExecuteTime the value of max event loop execute time, in {@link VertxOptions#setMaxEventLoopExecuteTimeUnit maxEventLoopExecuteTimeUnit}.
* @return a reference to this, so the API can be used fluently
*/
public VertxOptions setMaxEventLoopExecuteTime(long maxEventLoopExecuteTime) {
if (maxEventLoopExecuteTime < 1) {
throw new IllegalArgumentException("maxEventLoopExecuteTime must be > 0");
}
this.maxEventLoopExecuteTime = maxEventLoopExecuteTime;
return this;
}
/**
* Get the value of max worker execute time, in {@link VertxOptions#setMaxWorkerExecuteTimeUnit maxWorkerExecuteTimeUnit}.
* <p>
* Vert.x will automatically log a warning if it detects that worker threads haven't returned within this time.
* <p>
* This can be used to detect where the user is blocking a worker thread for too long. Although worker threads
* can be blocked longer than event loop threads, they shouldn't be blocked for long periods of time.
* <p>
* The default value of {@link VertxOptions#setMaxWorkerExecuteTimeUnit maxWorkerExecuteTimeUnit} is {@link TimeUnit#NANOSECONDS}
*
* @return The value of max worker execute time, in {@link VertxOptions#setMaxWorkerExecuteTimeUnit maxWorkerExecuteTimeUnit}.
*/
public long getMaxWorkerExecuteTime() {
return maxWorkerExecuteTime;
}
/**
* Sets the value of max worker execute time, in {@link VertxOptions#setMaxWorkerExecuteTimeUnit maxWorkerExecuteTimeUnit}.
* <p>
* The default value of {@link VertxOptions#setMaxWorkerExecuteTimeUnit maxWorkerExecuteTimeUnit} is {@link TimeUnit#NANOSECONDS}
*
* @param maxWorkerExecuteTime the value of max worker execute time, in {@link VertxOptions#setMaxWorkerExecuteTimeUnit maxWorkerExecuteTimeUnit}.
* @return a reference to this, so the API can be used fluently
*/
public VertxOptions setMaxWorkerExecuteTime(long maxWorkerExecuteTime) {
if (maxWorkerExecuteTime < 1) {
throw new IllegalArgumentException("maxWorkerpExecuteTime must be > 0");
}
this.maxWorkerExecuteTime = maxWorkerExecuteTime;
return this;
}
/**
* Get the cluster manager to be used when clustering.
* <p>
* If the cluster manager has been programmatically set here, then that will be used when clustering.
* <p>
* Otherwise Vert.x attempts to locate a cluster manager on the classpath.
*
* @return the cluster manager.
*/
public ClusterManager getClusterManager() {
return clusterManager;
}
/**
* Programmatically set the cluster manager to be used when clustering.
* <p>
* Only valid if clustered = true.
* <p>
* Normally Vert.x will look on the classpath for a cluster manager, but if you want to set one
* programmatically you can use this method.
*
* @param clusterManager the cluster manager
* @return a reference to this, so the API can be used fluently
* @deprecated instead use {@link io.vertx.core.VertxBuilder#withClusterManager(ClusterManager)}
*/
@Deprecated
public VertxOptions setClusterManager(ClusterManager clusterManager) {
this.clusterManager = clusterManager;
return this;
}
/**
* Get the value of internal blocking pool size.
* <p>
* Vert.x maintains a pool for internal blocking operations
*
* @return the value of internal blocking pool size
*/
public int getInternalBlockingPoolSize() {
return internalBlockingPoolSize;
}
/**
* Set the value of internal blocking pool size
*
* @param internalBlockingPoolSize the maximumn number of threads in the internal blocking pool
* @return a reference to this, so the API can be used fluently
*/
public VertxOptions setInternalBlockingPoolSize(int internalBlockingPoolSize) {
if (internalBlockingPoolSize < 1) {
throw new IllegalArgumentException("internalBlockingPoolSize must be > 0");
}
this.internalBlockingPoolSize = internalBlockingPoolSize;
return this;
}
/**
* Will HA be enabled on the Vert.x instance?
*
* @return true if HA enabled, false otherwise
*/
public boolean isHAEnabled() {
return haEnabled;
}
/**
* Set whether HA will be enabled on the Vert.x instance.
*
* @param haEnabled true if enabled, false if not.
* @return a reference to this, so the API can be used fluently
*/
public VertxOptions setHAEnabled(boolean haEnabled) {
this.haEnabled = haEnabled;
return this;
}
/**
* Get the quorum size to be used when HA is enabled.
*
* @return the quorum size
*/
public int getQuorumSize() {
return quorumSize;
}
/**
* Set the quorum size to be used when HA is enabled.
*
* @param quorumSize the quorum size
* @return a reference to this, so the API can be used fluently
*/
public VertxOptions setQuorumSize(int quorumSize) {
if (quorumSize < 1) {
throw new IllegalArgumentException("quorumSize should be >= 1");
}
this.quorumSize = quorumSize;
return this;
}
/**
* Get the HA group to be used when HA is enabled.
*
* @return the HA group
*/
public String getHAGroup() {
return haGroup;
}
/**
* Set the HA group to be used when HA is enabled.
*
* @param haGroup the HA group to use
* @return a reference to this, so the API can be used fluently
*/
public VertxOptions setHAGroup(String haGroup) {
Objects.requireNonNull(haGroup, "ha group cannot be null");
this.haGroup = haGroup;
return this;
}
/**
* @return the metrics options
*/
public MetricsOptions getMetricsOptions() {
return metricsOptions;
}
/**
* @return the file system options
*/
public FileSystemOptions getFileSystemOptions() {
return fileSystemOptions;
}
/**
* Set the metrics options
*
* @param metrics the options
* @return a reference to this, so the API can be used fluently
*/
public VertxOptions setMetricsOptions(MetricsOptions metrics) {
this.metricsOptions = metrics;
return this;
}
/**
* Set the file system options
*
* @param fileSystemOptions the options
* @return a reference to this, so the API can be used fluently
*/
public VertxOptions setFileSystemOptions(FileSystemOptions fileSystemOptions) {
this.fileSystemOptions = fileSystemOptions;
return this;
}
/**
* Get the threshold value above this, the blocked warning contains a stack trace. in {@link VertxOptions#setWarningExceptionTimeUnit warningExceptionTimeUnit}.
* <p>
* The default value of {@link VertxOptions#setWarningExceptionTimeUnit warningExceptionTimeUnit} is {@link TimeUnit#NANOSECONDS}
*
* @return the warning exception time threshold
*/
public long getWarningExceptionTime() {
return warningExceptionTime;
}
/**
* Set the threshold value above this, the blocked warning contains a stack trace. in {@link VertxOptions#setWarningExceptionTimeUnit warningExceptionTimeUnit}.
* The default value of {@link VertxOptions#setWarningExceptionTimeUnit warningExceptionTimeUnit} is {@link TimeUnit#NANOSECONDS}
*
* @param warningExceptionTime
* @return a reference to this, so the API can be used fluently
*/
public VertxOptions setWarningExceptionTime(long warningExceptionTime) {
if (warningExceptionTime < 1) {
throw new IllegalArgumentException("warningExceptionTime must be > 0");
}
this.warningExceptionTime = warningExceptionTime;
return this;
}
/**
* @return the event bus option to configure the event bus communication (host, port, ssl...)
*/
public EventBusOptions getEventBusOptions() {
return eventBusOptions;
}
/**
* Sets the event bus configuration to configure the host, port, ssl...
*
* @param options the event bus options
* @return a reference to this, so the API can be used fluently
*/
public VertxOptions setEventBusOptions(EventBusOptions options) {
Objects.requireNonNull(options);
this.eventBusOptions = options;
return this;
}
/**
* @return the address resolver options to configure resolving DNS servers, cache TTL, etc...
*/
public AddressResolverOptions getAddressResolverOptions() {
return addressResolverOptions;
}
/**
* Sets the address resolver configuration to configure resolving DNS servers, cache TTL, etc...
*
* @param addressResolverOptions the address resolver options
* @return a reference to this, so the API can be used fluently
*/
public VertxOptions setAddressResolverOptions(AddressResolverOptions addressResolverOptions) {
this.addressResolverOptions = addressResolverOptions;
return this;
}
/**
* @return wether to prefer the native transport to the JDK transport
*/
public boolean getPreferNativeTransport() {
return preferNativeTransport;
}
/**
* Set wether to prefer the native transport to the JDK transport.
*
* @param preferNativeTransport {@code true} to prefer the native transport
* @return a reference to this, so the API can be used fluently
*/
public VertxOptions setPreferNativeTransport(boolean preferNativeTransport) {
this.preferNativeTransport = preferNativeTransport;
return this;
}
/**
* @return the time unit of {@code maxEventLoopExecuteTime}
*/
public TimeUnit getMaxEventLoopExecuteTimeUnit() {
return maxEventLoopExecuteTimeUnit;
}
/**
* Set the time unit of {@code maxEventLoopExecuteTime}.
*
* @param maxEventLoopExecuteTimeUnit the time unit of {@code maxEventLoopExecuteTime}
* @return a reference to this, so the API can be used fluently
*/
public VertxOptions setMaxEventLoopExecuteTimeUnit(TimeUnit maxEventLoopExecuteTimeUnit) {
this.maxEventLoopExecuteTimeUnit = maxEventLoopExecuteTimeUnit;
return this;
}
/**
* @return the time unit of {@code maxWorkerExecuteTime}
*/
public TimeUnit getMaxWorkerExecuteTimeUnit() {
return maxWorkerExecuteTimeUnit;
}
/**
* Set the time unit of {@code maxWorkerExecuteTime}.
*
* @param maxWorkerExecuteTimeUnit the time unit of {@code maxWorkerExecuteTime}
* @return a reference to this, so the API can be used fluently
*/
public VertxOptions setMaxWorkerExecuteTimeUnit(TimeUnit maxWorkerExecuteTimeUnit) {
this.maxWorkerExecuteTimeUnit = maxWorkerExecuteTimeUnit;
return this;
}
/**
* @return the time unit of {@code warningExceptionTime}
*/
public TimeUnit getWarningExceptionTimeUnit() {
return warningExceptionTimeUnit;
}
/**
* Set the time unit of {@code warningExceptionTime}.
*
* @param warningExceptionTimeUnit the time unit of {@code warningExceptionTime}
* @return a reference to this, so the API can be used fluently
*/
public VertxOptions setWarningExceptionTimeUnit(TimeUnit warningExceptionTimeUnit) {
this.warningExceptionTimeUnit = warningExceptionTimeUnit;
return this;
}
/**
* @return the time unit of {@code blockedThreadCheckInterval}
*/
public TimeUnit getBlockedThreadCheckIntervalUnit() {
return blockedThreadCheckIntervalUnit;
}
/**
* Set the time unit of {@code blockedThreadCheckInterval}.
*
* @param blockedThreadCheckIntervalUnit the time unit of {@code warningExceptionTime}
* @return a reference to this, so the API can be used fluently
*/
public VertxOptions setBlockedThreadCheckIntervalUnit(TimeUnit blockedThreadCheckIntervalUnit) {
this.blockedThreadCheckIntervalUnit = blockedThreadCheckIntervalUnit;
return this;
}
/**
* If tracing is disabled, the value will be {@code null}.
*
* @return the tracing options
*/
public TracingOptions getTracingOptions() {
return tracingOptions;
}
/**
* Set the tracing options
*
* @param tracingOptions the options
* @return a reference to this, so the API can be used fluently
*/
public VertxOptions setTracingOptions(TracingOptions tracingOptions) {
this.tracingOptions = tracingOptions;
return this;
}
/**
* @return whether Vert.x sets the {@link Context} classloader as the thread context classloader on actions executed on that {@link Context}
*/
public boolean getDisableTCCL() {
return disableTCCL;
}
/**
* Configures whether Vert.x sets the {@link Context} classloader as the thread context classloader on actions executed on that {@link Context}.
*
* When a {@link Context} is created the current thread classloader is captured and associated with this classloader.
*
* Likewise when a Verticle is created, the Verticle's {@link Context} classloader is set to the current thread classloader
* unless this classloader is overriden by {@link DeploymentOptions#getClassLoader()}.
*
* This setting overrides the (legacy) system property {@code vertx.disableTCCL} and provides control at the
* Vertx instance level.
*
* @param disableTCCL {@code true} to disable thread context classloader update by Vertx
* @return a reference to this, so the API can be used fluently
*/
public VertxOptions setDisableTCCL(boolean disableTCCL) {
this.disableTCCL = disableTCCL;
return this;
}
/**
* Returns whether we want to use daemon vertx thread.
*
* @return {@code true} means daemon, {@code false} means not daemon(user), {@code null} means do
* not change the daemon option of the created vertx thread.
*/
public Boolean getUseDaemonThread() {
return useDaemonThread;
}
/**
* Mark the vertx thread as daemon thread or user thread.
* <p/>
* For keeping the old behavior, the default value is {@code false} instead of {@code null}.
*
* @param daemon {@code true} means daemon, {@code false} means not daemon(user), {@code null}
* means do not change the daemon option of the created vertx thread.
*/
public VertxOptions setUseDaemonThread(Boolean daemon) {
this.useDaemonThread = daemon;
return this;
}
public JsonObject toJson() {
JsonObject json = new JsonObject();
VertxOptionsConverter.toJson(this, json);
return json;
}
@Override
public String toString() {
return "VertxOptions{" +
"eventLoopPoolSize=" + eventLoopPoolSize +
", workerPoolSize=" + workerPoolSize +
", internalBlockingPoolSize=" + internalBlockingPoolSize +
", blockedThreadCheckIntervalUnit=" + blockedThreadCheckIntervalUnit +
", blockedThreadCheckInterval=" + blockedThreadCheckInterval +
", maxEventLoopExecuteTimeUnit=" + maxEventLoopExecuteTimeUnit +
", maxEventLoopExecuteTime=" + maxEventLoopExecuteTime +
", maxWorkerExecuteTimeUnit=" + maxWorkerExecuteTimeUnit +
", maxWorkerExecuteTime=" + maxWorkerExecuteTime +
", clusterManager=" + clusterManager +
", haEnabled=" + haEnabled +
", preferNativeTransport=" + preferNativeTransport +
", quorumSize=" + quorumSize +
", haGroup='" + haGroup + '\'' +
", metrics=" + metricsOptions +
", tracing=" + tracingOptions +
", fileSystemOptions=" + fileSystemOptions +
", addressResolver=" + addressResolverOptions.toJson() +
", eventbus=" + eventBusOptions.toJson() +
", warningExceptionTimeUnit=" + warningExceptionTimeUnit +
", warningExceptionTime=" + warningExceptionTime +
", disableTCCL=" + disableTCCL +
", useDaemonThread=" + useDaemonThread +
'}';
}
}