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:
Dave Borowitz
2013-10-08 16:03:31 -07:00
parent 398cf16244
commit bb5a30f8a5
6 changed files with 18 additions and 19 deletions

View File

@@ -25,7 +25,6 @@ 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.ListenableFuture;
import com.google.common.util.concurrent.ListeningExecutorService; import com.google.common.util.concurrent.ListeningExecutorService;
import com.google.common.util.concurrent.ListeningScheduledExecutorService;
import com.google.gerrit.common.Nullable; import com.google.gerrit.common.Nullable;
import com.google.gerrit.reviewdb.client.Change; import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.reviewdb.client.PatchSetApproval; import com.google.gerrit.reviewdb.client.PatchSetApproval;
@@ -156,7 +155,7 @@ public class LuceneChangeIndex implements ChangeIndex {
LuceneChangeIndex( LuceneChangeIndex(
@GerritServerConfig Config cfg, @GerritServerConfig Config cfg,
SitePaths sitePaths, SitePaths sitePaths,
@IndexExecutor ListeningScheduledExecutorService executor, @IndexExecutor ListeningExecutorService executor,
FillArgs fillArgs, FillArgs fillArgs,
@Assisted Schema<ChangeData> schema, @Assisted Schema<ChangeData> schema,
@Assisted @Nullable String base) throws IOException { @Assisted @Nullable String base) throws IOException {

View File

@@ -25,7 +25,7 @@ import com.google.common.collect.Sets;
import com.google.common.util.concurrent.AsyncFunction; import com.google.common.util.concurrent.AsyncFunction;
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.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.common.util.concurrent.MoreExecutors;
import com.google.gerrit.reviewdb.client.Change; import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.reviewdb.client.Project; import com.google.gerrit.reviewdb.client.Project;
@@ -105,13 +105,13 @@ public class ChangeBatchIndexer {
private final Provider<ReviewDb> db; private final Provider<ReviewDb> db;
private final GitRepositoryManager repoManager; private final GitRepositoryManager repoManager;
private final ListeningScheduledExecutorService executor; private final ListeningExecutorService executor;
private final ChangeIndexer.Factory indexerFactory; private final ChangeIndexer.Factory indexerFactory;
@Inject @Inject
ChangeBatchIndexer(Provider<ReviewDb> db, ChangeBatchIndexer(Provider<ReviewDb> db,
GitRepositoryManager repoManager, GitRepositoryManager repoManager,
@IndexExecutor ListeningScheduledExecutorService executor, @IndexExecutor ListeningExecutorService executor,
ChangeIndexer.Factory indexerFactory) { ChangeIndexer.Factory indexerFactory) {
this.db = db; this.db = db;
this.repoManager = repoManager; this.repoManager = repoManager;

View File

@@ -18,7 +18,7 @@ import com.google.common.base.Function;
import com.google.common.util.concurrent.Callables; import com.google.common.util.concurrent.Callables;
import com.google.common.util.concurrent.CheckedFuture; import com.google.common.util.concurrent.CheckedFuture;
import com.google.common.util.concurrent.Futures; 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.reviewdb.client.Change;
import com.google.gerrit.server.query.change.ChangeData; 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; this.executor = executor;
} }

View File

@@ -15,7 +15,7 @@
package com.google.gerrit.server.index; package com.google.gerrit.server.index;
import com.google.common.util.concurrent.Atomics; 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.reviewdb.server.ReviewDb;
import com.google.gerrit.server.CurrentUser; import com.google.gerrit.server.CurrentUser;
import com.google.gerrit.server.query.change.ChangeData; import com.google.gerrit.server.query.change.ChangeData;
@@ -53,7 +53,7 @@ public class ChangeIndexerImpl extends ChangeIndexer {
private final ThreadLocalRequestContext context; private final ThreadLocalRequestContext context;
@AssistedInject @AssistedInject
ChangeIndexerImpl(@IndexExecutor ListeningScheduledExecutorService executor, ChangeIndexerImpl(@IndexExecutor ListeningExecutorService executor,
SchemaFactory<ReviewDb> schemaFactory, SchemaFactory<ReviewDb> schemaFactory,
ThreadLocalRequestContext context, ThreadLocalRequestContext context,
@Assisted ChangeIndex index) { @Assisted ChangeIndex index) {
@@ -65,7 +65,7 @@ public class ChangeIndexerImpl extends ChangeIndexer {
} }
@AssistedInject @AssistedInject
ChangeIndexerImpl(@IndexExecutor ListeningScheduledExecutorService executor, ChangeIndexerImpl(@IndexExecutor ListeningExecutorService executor,
SchemaFactory<ReviewDb> schemaFactory, SchemaFactory<ReviewDb> schemaFactory,
ThreadLocalRequestContext context, ThreadLocalRequestContext context,
@Assisted IndexCollection indexes) { @Assisted IndexCollection indexes) {

View File

@@ -16,14 +16,14 @@ package com.google.gerrit.server.index;
import static java.lang.annotation.RetentionPolicy.RUNTIME; 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 com.google.inject.BindingAnnotation;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
/** /**
* Marker on {@link ListeningScheduledExecutorService} used by secondary * Marker on {@link ListeningExecutorService} used by secondary indexing
* indexing threads. * threads.
*/ */
@Retention(RUNTIME) @Retention(RUNTIME)
@BindingAnnotation @BindingAnnotation

View File

@@ -14,7 +14,7 @@
package com.google.gerrit.server.index; 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.common.util.concurrent.MoreExecutors;
import com.google.gerrit.lifecycle.LifecycleModule; import com.google.gerrit.lifecycle.LifecycleModule;
import com.google.gerrit.server.config.GerritServerConfig; import com.google.gerrit.server.config.GerritServerConfig;
@@ -49,14 +49,14 @@ public class IndexModule extends LifecycleModule {
} }
private final int threads; private final int threads;
private final ListeningScheduledExecutorService indexExecutor; private final ListeningExecutorService indexExecutor;
public IndexModule(int threads) { public IndexModule(int threads) {
this.threads = threads; this.threads = threads;
this.indexExecutor = null; this.indexExecutor = null;
} }
public IndexModule(ListeningScheduledExecutorService indexExecutor) { public IndexModule(ListeningExecutorService indexExecutor) {
this.threads = -1; this.threads = -1;
this.indexExecutor = indexExecutor; this.indexExecutor = indexExecutor;
} }
@@ -72,7 +72,7 @@ public class IndexModule extends LifecycleModule {
.build(ChangeIndexer.Factory.class)); .build(ChangeIndexer.Factory.class));
if (indexExecutor != null) { if (indexExecutor != null) {
bind(ListeningScheduledExecutorService.class) bind(ListeningExecutorService.class)
.annotatedWith(IndexExecutor.class) .annotatedWith(IndexExecutor.class)
.toInstance(indexExecutor); .toInstance(indexExecutor);
} else { } else {
@@ -101,7 +101,7 @@ public class IndexModule extends LifecycleModule {
@Provides @Provides
@Singleton @Singleton
@IndexExecutor @IndexExecutor
ListeningScheduledExecutorService getIndexExecutor( ListeningExecutorService getIndexExecutor(
@GerritServerConfig Config config, @GerritServerConfig Config config,
WorkQueue workQueue) { WorkQueue workQueue) {
int threads = this.threads; int threads = this.threads;