Class NoteDbMigrator.Builder

    • Method Detail

      • setThreads

        public NoteDbMigrator.Builder setThreads​(int threads)
        Set the number of threads used by parallelizable phases of the migration, such as rebuilding all changes.

        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.

        Parameters:
        threads - thread count; if less than 2, all work happens in the calling thread.
        Returns:
        this.
      • setChanges

        public NoteDbMigrator.Builder setChanges​(Collection<Change.Id> changes)
        Limit the set of changes that are processed.

        Incompatible with setProjects(Collection).

        By default, all changes will be processed.

        Parameters:
        changes - set of changes; if null or empty, all changes will be processed.
        Returns:
        this.
      • setProgressOut

        public NoteDbMigrator.Builder setProgressOut​(OutputStream progressOut)
        Set output stream for progress monitors.

        By default, there is no progress monitor output (although there may be other logs).

        Parameters:
        progressOut - output stream.
        Returns:
        this.
      • setStopAtStateForTesting

        public NoteDbMigrator.Builder setStopAtStateForTesting​(NotesMigrationState stopAtState)
        Stop at a specific migration state, for testing only.
        Parameters:
        stopAtState - state to stop at.
        Returns:
        this.
      • setTrialMode

        public 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.

        By default, trial mode is off, and NoteDb is the source of truth for all changes following the migration.

        Parameters:
        trial - whether to rebuild in trial mode.
        Returns:
        this.
      • setForceRebuild

        public NoteDbMigrator.Builder setForceRebuild​(boolean forceRebuild)
        Rebuild all changes in NoteDb from ReviewDb, even if Gerrit is currently configured to read from NoteDb.

        Only supported if ReviewDb is still the source of truth for all changes.

        By default, force rebuilding is off.

        Parameters:
        forceRebuild - whether to force rebuilding.
        Returns:
        this.
      • setForceStateChangeWithSkip

        public NoteDbMigrator.Builder setForceStateChangeWithSkip​(boolean forceStateChangeWithSkip)
        Force state change to next migration state if some projects were skipped.

        This makes sense when the skipped projects are migrated in a copy of the site and migrated data will be transported using git fetch.

        Parameters:
        forceStateChangeWithSkip - whether state change to next migration state should be enforced if some projects were skipped.
        Returns:
        this.
      • setSequenceGap

        public NoteDbMigrator.Builder setSequenceGap​(int sequenceGap)
        Gap between ReviewDb change sequence numbers and NoteDb.

        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.

        Parameters:
        sequenceGap - sequence gap size; if negative, use the default.
        Returns:
        this.
      • setAutoMigrate

        public NoteDbMigrator.Builder setAutoMigrate​(boolean autoMigrate)
        Enable auto-migration on subsequent daemon launches.

        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.

        Parameters:
        autoMigrate - whether to set auto-migration config.
        Returns:
        this.
      • setVerbose

        public NoteDbMigrator.Builder setVerbose​(boolean verbose)
        Enable verbose log output
        Parameters:
        verbose - enable verbose log output
        Returns:
        this.