diff --git a/gerrit-lucene/src/main/java/com/google/gerrit/lucene/AbstractLuceneIndex.java b/gerrit-lucene/src/main/java/com/google/gerrit/lucene/AbstractLuceneIndex.java index 5acdc25358..28ad605ab2 100644 --- a/gerrit-lucene/src/main/java/com/google/gerrit/lucene/AbstractLuceneIndex.java +++ b/gerrit-lucene/src/main/java/com/google/gerrit/lucene/AbstractLuceneIndex.java @@ -16,6 +16,7 @@ package com.google.gerrit.lucene; import static java.util.concurrent.TimeUnit.MILLISECONDS; +import com.google.common.base.Joiner; import com.google.common.collect.Sets; import com.google.common.util.concurrent.AbstractFuture; import com.google.common.util.concurrent.ListenableFuture; @@ -94,12 +95,14 @@ public abstract class AbstractLuceneIndex implements Index { Schema schema, SitePaths sitePaths, Directory dir, - final String name, + String name, + String subIndex, GerritIndexWriterConfig writerConfig, SearcherFactory searcherFactory) throws IOException { this.schema = schema; this.sitePaths = sitePaths; this.dir = dir; + final String index = Joiner.on('_').skipNulls().join(name, subIndex); IndexWriter delegateWriter; long commitPeriod = writerConfig.getCommitWithinMs(); @@ -114,7 +117,7 @@ public abstract class AbstractLuceneIndex implements Index { delegateWriter = autoCommitWriter; new ScheduledThreadPoolExecutor(1, new ThreadFactoryBuilder() - .setNameFormat("Commit-%d " + name) + .setNameFormat("Commit-%d " + index) .setDaemon(true) .build()) .scheduleAtFixedRate(new Runnable() { @@ -126,13 +129,13 @@ public abstract class AbstractLuceneIndex implements Index { autoCommitWriter.commit(); } } catch (IOException e) { - log.error("Error committing " + name + " Lucene index", e); + log.error("Error committing " + index + " Lucene index", e); } catch (OutOfMemoryError e) { - log.error("Error committing " + name + " Lucene index", e); + log.error("Error committing " + index + " Lucene index", e); try { autoCommitWriter.close(); } catch (IOException e2) { - log.error("SEVERE: Error closing " + name + log.error("SEVERE: Error closing " + index + " Lucene index after OOM; index may be corrupted.", e); } } diff --git a/gerrit-lucene/src/main/java/com/google/gerrit/lucene/ChangeSubIndex.java b/gerrit-lucene/src/main/java/com/google/gerrit/lucene/ChangeSubIndex.java index ad5349383a..6f0df0f7bb 100644 --- a/gerrit-lucene/src/main/java/com/google/gerrit/lucene/ChangeSubIndex.java +++ b/gerrit-lucene/src/main/java/com/google/gerrit/lucene/ChangeSubIndex.java @@ -17,6 +17,7 @@ package com.google.gerrit.lucene; import static com.google.common.collect.Iterables.getOnlyElement; import static com.google.gerrit.lucene.LuceneChangeIndex.ID_SORT_FIELD; import static com.google.gerrit.lucene.LuceneChangeIndex.UPDATED_SORT_FIELD; +import static com.google.gerrit.server.index.change.ChangeSchemaDefinitions.NAME; import com.google.gerrit.reviewdb.client.Change; import com.google.gerrit.server.config.SitePaths; @@ -57,10 +58,11 @@ public class ChangeSubIndex extends AbstractLuceneIndex Schema schema, SitePaths sitePaths, Directory dir, - String name, + String subIndex, GerritIndexWriterConfig writerConfig, SearcherFactory searcherFactory) throws IOException { - super(schema, sitePaths, dir, name, writerConfig, searcherFactory); + super(schema, sitePaths, dir, NAME, subIndex, writerConfig, + searcherFactory); } @Override diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/index/change/ChangeSchemaDefinitions.java b/gerrit-server/src/main/java/com/google/gerrit/server/index/change/ChangeSchemaDefinitions.java index 8fb900069a..1e59cdba80 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/index/change/ChangeSchemaDefinitions.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/index/change/ChangeSchemaDefinitions.java @@ -70,10 +70,11 @@ public class ChangeSchemaDefinitions extends SchemaDefinitions { static final Schema V29 = schema(V28, ChangeField.HASHTAG_CASE_AWARE); + public static final String NAME = "changes"; public static final ChangeSchemaDefinitions INSTANCE = new ChangeSchemaDefinitions(); private ChangeSchemaDefinitions() { - super("changes", ChangeData.class); + super(NAME, ChangeData.class); } }