public abstract class NotesMigration
extends java.lang.Object
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 the NotesMigration
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-running MigrateToNoteDb
. 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.
Modifier and Type | Class and Description |
---|---|
static class |
NotesMigration.Module |
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
SECTION_NOTE_DB |
protected java.util.concurrent.atomic.AtomicReference<com.google.gerrit.server.notedb.NotesMigration.Snapshot> |
snapshot |
Modifier | Constructor and Description |
---|---|
protected |
NotesMigration(com.google.gerrit.server.notedb.NotesMigration.Snapshot snapshot) |
Modifier and Type | Method and Description |
---|---|
NoteDbChangeState.PrimaryStorage |
changePrimaryStorage() |
boolean |
commitChangeWrites() |
boolean |
disableChangeReviewDb()
Disable ReviewDb access for changes.
|
boolean |
equals(java.lang.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) |
public static final java.lang.String SECTION_NOTE_DB
protected final java.util.concurrent.atomic.AtomicReference<com.google.gerrit.server.notedb.NotesMigration.Snapshot> snapshot
protected NotesMigration(com.google.gerrit.server.notedb.NotesMigration.Snapshot snapshot)
public final boolean readChanges()
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.
public final boolean rawWriteChangesSetting()
This method is awkwardly named because you should be using either commitChangeWrites()
or failChangeWrites()
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()
. If readChanges() = false
, writes to NoteDb are simply ignored; if true
, any attempts to
write will generate an error.
public final boolean readChangeSequence()
If true, change IDs are read from refs/sequences/changes
in All-Projects. If false,
change IDs are read from ReviewDb's native sequences.
public final NoteDbChangeState.PrimaryStorage changePrimaryStorage()
public final boolean disableChangeReviewDb()
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.
public boolean failOnLoadForTest()
Used in conjunction with readChanges()
for tests.
public final boolean commitChangeWrites()
public final boolean failChangeWrites()
public final void setConfigValues(org.eclipse.jgit.lib.Config cfg)
public final boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public final int hashCode()
hashCode
in class java.lang.Object