James Moger
2012-10-31 dad8b4b5dc2ad22556968b878c466a59ba80933a
Don't even bother running Lucene indexer if we are GCing anything
3 files modified
23 ■■■■■ changed files
src/com/gitblit/GCExecutor.java 10 ●●●●● patch | view | raw | blame | history
src/com/gitblit/GitBlit.java 8 ●●●●● patch | view | raw | blame | history
src/com/gitblit/LuceneExecutor.java 5 ●●●●● patch | view | raw | blame | history
src/com/gitblit/GCExecutor.java
@@ -53,6 +53,8 @@
    private final IStoredSettings settings;
    
    private AtomicBoolean running = new AtomicBoolean(false);
    private AtomicBoolean forceClose = new AtomicBoolean(false);
    
    private final Map<String, GCStatus> gcCache = new ConcurrentHashMap<String, GCStatus>();
@@ -68,6 +70,10 @@
     */
    public boolean isReady() {
        return settings.getBoolean(Keys.git.enableGarbageCollection, false);
    }
    public boolean isRunning() {
        return running.get();
    }
    
    public boolean lock(String repositoryName) {
@@ -121,6 +127,8 @@
        if (!isReady()) {
            return;
        }
        running.set(true);
        Date now = new Date();
        for (String repositoryName : GitBlit.self().getRepositoryList()) {
@@ -205,6 +213,8 @@
                logger.debug(MessageFormat.format("GCExecutor released GC lock for {0}", repositoryName));
            }
        }
        running.set(false);
    }
    
    private boolean isRepositoryIdle(FileRepository repository) {
src/com/gitblit/GitBlit.java
@@ -2907,6 +2907,14 @@
    }
    
    /**
     *
     * @return true if we are running the gc executor
     */
    public boolean isCollectingGarbage() {
        return gcExecutor.isRunning();
    }
    /**
     * Returns true if Gitblit is actively collecting garbage in this repository.
     * 
     * @param repositoryName
src/com/gitblit/LuceneExecutor.java
@@ -167,6 +167,11 @@
        String exts = storedSettings.getString(Keys.web.luceneIgnoreExtensions, luceneIgnoreExtensions);
        excludedExtensions = new TreeSet<String>(StringUtils.getStringsFromValue(exts));
        if (GitBlit.self().isCollectingGarbage()) {
            // busy collecting garbage, try again later
            return;
        }
        for (String repositoryName: GitBlit.self().getRepositoryList()) {
            RepositoryModel model = GitBlit.self().getRepositoryModel(repositoryName);
            if (model.hasCommits && !ArrayUtils.isEmpty(model.indexedBranches)) {