+ public long getShardElectionTimeoutFactor() {
+ return raftConfig.getElectionTimeoutFactor();
+ }
+
+ public String getDataStoreName() {
+ return dataStoreName;
+ }
+
+ public LogicalDatastoreType getLogicalStoreType() {
+ return logicalStoreType;
+ }
+
+ public YangInstanceIdentifier getStoreRoot() {
+ return storeRoot;
+ }
+
+ public long getTransactionCreationInitialRateLimit() {
+ return transactionCreationInitialRateLimit;
+ }
+
+ public String getShardManagerPersistenceId() {
+ return shardManagerPersistenceId;
+ }
+
+ @Override
+ public String getTempFileDirectory() {
+ return raftConfig.getTempFileDirectory();
+ }
+
+ private void setTempFileDirectory(final String tempFileDirectory) {
+ raftConfig.setTempFileDirectory(tempFileDirectory);
+ }
+
+ @Override
+ public int getFileBackedStreamingThreshold() {
+ return raftConfig.getFileBackedStreamingThreshold();
+ }
+
+ private void setFileBackedStreamingThreshold(final int fileBackedStreamingThreshold) {
+ raftConfig.setFileBackedStreamingThreshold(fileBackedStreamingThreshold);
+ }
+
+ private void setPeerAddressResolver(final PeerAddressResolver resolver) {
+ raftConfig.setPeerAddressResolver(resolver);
+ }
+
+ private void setHeartbeatInterval(final long shardHeartbeatIntervalInMillis) {
+ raftConfig.setHeartBeatInterval(new FiniteDuration(shardHeartbeatIntervalInMillis,
+ TimeUnit.MILLISECONDS));
+ }
+
+ private void setShardJournalRecoveryLogBatchSize(final int shardJournalRecoveryLogBatchSize) {
+ raftConfig.setJournalRecoveryLogBatchSize(shardJournalRecoveryLogBatchSize);
+ }
+
+
+ private void setIsolatedLeaderCheckInterval(final long shardIsolatedLeaderCheckIntervalInMillis) {
+ raftConfig.setIsolatedLeaderCheckInterval(
+ new FiniteDuration(shardIsolatedLeaderCheckIntervalInMillis, TimeUnit.MILLISECONDS));
+ }
+
+ private void setElectionTimeoutFactor(final long shardElectionTimeoutFactor) {
+ raftConfig.setElectionTimeoutFactor(shardElectionTimeoutFactor);
+ }
+
+ private void setCustomRaftPolicyImplementation(final String customRaftPolicyImplementation) {
+ raftConfig.setCustomRaftPolicyImplementationClass(customRaftPolicyImplementation);
+ }
+
+ private void setSnapshotDataThresholdPercentage(final int shardSnapshotDataThresholdPercentage) {
+ Preconditions.checkArgument(shardSnapshotDataThresholdPercentage >= 0
+ && shardSnapshotDataThresholdPercentage <= 100);
+ raftConfig.setSnapshotDataThresholdPercentage(shardSnapshotDataThresholdPercentage);
+ }
+
+ private void setSnapshotBatchCount(final long shardSnapshotBatchCount) {
+ raftConfig.setSnapshotBatchCount(shardSnapshotBatchCount);
+ }
+
+ @Deprecated
+ private void setShardSnapshotChunkSize(final int shardSnapshotChunkSize) {
+ // We'll honor the shardSnapshotChunkSize setting for backwards compatibility but only if it doesn't exceed
+ // maximumMessageSliceSize.
+ if (shardSnapshotChunkSize < maximumMessageSliceSize) {
+ raftConfig.setSnapshotChunkSize(shardSnapshotChunkSize);
+ }
+ }
+
+ private void setMaximumMessageSliceSize(final int maximumMessageSliceSize) {
+ raftConfig.setSnapshotChunkSize(maximumMessageSliceSize);
+ this.maximumMessageSliceSize = maximumMessageSliceSize;
+ }
+
+ private void setSyncIndexThreshold(final long syncIndexThreshold) {
+ raftConfig.setSyncIndexThreshold(syncIndexThreshold);
+ }
+
+ public int getShardBatchedModificationCount() {
+ return shardBatchedModificationCount;
+ }
+
+ public boolean isWriteOnlyTransactionOptimizationsEnabled() {
+ return writeOnlyTransactionOptimizationsEnabled;
+ }
+
+ public long getShardCommitQueueExpiryTimeoutInMillis() {
+ return shardCommitQueueExpiryTimeoutInMillis;
+ }
+
+ public boolean isTransactionDebugContextEnabled() {
+ return transactionDebugContextEnabled;
+ }
+
+ public boolean isUseTellBasedProtocol() {
+ return useTellBasedProtocol;
+ }
+
+ @Override
+ public int getMaximumMessageSliceSize() {
+ return maximumMessageSliceSize;
+ }
+
+ @Override
+ public long getBackendAlivenessTimerInterval() {
+ return backendAlivenessTimerInterval;
+ }
+
+ @Override
+ public long getRequestTimeout() {
+ return requestTimeout;
+ }
+
+ @Override
+ public long getNoProgressTimeout() {
+ return noProgressTimeout;
+ }
+
+ public static class Builder implements org.opendaylight.yangtools.concepts.Builder<DatastoreContext> {
+ private final DatastoreContext datastoreContext;
+ private int maxShardDataChangeExecutorPoolSize =
+ InMemoryDOMDataStoreConfigProperties.DEFAULT_MAX_DATA_CHANGE_EXECUTOR_POOL_SIZE;
+ private int maxShardDataChangeExecutorQueueSize =
+ InMemoryDOMDataStoreConfigProperties.DEFAULT_MAX_DATA_CHANGE_EXECUTOR_QUEUE_SIZE;
+ private int maxShardDataChangeListenerQueueSize =
+ InMemoryDOMDataStoreConfigProperties.DEFAULT_MAX_DATA_CHANGE_LISTENER_QUEUE_SIZE;
+ private int maxShardDataStoreExecutorQueueSize =
+ InMemoryDOMDataStoreConfigProperties.DEFAULT_MAX_DATA_STORE_EXECUTOR_QUEUE_SIZE;
+
+ Builder(final DatastoreContext datastoreContext) {
+ this.datastoreContext = datastoreContext;
+
+ if (datastoreContext.getDataStoreProperties() != null) {
+ maxShardDataChangeExecutorPoolSize =
+ datastoreContext.getDataStoreProperties().getMaxDataChangeExecutorPoolSize();
+ maxShardDataChangeExecutorQueueSize =
+ datastoreContext.getDataStoreProperties().getMaxDataChangeExecutorQueueSize();
+ maxShardDataChangeListenerQueueSize =
+ datastoreContext.getDataStoreProperties().getMaxDataChangeListenerQueueSize();
+ maxShardDataStoreExecutorQueueSize =
+ datastoreContext.getDataStoreProperties().getMaxDataStoreExecutorQueueSize();
+ }
+ }
+
+ public Builder boundedMailboxCapacity(final int boundedMailboxCapacity) {
+ // TODO - this is defined in the yang DataStoreProperties but not currently used.
+ return this;
+ }
+
+ public Builder enableMetricCapture(final boolean enableMetricCapture) {
+ // TODO - this is defined in the yang DataStoreProperties but not currently used.
+ return this;
+ }
+
+
+ public Builder shardTransactionIdleTimeout(final long timeout, final TimeUnit unit) {
+ datastoreContext.shardTransactionIdleTimeout = Duration.create(timeout, unit);
+ return this;
+ }
+
+ public Builder shardTransactionIdleTimeoutInMinutes(final long timeout) {
+ return shardTransactionIdleTimeout(timeout, TimeUnit.MINUTES);
+ }
+
+ public Builder operationTimeoutInSeconds(final int operationTimeoutInSeconds) {
+ datastoreContext.operationTimeoutInMillis = TimeUnit.SECONDS.toMillis(operationTimeoutInSeconds);
+ return this;
+ }
+
+ public Builder operationTimeoutInMillis(final long operationTimeoutInMillis) {
+ datastoreContext.operationTimeoutInMillis = operationTimeoutInMillis;
+ return this;
+ }
+
+ public Builder dataStoreMXBeanType(final String dataStoreMXBeanType) {
+ datastoreContext.dataStoreMXBeanType = dataStoreMXBeanType;
+ return this;
+ }
+
+ public Builder shardTransactionCommitTimeoutInSeconds(final int shardTransactionCommitTimeoutInSeconds) {
+ datastoreContext.shardTransactionCommitTimeoutInSeconds = shardTransactionCommitTimeoutInSeconds;
+ return this;
+ }
+
+ public Builder shardJournalRecoveryLogBatchSize(final int shardJournalRecoveryLogBatchSize) {
+ datastoreContext.setShardJournalRecoveryLogBatchSize(shardJournalRecoveryLogBatchSize);
+ return this;
+ }
+
+ public Builder shardSnapshotBatchCount(final int shardSnapshotBatchCount) {
+ datastoreContext.setSnapshotBatchCount(shardSnapshotBatchCount);
+ return this;
+ }
+
+ public Builder shardSnapshotDataThresholdPercentage(final int shardSnapshotDataThresholdPercentage) {
+ datastoreContext.setSnapshotDataThresholdPercentage(shardSnapshotDataThresholdPercentage);
+ return this;
+ }
+
+ public Builder shardHeartbeatIntervalInMillis(final int shardHeartbeatIntervalInMillis) {
+ datastoreContext.setHeartbeatInterval(shardHeartbeatIntervalInMillis);
+ return this;
+ }
+
+ public Builder shardTransactionCommitQueueCapacity(final int shardTransactionCommitQueueCapacity) {
+ datastoreContext.shardTransactionCommitQueueCapacity = shardTransactionCommitQueueCapacity;
+ return this;
+ }
+
+ public Builder shardInitializationTimeout(final long timeout, final TimeUnit unit) {
+ datastoreContext.shardInitializationTimeout = new Timeout(timeout, unit);
+ return this;
+ }
+
+ public Builder shardInitializationTimeoutInSeconds(final long timeout) {
+ return shardInitializationTimeout(timeout, TimeUnit.SECONDS);
+ }
+
+ public Builder shardLeaderElectionTimeout(final long timeout, final TimeUnit unit) {
+ datastoreContext.shardLeaderElectionTimeout = new Timeout(timeout, unit);
+ return this;
+ }
+
+ public Builder shardLeaderElectionTimeoutInSeconds(final long timeout) {
+ return shardLeaderElectionTimeout(timeout, TimeUnit.SECONDS);
+ }
+
+ public Builder configurationReader(final AkkaConfigurationReader configurationReader) {
+ datastoreContext.configurationReader = configurationReader;
+ return this;
+ }
+
+ public Builder persistent(final boolean persistent) {
+ datastoreContext.persistent = persistent;
+ return this;
+ }
+
+ public Builder shardIsolatedLeaderCheckIntervalInMillis(final int shardIsolatedLeaderCheckIntervalInMillis) {
+ datastoreContext.setIsolatedLeaderCheckInterval(shardIsolatedLeaderCheckIntervalInMillis);
+ return this;
+ }
+
+ public Builder shardElectionTimeoutFactor(final long shardElectionTimeoutFactor) {
+ datastoreContext.setElectionTimeoutFactor(shardElectionTimeoutFactor);
+ return this;
+ }
+
+ public Builder transactionCreationInitialRateLimit(final long initialRateLimit) {
+ datastoreContext.transactionCreationInitialRateLimit = initialRateLimit;
+ return this;
+ }
+
+ public Builder logicalStoreType(final LogicalDatastoreType logicalStoreType) {
+ datastoreContext.logicalStoreType = Preconditions.checkNotNull(logicalStoreType);
+
+ // Retain compatible naming
+ switch (logicalStoreType) {
+ case CONFIGURATION:
+ dataStoreName("config");
+ break;
+ case OPERATIONAL:
+ dataStoreName("operational");
+ break;
+ default:
+ dataStoreName(logicalStoreType.name());
+ }