Merge changes Iac79af54,Ief41eccc,Iae52ade9,I0bd9eabb,I2ef5b9e1

* changes:
  Solr index requires SolrCloud rather than plain Solr
  Handle exceptions during reindexing
  InitIndex: Allow user to configure the Solr index URL
  Solr index URL should be configured under the main "index" section
  Improve information message about rebuilding the index
This commit is contained in:
Shawn Pearce 2014-02-13 17:02:23 +00:00 committed by Gerrit Code Review
commit 4d42596868
4 changed files with 27 additions and 10 deletions

View File

@ -1889,7 +1889,8 @@ A link:http://lucene.apache.org/[Lucene] index is used.
+
* `SOLR`
+
A link:http://lucene.apache.org/solr/[Solr] index is used.
A link:https://cwiki.apache.org/confluence/display/solr/SolrCloud[
SolrCloud] index is used.
+
By default, `LUCENE`.
@ -1901,6 +1902,12 @@ Gerrit server.
Open and closed changes are indexed in separate indexes named
'changes_open' and 'changes_closed' respectively.
[[index.url]]index.url::
+
Only used when the type is `SOLR`.
+
URL of the index server.
[[index.name.ramBufferSize]]index.name.ramBufferSize::
+
Only used when the type is `LUCENE`.

View File

@ -143,11 +143,15 @@ public class Reindex extends SiteProgram {
sysManager.start();
index = sysInjector.getInstance(IndexCollection.class).getSearchIndex();
index.markReady(false);
index.deleteAll();
int result = indexAll();
index.markReady(true);
int result = 0;
try {
index.markReady(false);
index.deleteAll();
result = indexAll();
index.markReady(true);
} catch (Exception e) {
throw die(e.getMessage());
}
sysManager.stop();
dbManager.stop();
return result;

View File

@ -47,12 +47,18 @@ class InitIndex implements InitStep {
ui.header("Index");
IndexType type = index.select("Type", "type", IndexType.LUCENE);
if (type == IndexType.SOLR) {
index.string("Solr Index URL", "url", "localhost:9983");
}
if (site.isNew && type == IndexType.LUCENE) {
LuceneChangeIndex.setReady(
site, ChangeSchemas.getLatest().getVersion(), true);
} else {
ui.message("The index must be built before starting Gerrit:\n"
+ " java -jar gerrit.war reindex -d site_path\n");
final String message = String.format(
"\nThe index must be %sbuilt before starting Gerrit:\n"
+ " java -jar gerrit.war reindex -d site_path\n",
site.isNew ? "" : "re");
ui.message(message);
initFlags.autoStart = false;
}
}

View File

@ -103,9 +103,9 @@ class SolrChangeIndex implements ChangeIndex, LifecycleListener {
this.indexes = indexes;
this.schema = schema;
String url = cfg.getString("index", "solr", "url");
String url = cfg.getString("index", null, "url");
if (Strings.isNullOrEmpty(url)) {
throw new IllegalStateException("index.solr.url must be supplied");
throw new IllegalStateException("index.url must be supplied");
}
// Version is only used to determine the list of stop words used by the