Lower verbosity of TransactionProxy logging
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / DatastoreContext.java
index 07115b71699095e4891d819759dc5a3016aad6c0..df5d70f51eba7d04ef5ea899ab0a203da16aa935 100644 (file)
@@ -14,7 +14,9 @@ import com.google.common.base.Preconditions;
 import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.TimeUnit;
-import org.apache.commons.lang3.text.WordUtils;
+import org.apache.commons.text.WordUtils;
+import org.opendaylight.controller.cluster.access.client.AbstractClientConnection;
+import org.opendaylight.controller.cluster.access.client.ClientActorConfig;
 import org.opendaylight.controller.cluster.common.actor.AkkaConfigurationReader;
 import org.opendaylight.controller.cluster.common.actor.FileAkkaConfigurationReader;
 import org.opendaylight.controller.cluster.raft.ConfigParams;
@@ -33,7 +35,8 @@ import scala.concurrent.duration.FiniteDuration;
  *
  * @author Thomas Pantelis
  */
-public class DatastoreContext {
+// Noo-final for mocking
+public class DatastoreContext implements ClientActorConfig {
     public static final String METRICS_DOMAIN = "org.opendaylight.controller.cluster.datastore";
 
     public static final Duration DEFAULT_SHARD_TRANSACTION_IDLE_TIMEOUT = Duration.create(10, TimeUnit.MINUTES);
@@ -87,12 +90,15 @@ public class DatastoreContext {
     private boolean transactionDebugContextEnabled = false;
     private String shardManagerPersistenceId;
     private int maximumMessageSliceSize = DEFAULT_MAX_MESSAGE_SLICE_SIZE;
+    private long backendAlivenessTimerInterval = AbstractClientConnection.DEFAULT_BACKEND_ALIVE_TIMEOUT_NANOS;
+    private long requestTimeout = AbstractClientConnection.DEFAULT_REQUEST_TIMEOUT_NANOS;
+    private long noProgressTimeout = AbstractClientConnection.DEFAULT_NO_PROGRESS_TIMEOUT_NANOS;
 
     public static Set<String> getGlobalDatastoreNames() {
         return GLOBAL_DATASTORE_NAMES;
     }
 
-    private DatastoreContext() {
+    DatastoreContext() {
         setShardJournalRecoveryLogBatchSize(DEFAULT_JOURNAL_RECOVERY_BATCH_SIZE);
         setSnapshotBatchCount(DEFAULT_SNAPSHOT_BATCH_COUNT);
         setHeartbeatInterval(DEFAULT_HEARTBEAT_INTERVAL_IN_MILLIS);
@@ -124,6 +130,9 @@ public class DatastoreContext {
         this.transactionDebugContextEnabled = other.transactionDebugContextEnabled;
         this.shardManagerPersistenceId = other.shardManagerPersistenceId;
         this.useTellBasedProtocol = other.useTellBasedProtocol;
+        this.backendAlivenessTimerInterval = other.backendAlivenessTimerInterval;
+        this.requestTimeout = other.requestTimeout;
+        this.noProgressTimeout = other.noProgressTimeout;
 
         setShardJournalRecoveryLogBatchSize(other.raftConfig.getJournalRecoveryLogBatchSize());
         setSnapshotBatchCount(other.raftConfig.getSnapshotBatchCount());
@@ -216,6 +225,7 @@ public class DatastoreContext {
         return shardManagerPersistenceId;
     }
 
+    @Override
     public String getTempFileDirectory() {
         return raftConfig.getTempFileDirectory();
     }
@@ -224,6 +234,7 @@ public class DatastoreContext {
         raftConfig.setTempFileDirectory(tempFileDirectory);
     }
 
+    @Override
     public int getFileBackedStreamingThreshold() {
         return raftConfig.getFileBackedStreamingThreshold();
     }
@@ -307,10 +318,26 @@ public class DatastoreContext {
         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 =
@@ -322,7 +349,7 @@ public class DatastoreContext {
         private int maxShardDataStoreExecutorQueueSize =
                 InMemoryDOMDataStoreConfigProperties.DEFAULT_MAX_DATA_STORE_EXECUTOR_QUEUE_SIZE;
 
-        private Builder(final DatastoreContext datastoreContext) {
+        Builder(final DatastoreContext datastoreContext) {
             this.datastoreContext = datastoreContext;
 
             if (datastoreContext.getDataStoreProperties() != null) {
@@ -500,23 +527,23 @@ public class DatastoreContext {
             return this;
         }
 
-        public Builder maxShardDataChangeExecutorPoolSize(final int maxShardDataChangeExecutorPoolSize) {
-            this.maxShardDataChangeExecutorPoolSize = maxShardDataChangeExecutorPoolSize;
+        public Builder maxShardDataChangeExecutorPoolSize(final int newMaxShardDataChangeExecutorPoolSize) {
+            this.maxShardDataChangeExecutorPoolSize = newMaxShardDataChangeExecutorPoolSize;
             return this;
         }
 
-        public Builder maxShardDataChangeExecutorQueueSize(final int maxShardDataChangeExecutorQueueSize) {
-            this.maxShardDataChangeExecutorQueueSize = maxShardDataChangeExecutorQueueSize;
+        public Builder maxShardDataChangeExecutorQueueSize(final int newMaxShardDataChangeExecutorQueueSize) {
+            this.maxShardDataChangeExecutorQueueSize = newMaxShardDataChangeExecutorQueueSize;
             return this;
         }
 
-        public Builder maxShardDataChangeListenerQueueSize(final int maxShardDataChangeListenerQueueSize) {
-            this.maxShardDataChangeListenerQueueSize = maxShardDataChangeListenerQueueSize;
+        public Builder maxShardDataChangeListenerQueueSize(final int newMaxShardDataChangeListenerQueueSize) {
+            this.maxShardDataChangeListenerQueueSize = newMaxShardDataChangeListenerQueueSize;
             return this;
         }
 
-        public Builder maxShardDataStoreExecutorQueueSize(final int maxShardDataStoreExecutorQueueSize) {
-            this.maxShardDataStoreExecutorQueueSize = maxShardDataStoreExecutorQueueSize;
+        public Builder maxShardDataStoreExecutorQueueSize(final int newMaxShardDataStoreExecutorQueueSize) {
+            this.maxShardDataStoreExecutorQueueSize = newMaxShardDataStoreExecutorQueueSize;
             return this;
         }
 
@@ -562,7 +589,7 @@ public class DatastoreContext {
             return this;
         }
 
-        public Builder fileBackedStreamingThresholdInMegabytes(final int  fileBackedStreamingThreshold) {
+        public Builder fileBackedStreamingThresholdInMegabytes(final int fileBackedStreamingThreshold) {
             datastoreContext.setFileBackedStreamingThreshold(fileBackedStreamingThreshold * ConfigParams.MEGABYTE);
             return this;
         }
@@ -572,6 +599,21 @@ public class DatastoreContext {
             return this;
         }
 
+        public Builder backendAlivenessTimerIntervalInSeconds(final long interval) {
+            datastoreContext.backendAlivenessTimerInterval = TimeUnit.SECONDS.toNanos(interval);
+            return this;
+        }
+
+        public Builder frontendRequestTimeoutInSeconds(final long timeout) {
+            datastoreContext.requestTimeout = TimeUnit.SECONDS.toNanos(timeout);
+            return this;
+        }
+
+        public Builder frontendNoProgressTimeoutInSeconds(final long timeout) {
+            datastoreContext.noProgressTimeout = TimeUnit.SECONDS.toNanos(timeout);
+            return this;
+        }
+
         @Override
         public DatastoreContext build() {
             datastoreContext.dataStoreProperties = InMemoryDOMDataStoreConfigProperties.create(