From: Tomas Cere Date: Fri, 29 May 2020 14:07:32 +0000 (+0200) Subject: Add multi journal configuration for segmented journal X-Git-Tag: v3.0.2~22 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=a3459dc797e4e0722b945b80bc8ef3123762fc8d Add multi journal configuration for segmented journal 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 Signed-off-by: Robert Varga --- diff --git a/opendaylight/md-sal/sal-clustering-config/src/main/resources/initial/factory-akka.conf b/opendaylight/md-sal/sal-clustering-config/src/main/resources/initial/factory-akka.conf index dbb5dc71e7..3296e0574c 100644 --- a/opendaylight/md-sal/sal-clustering-config/src/main/resources/initial/factory-akka.conf +++ b/opendaylight/md-sal/sal-clustering-config/src/main/resources/initial/factory-akka.conf @@ -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 } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/Shard.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/Shard.java index eeacdd9b6f..d476b332b3 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/Shard.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/Shard.java @@ -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 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; diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/resources/application.conf b/opendaylight/md-sal/sal-distributed-datastore/src/test/resources/application.conf index abefdf0ce9..72d00a4cdd 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/resources/application.conf +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/resources/application.conf @@ -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 { diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/resources/segmented.conf b/opendaylight/md-sal/sal-distributed-datastore/src/test/resources/segmented.conf index c667887b54..eebc201ca1 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/resources/segmented.conf +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/resources/segmented.conf @@ -32,6 +32,9 @@ Member1 { } } } + persistence.non-persistent.journal { + class = "org.opendaylight.controller.cluster.raft.utils.InMemoryJournal" + } loglevel = "INFO"