summaryrefslogtreecommitdiffstats
path: root/src/com/gitblit/LuceneExecutor.java
diff options
context:
space:
mode:
authorJames Moger <james.moger@gitblit.com>2012-03-09 20:45:52 -0500
committerJames Moger <james.moger@gitblit.com>2012-03-09 20:45:52 -0500
commit3d0494ad6db80843add9bf9d6eac783a691ac5a1 (patch)
tree2b2322ce73622f777da8e017986f07d746fc5d4e /src/com/gitblit/LuceneExecutor.java
parent9357e929bdc1237577b6f6302861dce0e9d1e39c (diff)
downloadgitblit-3d0494ad6db80843add9bf9d6eac783a691ac5a1.tar.gz
gitblit-3d0494ad6db80843add9bf9d6eac783a691ac5a1.zip
More Lucene progress
Diffstat (limited to 'src/com/gitblit/LuceneExecutor.java')
-rw-r--r--src/com/gitblit/LuceneExecutor.java52
1 files changed, 27 insertions, 25 deletions
diff --git a/src/com/gitblit/LuceneExecutor.java b/src/com/gitblit/LuceneExecutor.java
index b4e5134a..4f06b4ec 100644
--- a/src/com/gitblit/LuceneExecutor.java
+++ b/src/com/gitblit/LuceneExecutor.java
@@ -105,26 +105,26 @@ public class LuceneExecutor implements Runnable {
Set<String> processed = new HashSet<String>();
if (!queue.isEmpty()) {
// update the repository Lucene index
- String repositoryName = null;
- while ((repositoryName = queue.poll()) != null) {
- if (processed.contains(repositoryName)) {
+ String name = null;
+ while ((name = queue.poll()) != null) {
+ if (processed.contains(name)) {
// skipping multi-queued repository
continue;
}
try {
- Repository repository = GitBlit.self().getRepository(repositoryName);
+ Repository repository = GitBlit.self().getRepository(name);
if (repository == null) {
logger.warn(MessageFormat.format(
"Lucene executor could not find repository {0}. Skipping.",
- repositoryName));
+ name));
continue;
}
- index(repositoryName, repository);
+ index(name, repository);
repository.close();
- processed.add(repositoryName);
+ processed.add(name);
} catch (Throwable e) {
logger.error(MessageFormat.format("Failed to update {0} Lucene index",
- repositoryName), e);
+ name), e);
}
}
}
@@ -134,51 +134,53 @@ public class LuceneExecutor implements Runnable {
* Synchronously indexes a repository. This may build a complete index of a
* repository or it may update an existing index.
*
- * @param repositoryName
+ * @param name
* the name of the repository
* @param repository
* the repository object
*/
- public void index(String repositoryName, Repository repository) {
+ public void index(String name, Repository repository) {
try {
if (JGitUtils.hasCommits(repository)) {
if (LuceneUtils.shouldReindex(repository)) {
// (re)build the entire index
long start = System.currentTimeMillis();
- IndexResult result = LuceneUtils.reindex(repository);
- long duration = System.currentTimeMillis() - start;
+ String msg = "Building {0} Lucene index...";
+ logger.info(MessageFormat.format(msg, name));
+ IndexResult result = LuceneUtils.reindex(name, repository, true);
+ float duration = (System.currentTimeMillis() - start)/1000f;
if (result.success) {
if (result.commitCount > 0) {
- String msg = "Built {0} Lucene index from {1} commits in {2} msecs";
- logger.info(MessageFormat.format(msg, repositoryName,
- result.commitCount, duration));
+ msg = "Built {0} Lucene index from {1} commits and {2} files across {3} branches in {4} secs";
+ logger.info(MessageFormat.format(msg, name,
+ result.commitCount, result.blobCount, result.branchCount, duration));
}
} else {
- String msg = "Could not build {0} Lucene index!";
- logger.error(MessageFormat.format(msg, repositoryName));
+ msg = "Could not build {0} Lucene index!";
+ logger.error(MessageFormat.format(msg, name));
}
} else {
// update the index with latest commits
long start = System.currentTimeMillis();
- IndexResult result = LuceneUtils.updateIndex(repository);
- long duration = System.currentTimeMillis() - start;
+ IndexResult result = LuceneUtils.updateIndex(name, repository);
+ float duration = (System.currentTimeMillis() - start)/1000f;
if (result.success) {
if (result.commitCount > 0) {
- String msg = "Updated {0} Lucene index with {1} commits in {2} msecs";
- logger.info(MessageFormat.format(msg, repositoryName,
- result.commitCount, duration));
+ String msg = "Updated {0} Lucene index with {1} commits and {2} files across {3} branches in {4} secs";
+ logger.info(MessageFormat.format(msg, name,
+ result.commitCount, result.blobCount, result.branchCount, duration));
}
} else {
String msg = "Could not update {0} Lucene index!";
- logger.error(MessageFormat.format(msg, repositoryName));
+ logger.error(MessageFormat.format(msg, name));
}
}
} else {
logger.info(MessageFormat.format("Skipped Lucene index of empty repository {0}",
- repositoryName));
+ name));
}
} catch (Throwable t) {
- logger.error(MessageFormat.format("Lucene indexing failure for {0}", repositoryName), t);
+ logger.error(MessageFormat.format("Lucene indexing failure for {0}", name), t);
}
}