use of com.google.common.base.Stopwatch in project gerrit by GerritCodeReview.
the class AllGroupsIndexer method indexAll.
@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 {
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);
}
use of com.google.common.base.Stopwatch in project gerrit by GerritCodeReview.
the class AllAccountsIndexer method indexAll.
@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;
try {
ids = collectAccounts(progress);
} catch (OrmException e) {
log.error("Error collecting accounts", e);
return new SiteIndexer.Result(sw, false, 0, 0);
}
return reindexAccounts(index, ids, progress);
}
use of com.google.common.base.Stopwatch in project gerrit by GerritCodeReview.
the class AllChangesIndexer method indexAll.
@Override
public Result indexAll(ChangeIndex index) {
ProgressMonitor pm = new TextProgressMonitor();
pm.beginTask("Collecting projects", ProgressMonitor.UNKNOWN);
SortedSet<ProjectHolder> projects = new TreeSet<>();
int changeCount = 0;
Stopwatch sw = Stopwatch.createStarted();
for (Project.NameKey name : projectCache.all()) {
try (Repository repo = repoManager.openRepository(name)) {
int size = ChangeNotes.Factory.scan(repo).size();
changeCount += size;
projects.add(new ProjectHolder(name, size));
} catch (IOException e) {
log.error("Error collecting projects", e);
return new Result(sw, false, 0, 0);
}
pm.update(1);
}
pm.endTask();
setTotalWork(changeCount);
return indexAll(index, projects);
}
use of com.google.common.base.Stopwatch in project gerrit by GerritCodeReview.
the class SchemaVersion method migrateData.
private void migrateData(List<SchemaVersion> pending, UpdateUI ui, CurrentSchemaVersion curr, ReviewDb db) throws OrmException, SQLException {
for (SchemaVersion v : pending) {
Stopwatch sw = Stopwatch.createStarted();
ui.message(String.format("Migrating data to schema %d ...", v.getVersionNbr()));
v.migrateData(db, ui);
v.finish(curr, db);
ui.message(String.format("\t> Done (%.3f s)", sw.elapsed(TimeUnit.MILLISECONDS) / 1000d));
}
}
use of com.google.common.base.Stopwatch in project jackrabbit-oak by apache.
the class MarkSweepGarbageCollector method markAndSweep.
/**
* Mark and sweep. Main entry method for GC.
*
* @param markOnly whether to mark only
* @param forceBlobRetrieve force retrieve blob ids
* @throws Exception the exception
*/
protected void markAndSweep(boolean markOnly, boolean forceBlobRetrieve) throws Exception {
boolean threw = true;
GarbageCollectorFileState fs = new GarbageCollectorFileState(root);
try {
Stopwatch sw = Stopwatch.createStarted();
LOG.info("Starting Blob garbage collection with markOnly [{}]", markOnly);
long markStart = System.currentTimeMillis();
mark(fs);
if (!markOnly) {
long deleteCount = sweep(fs, markStart, forceBlobRetrieve);
threw = false;
long maxTime = getLastMaxModifiedTime(markStart) > 0 ? getLastMaxModifiedTime(markStart) : markStart;
sw.stop();
LOG.info("Blob garbage collection completed in {} ({} ms). Number of blobs deleted [{}] with max modification time of [{}]", sw.toString(), sw.elapsed(TimeUnit.MILLISECONDS), deleteCount, timestampToString(maxTime));
}
} catch (Exception e) {
LOG.error("Blob garbage collection error", e);
throw e;
} finally {
if (!LOG.isTraceEnabled()) {
Closeables.close(fs, threw);
}
}
}
Aggregations