public static class NoteDbMigrator.Builder
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
NoteDbMigrator |
build() |
NoteDbMigrator.Builder |
setAutoMigrate(boolean autoMigrate)
Enable auto-migration on subsequent daemon launches.
|
NoteDbMigrator.Builder |
setChanges(java.util.Collection<Change.Id> changes)
Limit the set of changes that are processed.
|
NoteDbMigrator.Builder |
setForceRebuild(boolean forceRebuild)
Rebuild all changes in NoteDb from ReviewDb, even if Gerrit is currently configured to read
from NoteDb.
|
NoteDbMigrator.Builder |
setForceStateChangeWithSkip(boolean forceStateChangeWithSkip)
Force state change to next migration state if some projects were skipped.
|
NoteDbMigrator.Builder |
setGC(boolean gc)
GC repositories regularly during noteDb migration.
|
NoteDbMigrator.Builder |
setProgressOut(java.io.OutputStream progressOut)
Set output stream for progress monitors.
|
NoteDbMigrator.Builder |
setProjects(java.util.Collection<Project.NameKey> projects)
Limit the set of projects that are processed.
|
NoteDbMigrator.Builder |
setSequenceGap(int sequenceGap)
Gap between ReviewDb change sequence numbers and NoteDb.
|
NoteDbMigrator.Builder |
setShuffleProjectSlices(boolean shuffleProjectSlices)
Shuffle project slices during the rebuild phase of noteDb migration.
|
NoteDbMigrator.Builder |
setSkipProjects(java.util.Collection<Project.NameKey> skipProjects)
Process all projects except these
|
NoteDbMigrator.Builder |
setStopAtStateForTesting(NotesMigrationState stopAtState)
Stop at a specific migration state, for testing only.
|
NoteDbMigrator.Builder |
setThreads(int threads)
Set the number of threads used by parallelizable phases of the migration, such as rebuilding
all changes.
|
NoteDbMigrator.Builder |
setTrialMode(boolean trial)
Rebuild in "trial mode": configure Gerrit to write to and read from NoteDb, but leave
ReviewDb as the source of truth for all changes.
|
NoteDbMigrator.Builder |
setVerbose(boolean verbose)
Enable verbose log output
|
public NoteDbMigrator.Builder setThreads(int threads)
Not all phases are parallelizable, and calling NoteDbMigrator.rebuild()
directly will do
substantial work in the calling thread regardless of the number of threads configured.
By default, all work is done in the calling thread.
threads
- thread count; if less than 2, all work happens in the calling thread.public NoteDbMigrator.Builder setProjects(java.util.Collection<Project.NameKey> projects)
Incompatible with setChanges(Collection)
.
By default, all projects will be processed.
projects
- set of projects; if null or empty, all projects will be processed.public NoteDbMigrator.Builder setSkipProjects(java.util.Collection<Project.NameKey> skipProjects)
Incompatible with setProjects(Collection)
and setChanges(Collection)
By default, all projects will be processed.
skipProjects
- set of projects; if null or empty all project will be processedpublic NoteDbMigrator.Builder setChanges(java.util.Collection<Change.Id> changes)
Incompatible with setProjects(Collection)
.
By default, all changes will be processed.
changes
- set of changes; if null or empty, all changes will be processed.public NoteDbMigrator.Builder setProgressOut(java.io.OutputStream progressOut)
By default, there is no progress monitor output (although there may be other logs).
progressOut
- output stream.public NoteDbMigrator.Builder setStopAtStateForTesting(NotesMigrationState stopAtState)
stopAtState
- state to stop at.public NoteDbMigrator.Builder setTrialMode(boolean trial)
By default, trial mode is off, and NoteDb is the source of truth for all changes following the migration.
trial
- whether to rebuild in trial mode.public NoteDbMigrator.Builder setForceRebuild(boolean forceRebuild)
Only supported if ReviewDb is still the source of truth for all changes.
By default, force rebuilding is off.
forceRebuild
- whether to force rebuilding.public NoteDbMigrator.Builder setForceStateChangeWithSkip(boolean forceStateChangeWithSkip)
This makes sense when the skipped projects are migrated in a copy of the site and migrated data will be transported using git fetch.
forceStateChangeWithSkip
- whether state change to next migration state should be
enforced if some projects were skipped.public NoteDbMigrator.Builder setGC(boolean gc)
This might help improve performance in some instances. If enabled, auto GC will be run for every new 10000 refs which are created during the migration of a project. Auto GC will do garbage collection by default, if it finds more than 6700 loose objects or more than 50 pack files. These defaults can be changed by updating gc.auto and gc.autoPackLimit.
gc
- whether GC must be done on repositories during migrationpublic NoteDbMigrator.Builder setShuffleProjectSlices(boolean shuffleProjectSlices)
This might help reduce memory allocation if the site has few large and many small repositories. It mixes slices from large and small repositories to reduce overall memory allocation, so that the number of migration threads can be increased without driving java GC crazy. However, it has the down-side of reducing disk cache hits.
shuffleProjectSlices
- whether project slices must be shuffled during migrationpublic NoteDbMigrator.Builder setSequenceGap(int sequenceGap)
If NoteDb sequences are enabled in a running server, there is a race between the migration
step that calls nextChangeId()
to seed the ref, and other threads that call nextChangeId()
to create new changes. In order to prevent these operations stepping on one
another, we use this value to skip some predefined sequence numbers. This is strongly
recommended in a running server.
If the migration takes place offline, there is no race with other threads, and this option may be set to 0. However, admins may still choose to use a gap, for example to make it easier to distinguish changes that were created before and after the NoteDb migration.
By default, uses the value from noteDb.changes.initialSequenceGap
in gerrit.config
, which defaults to 1000.
sequenceGap
- sequence gap size; if negative, use the default.public NoteDbMigrator.Builder setAutoMigrate(boolean autoMigrate)
If true, prior to running any migration steps, sets the necessary configuration in gerrit.config
to make gerrit.war daemon
retry the migration on next startup, if it
fails.
autoMigrate
- whether to set auto-migration config.public NoteDbMigrator.Builder setVerbose(boolean verbose)
verbose
- enable verbose log outputpublic NoteDbMigrator build() throws MigrationException
MigrationException