public Properties getStatistics() throws GitAPIException { // not inside a doLocked/synchronized block because we don't want to block the server status service. return git.gc().getStatistics(); }
public void run() throws Exception { try { LOGGER.info("Before GC: {}", git.gc().getStatistics()); LOGGER.debug("Before GC: Size - {}", getConfigRepoDisplaySize()); long expireTimeInMs = systemEnvironment.getConfigGitGCExpireTime(); git.gc().setAggressive(systemEnvironment.get(SystemEnvironment.GO_CONFIG_REPO_GC_AGGRESSIVE)) .setExpire(new Date(System.currentTimeMillis() - expireTimeInMs)) .call(); LOGGER.info("After GC: {}", git.gc().getStatistics()); LOGGER.debug("After GC: Size: {}", getConfigRepoDisplaySize()); } catch (GitAPIException e) { LOGGER.error("Could not perform GC", e); throw e; } } });
@Test public void shouldNotPerformGCWhenPeriodicGCIsTurnedOff() throws Exception { when(systemEnvironment.get(SystemEnvironment.GO_CONFIG_REPO_PERIODIC_GC)).thenReturn(false); configRepo.checkin(goConfigRevision("v1", "md5-1")); Long numberOfLooseObjectsOld = (Long) configRepo.git().gc().getStatistics().get("sizeOfLooseObjects"); configRepo.garbageCollect(); Long numberOfLooseObjectsNow = (Long) configRepo.git().gc().getStatistics().get("sizeOfLooseObjects"); assertThat(numberOfLooseObjectsNow, is(numberOfLooseObjectsOld)); }
@Test public void shouldPerformGC() throws Exception { configRepo.checkin(goConfigRevision("v1", "md5-1")); Long numberOfLooseObjects = (Long) configRepo.git().gc().getStatistics().get("sizeOfLooseObjects"); assertThat(numberOfLooseObjects > 0l, is(true)); configRepo.garbageCollect(); numberOfLooseObjects = (Long) configRepo.git().gc().getStatistics().get("sizeOfLooseObjects"); assertThat(numberOfLooseObjects, is(0l)); }
@Test public void shouldGetLooseObjectCount() throws Exception { configRepo.checkin(goConfigRevision("v1", "md5-1")); Long numberOfLooseObjects = (Long) configRepo.git().gc().getStatistics().get("numberOfLooseObjects"); assertThat(configRepo.getLooseObjectCount(), is(numberOfLooseObjects)); }
private void statistics(Repository repository, GarbageCollectCommand gcc) throws GitAPIException { Properties properties = gcc.getStatistics(); logger.info(message(repository, properties, "before")); }