Scan index directory to determine Lucene versions

Mark index versions as "ready" when they are fully indexed and the
server is not running (i.e. from Reindex). By default, search from the
most recent ready index version, and write to both the most recent
ready version and (if different) the most recent known version.

At server startup, mark all versions except those we are about to
start writing to as not ready.

Change-Id: Icf42a3eb27b0445899300d60941cd701a8072d41
This commit is contained in:
Dave Borowitz
2013-06-26 08:17:28 -06:00
parent f7cbbe8017
commit d103b2b61c
14 changed files with 372 additions and 202 deletions

View File

@@ -31,8 +31,8 @@ import java.util.Map;
class IndexVersionCheck implements LifecycleListener {
public static final Map<String, Integer> SCHEMA_VERSIONS = ImmutableMap.of(
SolrChangeIndex.CHANGES_OPEN, ChangeSchemas.getLatestRelease().getVersion(),
SolrChangeIndex.CHANGES_CLOSED, ChangeSchemas.getLatestRelease().getVersion());
SolrChangeIndex.CHANGES_OPEN, ChangeSchemas.getLatest().getVersion(),
SolrChangeIndex.CHANGES_CLOSED, ChangeSchemas.getLatest().getVersion());
public static File solrIndexConfig(SitePaths sitePaths) {
return new File(sitePaths.index_dir, "gerrit_index.config");

View File

@@ -52,7 +52,6 @@ import org.apache.solr.client.solrj.impl.CloudSolrServer;
import org.apache.solr.common.SolrDocument;
import org.apache.solr.common.SolrDocumentList;
import org.apache.solr.common.SolrInputDocument;
import org.eclipse.jgit.errors.ConfigInvalidException;
import org.eclipse.jgit.lib.Config;
import org.eclipse.jgit.storage.file.FileBasedConfig;
import org.eclipse.jgit.util.FS;
@@ -120,6 +119,11 @@ class SolrChangeIndex implements ChangeIndex, LifecycleListener {
return schema;
}
@Override
public void close() {
stop();
}
@Override
public ListenableFuture<Void> insert(ChangeData cd) throws IOException {
String id = cd.getId().toString();
@@ -321,8 +325,7 @@ class SolrChangeIndex implements ChangeIndex, LifecycleListener {
}
@Override
public void finishIndex() throws IOException,
ConfigInvalidException {
public void markReady() throws IOException {
// TODO Move the schema version information to a special meta-document
FileBasedConfig cfg = new FileBasedConfig(
solrIndexConfig(sitePaths),

View File

@@ -61,6 +61,6 @@ public class SolrIndexModule extends LifecycleModule {
IndexCollection indexes,
FillArgs fillArgs) throws IOException {
return new SolrChangeIndex(cfg, fillArgs, sitePaths, indexes,
ChangeSchemas.getLatestRelease(), base);
ChangeSchemas.getLatest(), base);
}
}