Add multi journal configuration for segmented journal 86/90186/9
authorTomas Cere <tomas.cere@pantheon.tech>
Fri, 29 May 2020 14:07:32 +0000 (16:07 +0200)
committerRobert Varga <nite@hq.sk>
Thu, 22 Oct 2020 21:01:47 +0000 (21:01 +0000)
We dont need to have large segments for operational shards.
Add in multi journal configuration that gets used when shard has
persistence turned off.

JIRA: CONTROLLER-1938
Change-Id: I39349503079ef03177c8b9b52909078c5f35d6ba
Signed-off-by: Tomas Cere <tomas.cere@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
opendaylight/md-sal/sal-clustering-config/src/main/resources/initial/factory-akka.conf
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/Shard.java
opendaylight/md-sal/sal-distributed-datastore/src/test/resources/application.conf
opendaylight/md-sal/sal-distributed-datastore/src/test/resources/segmented.conf

index dbb5dc7..3296e05 100644 (file)
@@ -126,7 +126,7 @@ odl-cluster-data {
       journal {
         # The following activates the default segmented file journal. Each persistent actor
         # is stored in a separate directory, with multiple segment files. Segments are removed
-        # when they are not longer required.
+        # when they are no longer required.
         #
         plugin = akka.persistence.journal.segmented-file
 
@@ -144,6 +144,24 @@ odl-cluster-data {
         }
       }
 
+      # Journal configuration for shards that have persistence turned off. They still need to have a journal plugin
+      # configured, since they still need to store things in the journal occasionally, but having larger segment sizes
+      # would be wastefull.
+      non-persistent {
+        journal {
+          class = "org.opendaylight.controller.akka.segjournal.SegmentedFileJournal"
+          # Root directory for segmented journal storage
+          root-directory = "segmented-journal"
+          # Maximum size of a single entry in the segmented journal
+          max-entry-size = 512K
+          # Maximum size of a segment
+          max-segment-size = 1M
+          # Map each segment into memory. Note that while this can improve performance,
+          # it will also place additional burden on system resources.
+          memory-mapped = false
+        }
+      }
+
       snapshot-store.local.class = "org.opendaylight.controller.cluster.persistence.LocalSnapshotStore"
       snapshot-store.plugin = akka.persistence.snapshot-store.local
     }
index eeacdd9..d476b33 100644 (file)
@@ -9,6 +9,7 @@ package org.opendaylight.controller.cluster.datastore;
 
 import static com.google.common.base.Preconditions.checkState;
 import static com.google.common.base.Verify.verify;
+import static com.google.common.base.Verify.verifyNotNull;
 import static java.util.Objects.requireNonNull;
 
 import akka.actor.ActorRef;
@@ -151,6 +152,9 @@ public class Shard extends RaftActor {
 
     private static final Collection<ABIVersion> SUPPORTED_ABIVERSIONS;
 
+    // Make sure to keep this in sync with the journal configuration in factory-akka.conf
+    public static final String NON_PERSISTENT_JOURNAL_ID = "akka.persistence.non-persistent.journal";
+
     static {
         final ABIVersion[] values = ABIVersion.values();
         final ABIVersion[] real = Arrays.copyOfRange(values, 1, values.length - 1);
@@ -645,7 +649,7 @@ public class Shard extends RaftActor {
     }
 
     protected void onDatastoreContext(final DatastoreContext context) {
-        datastoreContext = context;
+        datastoreContext = verifyNotNull(context);
 
         setTransactionCommitTimeout();
 
@@ -1082,6 +1086,16 @@ public class Shard extends RaftActor {
         return this.name;
     }
 
+    @Override
+    public String journalPluginId() {
+        // This method may be invoked from super constructor (wonderful), hence we also need to handle the case of
+        // the field being uninitialized because our constructor is not finished.
+        if (datastoreContext != null && !datastoreContext.isPersistent()) {
+            return NON_PERSISTENT_JOURNAL_ID;
+        }
+        return super.journalPluginId();
+    }
+
     @VisibleForTesting
     ShardCommitCoordinator getCommitCoordinator() {
         return commitCoordinator;
index abefdf0..72d00a4 100644 (file)
@@ -1,6 +1,9 @@
 akka {
     persistence.snapshot-store.plugin = "in-memory-snapshot-store"
     persistence.journal.plugin = "in-memory-journal"
+    persistence.non-persistent.journal {
+      class = "org.opendaylight.controller.cluster.raft.utils.InMemoryJournal"
+    }
 
     loggers = ["akka.testkit.TestEventListener", "akka.event.slf4j.Slf4jLogger"]
 
@@ -52,6 +55,9 @@ test-config {
     persistence.snapshot-store.plugin = "in-memory-snapshot-store"
     persistence.journal.plugin = "in-memory-journal"
 
+    persistence.non-persistent.journal {
+      class = "org.opendaylight.controller.cluster.raft.utils.InMemoryJournal"
+    }
     loglevel = "INFO"
 
     actor {
@@ -118,6 +124,10 @@ Member1 {
     persistence.snapshot-store.plugin = "in-memory-snapshot-store"
     persistence.journal.plugin = "in-memory-journal"
 
+    persistence.non-persistent.journal {
+      class = "org.opendaylight.controller.cluster.raft.utils.InMemoryJournal"
+    }
+
     loglevel = "INFO"
 
     actor {
@@ -183,6 +193,10 @@ Member2 {
     persistence.snapshot-store.plugin = "in-memory-snapshot-store"
     persistence.journal.plugin = "in-memory-journal"
 
+    persistence.non-persistent.journal {
+      class = "org.opendaylight.controller.cluster.raft.utils.InMemoryJournal"
+    }
+
     actor {
       provider = "akka.cluster.ClusterActorRefProvider"
 
@@ -246,6 +260,10 @@ Member3 {
     persistence.snapshot-store.plugin = "in-memory-snapshot-store"
     persistence.journal.plugin = "in-memory-journal"
 
+    persistence.non-persistent.journal {
+      class = "org.opendaylight.controller.cluster.raft.utils.InMemoryJournal"
+    }
+
     loglevel = "INFO"
 
     actor {
@@ -311,6 +329,10 @@ Member4 {
     persistence.snapshot-store.plugin = "in-memory-snapshot-store"
     persistence.journal.plugin = "in-memory-journal"
 
+    persistence.non-persistent.journal {
+      class = "org.opendaylight.controller.cluster.raft.utils.InMemoryJournal"
+    }
+
     loglevel = "INFO"
 
     actor {
@@ -376,6 +398,10 @@ Member5 {
     persistence.snapshot-store.plugin = "in-memory-snapshot-store"
     persistence.journal.plugin = "in-memory-journal"
 
+    persistence.non-persistent.journal {
+      class = "org.opendaylight.controller.cluster.raft.utils.InMemoryJournal"
+    }
+
     loglevel = "INFO"
 
     actor {
@@ -441,6 +467,10 @@ Member256 {
     persistence.snapshot-store.plugin = "in-memory-snapshot-store"
     persistence.journal.plugin = "in-memory-journal"
 
+    persistence.non-persistent.journal {
+      class = "org.opendaylight.controller.cluster.raft.utils.InMemoryJournal"
+    }
+
     loglevel = "INFO"
 
     actor {
index c667887..eebc201 100644 (file)
@@ -32,6 +32,9 @@ Member1 {
         }
       }
     }
+    persistence.non-persistent.journal {
+      class = "org.opendaylight.controller.cluster.raft.utils.InMemoryJournal"
+    }
 
     loglevel = "INFO"
 

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.