use of com.google.gerrit.server.git.MultiProgressMonitor.Task in project gerrit by GerritCodeReview.
the class AllChangesIndexer method indexAll.
public SiteIndexer.Result indexAll(ChangeIndex index, Iterable<ProjectHolder> projects) {
Stopwatch sw = Stopwatch.createStarted();
final MultiProgressMonitor mpm = new MultiProgressMonitor(progressOut, "Reindexing changes");
final Task projTask = mpm.beginSubTask("projects", (projects instanceof Collection) ? ((Collection<?>) projects).size() : MultiProgressMonitor.UNKNOWN);
final Task doneTask = mpm.beginSubTask(null, totalWork >= 0 ? totalWork : MultiProgressMonitor.UNKNOWN);
final Task failedTask = mpm.beginSubTask("failed", MultiProgressMonitor.UNKNOWN);
final List<ListenableFuture<?>> futures = new ArrayList<>();
final AtomicBoolean ok = new AtomicBoolean(true);
for (final ProjectHolder project : projects) {
ListenableFuture<?> future = executor.submit(reindexProject(indexerFactory.create(executor, index), project.name, doneTask, failedTask, verboseWriter));
addErrorListener(future, "project " + project.name, projTask, ok);
futures.add(future);
}
try {
mpm.waitFor(transform(successfulAsList(futures), x -> {
mpm.end();
return null;
}, directExecutor()));
} catch (ExecutionException e) {
log.error("Error in batch indexer", e);
ok.set(false);
}
// If too many changes failed, maybe there was a bug in the indexer. Don't
// trust the results. This is not an exact percentage since we bump the same
// failure counter if a project can't be read, but close enough.
int nFailed = failedTask.getCount();
int nDone = doneTask.getCount();
int nTotal = nFailed + nDone;
double pctFailed = ((double) nFailed) / nTotal * 100;
if (pctFailed > 10) {
log.error("Failed {}/{} changes ({}%); not marking new index as ready", nFailed, nTotal, Math.round(pctFailed));
ok.set(false);
}
return new Result(sw, ok.get(), nDone, nFailed);
}
use of com.google.gerrit.server.git.MultiProgressMonitor.Task in project gerrit by GerritCodeReview.
the class Index method apply.
@Override
public Response.Accepted apply(ProjectResource resource, ProjectInput input) {
Project.NameKey project = resource.getNameKey();
Task mpt = new MultiProgressMonitor(ByteStreams.nullOutputStream(), "Reindexing project").beginSubTask("", MultiProgressMonitor.UNKNOWN);
PrintWriter pw = new PrintWriter(CharStreams.nullWriter());
executor.submit(allChangesIndexer.reindexProject(indexer, project, mpt, mpt, pw));
return Response.accepted("Project " + project + " submitted for reindexing");
}
Aggregations