use of org.eclipse.jgit.lib.TextProgressMonitor in project gerrit by GerritCodeReview.
the class Schema_123 method migrateData.
@Override
protected void migrateData(ReviewDb db, UpdateUI ui) throws OrmException, SQLException {
ListMultimap<Account.Id, Change.Id> imports = MultimapBuilder.hashKeys().arrayListValues().build();
try (Statement stmt = ((JdbcSchema) db).getConnection().createStatement();
ResultSet rs = stmt.executeQuery("SELECT account_id, change_id FROM starred_changes")) {
while (rs.next()) {
Account.Id accountId = new Account.Id(rs.getInt(1));
Change.Id changeId = new Change.Id(rs.getInt(2));
imports.put(accountId, changeId);
}
}
if (imports.isEmpty()) {
return;
}
try (Repository git = repoManager.openRepository(allUsersName);
RevWalk rw = new RevWalk(git)) {
BatchRefUpdate bru = git.getRefDatabase().newBatchUpdate();
ObjectId id = StarredChangesUtil.writeLabels(git, StarredChangesUtil.DEFAULT_LABELS);
for (Map.Entry<Account.Id, Change.Id> e : imports.entries()) {
bru.addCommand(new ReceiveCommand(ObjectId.zeroId(), id, RefNames.refsStarredChanges(e.getValue(), e.getKey())));
}
bru.execute(rw, new TextProgressMonitor());
} catch (IOException ex) {
throw new OrmException(ex);
}
}
use of org.eclipse.jgit.lib.TextProgressMonitor in project gerrit by GerritCodeReview.
the class AllAccountsIndexer method indexAll.
@Override
public SiteIndexer.Result indexAll(AccountIndex index) {
ProgressMonitor progress = new TextProgressMonitor(newPrintWriter(progressOut));
progress.start(2);
Stopwatch sw = Stopwatch.createStarted();
List<Account.Id> ids;
try {
ids = collectAccounts(progress);
} catch (IOException e) {
logger.atSevere().withCause(e).log("Error collecting accounts");
return SiteIndexer.Result.create(sw, false, 0, 0);
}
return reindexAccounts(index, ids, progress);
}
use of org.eclipse.jgit.lib.TextProgressMonitor in project gerrit by GerritCodeReview.
the class AllGroupsIndexer method indexAll.
@Override
public SiteIndexer.Result indexAll(GroupIndex index) {
ProgressMonitor progress = new TextProgressMonitor(newPrintWriter(progressOut));
progress.start(2);
Stopwatch sw = Stopwatch.createStarted();
List<AccountGroup.UUID> uuids;
try {
uuids = collectGroups(progress);
} catch (IOException | ConfigInvalidException e) {
logger.atSevere().withCause(e).log("Error collecting groups");
return SiteIndexer.Result.create(sw, false, 0, 0);
}
return reindexGroups(index, uuids, progress);
}
use of org.eclipse.jgit.lib.TextProgressMonitor in project gerrit by GerritCodeReview.
the class AllProjectsIndexer method indexAll.
@Override
public SiteIndexer.Result indexAll(final ProjectIndex index) {
ProgressMonitor progress = new TextProgressMonitor(newPrintWriter(progressOut));
progress.start(2);
List<Project.NameKey> names = collectProjects(progress);
return reindexProjects(index, names, progress);
}
use of org.eclipse.jgit.lib.TextProgressMonitor in project gerrit by GerritCodeReview.
the class ProtobufImport method run.
@Override
public int run() throws Exception {
mustHaveValidSite();
Injector dbInjector = createDbInjector(SINGLE_USER);
manager.add(dbInjector);
manager.start();
RuntimeShutdown.add(manager::stop);
dbInjector.injectMembers(this);
ProgressMonitor progress = new TextProgressMonitor();
progress.beginTask("Importing entities", ProgressMonitor.UNKNOWN);
try (ReviewDb db = schemaFactory.open()) {
for (RelationModel model : new JavaSchemaModel(ReviewDb.class).getRelations()) {
relations.put(model.getRelationID(), Relation.create(model, db));
}
Parser<UnknownFieldSet> parser = UnknownFieldSet.getDefaultInstance().getParserForType();
try (InputStream in = new BufferedInputStream(Files.newInputStream(file.toPath()))) {
UnknownFieldSet msg;
while ((msg = parser.parseDelimitedFrom(in)) != null) {
Map.Entry<Integer, UnknownFieldSet.Field> e = Iterables.getOnlyElement(msg.asMap().entrySet());
Relation rel = checkNotNull(relations.get(e.getKey()), "unknown relation ID %s in message: %s", e.getKey(), msg);
List<ByteString> values = e.getValue().getLengthDelimitedList();
checkState(values.size() == 1, "expected one string field in message: %s", msg);
upsert(rel, values.get(0));
progress.update(1);
}
}
progress.endTask();
}
return 0;
}
Aggregations