Skip to content

Commit

Permalink
HSEARCH-3739 Use a ThreadPool instead of a ForkJoinPool for asynchron…
Browse files Browse the repository at this point in the history
…ous mass indexing

The ForkJoinPool does not use interruption to cancel tasks, which makes
it hard to integrate to the current implementation of MassIndexer where
everything uses interruptions for cancellation.
  • Loading branch information
yrodiere committed Oct 25, 2019
1 parent 2e9ccf8 commit d448dca
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import java.util.LinkedHashSet;
import java.util.Set;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.ExecutorService;

import org.hibernate.CacheMode;
import org.hibernate.search.engine.backend.session.spi.DetachedBackendSessionContext;
Expand Down Expand Up @@ -164,7 +164,16 @@ public MassIndexer monitor(MassIndexingMonitor monitor) {

@Override
public CompletableFuture<?> start() {
return Futures.runAsync( createCoordinator(), ForkJoinPool.commonPool() );
BatchCoordinator coordinator = createCoordinator();
ExecutorService executor = mappingContext.getThreadPoolProvider()
.newFixedThreadPool( 1, THREAD_NAME_PREFIX + "Coordinator" );
try {
return Futures.runAsync( coordinator, executor );
}
finally {
executor.shutdown();
}

}

@Override
Expand Down

0 comments on commit d448dca

Please sign in to comment.