Class NotesMigration
- java.lang.Object
-
- com.google.gerrit.server.notedb.NotesMigration
-
- Direct Known Subclasses:
MutableNotesMigration
public abstract class NotesMigration extends Object
Current low-level settings of the NoteDb migration for changes.This class only describes the migration state of the
Change
entity group, since it is possible for a given site to be in different states of the Change NoteDb migration process while staying at the same ReviewDb schema version. It does not describe the migration state of non-Change tables; those are automatically migrated using the ReviewDb schema migration process, so the NoteDb migration state at a given ReviewDb schema cannot vary.In many places, core Gerrit code should not directly care about the NoteDb migration state, and should prefer high-level APIs like
ApprovalsUtil
that don't require callers to inspect the migration state. The implementation of those utilities does care about the state, and should query theNotesMigration
for the properties of the migration, for example,where new changes should be stored
.Core Gerrit code is mostly interested in one facet of the migration at a time (reading or writing, say), but not all combinations of return values are supported or even make sense.
This class controls the state of the migration according to options in
gerrit.config
. In general, any changes to these options should only be made by adventurous administrators, who know what they're doing, on non-production data, for the purposes of testing the NoteDb implementation. Changing options quite likely requires re-runningMigrateToNoteDb
. For these reasons, the options remain undocumented.Note: Callers should not assume the values returned by
NotesMigration
's methods will not change in a running server.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
NotesMigration.Module
-
Field Summary
Fields Modifier and Type Field Description static String
SECTION_NOTE_DB
protected AtomicReference<com.google.gerrit.server.notedb.NotesMigration.Snapshot>
snapshot
-
Constructor Summary
Constructors Modifier Constructor Description protected
NotesMigration(com.google.gerrit.server.notedb.NotesMigration.Snapshot snapshot)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description NoteDbChangeState.PrimaryStorage
changePrimaryStorage()
boolean
commitChangeWrites()
boolean
disableChangeReviewDb()
Disable ReviewDb access for changes.boolean
equals(Object o)
boolean
failChangeWrites()
boolean
failOnLoadForTest()
Whether to fail when reading any data from NoteDb.int
hashCode()
boolean
rawWriteChangesSetting()
Write changes to NoteDb.boolean
readChanges()
Read changes from NoteDb.boolean
readChangeSequence()
Read sequential change ID numbers from NoteDb.void
setConfigValues(org.eclipse.jgit.lib.Config cfg)
-
-
-
Field Detail
-
SECTION_NOTE_DB
public static final String SECTION_NOTE_DB
- See Also:
- Constant Field Values
-
snapshot
protected final AtomicReference<com.google.gerrit.server.notedb.NotesMigration.Snapshot> snapshot
-
-
Method Detail
-
readChanges
public final boolean readChanges()
Read changes from NoteDb.Change data is read from NoteDb refs, but ReviewDb is still the source of truth. If the loader determines NoteDb is out of date, the change data in NoteDb will be transparently rebuilt. This means that some code paths that look read-only may in fact attempt to write.
If true and
writeChanges() = false
, changes can still be read from NoteDb, but any attempts to write will generate an error.
-
rawWriteChangesSetting
public final boolean rawWriteChangesSetting()
Write changes to NoteDb.This method is awkwardly named because you should be using either
commitChangeWrites()
orfailChangeWrites()
instead.Updates to change data are written to NoteDb refs, but ReviewDb is still the source of truth. Change data will not be written unless the NoteDb refs are already up to date, and the write path will attempt to rebuild the change if not.
If false, the behavior when attempting to write depends on
readChanges()
. IfreadChanges() = false
, writes to NoteDb are simply ignored; iftrue
, any attempts to write will generate an error.
-
readChangeSequence
public final boolean readChangeSequence()
Read sequential change ID numbers from NoteDb.If true, change IDs are read from
refs/sequences/changes
in All-Projects. If false, change IDs are read from ReviewDb's native sequences.
-
changePrimaryStorage
public final NoteDbChangeState.PrimaryStorage changePrimaryStorage()
- Returns:
- default primary storage for new changes.
-
disableChangeReviewDb
public final boolean disableChangeReviewDb()
Disable ReviewDb access for changes.When set, ReviewDb operations involving the Changes table become no-ops. Lookups return no results; updates do nothing, as does opening, committing, or rolling back a transaction on the Changes table.
-
failOnLoadForTest
public boolean failOnLoadForTest()
Whether to fail when reading any data from NoteDb.Used in conjunction with
readChanges()
for tests.
-
commitChangeWrites
public final boolean commitChangeWrites()
-
failChangeWrites
public final boolean failChangeWrites()
-
setConfigValues
public final void setConfigValues(org.eclipse.jgit.lib.Config cfg)
-
-