\r
private final IStoredSettings settings;\r
\r
+ private AtomicBoolean running = new AtomicBoolean(false);\r
+ \r
private AtomicBoolean forceClose = new AtomicBoolean(false);\r
\r
private final Map<String, GCStatus> gcCache = new ConcurrentHashMap<String, GCStatus>();\r
return settings.getBoolean(Keys.git.enableGarbageCollection, false);\r
}\r
\r
+ public boolean isRunning() {\r
+ return running.get();\r
+ }\r
+ \r
public boolean lock(String repositoryName) {\r
return setGCStatus(repositoryName, GCStatus.COLLECTING);\r
}\r
if (!isReady()) {\r
return;\r
}\r
+ \r
+ running.set(true); \r
Date now = new Date();\r
\r
for (String repositoryName : GitBlit.self().getRepositoryList()) {\r
logger.debug(MessageFormat.format("GCExecutor released GC lock for {0}", repositoryName));\r
}\r
}\r
+ \r
+ running.set(false);\r
}\r
\r
private boolean isRepositoryIdle(FileRepository repository) {\r
gcExecutor.close();\r
}\r
\r
+ /**\r
+ * \r
+ * @return true if we are running the gc executor\r
+ */\r
+ public boolean isCollectingGarbage() {\r
+ return gcExecutor.isRunning();\r
+ }\r
+ \r
/**\r
* Returns true if Gitblit is actively collecting garbage in this repository.\r
* \r
String exts = storedSettings.getString(Keys.web.luceneIgnoreExtensions, luceneIgnoreExtensions);\r
excludedExtensions = new TreeSet<String>(StringUtils.getStringsFromValue(exts));\r
\r
+ if (GitBlit.self().isCollectingGarbage()) {\r
+ // busy collecting garbage, try again later\r
+ return;\r
+ }\r
+ \r
for (String repositoryName: GitBlit.self().getRepositoryList()) {\r
RepositoryModel model = GitBlit.self().getRepositoryModel(repositoryName);\r
if (model.hasCommits && !ArrayUtils.isEmpty(model.indexedBranches)) {\r