-
Notifications
You must be signed in to change notification settings - Fork 31
/
ListenerParameters.java
761 lines (633 loc) · 23.7 KB
/
ListenerParameters.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
754
755
756
757
758
759
760
761
/*
* Copyright 2019 EPAM Systems
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.epam.reportportal.listeners;
import com.epam.reportportal.service.LoggingContext;
import com.epam.reportportal.service.launch.lock.LaunchIdLockMode;
import com.epam.reportportal.utils.AttributeParser;
import com.epam.reportportal.utils.properties.ListenerProperty;
import com.epam.reportportal.utils.properties.PropertiesLoader;
import com.epam.ta.reportportal.ws.model.attribute.ItemAttributesRQ;
import com.epam.ta.reportportal.ws.model.launch.Mode;
import com.google.common.annotations.VisibleForTesting;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.lang.reflect.Modifier;
import java.time.Duration;
import java.time.temporal.ChronoUnit;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import static com.epam.reportportal.utils.properties.ListenerProperty.*;
import static java.util.Optional.ofNullable;
/**
* Report portal client parameters. The class is a placeholder for client and agent parameters.
*/
public class ListenerParameters implements Cloneable {
private static final Logger LOGGER = LoggerFactory.getLogger(ListenerParameters.class);
private static final String PROPERTY_WILL_BE_REMOVED = "Property '{}' will be removed in the next major version, please use '{}' instead";
private static final int DEFAULT_REPORTING_TIMEOUT = 5 * 60;
private static final int DEFAULT_IO_POOL_SIZE = 100;
private static final boolean DEFAULT_ENABLE = true;
private static final boolean DEFAULT_SKIP_ISSUE = true;
private static final boolean DEFAULT_CONVERT_IMAGE = false;
private static final boolean DEFAULT_RETURN = false;
private static final boolean DEFAULT_ASYNC_REPORTING = false;
private static final boolean DEFAULT_CALLBACK_REPORTING_ENABLED = false;
private static final boolean DEFAULT_HTTP_LOGGING = false;
private static final int DEFAULT_RX_BUFFER_SIZE = 128;
private static final boolean DEFAULT_CLIENT_JOIN = true;
private static final String DEFAULT_CLIENT_JOIN_MODE = "FILE";
private static final String DEFAULT_LOCK_FILE_NAME = "reportportal.lock";
private static final String DEFAULT_SYNC_FILE_NAME = "reportportal.sync";
public static final long DEFAULT_FILE_WAIT_TIMEOUT_MS = TimeUnit.MINUTES.toMillis(1);
private static final long DEFAULT_CLIENT_JOIN_TIMEOUT = TimeUnit.MINUTES.toMillis(30);
private static final String DEFAULT_CLIENT_JOIN_TIMEOUT_UNIT = "MILLISECONDS";
private static final String DEFAULT_CLIENT_JOIN_LOCK_TIMEOUT_UNIT = DEFAULT_CLIENT_JOIN_TIMEOUT_UNIT;
private static final int DEFAULT_CLIENT_JOIN_LOCK_PORT = 25464;
private static final boolean DEFAULT_TRUNCATE = true;
private static final int DEFAULT_TRUNCATE_ITEM_NAMES_LIMIT = 1024;
private static final int DEFAULT_TRUNCATE_ATTRIBUTE_LIMIT = 128;
private static final String DEFAULT_TRUNCATE_REPLACEMENT = "...";
// Due to shortcoming of payload calculation mechanism this value is set to 65 million of bytes rather than 65 megabytes
public static final long DEFAULT_BATCH_PAYLOAD_LIMIT = 65 * 1000 * 1000;
private String description;
private String apiKey;
private String baseUrl;
private String proxyUrl;
private boolean httpLogging;
private Duration httpCallTimeout;
private Duration httpConnectTimeout;
private Duration httpReadTimeout;
private Duration httpWriteTimeout;
private String projectName;
private String launchName;
private String launchUuid;
private Mode launchRunningMode;
private Set<ItemAttributesRQ> attributes;
private Boolean enable;
private Boolean isSkippedAnIssue;
private Integer batchLogsSize;
private Long batchPayloadLimit;
private boolean convertImage;
private Integer reportingTimeout;
private String keystore;
private String keystorePassword;
private boolean rerun;
private String rerunOf;
private boolean asyncReporting;
private boolean callbackReportingEnabled;
private Integer ioPoolSize;
private boolean clientJoin;
private LaunchIdLockMode clientJoinMode;
private String lockFileName;
private String syncFileName;
private long lockWaitTimeout;
private long clientJoinTimeout;
private int lockPortNumber;
private int rxBufferSize;
private boolean truncateFields;
private int truncateItemNamesLimit;
private String truncateReplacement;
private int attributeLengthLimit;
@Nonnull
private static ChronoUnit toChronoUnit(@Nonnull TimeUnit t) {
switch (t) {
case NANOSECONDS:
return ChronoUnit.NANOS;
case MICROSECONDS:
return ChronoUnit.MICROS;
case MILLISECONDS:
return ChronoUnit.MILLIS;
case SECONDS:
return ChronoUnit.SECONDS;
case MINUTES:
return ChronoUnit.MINUTES;
case HOURS:
return ChronoUnit.HOURS;
case DAYS:
return ChronoUnit.DAYS;
default:
throw new AssertionError();
}
}
@Nullable
private static Duration getDurationProperty(@Nonnull PropertiesLoader properties, @Nonnull ListenerProperty value,
@Nonnull ListenerProperty unit) {
return ofNullable(properties.getProperty(value)).map(Long::parseLong).map(t -> Duration.of(t,
ofNullable(properties.getProperty(unit)).map(u -> toChronoUnit(TimeUnit.valueOf(u)))
.orElse(ChronoUnit.MILLIS)
)).orElse(null);
}
/**
* Create class instance with default parameters
*/
public ListenerParameters() {
this.isSkippedAnIssue = DEFAULT_SKIP_ISSUE;
this.batchLogsSize = LoggingContext.DEFAULT_LOG_BATCH_SIZE;
this.batchPayloadLimit = DEFAULT_BATCH_PAYLOAD_LIMIT;
this.convertImage = DEFAULT_CONVERT_IMAGE;
this.reportingTimeout = DEFAULT_REPORTING_TIMEOUT;
this.httpLogging = DEFAULT_HTTP_LOGGING;
this.attributes = Collections.emptySet();
this.rerun = DEFAULT_RETURN;
this.asyncReporting = DEFAULT_ASYNC_REPORTING;
this.callbackReportingEnabled = DEFAULT_CALLBACK_REPORTING_ENABLED;
this.ioPoolSize = DEFAULT_IO_POOL_SIZE;
this.clientJoin = DEFAULT_CLIENT_JOIN;
this.clientJoinMode = LaunchIdLockMode.valueOf(DEFAULT_CLIENT_JOIN_MODE);
this.clientJoinTimeout = DEFAULT_CLIENT_JOIN_TIMEOUT;
this.lockFileName = DEFAULT_LOCK_FILE_NAME;
this.syncFileName = DEFAULT_SYNC_FILE_NAME;
this.lockWaitTimeout = DEFAULT_FILE_WAIT_TIMEOUT_MS;
this.lockPortNumber = DEFAULT_CLIENT_JOIN_LOCK_PORT;
this.rxBufferSize = DEFAULT_RX_BUFFER_SIZE;
this.truncateFields = DEFAULT_TRUNCATE;
this.truncateItemNamesLimit = DEFAULT_TRUNCATE_ITEM_NAMES_LIMIT;
this.truncateReplacement = DEFAULT_TRUNCATE_REPLACEMENT;
this.attributeLengthLimit = DEFAULT_TRUNCATE_ATTRIBUTE_LIMIT;
}
/**
* Create class instance with parameters from property source
*
* @param properties property source
*/
public ListenerParameters(PropertiesLoader properties) {
this.description = properties.getProperty(DESCRIPTION);
this.apiKey = ofNullable(properties.getProperty(API_KEY, properties.getProperty(UUID))).map(String::trim)
.orElse(null);
this.baseUrl = properties.getProperty(BASE_URL) != null ? properties.getProperty(BASE_URL).trim() : null;
this.proxyUrl = properties.getProperty(HTTP_PROXY_URL);
this.httpLogging = properties.getPropertyAsBoolean(HTTP_LOGGING, DEFAULT_HTTP_LOGGING);
this.httpCallTimeout = getDurationProperty(properties, HTTP_CALL_TIMEOUT_VALUE, HTTP_CALL_TIMEOUT_UNIT);
this.httpConnectTimeout = getDurationProperty(properties,
HTTP_CONNECT_TIMEOUT_VALUE,
HTTP_CONNECT_TIMEOUT_UNIT
);
this.httpReadTimeout = getDurationProperty(properties, HTTP_READ_TIMEOUT_VALUE, HTTP_READ_TIMEOUT_UNIT);
this.httpWriteTimeout = getDurationProperty(properties, HTTP_WRITE_TIMEOUT_VALUE, HTTP_WRITE_TIMEOUT_UNIT);
this.projectName =
properties.getProperty(PROJECT_NAME) != null ? properties.getProperty(PROJECT_NAME).trim() : null;
this.launchName = properties.getProperty(LAUNCH_NAME);
this.launchUuid = properties.getProperty(LAUNCH_UUID);
this.attributes = Collections.unmodifiableSet(AttributeParser.parseAsSet(properties.getProperty(
LAUNCH_ATTRIBUTES)));
this.launchRunningMode = parseLaunchMode(properties.getProperty(MODE));
this.enable = properties.getPropertyAsBoolean(ENABLE, DEFAULT_ENABLE);
this.isSkippedAnIssue = properties.getPropertyAsBoolean(SKIPPED_AS_ISSUE, DEFAULT_SKIP_ISSUE);
this.batchLogsSize = properties.getPropertyAsInt(BATCH_SIZE_LOGS, LoggingContext.DEFAULT_LOG_BATCH_SIZE);
this.batchPayloadLimit = properties.getPropertyAsLong(BATCH_PAYLOAD_LIMIT, DEFAULT_BATCH_PAYLOAD_LIMIT);
this.convertImage = properties.getPropertyAsBoolean(IS_CONVERT_IMAGE, DEFAULT_CONVERT_IMAGE);
this.reportingTimeout = properties.getPropertyAsInt(REPORTING_TIMEOUT, DEFAULT_REPORTING_TIMEOUT);
this.keystore = properties.getProperty(KEYSTORE_RESOURCE);
this.keystorePassword = properties.getProperty(KEYSTORE_PASSWORD);
this.rerun = properties.getPropertyAsBoolean(RERUN, DEFAULT_RETURN);
this.rerunOf = properties.getProperty(RERUN_OF);
this.asyncReporting = properties.getPropertyAsBoolean(ASYNC_REPORTING, DEFAULT_ASYNC_REPORTING);
this.callbackReportingEnabled = properties.getPropertyAsBoolean(CALLBACK_REPORTING_ENABLED,
DEFAULT_CALLBACK_REPORTING_ENABLED
);
this.ioPoolSize = properties.getPropertyAsInt(IO_POOL_SIZE, DEFAULT_IO_POOL_SIZE);
clientJoin = properties.getPropertyAsBoolean(CLIENT_JOIN_MODE, DEFAULT_CLIENT_JOIN);
clientJoinMode = LaunchIdLockMode.valueOf(properties.getProperty(CLIENT_JOIN_MODE_VALUE,
DEFAULT_CLIENT_JOIN_MODE
));
clientJoinTimeout = ofNullable(properties.getProperty(CLIENT_JOIN_TIMEOUT_VALUE)).map(t -> TimeUnit.valueOf(
properties.getProperty(CLIENT_JOIN_TIMEOUT_UNIT, DEFAULT_CLIENT_JOIN_TIMEOUT_UNIT))
.toMillis(Long.parseLong(t))).orElse(DEFAULT_CLIENT_JOIN_TIMEOUT);
lockFileName = properties.getProperty(LOCK_FILE_NAME);
if (lockFileName != null) {
LOGGER.warn(PROPERTY_WILL_BE_REMOVED, LOCK_FILE_NAME.getPropertyName(), FILE_LOCK_NAME.getPropertyName());
lockFileName = properties.getProperty(FILE_LOCK_NAME, lockFileName);
} else {
lockFileName = properties.getProperty(FILE_LOCK_NAME, DEFAULT_LOCK_FILE_NAME);
}
syncFileName = properties.getProperty(SYNC_FILE_NAME);
if (syncFileName != null) {
LOGGER.warn(PROPERTY_WILL_BE_REMOVED, SYNC_FILE_NAME.getPropertyName(), FILE_SYNC_NAME.getPropertyName());
syncFileName = properties.getProperty(FILE_SYNC_NAME, syncFileName);
} else {
syncFileName = properties.getProperty(FILE_SYNC_NAME, DEFAULT_SYNC_FILE_NAME);
}
String fileWaitTimeoutStr = properties.getProperty(FILE_WAIT_TIMEOUT_MS);
if (fileWaitTimeoutStr != null) {
LOGGER.warn(PROPERTY_WILL_BE_REMOVED,
FILE_WAIT_TIMEOUT_MS.getPropertyName(),
CLIENT_JOIN_LOCK_TIMEOUT_VALUE.getPropertyName() + ","
+ CLIENT_JOIN_LOCK_TIMEOUT_UNIT.getPropertyName()
);
lockWaitTimeout = Long.parseLong(fileWaitTimeoutStr);
}
String waitTimeoutStr = properties.getProperty(CLIENT_JOIN_LOCK_TIMEOUT_VALUE);
if (waitTimeoutStr != null) {
TimeUnit waitTimeUnit = TimeUnit.valueOf(properties.getProperty(CLIENT_JOIN_LOCK_TIMEOUT_UNIT,
DEFAULT_CLIENT_JOIN_LOCK_TIMEOUT_UNIT
));
lockWaitTimeout = waitTimeUnit.toMillis(Long.parseLong(waitTimeoutStr));
}
if (fileWaitTimeoutStr == null && waitTimeoutStr == null) {
lockWaitTimeout = DEFAULT_FILE_WAIT_TIMEOUT_MS;
}
lockPortNumber = properties.getPropertyAsInt(CLIENT_JOIN_LOCK_PORT, DEFAULT_CLIENT_JOIN_LOCK_PORT);
this.rxBufferSize = properties.getPropertyAsInt(RX_BUFFER_SIZE, DEFAULT_RX_BUFFER_SIZE);
String truncateLegacy = properties.getProperty(TRUNCATE_ITEM_NAMES);
if (StringUtils.isNotBlank(truncateLegacy)) {
LOGGER.warn(PROPERTY_WILL_BE_REMOVED,
TRUNCATE_ITEM_NAMES.getPropertyName(),
TRUNCATE_FIELDS.getPropertyName()
);
this.truncateFields = properties.getPropertyAsBoolean(TRUNCATE_FIELDS,
Boolean.parseBoolean(truncateLegacy)
);
} else {
this.truncateFields = properties.getPropertyAsBoolean(TRUNCATE_FIELDS, DEFAULT_TRUNCATE);
}
String legacyTruncateItemNamesLimit = properties.getProperty(TRUNCATE_ITEM_LIMIT);
if (StringUtils.isNotBlank(legacyTruncateItemNamesLimit)) {
LOGGER.warn(PROPERTY_WILL_BE_REMOVED,
TRUNCATE_ITEM_LIMIT.getPropertyName(),
TRUNCATE_ITEM_NAME_LIMIT.getPropertyName()
);
this.truncateItemNamesLimit = properties.getPropertyAsInt(TRUNCATE_ITEM_NAME_LIMIT,
Integer.parseInt(legacyTruncateItemNamesLimit)
);
} else {
this.truncateItemNamesLimit = properties.getPropertyAsInt(TRUNCATE_ITEM_NAME_LIMIT,
DEFAULT_TRUNCATE_ITEM_NAMES_LIMIT
);
}
String legacyTruncateReplacement = properties.getProperty(TRUNCATE_ITEM_REPLACEMENT);
if (StringUtils.isNotBlank(legacyTruncateReplacement)) {
LOGGER.warn(PROPERTY_WILL_BE_REMOVED,
TRUNCATE_ITEM_REPLACEMENT.getPropertyName(),
TRUNCATE_REPLACEMENT.getPropertyName()
);
this.truncateReplacement = properties.getProperty(TRUNCATE_REPLACEMENT, legacyTruncateReplacement);
} else {
this.truncateReplacement = properties.getProperty(TRUNCATE_REPLACEMENT, DEFAULT_TRUNCATE_REPLACEMENT);
}
this.attributeLengthLimit = properties.getPropertyAsInt(
TRUNCATE_ATTRIBUTE_LIMIT,
DEFAULT_TRUNCATE_ATTRIBUTE_LIMIT
);
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getApiKey() {
return apiKey;
}
public void setApiKey(String apiKey) {
this.apiKey = apiKey;
}
public String getBaseUrl() {
return baseUrl;
}
public void setBaseUrl(String baseUrl) {
this.baseUrl = baseUrl;
}
public String getProxyUrl() {
return proxyUrl;
}
public void setProxyUrl(String proxyUrl) {
this.proxyUrl = proxyUrl;
}
public String getProjectName() {
return projectName;
}
public void setProjectName(String projectName) {
this.projectName = projectName;
}
public String getLaunchName() {
return launchName;
}
public void setLaunchName(String launchName) {
this.launchName = launchName;
}
@Nullable
public String getLaunchUuid() {
return launchUuid;
}
public void setLaunchUuid(@Nullable String launchUuid) {
this.launchUuid = launchUuid;
}
public Mode getLaunchRunningMode() {
return launchRunningMode;
}
public void setLaunchRunningMode(Mode launchRunningMode) {
this.launchRunningMode = launchRunningMode;
}
public Set<ItemAttributesRQ> getAttributes() {
return Collections.unmodifiableSet(attributes);
}
public void setAttributes(Set<ItemAttributesRQ> attributes) {
this.attributes = new HashSet<>(attributes);
}
public Boolean getEnable() {
return enable;
}
public void setEnable(Boolean enable) {
this.enable = enable;
}
public Boolean getSkippedAnIssue() {
return isSkippedAnIssue;
}
public void setSkippedAnIssue(Boolean skippedAnIssue) {
isSkippedAnIssue = skippedAnIssue;
}
public Integer getBatchLogsSize() {
return batchLogsSize;
}
public void setBatchLogsSize(Integer batchLogsSize) {
this.batchLogsSize = batchLogsSize;
}
public Long getBatchPayloadLimit() {
return batchPayloadLimit;
}
public void setBatchPayloadLimit(Long batchPayloadLimit) {
this.batchPayloadLimit = batchPayloadLimit;
}
public boolean isConvertImage() {
return convertImage;
}
public void setConvertImage(boolean convertImage) {
this.convertImage = convertImage;
}
public Integer getReportingTimeout() {
return reportingTimeout;
}
public String getKeystore() {
return keystore;
}
public void setKeystore(String keystore) {
this.keystore = keystore;
}
public void setReportingTimeout(Integer reportingTimeout) {
this.reportingTimeout = reportingTimeout;
}
public String getKeystorePassword() {
return keystorePassword;
}
public void setKeystorePassword(String keystorePassword) {
this.keystorePassword = keystorePassword;
}
public boolean isRerun() {
return rerun;
}
public boolean isAsyncReporting() {
return asyncReporting;
}
public void setAsyncReporting(boolean asyncReporting) {
this.asyncReporting = asyncReporting;
}
public boolean isCallbackReportingEnabled() {
return callbackReportingEnabled;
}
public void setCallbackReportingEnabled(boolean callbackReportingEnabled) {
this.callbackReportingEnabled = callbackReportingEnabled;
}
public void setRerun(boolean rerun) {
this.rerun = rerun;
}
public String getRerunOf() {
return rerunOf;
}
public void setRerunOf(String rerunOf) {
this.rerunOf = rerunOf;
}
public Integer getIoPoolSize() {
return ioPoolSize;
}
public void setIoPoolSize(Integer ioPoolSize) {
this.ioPoolSize = ioPoolSize;
}
public boolean getClientJoin() {
return clientJoin;
}
public void setClientJoin(boolean mode) {
this.clientJoin = mode;
}
public LaunchIdLockMode getClientJoinMode() {
return clientJoinMode;
}
public void setClientJoinMode(LaunchIdLockMode clientJoinMode) {
this.clientJoinMode = clientJoinMode;
}
public String getLockFileName() {
return lockFileName;
}
public void setLockFileName(String fileName) {
this.lockFileName = fileName;
}
public String getSyncFileName() {
return syncFileName;
}
public void setSyncFileName(String fileName) {
this.syncFileName = fileName;
}
public long getClientJoinTimeout() {
return clientJoinTimeout;
}
public void setClientJoinTimeout(long clientJoinTimeout) {
this.clientJoinTimeout = clientJoinTimeout;
}
public long getLockWaitTimeout() {
return lockWaitTimeout;
}
public void setLockWaitTimeout(long timeout) {
this.lockWaitTimeout = timeout;
}
public int getLockPortNumber() {
return lockPortNumber;
}
public void setLockPortNumber(int lockPortNumber) {
this.lockPortNumber = lockPortNumber;
}
public boolean isHttpLogging() {
return httpLogging;
}
public void setHttpLogging(boolean httpLogging) {
this.httpLogging = httpLogging;
}
public int getRxBufferSize() {
return ofNullable(System.getProperty("rx2.buffer-size")).map(Integer::valueOf)
.map(s -> Math.max(1, s))
.orElse(rxBufferSize);
}
public void setRxBufferSize(int size) {
rxBufferSize = size;
}
/**
* @return to truncate or not truncate
* @deprecated use {@link #isTruncateFields} instead
*/
@Deprecated
public boolean isTruncateItemNames() {
return truncateFields;
}
/**
* @param truncate to truncate or not truncate
* @deprecated use {@link #setTruncateFields} instead
*/
@Deprecated
public void setTruncateItemNames(boolean truncate) {
this.truncateFields = truncate;
}
public boolean isTruncateFields() {
return truncateFields;
}
public void setTruncateFields(boolean truncateFields) {
this.truncateFields = truncateFields;
}
public int getTruncateItemNamesLimit() {
return truncateItemNamesLimit;
}
public void setTruncateItemNamesLimit(int limit) {
this.truncateItemNamesLimit = limit;
}
/**
* @return truncation replacement
* @deprecated Use {@link #getTruncateReplacement} instead
*/
@Deprecated
public String getTruncateItemNamesReplacement() {
return truncateReplacement;
}
/**
* @param replacement truncation replacement
* @deprecated Use {@link #setTruncateReplacement} instead
*/
@Deprecated
public void setTruncateItemNamesReplacement(String replacement) {
this.truncateReplacement = replacement;
}
public String getTruncateReplacement() {
return truncateReplacement;
}
public void setTruncateReplacement(String replacement) {
this.truncateReplacement = replacement;
}
public int getAttributeLengthLimit() {
return attributeLengthLimit;
}
public void setAttributeLengthLimit(int attributeLengthLimit) {
this.attributeLengthLimit = attributeLengthLimit;
}
public void setHttpCallTimeout(@Nullable Duration httpCallTimeout) {
this.httpCallTimeout = httpCallTimeout;
}
@Nullable
public Duration getHttpCallTimeout() {
return httpCallTimeout;
}
public void setHttpConnectTimeout(@Nullable Duration httpConnectTimeout) {
this.httpConnectTimeout = httpConnectTimeout;
}
@Nullable
public Duration getHttpConnectTimeout() {
return httpConnectTimeout;
}
public void setHttpReadTimeout(@Nullable Duration httpReadTimeout) {
this.httpReadTimeout = httpReadTimeout;
}
@Nullable
public Duration getHttpReadTimeout() {
return httpReadTimeout;
}
public void setHttpWriteTimeout(@Nullable Duration httpWriteTimeout) {
this.httpWriteTimeout = httpWriteTimeout;
}
@Nullable
public Duration getHttpWriteTimeout() {
return httpWriteTimeout;
}
@VisibleForTesting
Mode parseLaunchMode(String mode) {
return Mode.isExists(mode) ? Mode.valueOf(mode.toUpperCase()) : Mode.DEFAULT;
}
@Override
@Nonnull
public ListenerParameters clone() {
ListenerParameters clonedParent;
try {
clonedParent = (ListenerParameters) super.clone();
} catch (CloneNotSupportedException exc) {
clonedParent = new ListenerParameters();
}
final ListenerParameters clone = clonedParent;
Arrays.stream(getClass().getDeclaredFields()).forEach(f -> {
if (Modifier.isFinal(f.getModifiers())) {
return; // skip constants
}
try {
f.set(clone, f.get(this));
} catch (IllegalAccessException e) {
// actually, we are calling field set from within the class, so that should not happen, unless we try to set final fields
throw new IllegalStateException(e);
}
});
return clone;
}
@Override
@Nonnull
public String toString() {
@SuppressWarnings("StringBufferReplaceableByString")
final StringBuilder sb = new StringBuilder("ListenerParameters{");
sb.append("description='").append(description).append('\'');
sb.append(", apiKey='").append(apiKey).append('\'');
sb.append(", baseUrl='").append(baseUrl).append('\'');
sb.append(", proxyUrl='").append(proxyUrl).append('\'');
sb.append(", httpLogging='").append(httpLogging).append('\'');
sb.append(", httpCallTimeout='").append(httpCallTimeout).append('\'');
sb.append(", httpConnectTimeout='").append(httpConnectTimeout).append('\'');
sb.append(", httpReadTimeout='").append(httpReadTimeout).append('\'');
sb.append(", httpWriteTimeout='").append(httpWriteTimeout).append('\'');
sb.append(", projectName='").append(projectName).append('\'');
sb.append(", launchName='").append(launchName).append('\'');
sb.append(", launchUuid='").append(launchUuid).append('\'');
sb.append(", launchRunningMode=").append(launchRunningMode);
sb.append(", attributes=").append(attributes);
sb.append(", enable=").append(enable);
sb.append(", isSkippedAnIssue=").append(isSkippedAnIssue);
sb.append(", batchLogsSize=").append(batchLogsSize);
sb.append(", convertImage=").append(convertImage);
sb.append(", reportingTimeout=").append(reportingTimeout);
sb.append(", keystore='").append(keystore).append('\'');
sb.append(", keystorePassword='").append(keystorePassword).append('\'');
sb.append(", rerun=").append(rerun);
sb.append(", rerunOf='").append(rerunOf).append('\'');
sb.append(", asyncReporting=").append(asyncReporting);
sb.append(", ioPoolSize=").append(ioPoolSize);
sb.append(", callbackReportingEnabled=").append(callbackReportingEnabled);
sb.append(", clientJoin=").append(clientJoin);
sb.append(", clientJoinMode=").append(ofNullable(clientJoinMode).map(Enum::name).orElse(null));
sb.append(", clientJoinTimeout=").append(clientJoinTimeout);
sb.append(", lockFileName=").append(lockFileName);
sb.append(", syncFileName=").append(syncFileName);
sb.append(", lockWaitTimeout=").append(lockWaitTimeout);
sb.append(", lockPortNumber=").append(lockPortNumber);
sb.append(", rxBufferSize=").append(rxBufferSize);
sb.append('}');
return sb.toString();
}
}