Enforce memory percentage
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / DatastoreContext.java
index 8c01110f5caca322bcea29c83642ce9a4d6d0061..cf14ebe28d11b0c39e105ab6396f8aff4c37903a 100644 (file)
@@ -36,7 +36,7 @@ public class DatastoreContext {
     public static final Duration DEFAULT_SHARD_TRANSACTION_IDLE_TIMEOUT = Duration.create(10, TimeUnit.MINUTES);
     public static final int DEFAULT_OPERATION_TIMEOUT_IN_MS = 5000;
     public static final int DEFAULT_SHARD_TX_COMMIT_TIMEOUT_IN_SECONDS = 30;
-    public static final int DEFAULT_JOURNAL_RECOVERY_BATCH_SIZE = 1000;
+    public static final int DEFAULT_JOURNAL_RECOVERY_BATCH_SIZE = 1;
     public static final int DEFAULT_SNAPSHOT_BATCH_COUNT = 20000;
     public static final int DEFAULT_HEARTBEAT_INTERVAL_IN_MILLIS = 500;
     public static final int DEFAULT_ISOLATED_LEADER_CHECK_INTERVAL_IN_MILLIS = DEFAULT_HEARTBEAT_INTERVAL_IN_MILLIS * 10;
@@ -53,7 +53,7 @@ public class DatastoreContext {
     public static final long DEFAULT_SHARD_COMMIT_QUEUE_EXPIRY_TIMEOUT_IN_MS = TimeUnit.MILLISECONDS.convert(2, TimeUnit.MINUTES);
     public static final int DEFAULT_SHARD_SNAPSHOT_CHUNK_SIZE = 2048000;
 
-    private static final Set<String> globalDatastoreTypes = Sets.newConcurrentHashSet();
+    private static final Set<String> globalDatastoreNames = Sets.newConcurrentHashSet();
 
     private InMemoryDOMDataStoreConfigProperties dataStoreProperties;
     private Duration shardTransactionIdleTimeout = DatastoreContext.DEFAULT_SHARD_TRANSACTION_IDLE_TIMEOUT;
@@ -75,8 +75,8 @@ public class DatastoreContext {
     private boolean transactionDebugContextEnabled = false;
     private String shardManagerPersistenceId;
 
-    public static Set<String> getGlobalDatastoreTypes() {
-        return globalDatastoreTypes;
+    public static Set<String> getGlobalDatastoreNames() {
+        return globalDatastoreNames;
     }
 
     private DatastoreContext() {
@@ -220,6 +220,8 @@ public class DatastoreContext {
     }
 
     private void setSnapshotDataThresholdPercentage(int shardSnapshotDataThresholdPercentage) {
+        Preconditions.checkArgument(shardSnapshotDataThresholdPercentage >= 0
+                && shardSnapshotDataThresholdPercentage <= 100);
         raftConfig.setSnapshotDataThresholdPercentage(shardSnapshotDataThresholdPercentage);
     }
 
@@ -385,14 +387,6 @@ public class DatastoreContext {
             return this;
         }
 
-        /**
-         * @deprecated Use {@link #logicalStoreType(LogicalDatastoreType)} or {@link #dataStoreName(String)}.
-         */
-        @Deprecated
-        public Builder dataStoreType(String dataStoreType){
-            return dataStoreName(dataStoreType);
-        }
-
         public Builder logicalStoreType(LogicalDatastoreType logicalStoreType){
             datastoreContext.logicalStoreType = Preconditions.checkNotNull(logicalStoreType);
 
@@ -478,7 +472,7 @@ public class DatastoreContext {
                     maxShardDataChangeListenerQueueSize, maxShardDataStoreExecutorQueueSize);
 
             if(datastoreContext.dataStoreName != null) {
-                globalDatastoreTypes.add(datastoreContext.dataStoreName);
+                globalDatastoreNames.add(datastoreContext.dataStoreName);
             }
 
             return datastoreContext;