/
VoldemortConfig.java
1514 lines (1229 loc) · 53.5 KB
/
VoldemortConfig.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
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* Copyright 2008-2010 LinkedIn, Inc
*
* 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 voldemort.server;
import java.io.File;
import java.io.IOException;
import java.io.Serializable;
import java.util.List;
import java.util.Properties;
import java.util.concurrent.TimeUnit;
import voldemort.client.protocol.RequestFormatType;
import voldemort.cluster.failuredetector.FailureDetectorConfig;
import voldemort.server.scheduler.slop.StreamingSlopPusherJob;
import voldemort.store.bdb.BdbStorageConfiguration;
import voldemort.store.memory.CacheStorageConfiguration;
import voldemort.store.memory.InMemoryStorageConfiguration;
import voldemort.store.mysql.MysqlStorageConfiguration;
import voldemort.store.readonly.BinarySearchStrategy;
import voldemort.store.readonly.ReadOnlyStorageConfiguration;
import voldemort.utils.ConfigurationException;
import voldemort.utils.Props;
import voldemort.utils.Time;
import voldemort.utils.TimeoutConfig;
import voldemort.utils.UndefinedPropertyException;
import voldemort.utils.Utils;
import com.google.common.collect.ImmutableList;
/**
* Configuration parameters for the voldemort server.
*
*
*/
public class VoldemortConfig implements Serializable {
private static final long serialVersionUID = 1;
public static final String VOLDEMORT_HOME_VAR_NAME = "VOLDEMORT_HOME";
public static final String VOLDEMORT_CONFIG_DIR = "VOLDEMORT_CONFIG_DIR";
private static final String VOLDEMORT_NODE_ID_VAR_NAME = "VOLDEMORT_NODE_ID";
public static int VOLDEMORT_DEFAULT_ADMIN_PORT = 6660;
public static final long REPORTING_INTERVAL_BYTES = 25 * 1024 * 1024;
public static final int DEFAULT_BUFFER_SIZE = 64 * 1024;
private int nodeId;
private String voldemortHome;
private String dataDirectory;
private String metadataDirectory;
private long bdbCacheSize;
private boolean bdbWriteTransactions;
private boolean bdbFlushTransactions;
private boolean bdbSortedDuplicates;
private String bdbDataDirectory;
private long bdbMaxLogFileSize;
private int bdbBtreeFanout;
private long bdbCheckpointBytes;
private long bdbCheckpointMs;
private boolean bdbOneEnvPerStore;
private int bdbCleanerMinFileUtilization;
private int bdbCleanerMinUtilization;
private int bdbCleanerLookAheadCacheSize;
private boolean bdbCheckpointerHighPriority;
private int bdbCleanerMaxBatchFiles;
private boolean bdbReadUncommitted;
private int bdbCleanerThreads;
private long bdbLockTimeoutMs;
private int bdbLockNLockTables;
private int bdbLogFaultReadSize;
private int bdbLogIteratorReadSize;
private boolean bdbFairLatches;
private long bdbStatsCacheTtlMs;
private String mysqlUsername;
private String mysqlPassword;
private String mysqlDatabaseName;
private String mysqlHost;
private int mysqlPort;
private int readOnlyBackups;
private String readOnlyStorageDir;
private String readOnlySearchStrategy;
private int readOnlyDeleteBackupTimeMs;
private long maxBytesPerSecond;
private long minBytesPerSecond;
private long reportingIntervalBytes;
private int fetcherBufferSize;
private int coreThreads;
private int maxThreads;
private int socketTimeoutMs;
private int socketBufferSize;
private boolean socketKeepAlive;
private boolean useNioConnector;
private int nioConnectorSelectors;
private int nioAdminConnectorSelectors;
private int clientSelectors;
private int clientRoutingTimeoutMs;
private TimeoutConfig clientTimeoutConfig;
private int clientMaxConnectionsPerNode;
private int clientConnectionTimeoutMs;
private int clientMaxThreads;
private int clientThreadIdleMs;
private int clientMaxQueuedRequests;
private int schedulerThreads;
private boolean mayInterruptService;
private int numScanPermits;
private RequestFormatType requestFormatType;
private boolean enableSlop;
private boolean enableSlopPusherJob;
private boolean enableRepair;
private boolean enableGui;
private boolean enableHttpServer;
private boolean enableSocketServer;
private boolean enableAdminServer;
private boolean enableJmx;
private boolean enablePipelineRoutedStore;
private boolean enableVerboseLogging;
private boolean enableStatTracking;
private boolean enableServerRouting;
private boolean enableMetadataChecking;
private boolean enableNetworkClassLoader;
private boolean enableGossip;
private boolean enableRebalanceService;
private boolean enableJmxClusterName;
private List<String> storageConfigurations;
private Props allProps;
private String slopStoreType;
private String pusherType;
private long slopFrequencyMs;
private long repairStartMs;
private long slopMaxWriteBytesPerSec;
private long slopMaxReadBytesPerSec;
private int slopBatchSize;
private int slopZonesDownToTerminate;
private int adminCoreThreads;
private int adminMaxThreads;
private int adminStreamBufferSize;
private int adminSocketTimeout;
private int adminConnectionTimeout;
private long streamMaxReadBytesPerSec;
private long streamMaxWriteBytesPerSec;
private int gossipInterval;
private String failureDetectorImplementation;
private long failureDetectorBannagePeriod;
private int failureDetectorThreshold;
private int failureDetectorThresholdCountMinimum;
private long failureDetectorThresholdInterval;
private long failureDetectorAsyncRecoveryInterval;
private volatile List<String> failureDetectorCatastrophicErrorTypes;
private long failureDetectorRequestLengthThreshold;
private int retentionCleanupFirstStartTimeInHour;
private int retentionCleanupScheduledPeriodInHour;
private int maxRebalancingAttempt;
private long rebalancingTimeoutSec;
private int maxParallelStoresRebalancing;
private boolean rebalancingOptimization;
public VoldemortConfig(Properties props) {
this(new Props(props));
}
public VoldemortConfig(Props props) {
try {
this.nodeId = props.getInt("node.id");
} catch(UndefinedPropertyException e) {
this.nodeId = getIntEnvVariable(VOLDEMORT_NODE_ID_VAR_NAME);
}
this.voldemortHome = props.getString("voldemort.home");
this.dataDirectory = props.getString("data.directory", this.voldemortHome + File.separator
+ "data");
this.metadataDirectory = props.getString("metadata.directory", voldemortHome
+ File.separator + "config");
this.bdbCacheSize = props.getBytes("bdb.cache.size", 200 * 1024 * 1024);
this.bdbWriteTransactions = props.getBoolean("bdb.write.transactions", false);
this.bdbFlushTransactions = props.getBoolean("bdb.flush.transactions", false);
this.bdbDataDirectory = props.getString("bdb.data.directory", this.dataDirectory
+ File.separator + "bdb");
this.bdbMaxLogFileSize = props.getBytes("bdb.max.logfile.size", 60 * 1024 * 1024);
this.bdbBtreeFanout = props.getInt("bdb.btree.fanout", 512);
this.bdbCheckpointBytes = props.getLong("bdb.checkpoint.interval.bytes", 20 * 1024 * 1024);
this.bdbCheckpointMs = props.getLong("bdb.checkpoint.interval.ms", 30 * Time.MS_PER_SECOND);
this.bdbSortedDuplicates = props.getBoolean("bdb.enable.sorted.duplicates", true);
this.bdbOneEnvPerStore = props.getBoolean("bdb.one.env.per.store", false);
this.bdbCleanerMinFileUtilization = props.getInt("bdb.cleaner.min.file.utilization", 5);
this.bdbCleanerMinUtilization = props.getInt("bdb.cleaner.minUtilization", 50);
this.bdbCleanerThreads = props.getInt("bdb.cleaner.threads", 1);
this.bdbCleanerLookAheadCacheSize = props.getInt("bdb.cleaner.lookahead.cache.size", 8192);
this.bdbLockTimeoutMs = props.getLong("bdb.lock.timeout.ms", 500);
this.bdbLockNLockTables = props.getInt("bdb.lock.nLockTables", 1);
this.bdbLogFaultReadSize = props.getInt("bdb.log.fault.read.size", 2048);
this.bdbLogIteratorReadSize = props.getInt("bdb.log.iterator.read.size", 8192);
this.bdbFairLatches = props.getBoolean("bdb.fair.latches", false);
this.bdbCheckpointerHighPriority = props.getBoolean("bdb.checkpointer.high.priority", false);
this.bdbCleanerMaxBatchFiles = props.getInt("bdb.cleaner.max.batch.files", 0);
this.bdbReadUncommitted = props.getBoolean("bdb.lock.read_uncommitted", true);
this.bdbStatsCacheTtlMs = props.getLong("bdb.stats.cache.ttl.ms", 5 * Time.MS_PER_SECOND);
this.readOnlyBackups = props.getInt("readonly.backups", 1);
this.readOnlySearchStrategy = props.getString("readonly.search.strategy",
BinarySearchStrategy.class.getName());
this.readOnlyStorageDir = props.getString("readonly.data.directory", this.dataDirectory
+ File.separator
+ "read-only");
this.readOnlyDeleteBackupTimeMs = props.getInt("readonly.delete.backup.ms", 0);
this.maxBytesPerSecond = props.getBytes("fetcher.max.bytes.per.sec", 0);
this.minBytesPerSecond = props.getBytes("fetcher.min.bytes.per.sec", 0);
this.reportingIntervalBytes = props.getBytes("fetcher.reporting.interval.bytes",
REPORTING_INTERVAL_BYTES);
this.fetcherBufferSize = (int) props.getBytes("hdfs.fetcher.buffer.size",
DEFAULT_BUFFER_SIZE);
this.mysqlUsername = props.getString("mysql.user", "root");
this.mysqlPassword = props.getString("mysql.password", "");
this.mysqlHost = props.getString("mysql.host", "localhost");
this.mysqlPort = props.getInt("mysql.port", 3306);
this.mysqlDatabaseName = props.getString("mysql.database", "voldemort");
this.maxThreads = props.getInt("max.threads", 100);
this.coreThreads = props.getInt("core.threads", Math.max(1, maxThreads / 2));
// Admin client should have less threads but very high buffer size.
this.adminMaxThreads = props.getInt("admin.max.threads", 20);
this.adminCoreThreads = props.getInt("admin.core.threads", Math.max(1, adminMaxThreads / 2));
this.adminStreamBufferSize = (int) props.getBytes("admin.streams.buffer.size",
10 * 1000 * 1000);
this.adminConnectionTimeout = props.getInt("admin.client.connection.timeout.sec", 60);
this.adminSocketTimeout = props.getInt("admin.client.socket.timeout.sec", 24 * 60 * 60);
this.streamMaxReadBytesPerSec = props.getBytes("stream.read.byte.per.sec", 10 * 1000 * 1000);
this.streamMaxWriteBytesPerSec = props.getBytes("stream.write.byte.per.sec",
10 * 1000 * 1000);
this.socketTimeoutMs = props.getInt("socket.timeout.ms", 5000);
this.socketBufferSize = (int) props.getBytes("socket.buffer.size", 64 * 1024);
this.socketKeepAlive = props.getBoolean("socket.keepalive", false);
this.useNioConnector = props.getBoolean("enable.nio.connector", true);
this.nioConnectorSelectors = props.getInt("nio.connector.selectors",
Math.max(8, Runtime.getRuntime()
.availableProcessors()));
this.nioAdminConnectorSelectors = props.getInt("nio.admin.connector.selectors",
Math.max(8, Runtime.getRuntime()
.availableProcessors()));
this.clientSelectors = props.getInt("client.selectors", 4);
this.clientMaxConnectionsPerNode = props.getInt("client.max.connections.per.node", 50);
this.clientConnectionTimeoutMs = props.getInt("client.connection.timeout.ms", 500);
this.clientRoutingTimeoutMs = props.getInt("client.routing.timeout.ms", 15000);
this.clientTimeoutConfig = new TimeoutConfig(this.clientRoutingTimeoutMs, false);
this.clientTimeoutConfig.getTimeoutMs(props.getInt("client.routing.get.timeout.ms",
this.clientRoutingTimeoutMs),
TimeUnit.MILLISECONDS);
this.clientTimeoutConfig.getAllTimeoutMs(props.getInt("client.routing.getall.timeout.ms",
this.clientRoutingTimeoutMs),
TimeUnit.MILLISECONDS);
this.clientTimeoutConfig.putTimeoutMs(props.getInt("client.routing.put.timeout.ms",
this.clientRoutingTimeoutMs),
TimeUnit.MILLISECONDS);
this.clientTimeoutConfig.getVersionsTimeoutMs(props.getLong("client.routing.getversions.timeout.ms",
this.clientTimeoutConfig.putTimeoutMs()),
TimeUnit.MILLISECONDS);
this.clientTimeoutConfig.deleteTimeoutMs(props.getInt("client.routing.delete.timeout.ms",
this.clientRoutingTimeoutMs),
TimeUnit.MILLISECONDS);
this.clientTimeoutConfig.setPartialGetAllAllowed(props.getBoolean("client.routing.allow.partial.getall",
false));
this.clientMaxThreads = props.getInt("client.max.threads", 500);
this.clientThreadIdleMs = props.getInt("client.thread.idle.ms", 100000);
this.clientMaxQueuedRequests = props.getInt("client.max.queued.requests", 1000);
this.enableHttpServer = props.getBoolean("http.enable", true);
this.enableSocketServer = props.getBoolean("socket.enable", true);
this.enableAdminServer = props.getBoolean("admin.enable", true);
this.enableJmx = props.getBoolean("jmx.enable", true);
this.enablePipelineRoutedStore = props.getBoolean("enable.pipeline.routed.store", true);
this.enableSlop = props.getBoolean("slop.enable", true);
this.enableSlopPusherJob = props.getBoolean("slop.pusher.enable", true);
this.slopMaxWriteBytesPerSec = props.getBytes("slop.write.byte.per.sec", 10 * 1000 * 1000);
this.enableVerboseLogging = props.getBoolean("enable.verbose.logging", true);
this.enableStatTracking = props.getBoolean("enable.stat.tracking", true);
this.enableServerRouting = props.getBoolean("enable.server.routing", true);
this.enableMetadataChecking = props.getBoolean("enable.metadata.checking", true);
this.enableGossip = props.getBoolean("enable.gossip", false);
this.enableRebalanceService = props.getBoolean("enable.rebalancing", true);
this.enableRepair = props.getBoolean("enable.repair", true);
this.enableJmxClusterName = props.getBoolean("enable.jmx.clustername", false);
this.gossipInterval = props.getInt("gossip.interval.ms", 30 * 1000);
this.slopMaxWriteBytesPerSec = props.getBytes("slop.write.byte.per.sec", 10 * 1000 * 1000);
this.slopMaxReadBytesPerSec = props.getBytes("slop.read.byte.per.sec", 10 * 1000 * 1000);
this.slopStoreType = props.getString("slop.store.engine", BdbStorageConfiguration.TYPE_NAME);
this.slopFrequencyMs = props.getLong("slop.frequency.ms", 5 * 60 * 1000);
this.repairStartMs = props.getLong("repair.start.ms", 24 * 60 * 60 * 1000);
this.slopBatchSize = props.getInt("slop.batch.size", 100);
this.pusherType = props.getString("pusher.type", StreamingSlopPusherJob.TYPE_NAME);
this.slopZonesDownToTerminate = props.getInt("slop.zones.terminate", 0);
this.schedulerThreads = props.getInt("scheduler.threads", 6);
this.mayInterruptService = props.getBoolean("service.interruptible", true);
this.numScanPermits = props.getInt("num.scan.permits", 1);
this.storageConfigurations = props.getList("storage.configs",
ImmutableList.of(BdbStorageConfiguration.class.getName(),
MysqlStorageConfiguration.class.getName(),
InMemoryStorageConfiguration.class.getName(),
CacheStorageConfiguration.class.getName(),
ReadOnlyStorageConfiguration.class.getName()));
// start at midnight (0-23)
this.retentionCleanupFirstStartTimeInHour = props.getInt("retention.cleanup.first.start.hour",
0);
// repeat every 24 hours
this.retentionCleanupScheduledPeriodInHour = props.getInt("retention.cleanup.period.hours",
24);
// save props for access from plugins
this.allProps = props;
String requestFormatName = props.getString("request.format",
RequestFormatType.VOLDEMORT_V1.getCode());
this.requestFormatType = RequestFormatType.fromCode(requestFormatName);
// rebalancing parameters
this.maxRebalancingAttempt = props.getInt("max.rebalancing.attempts", 3);
this.rebalancingTimeoutSec = props.getLong("rebalancing.timeout.seconds", 10 * 24 * 60 * 60);
this.maxParallelStoresRebalancing = props.getInt("max.parallel.stores.rebalancing", 3);
this.rebalancingOptimization = props.getBoolean("rebalancing.optimization", true);
this.failureDetectorImplementation = props.getString("failuredetector.implementation",
FailureDetectorConfig.DEFAULT_IMPLEMENTATION_CLASS_NAME);
// We're changing the property from "client.node.bannage.ms" to
// "failuredetector.bannage.period" so if we have the old one, migrate
// it over.
if(props.containsKey("client.node.bannage.ms")
&& !props.containsKey("failuredetector.bannage.period")) {
props.put("failuredetector.bannage.period", props.get("client.node.bannage.ms"));
}
this.failureDetectorBannagePeriod = props.getLong("failuredetector.bannage.period",
FailureDetectorConfig.DEFAULT_BANNAGE_PERIOD);
this.failureDetectorThreshold = props.getInt("failuredetector.threshold",
FailureDetectorConfig.DEFAULT_THRESHOLD);
this.failureDetectorThresholdCountMinimum = props.getInt("failuredetector.threshold.countminimum",
FailureDetectorConfig.DEFAULT_THRESHOLD_COUNT_MINIMUM);
this.failureDetectorThresholdInterval = props.getLong("failuredetector.threshold.interval",
FailureDetectorConfig.DEFAULT_THRESHOLD_INTERVAL);
this.failureDetectorAsyncRecoveryInterval = props.getLong("failuredetector.asyncrecovery.interval",
FailureDetectorConfig.DEFAULT_ASYNC_RECOVERY_INTERVAL);
this.failureDetectorCatastrophicErrorTypes = props.getList("failuredetector.catastrophic.error.types",
FailureDetectorConfig.DEFAULT_CATASTROPHIC_ERROR_TYPES);
this.failureDetectorRequestLengthThreshold = props.getLong("failuredetector.request.length.threshold",
getSocketTimeoutMs());
// network class loader disable by default.
this.enableNetworkClassLoader = props.getBoolean("enable.network.classloader", false);
validateParams();
}
private void validateParams() {
if(coreThreads < 0)
throw new IllegalArgumentException("core.threads cannot be less than 1");
else if(coreThreads > maxThreads)
throw new IllegalArgumentException("core.threads cannot be greater than max.threads.");
if(maxThreads < 1)
throw new ConfigurationException("max.threads cannot be less than 1.");
if(slopFrequencyMs < 1)
throw new ConfigurationException("slop.frequency.ms cannot be less than 1.");
if(socketTimeoutMs < 0)
throw new ConfigurationException("socket.timeout.ms must be 0 or more ms.");
if(clientSelectors < 1)
throw new ConfigurationException("client.selectors must be 1 or more.");
if(clientRoutingTimeoutMs < 0)
throw new ConfigurationException("routing.timeout.ms must be 0 or more ms.");
if(schedulerThreads < 1)
throw new ConfigurationException("Must have at least 1 scheduler thread, "
+ this.schedulerThreads + " set.");
if(enableServerRouting && !enableSocketServer)
throw new ConfigurationException("Server-side routing is enabled, this requires the socket server to also be enabled.");
}
private int getIntEnvVariable(String name) {
String var = System.getenv(name);
if(var == null)
throw new ConfigurationException("The environment variable " + name
+ " is not defined.");
try {
return Integer.parseInt(var);
} catch(NumberFormatException e) {
throw new ConfigurationException("Invalid format for environment variable " + name
+ ", expecting an integer.", e);
}
}
public static VoldemortConfig loadFromEnvironmentVariable() {
String voldemortHome = System.getenv(VoldemortConfig.VOLDEMORT_HOME_VAR_NAME);
if(voldemortHome == null)
throw new ConfigurationException("No environment variable "
+ VoldemortConfig.VOLDEMORT_HOME_VAR_NAME
+ " has been defined, set it!");
String voldemortConfigDir = System.getenv(VoldemortConfig.VOLDEMORT_CONFIG_DIR);
if(voldemortConfigDir != null) {
if(!Utils.isReadableDir(voldemortConfigDir))
throw new ConfigurationException("Attempt to load configuration from VOLDEMORT_CONFIG_DIR, "
+ voldemortConfigDir
+ " failed. That is not a readable directory.");
}
return loadFromVoldemortHome(voldemortHome, voldemortConfigDir);
}
public static VoldemortConfig loadFromVoldemortHome(String voldemortHome) {
String voldemortConfigDir = voldemortHome + File.separator + "config";
return loadFromVoldemortHome(voldemortHome, voldemortConfigDir);
}
public static VoldemortConfig loadFromVoldemortHome(String voldemortHome,
String voldemortConfigDir) {
if(!Utils.isReadableDir(voldemortHome))
throw new ConfigurationException("Attempt to load configuration from VOLDEMORT_HOME, "
+ voldemortHome
+ " failed. That is not a readable directory.");
if(voldemortConfigDir == null) {
voldemortConfigDir = voldemortHome + File.separator + "config";
}
String propertiesFile = voldemortConfigDir + File.separator + "server.properties";
if(!Utils.isReadableFile(propertiesFile))
throw new ConfigurationException(propertiesFile
+ " is not a readable configuration file.");
Props properties = null;
try {
properties = new Props(new File(propertiesFile));
properties.put("voldemort.home", voldemortHome);
properties.put("metadata.directory", voldemortConfigDir);
} catch(IOException e) {
throw new ConfigurationException(e);
}
return new VoldemortConfig(properties);
}
/**
* The interval at which gossip is run to exchange metadata
*/
public int getGossipInterval() {
return gossipInterval;
}
public void setGossipInterval(int gossipInterval) {
this.gossipInterval = gossipInterval;
}
/**
* The node id given by "node.id" property default: VOLDEMORT_NODE_ID
* environment variable
*/
public int getNodeId() {
return nodeId;
}
public void setNodeId(int nodeId) {
this.nodeId = nodeId;
}
/**
* The node id given by "voldemort.home" default: VOLDEMORT_HOME environment
* variable
*/
public String getVoldemortHome() {
return voldemortHome;
}
public void setVoldemortHome(String voldemortHome) {
this.voldemortHome = voldemortHome;
}
/**
* The directory name given by "data.directory" default: voldemort.home/data
*/
public String getDataDirectory() {
return dataDirectory;
}
public void setDataDirectory(String dataDirectory) {
this.dataDirectory = dataDirectory;
}
/**
* The directory name given by "metadata.directory" default:
* voldemort.home/config
*/
public String getMetadataDirectory() {
return metadataDirectory;
}
public void setMetadataDirectory(String metadataDirectory) {
this.metadataDirectory = metadataDirectory;
}
/**
* The cache size given by "bdb.cache.size" in bytes default: 200MB
*/
public long getBdbCacheSize() {
return bdbCacheSize;
}
public void setBdbCacheSize(int bdbCacheSize) {
this.bdbCacheSize = bdbCacheSize;
}
/**
* Given by "bdb.flush.transactions". If true then sync transactions to disk
* immediately. default: false
*/
public boolean isBdbFlushTransactionsEnabled() {
return bdbFlushTransactions;
}
public void setBdbFlushTransactions(boolean bdbSyncTransactions) {
this.bdbFlushTransactions = bdbSyncTransactions;
}
/**
* The directory in which bdb data is stored. Given by "bdb.data.directory"
* default: data.directory/bdb
*/
public String getBdbDataDirectory() {
return bdbDataDirectory;
}
public void setBdbDataDirectory(String bdbDataDirectory) {
this.bdbDataDirectory = bdbDataDirectory;
}
/**
* The maximum size of a single .jdb log file in bytes. Given by
* "bdb.max.logfile.size" default: 60MB
*/
public long getBdbMaxLogFileSize() {
return this.bdbMaxLogFileSize;
}
public void setBdbMaxLogFileSize(long bdbMaxLogFileSize) {
this.bdbMaxLogFileSize = bdbMaxLogFileSize;
}
/**
* A log file will be cleaned if its utilization percentage is below this
* value, irrespective of total utilization.
*
* <ul>
* <li>property: "bdb.cleaner.minFileUtilization"</li>
* <li>default: 5</li>
* <li>minimum: 0</li>
* <li>maximum: 50</li>
* </ul>
*/
public int getBdbCleanerMinFileUtilization() {
return bdbCleanerMinFileUtilization;
}
public final void setBdbCleanerMinFileUtilization(int minFileUtilization) {
if(minFileUtilization < 0 || minFileUtilization > 50)
throw new IllegalArgumentException("minFileUtilization should be between 0 and 50 (both inclusive)");
this.bdbCleanerMinFileUtilization = minFileUtilization;
}
/**
* If true, the checkpointer uses more resources in order to complete the
* checkpoint in a shorter time interval.
*
* <ul>
* <li>property: "bdb.checkpointer.high.priority"</li>
* <li>default: false</li>
* </ul>
*/
public boolean getBdbCheckpointerHighPriority() {
return bdbCheckpointerHighPriority;
}
public final void setBdbCheckpointerHighPriority(boolean bdbCheckpointerHighPriority) {
this.bdbCheckpointerHighPriority = bdbCheckpointerHighPriority;
}
/**
* The maximum number of log files in the cleaner's backlog, or zero if
* there is no limit
*
* <ul>
* <li>property: "bdb.cleaner.max.batch.files"</li>
* <li>default: 0</li>
* <li>minimum: 0</li>
* <li>maximum: 100000</li>
* </ul>
*/
public int getBdbCleanerMaxBatchFiles() {
return bdbCleanerMaxBatchFiles;
}
public final void setBdbCleanerMaxBatchFiles(int bdbCleanerMaxBatchFiles) {
if(bdbCleanerMaxBatchFiles < 0 || bdbCleanerMaxBatchFiles > 100000)
throw new IllegalArgumentException("bdbCleanerMaxBatchFiles should be between 0 and 100000 (both inclusive)");
this.bdbCleanerMaxBatchFiles = bdbCleanerMaxBatchFiles;
}
/**
*
* The number of cleaner threads
*
* <ul>
* <li>property: "bdb.cleaner.threads"</li>
* <li>default: 1</li>
* <li>minimum: 1</li>
* </ul>
*/
public int getBdbCleanerThreads() {
return bdbCleanerThreads;
}
public final void setBdbCleanerThreads(int bdbCleanerThreads) {
if(bdbCleanerThreads <= 0)
throw new IllegalArgumentException("bdbCleanerThreads should be greater than 0");
this.bdbCleanerThreads = bdbCleanerThreads;
}
public int getBdbCleanerLookAheadCacheSize() {
return bdbCleanerLookAheadCacheSize;
}
public final void setBdbCleanerLookAheadCacheSize(int bdbCleanerLookAheadCacheSize) {
if(bdbCleanerLookAheadCacheSize < 0)
throw new IllegalArgumentException("bdbCleanerLookAheadCacheSize should be at least 0");
this.bdbCleanerLookAheadCacheSize = bdbCleanerLookAheadCacheSize;
}
/**
*
* The lock timeout for all transactional and non-transactional operations.
* Value of zero disables lock timeouts i.e. a deadlock scenario will block
* forever
*
* <ul>
* <li>property: "bdb.lock.timeout.ms"</li>
* <li>default: 500</li>
* <li>minimum: 0</li>
* <li>maximum: 75 * 60 * 1000</li>
* </ul>
*/
public long getBdbLockTimeoutMs() {
return bdbLockTimeoutMs;
}
public final void setBdbLockTimeoutMs(long bdbLockTimeoutMs) {
if(bdbLockTimeoutMs < 0)
throw new IllegalArgumentException("bdbLockTimeoutMs should be greater than 0");
this.bdbLockTimeoutMs = bdbLockTimeoutMs;
}
public void setBdbLockNLockTables(int bdbLockNLockTables) {
if(bdbLockNLockTables < 1 || bdbLockNLockTables > 32767)
throw new IllegalArgumentException("bdbLockNLockTables should be greater than 0 and "
+ "less than 32767");
this.bdbLockNLockTables = bdbLockNLockTables;
}
public int getBdbLockNLockTables() {
return bdbLockNLockTables;
}
public void setBdbLogFaultReadSize(int bdbLogFaultReadSize) {
this.bdbLogFaultReadSize = bdbLogFaultReadSize;
}
public int getBdbLogFaultReadSize() {
return bdbLogFaultReadSize;
}
public void setBdbLogIteratorReadSize(int bdbLogIteratorReadSize) {
this.bdbLogIteratorReadSize = bdbLogIteratorReadSize;
}
public int getBdbLogIteratorReadSize() {
return bdbLogIteratorReadSize;
}
public boolean getBdbFairLatches() {
return bdbFairLatches;
}
public void setBdbFairLatches(boolean bdbFairLatches) {
this.bdbFairLatches = bdbFairLatches;
}
public boolean getBdbReadUncommitted() {
return bdbReadUncommitted;
}
public void setBdbReadUncommitted(boolean bdbReadUncommitted) {
this.bdbReadUncommitted = bdbReadUncommitted;
}
/**
*
* The cleaner will keep the total disk space utilization percentage above
* this value.
*
* <ul>
* <li>property: "bdb.cleaner.minUtilization"</li>
* <li>default: 50</li>
* <li>minimum: 0</li>
* <li>maximum: 90</li>
* </ul>
*/
public int getBdbCleanerMinUtilization() {
return bdbCleanerMinUtilization;
}
public final void setBdbCleanerMinUtilization(int minUtilization) {
if(minUtilization < 0 || minUtilization > 90)
throw new IllegalArgumentException("minUtilization should be between 0 and 90 (both inclusive)");
this.bdbCleanerMinUtilization = minUtilization;
}
/**
*
* The btree node fanout. Given by "bdb.btree.fanout". default: 512
*/
public int getBdbBtreeFanout() {
return this.bdbBtreeFanout;
}
public void setBdbBtreeFanout(int bdbBtreeFanout) {
this.bdbBtreeFanout = bdbBtreeFanout;
}
/**
* The comfortable number of threads the threadpool will attempt to
* maintain. Specified by "core.threads" default: max(1, floor(0.5 *
* max.threads))
*/
public int getCoreThreads() {
return coreThreads;
}
public void setCoreThreads(int coreThreads) {
this.coreThreads = coreThreads;
}
/**
* The maximum number of threadpool threads set by "max.threads" default:
* 100
*/
public int getMaxThreads() {
return maxThreads;
}
public void setMaxThreads(int maxThreads) {
this.maxThreads = maxThreads;
}
public int getAdminCoreThreads() {
return adminCoreThreads;
}
public void setAdminCoreThreads(int coreThreads) {
this.adminCoreThreads = coreThreads;
}
public int getAdminMaxThreads() {
return adminMaxThreads;
}
public void setAdminMaxThreads(int maxThreads) {
this.adminMaxThreads = maxThreads;
}
public boolean isHttpServerEnabled() {
return enableHttpServer;
}
public void setEnableHttpServer(boolean enableHttpServer) {
this.enableHttpServer = enableHttpServer;
}
public boolean isSocketServerEnabled() {
return enableSocketServer;
}
public void setAdminServerEnabled(boolean enableSocketServer) {
this.enableSocketServer = enableSocketServer;
}
public boolean isAdminServerEnabled() {
return enableAdminServer;
}
public long getStreamMaxReadBytesPerSec() {
return streamMaxReadBytesPerSec;
}
public void setStreamMaxReadBytesPerSec(long streamMaxReadBytesPerSec) {
this.streamMaxReadBytesPerSec = streamMaxReadBytesPerSec;
}
public long getStreamMaxWriteBytesPerSec() {
return streamMaxWriteBytesPerSec;
}
public void setStreamMaxWriteBytesPerSec(long streamMaxWriteBytesPerSec) {
this.streamMaxWriteBytesPerSec = streamMaxWriteBytesPerSec;
}
public long getSlopMaxWriteBytesPerSec() {
return slopMaxWriteBytesPerSec;
}
public void setSlopMaxWriteBytesPerSec(long slopMaxWriteBytesPerSec) {
this.slopMaxWriteBytesPerSec = slopMaxWriteBytesPerSec;
}
public long getSlopMaxReadBytesPerSec() {
return slopMaxReadBytesPerSec;
}
public void setSlopMaxReadBytesPerSec(long slopMaxReadBytesPerSec) {
this.slopMaxReadBytesPerSec = slopMaxReadBytesPerSec;
}
public void setEnableAdminServer(boolean enableAdminServer) {
this.enableAdminServer = enableAdminServer;
}
public boolean isJmxEnabled() {
return enableJmx;
}
public void setEnableJmx(boolean enableJmx) {
this.enableJmx = enableJmx;
}
public boolean isPipelineRoutedStoreEnabled() {
return enablePipelineRoutedStore;
}
public void setEnablePipelineRoutedStore(boolean enablePipelineRoutedStore) {
this.enablePipelineRoutedStore = enablePipelineRoutedStore;
}
public boolean isGuiEnabled() {
return enableGui;
}
public void setEnableGui(boolean enableGui) {
this.enableGui = enableGui;
}
public String getMysqlUsername() {
return mysqlUsername;
}
public void setMysqlUsername(String mysqlUsername) {
this.mysqlUsername = mysqlUsername;
}
public String getMysqlPassword() {
return mysqlPassword;
}
public void setMysqlPassword(String mysqlPassword) {
this.mysqlPassword = mysqlPassword;
}
public String getMysqlDatabaseName() {
return mysqlDatabaseName;
}
public void setMysqlDatabaseName(String mysqlDatabaseName) {
this.mysqlDatabaseName = mysqlDatabaseName;
}
public String getMysqlHost() {
return mysqlHost;
}
public void setMysqlHost(String mysqlHost) {
this.mysqlHost = mysqlHost;
}
public int getMysqlPort() {
return mysqlPort;
}
public void setMysqlPort(int mysqlPort) {
this.mysqlPort = mysqlPort;
}
/**
* The underlying store type which will be used to store slops. Defaults to
* Bdb
*/
public String getSlopStoreType() {
return slopStoreType;
}
public void setSlopStoreType(String slopStoreType) {
this.slopStoreType = slopStoreType;
}
/**
* The type of streaming job we would want to use to send hints. Defaults to
* streaming
*/
public String getPusherType() {
return this.pusherType;
}
public void setPusherType(String pusherType) {
this.pusherType = pusherType;
}
/**
* Number of zones declared down before we terminate the pusher job
*/
public int getSlopZonesDownToTerminate() {
return this.slopZonesDownToTerminate;
}
public void setSlopZonesDownToTerminate(int slopZonesDownToTerminate) {
this.slopZonesDownToTerminate = slopZonesDownToTerminate;
}
/**
* Returns the size of the batch used while streaming slops
*/
public int getSlopBatchSize() {
return this.slopBatchSize;
}
public void setSlopBatchSize(int slopBatchSize) {
this.slopBatchSize = slopBatchSize;
}
public int getSocketTimeoutMs() {
return this.socketTimeoutMs;
}
public long getSlopFrequencyMs() {
return this.slopFrequencyMs;
}
public void setSlopFrequencyMs(long slopFrequencyMs) {
this.slopFrequencyMs = slopFrequencyMs;
}
public long getRepairStartMs() {
return this.repairStartMs;
}
public void setRepairStartMs(long repairStartMs) {
this.repairStartMs = repairStartMs;
}