Search in sources :

Example 56 with Stopwatch

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);
}
Also used : TextProgressMonitor(org.eclipse.jgit.lib.TextProgressMonitor) ProgressMonitor(org.eclipse.jgit.lib.ProgressMonitor) SiteIndexer(com.google.gerrit.server.index.SiteIndexer) OrmException(com.google.gwtorm.server.OrmException) Stopwatch(com.google.common.base.Stopwatch) TextProgressMonitor(org.eclipse.jgit.lib.TextProgressMonitor) PrintWriter(java.io.PrintWriter)

Example 57 with Stopwatch

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);
}
Also used : ProgressMonitor(org.eclipse.jgit.lib.ProgressMonitor) TextProgressMonitor(org.eclipse.jgit.lib.TextProgressMonitor) SiteIndexer(com.google.gerrit.server.index.SiteIndexer) OrmException(com.google.gwtorm.server.OrmException) Stopwatch(com.google.common.base.Stopwatch) TextProgressMonitor(org.eclipse.jgit.lib.TextProgressMonitor) PrintWriter(java.io.PrintWriter)

Example 58 with Stopwatch

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);
}
Also used : TextProgressMonitor(org.eclipse.jgit.lib.TextProgressMonitor) MultiProgressMonitor(com.google.gerrit.server.git.MultiProgressMonitor) ProgressMonitor(org.eclipse.jgit.lib.ProgressMonitor) Project(com.google.gerrit.reviewdb.client.Project) Repository(org.eclipse.jgit.lib.Repository) TreeSet(java.util.TreeSet) Stopwatch(com.google.common.base.Stopwatch) IOException(java.io.IOException) TextProgressMonitor(org.eclipse.jgit.lib.TextProgressMonitor)

Example 59 with Stopwatch

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));
    }
}
Also used : CurrentSchemaVersion(com.google.gerrit.reviewdb.client.CurrentSchemaVersion) Stopwatch(com.google.common.base.Stopwatch)

Example 60 with Stopwatch

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);
        }
    }
}
Also used : Stopwatch(com.google.common.base.Stopwatch) DataStoreException(org.apache.jackrabbit.core.data.DataStoreException) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException)

Aggregations

Stopwatch (com.google.common.base.Stopwatch)314 IOException (java.io.IOException)81 ArrayList (java.util.ArrayList)29 ExecutionException (java.util.concurrent.ExecutionException)28 File (java.io.File)19 Map (java.util.Map)18 Test (org.junit.Test)18 DocumentStoreException (org.apache.jackrabbit.oak.plugins.document.DocumentStoreException)15 HashMap (java.util.HashMap)14 Path (org.apache.hadoop.fs.Path)14 List (java.util.List)12 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)11 DrillRuntimeException (org.apache.drill.common.exceptions.DrillRuntimeException)11 DBCollection (com.mongodb.DBCollection)9 ISE (io.druid.java.util.common.ISE)9 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)8 OptionsParser (com.google.devtools.common.options.OptionsParser)8 MongoException (com.mongodb.MongoException)8 Connection (java.sql.Connection)8 CountDownLatch (java.util.concurrent.CountDownLatch)8