Example usage for org.eclipse.jgit.lib ProgressMonitor start

List of usage examples for org.eclipse.jgit.lib ProgressMonitor start

Introduction

In this page you can find the example usage for org.eclipse.jgit.lib ProgressMonitor start.

Prototype

void start(int totalTasks);

Source Link

Document

Advise the monitor of the total number of subtasks.

Usage

From source file:com.google.gerrit.pgm.Reindex.java

License:Apache License

private int indexAll() throws Exception {
    ProgressMonitor pm = new TextProgressMonitor();
    pm.start(1);
    pm.beginTask("Collecting projects", ProgressMonitor.UNKNOWN);
    Set<Project.NameKey> projects = Sets.newTreeSet();
    int changeCount = 0;
    try (ReviewDb db = sysInjector.getInstance(ReviewDb.class)) {
        for (Change change : db.changes().all()) {
            changeCount++;/*  ww  w. j a va2  s .  co  m*/
            if (projects.add(change.getProject())) {
                pm.update(1);
            }
        }
    }
    pm.endTask();

    SiteIndexer batchIndexer = sysInjector.getInstance(SiteIndexer.class);
    SiteIndexer.Result result = batchIndexer.setNumChanges(changeCount).setProgressOut(System.err)
            .setVerboseOut(verbose ? System.out : NullOutputStream.INSTANCE).indexAll(index, projects);
    int n = result.doneCount() + result.failedCount();
    double t = result.elapsed(TimeUnit.MILLISECONDS) / 1000d;
    System.out.format("Reindexed %d changes in %.01fs (%.01f/s)\n", n, t, n / t);
    return result.success() ? 0 : 1;
}

From source file:com.google.gerrit.server.index.account.AllAccountsIndexer.java

License:Apache License

@Override
public SiteIndexer.Result indexAll(final AccountIndex index) {
    ProgressMonitor progress = new TextProgressMonitor(new PrintWriter(progressOut));
    progress.start(2);
    Stopwatch sw = Stopwatch.createStarted();
    List<Account.Id> ids;//from  ww  w . j a  v  a  2s . c  o  m
    try {
        ids = collectAccounts(progress);
    } catch (OrmException e) {
        log.error("Error collecting accounts", e);
        return new Result(sw, false, 0, 0);
    }
    return reindexAccounts(index, ids, progress);
}

From source file:com.google.gerrit.server.index.group.AllGroupsIndexer.java

License:Apache License

@Override
public SiteIndexer.Result indexAll(GroupIndex index) {
    ProgressMonitor progress = new TextProgressMonitor(new PrintWriter(progressOut));
    progress.start(2);
    Stopwatch sw = Stopwatch.createStarted();
    List<AccountGroup.UUID> uuids;
    try {//from  w ww. ja v a  2  s  .  co  m
        uuids = collectGroups(progress);
    } catch (OrmException e) {
        log.error("Error collecting groups", e);
        return new SiteIndexer.Result(sw, false, 0, 0);
    }
    return reindexGroups(index, uuids, progress);
}