Merge branch 'stable-2.13'
* stable-2.13: Drain executor of index change requests before closing index Change-Id: I2d676adf60d2eab0f9f7602b124574050af0ee3d
This commit is contained in:
@@ -46,6 +46,10 @@ public class ReadOnlyChangeIndex implements ChangeIndex {
|
|||||||
index.close();
|
index.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void stop() {
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void replace(ChangeData obj) throws IOException {
|
public void replace(ChangeData obj) throws IOException {
|
||||||
// do nothing
|
// do nothing
|
||||||
|
|||||||
@@ -117,6 +117,10 @@ class ElasticAccountIndex extends AbstractElasticIndex<Account.Id, AccountState>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void stop() {
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DataSource<AccountState> getSource(Predicate<AccountState> p,
|
public DataSource<AccountState> getSource(Predicate<AccountState> p,
|
||||||
QueryOptions opts) throws QueryParseException {
|
QueryOptions opts) throws QueryParseException {
|
||||||
|
|||||||
@@ -158,6 +158,10 @@ class ElasticChangeIndex extends AbstractElasticIndex<Change.Id, ChangeData>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void stop() {
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ChangeDataSource getSource(Predicate<ChangeData> p, QueryOptions opts)
|
public ChangeDataSource getSource(Predicate<ChangeData> p, QueryOptions opts)
|
||||||
throws QueryParseException {
|
throws QueryParseException {
|
||||||
|
|||||||
@@ -97,4 +97,8 @@ public class ChangeSubIndex extends AbstractLuceneIndex<Change.Id, ChangeData>
|
|||||||
}
|
}
|
||||||
super.add(doc, values);
|
super.add(doc, values);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void stop() {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -205,4 +205,8 @@ public class LuceneAccountIndex
|
|||||||
// to reindex when those change.
|
// to reindex when those change.
|
||||||
return accountCache.get(id);
|
return accountCache.get(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void stop() {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,12 +28,11 @@ import com.google.common.collect.ArrayListMultimap;
|
|||||||
import com.google.common.collect.Collections2;
|
import com.google.common.collect.Collections2;
|
||||||
import com.google.common.collect.FluentIterable;
|
import com.google.common.collect.FluentIterable;
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
import com.google.common.collect.Multimap;
|
import com.google.common.collect.Multimap;
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
import com.google.common.util.concurrent.Futures;
|
import com.google.common.util.concurrent.Futures;
|
||||||
import com.google.common.util.concurrent.ListenableFuture;
|
|
||||||
import com.google.common.util.concurrent.ListeningExecutorService;
|
import com.google.common.util.concurrent.ListeningExecutorService;
|
||||||
|
import com.google.common.util.concurrent.MoreExecutors;
|
||||||
import com.google.gerrit.reviewdb.client.Account;
|
import com.google.gerrit.reviewdb.client.Account;
|
||||||
import com.google.gerrit.reviewdb.client.Change;
|
import com.google.gerrit.reviewdb.client.Change;
|
||||||
import com.google.gerrit.reviewdb.client.PatchSet;
|
import com.google.gerrit.reviewdb.client.PatchSet;
|
||||||
@@ -96,6 +95,7 @@ import java.util.Set;
|
|||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
import java.util.concurrent.Future;
|
import java.util.concurrent.Future;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Secondary index implementation using Apache Lucene.
|
* Secondary index implementation using Apache Lucene.
|
||||||
@@ -189,22 +189,19 @@ public class LuceneChangeIndex implements ChangeIndex {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void stop() {
|
||||||
|
MoreExecutors.shutdownAndAwaitTermination(
|
||||||
|
executor, Long.MAX_VALUE, TimeUnit.SECONDS);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void close() {
|
public void close() {
|
||||||
List<ListenableFuture<?>> closeFutures = Lists.newArrayListWithCapacity(2);
|
try {
|
||||||
closeFutures.add(executor.submit(new Runnable() {
|
openIndex.close();
|
||||||
@Override
|
} finally {
|
||||||
public void run() {
|
closedIndex.close();
|
||||||
openIndex.close();
|
}
|
||||||
}
|
|
||||||
}));
|
|
||||||
closeFutures.add(executor.submit(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
closedIndex.close();
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
Futures.getUnchecked(Futures.allAsList(closeFutures));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -37,6 +37,9 @@ public interface Index<K, V> {
|
|||||||
/** @return the schema version used by this index. */
|
/** @return the schema version used by this index. */
|
||||||
Schema<V> getSchema();
|
Schema<V> getSchema();
|
||||||
|
|
||||||
|
/** Stop and await termination of all executor threads */
|
||||||
|
void stop();
|
||||||
|
|
||||||
/** Close this index. */
|
/** Close this index. */
|
||||||
void close();
|
void close();
|
||||||
|
|
||||||
|
|||||||
@@ -98,6 +98,7 @@ public abstract class IndexCollection<K, V, I extends Index<K, V>>
|
|||||||
}
|
}
|
||||||
for (I write : writeIndexes) {
|
for (I write : writeIndexes) {
|
||||||
if (write != read) {
|
if (write != read) {
|
||||||
|
write.stop();
|
||||||
write.close();
|
write.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,4 +57,8 @@ public class DummyChangeIndex implements ChangeIndex {
|
|||||||
public int getMaxLimit() {
|
public int getMaxLimit() {
|
||||||
return Integer.MAX_VALUE;
|
return Integer.MAX_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void stop() {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -108,4 +108,8 @@ public class FakeChangeIndex implements ChangeIndex {
|
|||||||
public void markReady(boolean ready) {
|
public void markReady(boolean ready) {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void stop() {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user