diff options
author | Matthias Sohn <matthias.sohn@sap.com> | 2020-07-31 00:53:50 +0200 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2020-10-06 23:47:31 +0200 |
commit | b18fd1f8970535573c0b94ac0ab25bd403712785 (patch) | |
tree | d3b7638418144949b1b362136b75f5895ffdbd75 | |
parent | 0b847ab19dcf7ffab90fb09389b18a9d2ecf2153 (diff) |
MigrateToNoteDb: implement option --verbose
This option was already defined but not fully implemented to enable
logging more detailed migration logs.
Change-Id: I6b179df9049a31d49e421c45c6a814a76240fa50
-rw-r--r-- | java/com/google/gerrit/pgm/MigrateToNoteDb.java | 1 | ||||
-rw-r--r-- | java/com/google/gerrit/server/notedb/rebuild/NoteDbMigrator.java | 23 |
2 files changed, 22 insertions, 2 deletions
diff --git a/java/com/google/gerrit/pgm/MigrateToNoteDb.java b/java/com/google/gerrit/pgm/MigrateToNoteDb.java index 0c2daa0b38..9bd00fcb92 100644 --- a/java/com/google/gerrit/pgm/MigrateToNoteDb.java +++ b/java/com/google/gerrit/pgm/MigrateToNoteDb.java @@ -146,6 +146,7 @@ public class MigrateToNoteDb extends SiteProgram { .setTrialMode(trial) .setForceRebuild(force) .setSequenceGap(sequenceGap) + .setVerbose(verbose) .build()) { if (!projects.isEmpty() || !changes.isEmpty() || !skipProjects.isEmpty()) { migrator.rebuild(); diff --git a/java/com/google/gerrit/server/notedb/rebuild/NoteDbMigrator.java b/java/com/google/gerrit/server/notedb/rebuild/NoteDbMigrator.java index 4f2f9ab62c..242e00f0ea 100644 --- a/java/com/google/gerrit/server/notedb/rebuild/NoteDbMigrator.java +++ b/java/com/google/gerrit/server/notedb/rebuild/NoteDbMigrator.java @@ -181,6 +181,7 @@ public class NoteDbMigrator implements AutoCloseable { private boolean forceRebuild; private int sequenceGap = -1; private boolean autoMigrate; + private boolean verbose; @Inject Builder( @@ -383,6 +384,17 @@ public class NoteDbMigrator implements AutoCloseable { return this; } + /** + * Enable verbose log output + * + * @param verbose enable verbose log output + * @return this. + */ + public Builder setVerbose(boolean verbose) { + this.verbose = verbose; + return this; + } + public NoteDbMigrator build() throws MigrationException { return new NoteDbMigrator( sitePaths, @@ -412,7 +424,8 @@ public class NoteDbMigrator implements AutoCloseable { trial, forceRebuild, sequenceGap >= 0 ? sequenceGap : Sequences.getChangeSequenceGap(cfg), - autoMigrate); + autoMigrate, + verbose); } } @@ -443,6 +456,7 @@ public class NoteDbMigrator implements AutoCloseable { private final boolean forceRebuild; private final int sequenceGap; private final boolean autoMigrate; + private final boolean verbose; private final AtomicLong globalChangeCounter = new AtomicLong(); @@ -471,7 +485,8 @@ public class NoteDbMigrator implements AutoCloseable { boolean trial, boolean forceRebuild, int sequenceGap, - boolean autoMigrate) + boolean autoMigrate, + boolean verbose) throws MigrationException { if (ImmutableList.of(!changes.isEmpty(), !projects.isEmpty(), !skipProjects.isEmpty()).stream() .filter(e -> e) @@ -507,6 +522,7 @@ public class NoteDbMigrator implements AutoCloseable { this.forceRebuild = forceRebuild; this.sequenceGap = sequenceGap; this.autoMigrate = autoMigrate; + this.verbose = verbose; // Stack notedb.config over gerrit.config, in the same way as GerritServerConfigProvider. this.gerritConfig = new FileBasedConfig(sitePaths.gerrit_config.toFile(), FS.detect()); @@ -975,6 +991,9 @@ public class NoteDbMigrator implements AutoCloseable { logger.atSevere().withCause(t).log("Failed to rebuild change %s", changeId); ok = false; } + if (verbose) { + logger.atInfo().log("Rebuilt change %s", changeId.get()); + } long cnt = globalChangeCounter.incrementAndGet(); if (cnt % 1000 == 0) { logger.atInfo().log("Total number of rebuilt changes %d", cnt); |