Make @IndexExecutor a non-scheduled executor
The scheduling functionality is not required and prevents us from substituting in a sameThreadExecutor for tests. Change-Id: I9fb7c93320199e92a193131057f376b03af03d26
This commit is contained in:
@@ -25,7 +25,6 @@ import com.google.common.collect.Sets;
|
||||
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.ListeningScheduledExecutorService;
|
||||
import com.google.gerrit.common.Nullable;
|
||||
import com.google.gerrit.reviewdb.client.Change;
|
||||
import com.google.gerrit.reviewdb.client.PatchSetApproval;
|
||||
@@ -156,7 +155,7 @@ public class LuceneChangeIndex implements ChangeIndex {
|
||||
LuceneChangeIndex(
|
||||
@GerritServerConfig Config cfg,
|
||||
SitePaths sitePaths,
|
||||
@IndexExecutor ListeningScheduledExecutorService executor,
|
||||
@IndexExecutor ListeningExecutorService executor,
|
||||
FillArgs fillArgs,
|
||||
@Assisted Schema<ChangeData> schema,
|
||||
@Assisted @Nullable String base) throws IOException {
|
||||
|
@@ -25,7 +25,7 @@ import com.google.common.collect.Sets;
|
||||
import com.google.common.util.concurrent.AsyncFunction;
|
||||
import com.google.common.util.concurrent.Futures;
|
||||
import com.google.common.util.concurrent.ListenableFuture;
|
||||
import com.google.common.util.concurrent.ListeningScheduledExecutorService;
|
||||
import com.google.common.util.concurrent.ListeningExecutorService;
|
||||
import com.google.common.util.concurrent.MoreExecutors;
|
||||
import com.google.gerrit.reviewdb.client.Change;
|
||||
import com.google.gerrit.reviewdb.client.Project;
|
||||
@@ -105,13 +105,13 @@ public class ChangeBatchIndexer {
|
||||
|
||||
private final Provider<ReviewDb> db;
|
||||
private final GitRepositoryManager repoManager;
|
||||
private final ListeningScheduledExecutorService executor;
|
||||
private final ListeningExecutorService executor;
|
||||
private final ChangeIndexer.Factory indexerFactory;
|
||||
|
||||
@Inject
|
||||
ChangeBatchIndexer(Provider<ReviewDb> db,
|
||||
GitRepositoryManager repoManager,
|
||||
@IndexExecutor ListeningScheduledExecutorService executor,
|
||||
@IndexExecutor ListeningExecutorService executor,
|
||||
ChangeIndexer.Factory indexerFactory) {
|
||||
this.db = db;
|
||||
this.repoManager = repoManager;
|
||||
|
@@ -18,7 +18,7 @@ import com.google.common.base.Function;
|
||||
import com.google.common.util.concurrent.Callables;
|
||||
import com.google.common.util.concurrent.CheckedFuture;
|
||||
import com.google.common.util.concurrent.Futures;
|
||||
import com.google.common.util.concurrent.ListeningScheduledExecutorService;
|
||||
import com.google.common.util.concurrent.ListeningExecutorService;
|
||||
import com.google.gerrit.reviewdb.client.Change;
|
||||
import com.google.gerrit.server.query.change.ChangeData;
|
||||
|
||||
@@ -71,9 +71,9 @@ public abstract class ChangeIndexer {
|
||||
}
|
||||
};
|
||||
|
||||
private final ListeningScheduledExecutorService executor;
|
||||
private final ListeningExecutorService executor;
|
||||
|
||||
protected ChangeIndexer(ListeningScheduledExecutorService executor) {
|
||||
protected ChangeIndexer(ListeningExecutorService executor) {
|
||||
this.executor = executor;
|
||||
}
|
||||
|
||||
|
@@ -15,7 +15,7 @@
|
||||
package com.google.gerrit.server.index;
|
||||
|
||||
import com.google.common.util.concurrent.Atomics;
|
||||
import com.google.common.util.concurrent.ListeningScheduledExecutorService;
|
||||
import com.google.common.util.concurrent.ListeningExecutorService;
|
||||
import com.google.gerrit.reviewdb.server.ReviewDb;
|
||||
import com.google.gerrit.server.CurrentUser;
|
||||
import com.google.gerrit.server.query.change.ChangeData;
|
||||
@@ -53,7 +53,7 @@ public class ChangeIndexerImpl extends ChangeIndexer {
|
||||
private final ThreadLocalRequestContext context;
|
||||
|
||||
@AssistedInject
|
||||
ChangeIndexerImpl(@IndexExecutor ListeningScheduledExecutorService executor,
|
||||
ChangeIndexerImpl(@IndexExecutor ListeningExecutorService executor,
|
||||
SchemaFactory<ReviewDb> schemaFactory,
|
||||
ThreadLocalRequestContext context,
|
||||
@Assisted ChangeIndex index) {
|
||||
@@ -65,7 +65,7 @@ public class ChangeIndexerImpl extends ChangeIndexer {
|
||||
}
|
||||
|
||||
@AssistedInject
|
||||
ChangeIndexerImpl(@IndexExecutor ListeningScheduledExecutorService executor,
|
||||
ChangeIndexerImpl(@IndexExecutor ListeningExecutorService executor,
|
||||
SchemaFactory<ReviewDb> schemaFactory,
|
||||
ThreadLocalRequestContext context,
|
||||
@Assisted IndexCollection indexes) {
|
||||
|
@@ -16,14 +16,14 @@ package com.google.gerrit.server.index;
|
||||
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
|
||||
import com.google.common.util.concurrent.ListeningScheduledExecutorService;
|
||||
import com.google.common.util.concurrent.ListeningExecutorService;
|
||||
import com.google.inject.BindingAnnotation;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
|
||||
/**
|
||||
* Marker on {@link ListeningScheduledExecutorService} used by secondary
|
||||
* indexing threads.
|
||||
* Marker on {@link ListeningExecutorService} used by secondary indexing
|
||||
* threads.
|
||||
*/
|
||||
@Retention(RUNTIME)
|
||||
@BindingAnnotation
|
||||
|
@@ -14,7 +14,7 @@
|
||||
|
||||
package com.google.gerrit.server.index;
|
||||
|
||||
import com.google.common.util.concurrent.ListeningScheduledExecutorService;
|
||||
import com.google.common.util.concurrent.ListeningExecutorService;
|
||||
import com.google.common.util.concurrent.MoreExecutors;
|
||||
import com.google.gerrit.lifecycle.LifecycleModule;
|
||||
import com.google.gerrit.server.config.GerritServerConfig;
|
||||
@@ -49,14 +49,14 @@ public class IndexModule extends LifecycleModule {
|
||||
}
|
||||
|
||||
private final int threads;
|
||||
private final ListeningScheduledExecutorService indexExecutor;
|
||||
private final ListeningExecutorService indexExecutor;
|
||||
|
||||
public IndexModule(int threads) {
|
||||
this.threads = threads;
|
||||
this.indexExecutor = null;
|
||||
}
|
||||
|
||||
public IndexModule(ListeningScheduledExecutorService indexExecutor) {
|
||||
public IndexModule(ListeningExecutorService indexExecutor) {
|
||||
this.threads = -1;
|
||||
this.indexExecutor = indexExecutor;
|
||||
}
|
||||
@@ -72,7 +72,7 @@ public class IndexModule extends LifecycleModule {
|
||||
.build(ChangeIndexer.Factory.class));
|
||||
|
||||
if (indexExecutor != null) {
|
||||
bind(ListeningScheduledExecutorService.class)
|
||||
bind(ListeningExecutorService.class)
|
||||
.annotatedWith(IndexExecutor.class)
|
||||
.toInstance(indexExecutor);
|
||||
} else {
|
||||
@@ -101,7 +101,7 @@ public class IndexModule extends LifecycleModule {
|
||||
@Provides
|
||||
@Singleton
|
||||
@IndexExecutor
|
||||
ListeningScheduledExecutorService getIndexExecutor(
|
||||
ListeningExecutorService getIndexExecutor(
|
||||
@GerritServerConfig Config config,
|
||||
WorkQueue workQueue) {
|
||||
int threads = this.threads;
|
||||
|
Reference in New Issue
Block a user