| | |
| | | import com.gitblit.Constants.FederationStrategy; |
| | | import com.gitblit.Constants.PermissionType; |
| | | import com.gitblit.Constants.RegistrantType; |
| | | import com.gitblit.GCExecutor; |
| | | import com.gitblit.GitBlitException; |
| | | import com.gitblit.IStoredSettings; |
| | | import com.gitblit.Keys; |
| | | import com.gitblit.LuceneExecutor; |
| | | import com.gitblit.MirrorExecutor; |
| | | import com.gitblit.models.ForkModel; |
| | | import com.gitblit.models.Metric; |
| | | import com.gitblit.models.RefModel; |
| | |
| | | import com.gitblit.models.SearchResult; |
| | | import com.gitblit.models.TeamModel; |
| | | import com.gitblit.models.UserModel; |
| | | import com.gitblit.service.GarbageCollectorService; |
| | | import com.gitblit.service.LuceneService; |
| | | import com.gitblit.service.MirrorService; |
| | | import com.gitblit.utils.ArrayUtils; |
| | | import com.gitblit.utils.ByteFormat; |
| | | import com.gitblit.utils.CommitCache; |
| | |
| | | |
| | | private final File repositoriesFolder; |
| | | |
| | | private LuceneExecutor luceneExecutor; |
| | | private LuceneService luceneExecutor; |
| | | |
| | | private GCExecutor gcExecutor; |
| | | private GarbageCollectorService gcExecutor; |
| | | |
| | | private MirrorExecutor mirrorExecutor; |
| | | private MirrorService mirrorExecutor; |
| | | |
| | | public RepositoryManager( |
| | | IRuntimeManager runtimeManager, |
| | |
| | | } |
| | | |
| | | @Override |
| | | public IManager setup() { |
| | | logger.info("Git repositories folder = " + repositoriesFolder.getAbsolutePath()); |
| | | public RepositoryManager start() { |
| | | logger.info("Repositories folder : {}", repositoriesFolder.getAbsolutePath()); |
| | | |
| | | // initialize utilities |
| | | String prefix = settings.getString(Keys.git.userRepositoryPrefix, "~"); |
| | |
| | | |
| | | // build initial repository list |
| | | if (settings.getBoolean(Keys.git.cacheRepositoryList, true)) { |
| | | logger.info("Identifying available repositories..."); |
| | | logger.info("Identifying repositories..."); |
| | | getRepositoryList(); |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | @Override |
| | | public IManager stop() { |
| | | public RepositoryManager stop() { |
| | | scheduledExecutor.shutdownNow(); |
| | | luceneExecutor.close(); |
| | | gcExecutor.close(); |
| | |
| | | } |
| | | |
| | | protected void configureLuceneIndexing() { |
| | | luceneExecutor = new LuceneExecutor(settings, this); |
| | | scheduledExecutor.scheduleAtFixedRate(luceneExecutor, 1, 2, TimeUnit.MINUTES); |
| | | logger.info("Lucene executor is scheduled to process indexed branches every 2 minutes."); |
| | | luceneExecutor = new LuceneService(settings, this); |
| | | int period = 2; |
| | | scheduledExecutor.scheduleAtFixedRate(luceneExecutor, 1, period, TimeUnit.MINUTES); |
| | | logger.info("Lucene will process indexed branches every {} minutes.", period); |
| | | } |
| | | |
| | | protected void configureGarbageCollector() { |
| | | // schedule gc engine |
| | | gcExecutor = new GCExecutor(settings, this); |
| | | gcExecutor = new GarbageCollectorService(settings, this); |
| | | if (gcExecutor.isReady()) { |
| | | logger.info("GC executor is scheduled to scan repositories every 24 hours."); |
| | | logger.info("Garbage Collector (GC) will scan repositories every 24 hours."); |
| | | Calendar c = Calendar.getInstance(); |
| | | c.set(Calendar.HOUR_OF_DAY, settings.getInteger(Keys.git.garbageCollectionHour, 0)); |
| | | c.set(Calendar.MINUTE, 0); |
| | |
| | | } |
| | | logger.info(MessageFormat.format("Next scheculed GC scan is in {0}", when)); |
| | | scheduledExecutor.scheduleAtFixedRate(gcExecutor, delay, 60 * 24, TimeUnit.MINUTES); |
| | | } else { |
| | | logger.info("Garbage Collector (GC) is disabled."); |
| | | } |
| | | } |
| | | |
| | | protected void configureMirrorExecutor() { |
| | | mirrorExecutor = new MirrorExecutor(settings, this); |
| | | mirrorExecutor = new MirrorService(settings, this); |
| | | if (mirrorExecutor.isReady()) { |
| | | int mins = TimeUtils.convertFrequencyToMinutes(settings.getString(Keys.git.mirrorPeriod, "30 mins")); |
| | | if (mins < 5) { |
| | |
| | | } |
| | | int delay = 1; |
| | | scheduledExecutor.scheduleAtFixedRate(mirrorExecutor, delay, mins, TimeUnit.MINUTES); |
| | | logger.info("Mirror executor is scheduled to fetch updates every {} minutes.", mins); |
| | | logger.info("Mirror service will fetch updates every {} minutes.", mins); |
| | | logger.info("Next scheduled mirror fetch is in {} minutes", delay); |
| | | } else { |
| | | logger.info("Mirror service is disabled."); |
| | | } |
| | | } |
| | | |
| | |
| | | protected void configureCommitCache() { |
| | | int daysToCache = settings.getInteger(Keys.web.activityCacheDays, 14); |
| | | if (daysToCache <= 0) { |
| | | logger.info("commit cache disabled"); |
| | | logger.info("Commit cache is disabled"); |
| | | } else { |
| | | long start = System.nanoTime(); |
| | | long repoCount = 0; |
| | | long commitCount = 0; |
| | | logger.info(MessageFormat.format("preparing {0} day commit cache. please wait...", daysToCache)); |
| | | logger.info(MessageFormat.format("Preparing {0} day commit cache. please wait...", daysToCache)); |
| | | CommitCache.instance().setCacheDays(daysToCache); |
| | | Date cutoff = CommitCache.instance().getCutoffDate(); |
| | | for (String repositoryName : getRepositoryList()) { |