From: James Moger Date: Sun, 25 Mar 2012 17:15:06 +0000 (-0400) Subject: Added web.allowLuceneIndexing to enable/disable Lucene integration X-Git-Tag: v0.9.0~17 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=7db0929ad58804ebc235730b9cfc83dc38835eb9;p=gitblit.git Added web.allowLuceneIndexing to enable/disable Lucene integration --- diff --git a/distrib/gitblit.properties b/distrib/gitblit.properties index ad822809..2846496e 100644 --- a/distrib/gitblit.properties +++ b/distrib/gitblit.properties @@ -184,6 +184,15 @@ web.allowGravatar = true # SINCE 0.5.0 web.allowZipDownloads = true +# Allow optional Lucene integration. Lucene indexing is an opt-in feature. +# A repository may specify branches to index with Lucene instead of using Git +# commit traversal. There are scenarios where you may want to completely disable +# Lucene indexing despite a repository specifying indexed branches. One such +# scenario is on a resource-constrained federated Gitblit mirror. +# +# SINCE 0.9.0 +web.allowLuceneIndexing = true + # Use Clippy (Flash solution) to provide a copy-to-clipboard button. # If false, a button with a more primitive JavaScript-based prompt box will # offer a 3-step (click, ctrl+c, enter) copy-to-clipboard alternative. diff --git a/docs/01_setup.mkd b/docs/01_setup.mkd index 09ddabbd..c5d78def 100644 --- a/docs/01_setup.mkd +++ b/docs/01_setup.mkd @@ -385,11 +385,11 @@ Repositories may optionally be indexed using the Lucene search engine. The Luce ### How do I use it? -Lucene indexing is an opt-in feature which means that no repositories are automatically indexed. +First you must ensure that *web.allowLuceneIndexing* is set *true* in `gitblit.properties` or `web.xml`. Then you must understand that Lucene indexing is an opt-in feature which means that no repositories are automatically indexed. Like anything else, this design has pros and cons. #### Pros -1. no wasted cycles on repositories you will never search +1. no wasted cycles indexing repositories you will never search 2. you specify exactly what branches are indexed; experimental/dead/personal branches can be ignored #### Cons @@ -408,6 +408,10 @@ You may specify which branches should be indexed per-repository in the *Edit Rep **NOTE:** After specifying branches, only the content from those branches can be searched via Gitblit. Gitblit will automatically redirect any queries entered on a repository's search box to the Lucene search page. Repositories that do not specify any indexed branches will use the traditional commit-traversal search. +#### Adequate Heap + +The initial indexing of an existing repository can potentially exhaust the memory allocated to your Java instance and may throw OutOfMemory exceptions. Be sure to provide your Gitblit server adequate heap space to index your repositories. The heap is set using the *-Xmx* JVM parameter in your Gitblit launch command (e.g. -Xmx1024M). + ## Client Setup and Configuration ### Https with Self-Signed Certificates You must tell Git/JGit not to verify the self-signed certificate in order to perform any remote Git operations. diff --git a/docs/04_releases.mkd b/docs/04_releases.mkd index 6e482103..5fec6e99 100644 --- a/docs/04_releases.mkd +++ b/docs/04_releases.mkd @@ -17,10 +17,12 @@ #### additions - Added optional Lucene branch indexing (issue 16) + **New:** *web.allowLuceneIndexing = true* **New:** *web.luceneIgnoreExtensions = 7z arc arj bin bmp dll doc docx exe gif gz jar jpg lib lzh odg odf odt pdf ppt png so swf xcf xls xlsx zip* Repository branches may be optionally indexed by Lucene for improved searching. To use this feature you must specify which branches to index within the *Edit Repository* page; _no repositories are automatically indexed_. Gitblit will build or incrementally update enrolled repositories on a 2 minute cycle. (i.e you will have to wait 2-3 minutes after respecifying indexed branches or pushing new commits before Gitblit will build/update the repository's Lucene index.) If a repository has Lucene-indexed branches the *search* form on the repository pages will redirect to the root-level Lucene search page and only the content of those branches can be searched. -If the repository does not specify any indexed branches then repository commit-traversal search is used. +If the repository does not specify any indexed branches then repository commit-traversal search is used. +**Note:** Initial indexing of an existing repository can be memory-exhaustive. Be sure to provide your Gitblit server adequate heap space to index your repositories (e.g. -Xmx1024M). - Allow specifying timezone to use for Gitblit which is independent of both the JVM and the system timezone (issue 54) **New:** *web.timezone =* - Added a built-in AJP connector for integrating Gitblit GO into an Apache mod_proxy setup (issue 59) diff --git a/resources/gitblit.css b/resources/gitblit.css index 3c265a48..8934cb2d 100644 --- a/resources/gitblit.css +++ b/resources/gitblit.css @@ -310,7 +310,8 @@ div.searchResult pre { } div.searchResult .text { - border-left: 5px solid #EEEEEE; + border-left: 2px solid #ccc; + border-radius: 0px; padding: 0 0 0 15px; } diff --git a/src/com/gitblit/LuceneExecutor.java b/src/com/gitblit/LuceneExecutor.java index 70d666f1..cd7074b6 100644 --- a/src/com/gitblit/LuceneExecutor.java +++ b/src/com/gitblit/LuceneExecutor.java @@ -157,6 +157,10 @@ public class LuceneExecutor implements Runnable { */ @Override public void run() { + if (!storedSettings.getBoolean(Keys.web.allowLuceneIndexing, true)) { + // Lucene indexing is disabled + return; + } // reload the excluded extensions String exts = storedSettings.getString(Keys.web.luceneIgnoreExtensions, luceneIgnoreExtensions); excludedExtensions = new TreeSet(StringUtils.getStringsFromValue(exts)); diff --git a/src/com/gitblit/wicket/GitBlitWebApp.properties b/src/com/gitblit/wicket/GitBlitWebApp.properties index 3b78b435..4300c04b 100644 --- a/src/com/gitblit/wicket/GitBlitWebApp.properties +++ b/src/com/gitblit/wicket/GitBlitWebApp.properties @@ -222,4 +222,5 @@ gb.indexedBranches = indexed branches gb.indexedBranchesDescription = select the branches to include in your Lucene index gb.noIndexedRepositoriesWarning = none of your repositories are configured for Lucene indexing gb.undefinedQueryWarning = query is undefined! -gb.noSelectedRepositoriesWarning = please select one or more repositories! \ No newline at end of file +gb.noSelectedRepositoriesWarning = please select one or more repositories! +gb.luceneDisabled = Lucene indexing is disabled \ No newline at end of file diff --git a/src/com/gitblit/wicket/pages/EditRepositoryPage.java b/src/com/gitblit/wicket/pages/EditRepositoryPage.java index 5b2124ac..c2fc9f5f 100644 --- a/src/com/gitblit/wicket/pages/EditRepositoryPage.java +++ b/src/com/gitblit/wicket/pages/EditRepositoryPage.java @@ -117,12 +117,11 @@ public class EditRepositoryPage extends RootSubPage { // indexed local branches palette List allLocalBranches = repositoryModel.getLocalBranches(); - + boolean luceneEnabled = GitBlit.getBoolean(Keys.web.allowLuceneIndexing, true); final Palette indexedBranchesPalette = new Palette("indexedBranches", new ListModel( indexedBranches), new CollectionModel(allLocalBranches), new StringChoiceRenderer(), 8, false); - indexedBranchesPalette.setEnabled(allLocalBranches.size() > 0); - + indexedBranchesPalette.setEnabled(luceneEnabled && (allLocalBranches.size() > 0)); // federation sets palette List sets = GitBlit.getStrings(Keys.federation.sets); diff --git a/src/com/gitblit/wicket/pages/LuceneSearchPage.java b/src/com/gitblit/wicket/pages/LuceneSearchPage.java index 997ef213..ea94fa43 100644 --- a/src/com/gitblit/wicket/pages/LuceneSearchPage.java +++ b/src/com/gitblit/wicket/pages/LuceneSearchPage.java @@ -105,9 +105,13 @@ public class LuceneSearchPage extends RootPage { availableRepositories.add(model.name); } } - - if (availableRepositories.size() == 0) { - info(getString("gb.noIndexedRepositoriesWarning")); + boolean luceneEnabled = GitBlit.getBoolean(Keys.web.allowLuceneIndexing, true); + if (luceneEnabled) { + if (availableRepositories.size() == 0) { + info(getString("gb.noIndexedRepositoriesWarning")); + } + } else { + error(getString("gb.luceneDisabled")); } // enforce user-accessible repository selections @@ -146,9 +150,9 @@ public class LuceneSearchPage extends RootPage { ListMultipleChoice selections = new ListMultipleChoice("repositories", repositoriesModel, availableRepositories, new StringChoiceRenderer()); selections.setMaxRows(8); - form.add(selections); - form.add(new TextField("query", queryModel)); - add(form); + form.add(selections.setEnabled(luceneEnabled)); + form.add(new TextField("query", queryModel).setEnabled(luceneEnabled)); + add(form.setEnabled(luceneEnabled)); // execute search final List results = new ArrayList(); diff --git a/src/com/gitblit/wicket/pages/RepositoryPage.java b/src/com/gitblit/wicket/pages/RepositoryPage.java index 132b1f7f..d90d6273 100644 --- a/src/com/gitblit/wicket/pages/RepositoryPage.java +++ b/src/com/gitblit/wicket/pages/RepositoryPage.java @@ -360,7 +360,8 @@ public abstract class RepositoryPage extends BasePage { } Class searchPageClass = GitSearchPage.class; RepositoryModel model = GitBlit.self().getRepositoryModel(repositoryName); - if (!ArrayUtils.isEmpty(model.indexedBranches)) { + if (GitBlit.getBoolean(Keys.web.allowLuceneIndexing, true) + && !ArrayUtils.isEmpty(model.indexedBranches)) { // this repository is Lucene-indexed searchPageClass = LuceneSearchPage.class; } diff --git a/src/com/gitblit/wicket/pages/RootPage.java b/src/com/gitblit/wicket/pages/RootPage.java index 57678dfb..d7b3ab73 100644 --- a/src/com/gitblit/wicket/pages/RootPage.java +++ b/src/com/gitblit/wicket/pages/RootPage.java @@ -101,7 +101,9 @@ public abstract class RootPage extends BasePage { pages.add(new PageRegistration("gb.repositories", RepositoriesPage.class, getRootPageParameters())); pages.add(new PageRegistration("gb.activity", ActivityPage.class, getRootPageParameters())); - pages.add(new PageRegistration("gb.search", LuceneSearchPage.class)); + if (GitBlit.getBoolean(Keys.web.allowLuceneIndexing, true)) { + pages.add(new PageRegistration("gb.search", LuceneSearchPage.class)); + } if (showAdmin) { pages.add(new PageRegistration("gb.users", UsersPage.class)); }