List of usage examples for org.eclipse.jgit.api GarbageCollectCommand setAggressive
public GarbageCollectCommand setAggressive(boolean aggressive)
From source file:com.google.gerrit.server.git.GarbageCollection.java
License:Apache License
public GarbageCollectionResult run(List<Project.NameKey> projectNames, boolean aggressive, PrintWriter writer) { GarbageCollectionResult result = new GarbageCollectionResult(); Set<Project.NameKey> projectsToGc = gcQueue.addAll(projectNames); for (Project.NameKey projectName : Sets.difference(Sets.newHashSet(projectNames), projectsToGc)) { result.addError(new GarbageCollectionResult.Error( GarbageCollectionResult.Error.Type.GC_ALREADY_SCHEDULED, projectName)); }/*from w w w. j a v a 2s . c o m*/ for (Project.NameKey p : projectsToGc) { try (Repository repo = repoManager.openRepository(p)) { logGcConfiguration(p, repo, aggressive); print(writer, "collecting garbage for \"" + p + "\":\n"); GarbageCollectCommand gc = Git.wrap(repo).gc(); gc.setAggressive(aggressive); logGcInfo(p, "before:", gc.getStatistics()); gc.setProgressMonitor( writer != null ? new TextProgressMonitor(writer) : NullProgressMonitor.INSTANCE); Properties statistics = gc.call(); logGcInfo(p, "after: ", statistics); print(writer, "done.\n\n"); fire(p, statistics); } catch (RepositoryNotFoundException e) { logGcError(writer, p, e); result.addError(new GarbageCollectionResult.Error( GarbageCollectionResult.Error.Type.REPOSITORY_NOT_FOUND, p)); } catch (Exception e) { logGcError(writer, p, e); result.addError(new GarbageCollectionResult.Error(GarbageCollectionResult.Error.Type.GC_FAILED, p)); } finally { gcQueue.gcFinished(p); } } return result; }