Replace Reindex --dry-run with --output
The line of what was a "dry run" was a bit arbitrary, doing all the Gerrit processing (including potential side effects like writing to persistent caches) but not all the index-specific processing, which could still be useful for evaluation or debugging purposes. Instead, provide an output base so administrators can test the indexing behavior without operating on production index data. For Lucene, this flag is interpreted as a path to the index directory; for Solr, it is a prefix added to the collection names. Change-Id: Ic4808d1e3467a780a818ac7d1c89de13610da630
This commit is contained in:
		| @@ -43,7 +43,6 @@ import com.google.gerrit.server.query.change.ChangeData; | ||||
| import com.google.gerrit.server.query.change.ChangeDataSource; | ||||
| import com.google.gwtorm.server.OrmException; | ||||
| import com.google.gwtorm.server.ResultSet; | ||||
| import com.google.inject.Singleton; | ||||
|  | ||||
| import org.apache.lucene.search.Query; | ||||
| import org.apache.solr.client.solrj.SolrQuery; | ||||
| @@ -67,7 +66,6 @@ import java.util.Map; | ||||
| import java.util.Set; | ||||
|  | ||||
| /** Secondary index implementation using a remote Solr instance. */ | ||||
| @Singleton | ||||
| class SolrChangeIndex implements ChangeIndex, LifecycleListener { | ||||
|   public static final String CHANGES_OPEN = "changes_open"; | ||||
|   public static final String CHANGES_CLOSED = "changes_closed"; | ||||
| @@ -85,7 +83,8 @@ class SolrChangeIndex implements ChangeIndex, LifecycleListener { | ||||
|       FillArgs fillArgs, | ||||
|       SitePaths sitePaths, | ||||
|       IndexCollection indexes, | ||||
|       Schema<ChangeData> schema) throws IOException { | ||||
|       Schema<ChangeData> schema, | ||||
|       String base) throws IOException { | ||||
|     this.fillArgs = fillArgs; | ||||
|     this.sitePaths = sitePaths; | ||||
|     this.indexes = indexes; | ||||
| @@ -96,11 +95,12 @@ class SolrChangeIndex implements ChangeIndex, LifecycleListener { | ||||
|       throw new IllegalStateException("index.solr.url must be supplied"); | ||||
|     } | ||||
|  | ||||
|     base = Strings.nullToEmpty(base); | ||||
|     openIndex = new CloudSolrServer(url); | ||||
|     openIndex.setDefaultCollection(CHANGES_OPEN); | ||||
|     openIndex.setDefaultCollection(base + CHANGES_OPEN); | ||||
|  | ||||
|     closedIndex = new CloudSolrServer(url); | ||||
|     closedIndex.setDefaultCollection(CHANGES_CLOSED); | ||||
|     closedIndex.setDefaultCollection(base + CHANGES_CLOSED); | ||||
|   } | ||||
|  | ||||
|   @Override | ||||
|   | ||||
| @@ -32,14 +32,16 @@ import java.io.IOException; | ||||
| public class SolrIndexModule extends LifecycleModule { | ||||
|   private final boolean checkVersion; | ||||
|   private final int threads; | ||||
|   private final String base; | ||||
|  | ||||
|   public SolrIndexModule() { | ||||
|     this(true, 0); | ||||
|     this(true, 0, null); | ||||
|   } | ||||
|  | ||||
|   public SolrIndexModule(boolean checkVersion, int threads) { | ||||
|   public SolrIndexModule(boolean checkVersion, int threads, String base) { | ||||
|     this.checkVersion = checkVersion; | ||||
|     this.threads = threads; | ||||
|     this.base = base; | ||||
|   } | ||||
|  | ||||
|   @Override | ||||
| @@ -59,6 +61,6 @@ public class SolrIndexModule extends LifecycleModule { | ||||
|       IndexCollection indexes, | ||||
|       FillArgs fillArgs) throws IOException { | ||||
|     return new SolrChangeIndex(cfg, fillArgs, sitePaths, indexes, | ||||
|         ChangeSchemas.getLatestRelease()); | ||||
|         ChangeSchemas.getLatestRelease(), base); | ||||
|   } | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Dave Borowitz
					Dave Borowitz