2 * Copyright (c) 2014 Brocade Communications Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.controller.cluster.datastore;
11 import akka.util.Timeout;
12 import com.google.common.annotations.VisibleForTesting;
13 import com.google.common.base.Preconditions;
15 import java.util.concurrent.ConcurrentHashMap;
16 import java.util.concurrent.TimeUnit;
17 import org.apache.commons.text.WordUtils;
18 import org.opendaylight.controller.cluster.access.client.AbstractClientConnection;
19 import org.opendaylight.controller.cluster.access.client.ClientActorConfig;
20 import org.opendaylight.controller.cluster.common.actor.AkkaConfigurationReader;
21 import org.opendaylight.controller.cluster.common.actor.FileAkkaConfigurationReader;
22 import org.opendaylight.controller.cluster.raft.ConfigParams;
23 import org.opendaylight.controller.cluster.raft.DefaultConfigParamsImpl;
24 import org.opendaylight.controller.cluster.raft.PeerAddressResolver;
25 import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStoreConfigProperties;
26 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
27 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
28 import org.slf4j.Logger;
29 import org.slf4j.LoggerFactory;
30 import scala.concurrent.duration.Duration;
31 import scala.concurrent.duration.FiniteDuration;
34 * Contains contextual data for a data store.
36 * @author Thomas Pantelis
38 // Noo-final for mocking
39 public class DatastoreContext implements ClientActorConfig {
40 public static final String METRICS_DOMAIN = "org.opendaylight.controller.cluster.datastore";
42 public static final Duration DEFAULT_SHARD_TRANSACTION_IDLE_TIMEOUT = Duration.create(10, TimeUnit.MINUTES);
43 public static final int DEFAULT_OPERATION_TIMEOUT_IN_MS = 5000;
44 public static final int DEFAULT_SHARD_TX_COMMIT_TIMEOUT_IN_SECONDS = 30;
45 public static final int DEFAULT_JOURNAL_RECOVERY_BATCH_SIZE = 1;
46 public static final int DEFAULT_SNAPSHOT_BATCH_COUNT = 20000;
47 public static final int DEFAULT_HEARTBEAT_INTERVAL_IN_MILLIS = 500;
48 public static final int DEFAULT_ISOLATED_LEADER_CHECK_INTERVAL_IN_MILLIS =
49 DEFAULT_HEARTBEAT_INTERVAL_IN_MILLIS * 10;
50 public static final int DEFAULT_SHARD_TX_COMMIT_QUEUE_CAPACITY = 50000;
51 public static final Timeout DEFAULT_SHARD_INITIALIZATION_TIMEOUT = new Timeout(5, TimeUnit.MINUTES);
52 public static final Timeout DEFAULT_SHARD_LEADER_ELECTION_TIMEOUT = new Timeout(30, TimeUnit.SECONDS);
53 public static final boolean DEFAULT_PERSISTENT = true;
54 public static final FileAkkaConfigurationReader DEFAULT_CONFIGURATION_READER = new FileAkkaConfigurationReader();
55 public static final int DEFAULT_SHARD_SNAPSHOT_DATA_THRESHOLD_PERCENTAGE = 12;
56 public static final int DEFAULT_SHARD_ELECTION_TIMEOUT_FACTOR = 2;
57 public static final int DEFAULT_TX_CREATION_INITIAL_RATE_LIMIT = 100;
58 public static final String UNKNOWN_DATA_STORE_TYPE = "unknown";
59 public static final int DEFAULT_SHARD_BATCHED_MODIFICATION_COUNT = 1000;
60 public static final long DEFAULT_SHARD_COMMIT_QUEUE_EXPIRY_TIMEOUT_IN_MS =
61 TimeUnit.MILLISECONDS.convert(2, TimeUnit.MINUTES);
62 public static final int DEFAULT_MAX_MESSAGE_SLICE_SIZE = 2048 * 1000; // 2MB
64 public static final long DEFAULT_SYNC_INDEX_THRESHOLD = 10;
66 private static final Logger LOG = LoggerFactory.getLogger(DatastoreContext.class);
68 private static final Set<String> GLOBAL_DATASTORE_NAMES = ConcurrentHashMap.newKeySet();
70 private final DefaultConfigParamsImpl raftConfig = new DefaultConfigParamsImpl();
72 private InMemoryDOMDataStoreConfigProperties dataStoreProperties;
73 private Duration shardTransactionIdleTimeout = DatastoreContext.DEFAULT_SHARD_TRANSACTION_IDLE_TIMEOUT;
74 private long operationTimeoutInMillis = DEFAULT_OPERATION_TIMEOUT_IN_MS;
75 private String dataStoreMXBeanType;
76 private int shardTransactionCommitTimeoutInSeconds = DEFAULT_SHARD_TX_COMMIT_TIMEOUT_IN_SECONDS;
77 private int shardTransactionCommitQueueCapacity = DEFAULT_SHARD_TX_COMMIT_QUEUE_CAPACITY;
78 private Timeout shardInitializationTimeout = DEFAULT_SHARD_INITIALIZATION_TIMEOUT;
79 private Timeout shardLeaderElectionTimeout = DEFAULT_SHARD_LEADER_ELECTION_TIMEOUT;
80 private boolean persistent = DEFAULT_PERSISTENT;
81 private AkkaConfigurationReader configurationReader = DEFAULT_CONFIGURATION_READER;
82 private long transactionCreationInitialRateLimit = DEFAULT_TX_CREATION_INITIAL_RATE_LIMIT;
83 private String dataStoreName = UNKNOWN_DATA_STORE_TYPE;
84 private LogicalDatastoreType logicalStoreType = LogicalDatastoreType.OPERATIONAL;
85 private YangInstanceIdentifier storeRoot = YangInstanceIdentifier.EMPTY;
86 private int shardBatchedModificationCount = DEFAULT_SHARD_BATCHED_MODIFICATION_COUNT;
87 private boolean writeOnlyTransactionOptimizationsEnabled = true;
88 private long shardCommitQueueExpiryTimeoutInMillis = DEFAULT_SHARD_COMMIT_QUEUE_EXPIRY_TIMEOUT_IN_MS;
89 private boolean useTellBasedProtocol = false;
90 private boolean transactionDebugContextEnabled = false;
91 private String shardManagerPersistenceId;
92 private int maximumMessageSliceSize = DEFAULT_MAX_MESSAGE_SLICE_SIZE;
93 private long backendAlivenessTimerInterval = AbstractClientConnection.DEFAULT_BACKEND_ALIVE_TIMEOUT_NANOS;
94 private long requestTimeout = AbstractClientConnection.DEFAULT_REQUEST_TIMEOUT_NANOS;
95 private long noProgressTimeout = AbstractClientConnection.DEFAULT_NO_PROGRESS_TIMEOUT_NANOS;
97 public static Set<String> getGlobalDatastoreNames() {
98 return GLOBAL_DATASTORE_NAMES;
102 setShardJournalRecoveryLogBatchSize(DEFAULT_JOURNAL_RECOVERY_BATCH_SIZE);
103 setSnapshotBatchCount(DEFAULT_SNAPSHOT_BATCH_COUNT);
104 setHeartbeatInterval(DEFAULT_HEARTBEAT_INTERVAL_IN_MILLIS);
105 setIsolatedLeaderCheckInterval(DEFAULT_ISOLATED_LEADER_CHECK_INTERVAL_IN_MILLIS);
106 setSnapshotDataThresholdPercentage(DEFAULT_SHARD_SNAPSHOT_DATA_THRESHOLD_PERCENTAGE);
107 setElectionTimeoutFactor(DEFAULT_SHARD_ELECTION_TIMEOUT_FACTOR);
108 setSyncIndexThreshold(DEFAULT_SYNC_INDEX_THRESHOLD);
109 setMaximumMessageSliceSize(DEFAULT_MAX_MESSAGE_SLICE_SIZE);
112 private DatastoreContext(final DatastoreContext other) {
113 this.dataStoreProperties = other.dataStoreProperties;
114 this.shardTransactionIdleTimeout = other.shardTransactionIdleTimeout;
115 this.operationTimeoutInMillis = other.operationTimeoutInMillis;
116 this.dataStoreMXBeanType = other.dataStoreMXBeanType;
117 this.shardTransactionCommitTimeoutInSeconds = other.shardTransactionCommitTimeoutInSeconds;
118 this.shardTransactionCommitQueueCapacity = other.shardTransactionCommitQueueCapacity;
119 this.shardInitializationTimeout = other.shardInitializationTimeout;
120 this.shardLeaderElectionTimeout = other.shardLeaderElectionTimeout;
121 this.persistent = other.persistent;
122 this.configurationReader = other.configurationReader;
123 this.transactionCreationInitialRateLimit = other.transactionCreationInitialRateLimit;
124 this.dataStoreName = other.dataStoreName;
125 this.logicalStoreType = other.logicalStoreType;
126 this.storeRoot = other.storeRoot;
127 this.shardBatchedModificationCount = other.shardBatchedModificationCount;
128 this.writeOnlyTransactionOptimizationsEnabled = other.writeOnlyTransactionOptimizationsEnabled;
129 this.shardCommitQueueExpiryTimeoutInMillis = other.shardCommitQueueExpiryTimeoutInMillis;
130 this.transactionDebugContextEnabled = other.transactionDebugContextEnabled;
131 this.shardManagerPersistenceId = other.shardManagerPersistenceId;
132 this.useTellBasedProtocol = other.useTellBasedProtocol;
133 this.backendAlivenessTimerInterval = other.backendAlivenessTimerInterval;
134 this.requestTimeout = other.requestTimeout;
135 this.noProgressTimeout = other.noProgressTimeout;
137 setShardJournalRecoveryLogBatchSize(other.raftConfig.getJournalRecoveryLogBatchSize());
138 setSnapshotBatchCount(other.raftConfig.getSnapshotBatchCount());
139 setHeartbeatInterval(other.raftConfig.getHeartBeatInterval().toMillis());
140 setIsolatedLeaderCheckInterval(other.raftConfig.getIsolatedCheckIntervalInMillis());
141 setSnapshotDataThresholdPercentage(other.raftConfig.getSnapshotDataThresholdPercentage());
142 setElectionTimeoutFactor(other.raftConfig.getElectionTimeoutFactor());
143 setCustomRaftPolicyImplementation(other.raftConfig.getCustomRaftPolicyImplementationClass());
144 setMaximumMessageSliceSize(other.getMaximumMessageSliceSize());
145 setShardSnapshotChunkSize(other.raftConfig.getSnapshotChunkSize());
146 setPeerAddressResolver(other.raftConfig.getPeerAddressResolver());
147 setTempFileDirectory(other.getTempFileDirectory());
148 setFileBackedStreamingThreshold(other.getFileBackedStreamingThreshold());
149 setSyncIndexThreshold(other.raftConfig.getSyncIndexThreshold());
152 public static Builder newBuilder() {
153 return new Builder(new DatastoreContext());
156 public static Builder newBuilderFrom(final DatastoreContext context) {
157 return new Builder(new DatastoreContext(context));
160 public InMemoryDOMDataStoreConfigProperties getDataStoreProperties() {
161 return dataStoreProperties;
164 public Duration getShardTransactionIdleTimeout() {
165 return shardTransactionIdleTimeout;
168 public String getDataStoreMXBeanType() {
169 return dataStoreMXBeanType;
172 public long getOperationTimeoutInMillis() {
173 return operationTimeoutInMillis;
176 public ConfigParams getShardRaftConfig() {
180 public int getShardTransactionCommitTimeoutInSeconds() {
181 return shardTransactionCommitTimeoutInSeconds;
184 public int getShardTransactionCommitQueueCapacity() {
185 return shardTransactionCommitQueueCapacity;
188 public Timeout getShardInitializationTimeout() {
189 return shardInitializationTimeout;
192 public Timeout getShardLeaderElectionTimeout() {
193 return shardLeaderElectionTimeout;
196 public boolean isPersistent() {
200 public AkkaConfigurationReader getConfigurationReader() {
201 return configurationReader;
204 public long getShardElectionTimeoutFactor() {
205 return raftConfig.getElectionTimeoutFactor();
208 public String getDataStoreName() {
209 return dataStoreName;
212 public LogicalDatastoreType getLogicalStoreType() {
213 return logicalStoreType;
216 public YangInstanceIdentifier getStoreRoot() {
220 public long getTransactionCreationInitialRateLimit() {
221 return transactionCreationInitialRateLimit;
224 public String getShardManagerPersistenceId() {
225 return shardManagerPersistenceId;
229 public String getTempFileDirectory() {
230 return raftConfig.getTempFileDirectory();
233 private void setTempFileDirectory(final String tempFileDirectory) {
234 raftConfig.setTempFileDirectory(tempFileDirectory);
238 public int getFileBackedStreamingThreshold() {
239 return raftConfig.getFileBackedStreamingThreshold();
242 private void setFileBackedStreamingThreshold(final int fileBackedStreamingThreshold) {
243 raftConfig.setFileBackedStreamingThreshold(fileBackedStreamingThreshold);
246 private void setPeerAddressResolver(final PeerAddressResolver resolver) {
247 raftConfig.setPeerAddressResolver(resolver);
250 private void setHeartbeatInterval(final long shardHeartbeatIntervalInMillis) {
251 raftConfig.setHeartBeatInterval(new FiniteDuration(shardHeartbeatIntervalInMillis,
252 TimeUnit.MILLISECONDS));
255 private void setShardJournalRecoveryLogBatchSize(final int shardJournalRecoveryLogBatchSize) {
256 raftConfig.setJournalRecoveryLogBatchSize(shardJournalRecoveryLogBatchSize);
260 private void setIsolatedLeaderCheckInterval(final long shardIsolatedLeaderCheckIntervalInMillis) {
261 raftConfig.setIsolatedLeaderCheckInterval(
262 new FiniteDuration(shardIsolatedLeaderCheckIntervalInMillis, TimeUnit.MILLISECONDS));
265 private void setElectionTimeoutFactor(final long shardElectionTimeoutFactor) {
266 raftConfig.setElectionTimeoutFactor(shardElectionTimeoutFactor);
269 private void setCustomRaftPolicyImplementation(final String customRaftPolicyImplementation) {
270 raftConfig.setCustomRaftPolicyImplementationClass(customRaftPolicyImplementation);
273 private void setSnapshotDataThresholdPercentage(final int shardSnapshotDataThresholdPercentage) {
274 Preconditions.checkArgument(shardSnapshotDataThresholdPercentage >= 0
275 && shardSnapshotDataThresholdPercentage <= 100);
276 raftConfig.setSnapshotDataThresholdPercentage(shardSnapshotDataThresholdPercentage);
279 private void setSnapshotBatchCount(final long shardSnapshotBatchCount) {
280 raftConfig.setSnapshotBatchCount(shardSnapshotBatchCount);
284 private void setShardSnapshotChunkSize(final int shardSnapshotChunkSize) {
285 // We'll honor the shardSnapshotChunkSize setting for backwards compatibility but only if it doesn't exceed
286 // maximumMessageSliceSize.
287 if (shardSnapshotChunkSize < maximumMessageSliceSize) {
288 raftConfig.setSnapshotChunkSize(shardSnapshotChunkSize);
292 private void setMaximumMessageSliceSize(final int maximumMessageSliceSize) {
293 raftConfig.setSnapshotChunkSize(maximumMessageSliceSize);
294 this.maximumMessageSliceSize = maximumMessageSliceSize;
297 private void setSyncIndexThreshold(final long syncIndexThreshold) {
298 raftConfig.setSyncIndexThreshold(syncIndexThreshold);
301 public int getShardBatchedModificationCount() {
302 return shardBatchedModificationCount;
305 public boolean isWriteOnlyTransactionOptimizationsEnabled() {
306 return writeOnlyTransactionOptimizationsEnabled;
309 public long getShardCommitQueueExpiryTimeoutInMillis() {
310 return shardCommitQueueExpiryTimeoutInMillis;
313 public boolean isTransactionDebugContextEnabled() {
314 return transactionDebugContextEnabled;
317 public boolean isUseTellBasedProtocol() {
318 return useTellBasedProtocol;
322 public int getMaximumMessageSliceSize() {
323 return maximumMessageSliceSize;
327 public long getBackendAlivenessTimerInterval() {
328 return backendAlivenessTimerInterval;
332 public long getRequestTimeout() {
333 return requestTimeout;
337 public long getNoProgressTimeout() {
338 return noProgressTimeout;
341 public static class Builder implements org.opendaylight.yangtools.concepts.Builder<DatastoreContext> {
342 private final DatastoreContext datastoreContext;
343 private int maxShardDataChangeExecutorPoolSize =
344 InMemoryDOMDataStoreConfigProperties.DEFAULT_MAX_DATA_CHANGE_EXECUTOR_POOL_SIZE;
345 private int maxShardDataChangeExecutorQueueSize =
346 InMemoryDOMDataStoreConfigProperties.DEFAULT_MAX_DATA_CHANGE_EXECUTOR_QUEUE_SIZE;
347 private int maxShardDataChangeListenerQueueSize =
348 InMemoryDOMDataStoreConfigProperties.DEFAULT_MAX_DATA_CHANGE_LISTENER_QUEUE_SIZE;
349 private int maxShardDataStoreExecutorQueueSize =
350 InMemoryDOMDataStoreConfigProperties.DEFAULT_MAX_DATA_STORE_EXECUTOR_QUEUE_SIZE;
352 Builder(final DatastoreContext datastoreContext) {
353 this.datastoreContext = datastoreContext;
355 if (datastoreContext.getDataStoreProperties() != null) {
356 maxShardDataChangeExecutorPoolSize =
357 datastoreContext.getDataStoreProperties().getMaxDataChangeExecutorPoolSize();
358 maxShardDataChangeExecutorQueueSize =
359 datastoreContext.getDataStoreProperties().getMaxDataChangeExecutorQueueSize();
360 maxShardDataChangeListenerQueueSize =
361 datastoreContext.getDataStoreProperties().getMaxDataChangeListenerQueueSize();
362 maxShardDataStoreExecutorQueueSize =
363 datastoreContext.getDataStoreProperties().getMaxDataStoreExecutorQueueSize();
367 public Builder boundedMailboxCapacity(final int boundedMailboxCapacity) {
368 // TODO - this is defined in the yang DataStoreProperties but not currently used.
372 public Builder enableMetricCapture(final boolean enableMetricCapture) {
373 // TODO - this is defined in the yang DataStoreProperties but not currently used.
378 public Builder shardTransactionIdleTimeout(final long timeout, final TimeUnit unit) {
379 datastoreContext.shardTransactionIdleTimeout = Duration.create(timeout, unit);
383 public Builder shardTransactionIdleTimeoutInMinutes(final long timeout) {
384 return shardTransactionIdleTimeout(timeout, TimeUnit.MINUTES);
387 public Builder operationTimeoutInSeconds(final int operationTimeoutInSeconds) {
388 datastoreContext.operationTimeoutInMillis = TimeUnit.SECONDS.toMillis(operationTimeoutInSeconds);
392 public Builder operationTimeoutInMillis(final long operationTimeoutInMillis) {
393 datastoreContext.operationTimeoutInMillis = operationTimeoutInMillis;
397 public Builder dataStoreMXBeanType(final String dataStoreMXBeanType) {
398 datastoreContext.dataStoreMXBeanType = dataStoreMXBeanType;
402 public Builder shardTransactionCommitTimeoutInSeconds(final int shardTransactionCommitTimeoutInSeconds) {
403 datastoreContext.shardTransactionCommitTimeoutInSeconds = shardTransactionCommitTimeoutInSeconds;
407 public Builder shardJournalRecoveryLogBatchSize(final int shardJournalRecoveryLogBatchSize) {
408 datastoreContext.setShardJournalRecoveryLogBatchSize(shardJournalRecoveryLogBatchSize);
412 public Builder shardSnapshotBatchCount(final int shardSnapshotBatchCount) {
413 datastoreContext.setSnapshotBatchCount(shardSnapshotBatchCount);
417 public Builder shardSnapshotDataThresholdPercentage(final int shardSnapshotDataThresholdPercentage) {
418 datastoreContext.setSnapshotDataThresholdPercentage(shardSnapshotDataThresholdPercentage);
422 public Builder shardHeartbeatIntervalInMillis(final int shardHeartbeatIntervalInMillis) {
423 datastoreContext.setHeartbeatInterval(shardHeartbeatIntervalInMillis);
427 public Builder shardTransactionCommitQueueCapacity(final int shardTransactionCommitQueueCapacity) {
428 datastoreContext.shardTransactionCommitQueueCapacity = shardTransactionCommitQueueCapacity;
432 public Builder shardInitializationTimeout(final long timeout, final TimeUnit unit) {
433 datastoreContext.shardInitializationTimeout = new Timeout(timeout, unit);
437 public Builder shardInitializationTimeoutInSeconds(final long timeout) {
438 return shardInitializationTimeout(timeout, TimeUnit.SECONDS);
441 public Builder shardLeaderElectionTimeout(final long timeout, final TimeUnit unit) {
442 datastoreContext.shardLeaderElectionTimeout = new Timeout(timeout, unit);
446 public Builder shardLeaderElectionTimeoutInSeconds(final long timeout) {
447 return shardLeaderElectionTimeout(timeout, TimeUnit.SECONDS);
450 public Builder configurationReader(final AkkaConfigurationReader configurationReader) {
451 datastoreContext.configurationReader = configurationReader;
455 public Builder persistent(final boolean persistent) {
456 datastoreContext.persistent = persistent;
460 public Builder shardIsolatedLeaderCheckIntervalInMillis(final int shardIsolatedLeaderCheckIntervalInMillis) {
461 datastoreContext.setIsolatedLeaderCheckInterval(shardIsolatedLeaderCheckIntervalInMillis);
465 public Builder shardElectionTimeoutFactor(final long shardElectionTimeoutFactor) {
466 datastoreContext.setElectionTimeoutFactor(shardElectionTimeoutFactor);
470 public Builder transactionCreationInitialRateLimit(final long initialRateLimit) {
471 datastoreContext.transactionCreationInitialRateLimit = initialRateLimit;
475 public Builder logicalStoreType(final LogicalDatastoreType logicalStoreType) {
476 datastoreContext.logicalStoreType = Preconditions.checkNotNull(logicalStoreType);
478 // Retain compatible naming
479 switch (logicalStoreType) {
481 dataStoreName("config");
484 dataStoreName("operational");
487 dataStoreName(logicalStoreType.name());
493 public Builder storeRoot(final YangInstanceIdentifier storeRoot) {
494 datastoreContext.storeRoot = storeRoot;
498 public Builder dataStoreName(final String dataStoreName) {
499 datastoreContext.dataStoreName = Preconditions.checkNotNull(dataStoreName);
500 datastoreContext.dataStoreMXBeanType = "Distributed" + WordUtils.capitalize(dataStoreName) + "Datastore";
504 public Builder shardBatchedModificationCount(final int shardBatchedModificationCount) {
505 datastoreContext.shardBatchedModificationCount = shardBatchedModificationCount;
509 public Builder writeOnlyTransactionOptimizationsEnabled(final boolean value) {
510 datastoreContext.writeOnlyTransactionOptimizationsEnabled = value;
514 public Builder shardCommitQueueExpiryTimeoutInMillis(final long value) {
515 datastoreContext.shardCommitQueueExpiryTimeoutInMillis = value;
519 public Builder shardCommitQueueExpiryTimeoutInSeconds(final long value) {
520 datastoreContext.shardCommitQueueExpiryTimeoutInMillis = TimeUnit.MILLISECONDS.convert(
521 value, TimeUnit.SECONDS);
525 public Builder transactionDebugContextEnabled(final boolean value) {
526 datastoreContext.transactionDebugContextEnabled = value;
530 public Builder maxShardDataChangeExecutorPoolSize(final int newMaxShardDataChangeExecutorPoolSize) {
531 this.maxShardDataChangeExecutorPoolSize = newMaxShardDataChangeExecutorPoolSize;
535 public Builder maxShardDataChangeExecutorQueueSize(final int newMaxShardDataChangeExecutorQueueSize) {
536 this.maxShardDataChangeExecutorQueueSize = newMaxShardDataChangeExecutorQueueSize;
540 public Builder maxShardDataChangeListenerQueueSize(final int newMaxShardDataChangeListenerQueueSize) {
541 this.maxShardDataChangeListenerQueueSize = newMaxShardDataChangeListenerQueueSize;
545 public Builder maxShardDataStoreExecutorQueueSize(final int newMaxShardDataStoreExecutorQueueSize) {
546 this.maxShardDataStoreExecutorQueueSize = newMaxShardDataStoreExecutorQueueSize;
550 public Builder useTellBasedProtocol(final boolean value) {
551 datastoreContext.useTellBasedProtocol = value;
556 * For unit tests only.
559 public Builder shardManagerPersistenceId(final String id) {
560 datastoreContext.shardManagerPersistenceId = id;
564 public Builder customRaftPolicyImplementation(final String customRaftPolicyImplementation) {
565 datastoreContext.setCustomRaftPolicyImplementation(customRaftPolicyImplementation);
570 public Builder shardSnapshotChunkSize(final int shardSnapshotChunkSize) {
571 LOG.warn("The shard-snapshot-chunk-size configuration parameter is deprecated - "
572 + "use maximum-message-slice-size instead");
573 datastoreContext.setShardSnapshotChunkSize(shardSnapshotChunkSize);
577 public Builder maximumMessageSliceSize(final int maximumMessageSliceSize) {
578 datastoreContext.setMaximumMessageSliceSize(maximumMessageSliceSize);
582 public Builder shardPeerAddressResolver(final PeerAddressResolver resolver) {
583 datastoreContext.setPeerAddressResolver(resolver);
587 public Builder tempFileDirectory(final String tempFileDirectory) {
588 datastoreContext.setTempFileDirectory(tempFileDirectory);
592 public Builder fileBackedStreamingThresholdInMegabytes(final int fileBackedStreamingThreshold) {
593 datastoreContext.setFileBackedStreamingThreshold(fileBackedStreamingThreshold * ConfigParams.MEGABYTE);
597 public Builder syncIndexThreshold(final long syncIndexThreshold) {
598 datastoreContext.setSyncIndexThreshold(syncIndexThreshold);
602 public Builder backendAlivenessTimerIntervalInSeconds(final long interval) {
603 datastoreContext.backendAlivenessTimerInterval = TimeUnit.SECONDS.toNanos(interval);
607 public Builder frontendRequestTimeoutInSeconds(final long timeout) {
608 datastoreContext.requestTimeout = TimeUnit.SECONDS.toNanos(timeout);
612 public Builder frontendNoProgressTimeoutInSeconds(final long timeout) {
613 datastoreContext.noProgressTimeout = TimeUnit.SECONDS.toNanos(timeout);
618 public DatastoreContext build() {
619 datastoreContext.dataStoreProperties = InMemoryDOMDataStoreConfigProperties.create(
620 maxShardDataChangeExecutorPoolSize, maxShardDataChangeExecutorQueueSize,
621 maxShardDataChangeListenerQueueSize, maxShardDataStoreExecutorQueueSize);
623 if (datastoreContext.dataStoreName != null) {
624 GLOBAL_DATASTORE_NAMES.add(datastoreContext.dataStoreName);
627 return datastoreContext;