Extend MigrateAccountPatchReviewDb summary with stats
Add the following information: 1. how many rows were migrated 2. how much time it took 3. what was migration speed (rows per/sec) So that it is more consistent with Reindex operation output. Change-Id: If49da15ed9806f2b0dd2e63911445a55785a5cfb
This commit is contained in:
@@ -15,6 +15,7 @@
|
|||||||
package com.google.gerrit.pgm;
|
package com.google.gerrit.pgm;
|
||||||
|
|
||||||
import com.google.auto.value.AutoValue;
|
import com.google.auto.value.AutoValue;
|
||||||
|
import com.google.common.base.Stopwatch;
|
||||||
import com.google.common.base.Strings;
|
import com.google.common.base.Strings;
|
||||||
import com.google.gerrit.pgm.util.SiteProgram;
|
import com.google.gerrit.pgm.util.SiteProgram;
|
||||||
import com.google.gerrit.server.config.GerritServerConfig;
|
import com.google.gerrit.server.config.GerritServerConfig;
|
||||||
@@ -31,6 +32,7 @@ import java.sql.SQLException;
|
|||||||
import java.sql.Statement;
|
import java.sql.Statement;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
import org.eclipse.jgit.lib.Config;
|
import org.eclipse.jgit.lib.Config;
|
||||||
import org.kohsuke.args4j.Option;
|
import org.kohsuke.args4j.Option;
|
||||||
|
|
||||||
@@ -91,6 +93,7 @@ public class MigrateAccountPatchReviewDb extends SiteProgram {
|
|||||||
+ "(?, ?, ?, ?)")) {
|
+ "(?, ?, ?, ?)")) {
|
||||||
targetCon.setAutoCommit(false);
|
targetCon.setAutoCommit(false);
|
||||||
long offset = 0;
|
long offset = 0;
|
||||||
|
Stopwatch sw = Stopwatch.createStarted();
|
||||||
List<Row> rows = selectRows(sourceStmt, offset);
|
List<Row> rows = selectRows(sourceStmt, offset);
|
||||||
while (!rows.isEmpty()) {
|
while (!rows.isEmpty()) {
|
||||||
insertRows(targetCon, targetStmt, rows);
|
insertRows(targetCon, targetStmt, rows);
|
||||||
@@ -98,7 +101,8 @@ public class MigrateAccountPatchReviewDb extends SiteProgram {
|
|||||||
System.out.printf("%8d rows migrated\n", offset);
|
System.out.printf("%8d rows migrated\n", offset);
|
||||||
rows = selectRows(sourceStmt, offset);
|
rows = selectRows(sourceStmt, offset);
|
||||||
}
|
}
|
||||||
System.out.println("Done");
|
double t = sw.elapsed(TimeUnit.MILLISECONDS) / 1000d;
|
||||||
|
System.out.printf("Migrated %d rows in %.01fs (%.01f/s)\n", offset, t, offset / t);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user