Examples of GarbageCollectCommand


Examples of org.eclipse.jgit.api.GarbageCollectCommand

  private static final Logger log = LoggerFactory.getLogger(GarbageCollectionCommand.class);

  @Override
  protected void runImpl() throws IOException, Failure {
    try {
      GarbageCollectCommand gc = Git.wrap(repo).gc();
      logGcInfo("before:", gc.getStatistics());
      gc.setProgressMonitor(NullProgressMonitor.INSTANCE);
      Properties statistics = gc.call();
      logGcInfo("after: ", statistics);
    } catch (Exception e) {
      throw new Failure(1, "fatal: Cannot run gc: ", e);
    }
  }
View Full Code Here

Examples of org.eclipse.jgit.api.GarbageCollectCommand

        }

        logger.debug(MessageFormat.format("GCExecutor locked idle repository {0}", repositoryName));

        Git git = new Git(repository);
        GarbageCollectCommand gc = git.gc();
        Properties stats = gc.getStatistics();

        // determine if this is a scheduled GC
        Calendar cal = Calendar.getInstance();
        cal.setTime(model.lastGC);
        cal.set(Calendar.HOUR_OF_DAY, 0);
        cal.set(Calendar.MINUTE, 0);
        cal.set(Calendar.SECOND, 0);
        cal.set(Calendar.MILLISECOND, 0);
        cal.add(Calendar.DATE, model.gcPeriod);
        Date gcDate = cal.getTime();
        boolean shouldCollectGarbage = now.after(gcDate);

        // determine if filesize triggered GC
        long gcThreshold = FileUtils.convertSizeToLong(model.gcThreshold, 500*1024L);
        long sizeOfLooseObjects = (Long) stats.get("sizeOfLooseObjects");
        boolean hasEnoughGarbage = sizeOfLooseObjects >= gcThreshold;

        // if we satisfy one of the requirements, GC
        boolean hasGarbage = sizeOfLooseObjects > 0;
        if (hasGarbage && (hasEnoughGarbage || shouldCollectGarbage)) {
          long looseKB = sizeOfLooseObjects/1024L;
          logger.info(MessageFormat.format("Collecting {1} KB of loose objects from {0}", repositoryName, looseKB));

          // do the deed
          gc.call();

          garbageCollected = true;
        }
      } catch (Exception e) {
        logger.error("Error collecting garbage in " + repositoryName, e);
View Full Code Here

Examples of org.eclipse.jgit.api.GarbageCollectCommand

    Repository repo = (Repository) getElement()
        .getAdapter(Repository.class);
    if (repo == null)
      return table;
    Git git = new Git(repo);
    GarbageCollectCommand gc = git.gc();
    try {
      Properties stats = gc.getStatistics();

      table.setLinesVisible(true);
      table.setHeaderVisible(true);
      GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
      data.heightHint = 200;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.