Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HSEARCH-1735 Clearly distinguish the Async from the BatchSync Process…
…ing strategies and make sure no unnecessary thread is started
- Loading branch information
Showing
6 changed files
with
150 additions
and
30 deletions.
There are no files selected for viewing
50 changes: 50 additions & 0 deletions
50
engine/src/main/java/org/hibernate/search/backend/impl/lucene/AsyncWorkProcessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* Hibernate Search, full-text search for your domain model | ||
* | ||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later | ||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>. | ||
*/ | ||
package org.hibernate.search.backend.impl.lucene; | ||
|
||
import java.util.List; | ||
|
||
import org.hibernate.search.backend.IndexingMonitor; | ||
import org.hibernate.search.backend.LuceneWork; | ||
|
||
|
||
/** | ||
* This is the asynchronous backend logic for the LuceneBackendQueueProcessor. | ||
* It merely forwards batches of indexing work to the async Executor for this indexing backend. | ||
* | ||
* @author Sanne Grinovero <sanne@hibernate.org> (C) 2014 Red Hat Inc. | ||
* @since 5.0 | ||
*/ | ||
final class AsyncWorkProcessor implements WorkProcessor { | ||
|
||
private volatile LuceneBackendResources resources; | ||
|
||
public AsyncWorkProcessor(LuceneBackendResources resources) { | ||
this.resources = resources; | ||
} | ||
|
||
@Override | ||
public void shutdown() { | ||
//no-op | ||
} | ||
|
||
@Override | ||
public void submit(List<LuceneWork> workList, IndexingMonitor monitor) { | ||
LuceneBackendQueueTask luceneBackendQueueProcessor = new LuceneBackendQueueTask( | ||
workList, | ||
resources, | ||
monitor | ||
); | ||
resources.getAsynchIndexingExecutor().execute( luceneBackendQueueProcessor ); | ||
} | ||
|
||
@Override | ||
public void updateResources(LuceneBackendResources resources) { | ||
this.resources = resources; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
engine/src/main/java/org/hibernate/search/backend/impl/lucene/WorkProcessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Hibernate Search, full-text search for your domain model | ||
* | ||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later | ||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>. | ||
*/ | ||
package org.hibernate.search.backend.impl.lucene; | ||
|
||
import java.util.List; | ||
|
||
import org.hibernate.search.backend.IndexingMonitor; | ||
import org.hibernate.search.backend.LuceneWork; | ||
|
||
|
||
/** | ||
* Defines the contract for async and synchronous processors to apply | ||
* batched of indexing work to the index. | ||
* | ||
* @author Sanne Grinovero <sanne@hibernate.org> (C) 2014 Red Hat Inc. | ||
* @since 5.0 | ||
*/ | ||
interface WorkProcessor { | ||
|
||
/** | ||
* Prepare for the queue to be shut down. | ||
* Needs to flush pending work and shutdown any internal threads. | ||
*/ | ||
void shutdown(); | ||
|
||
/** | ||
* Enqueues a new batch of indexing work to be applied. | ||
* @param workList the list of work | ||
* @param monitor any optional listener which needs to be notified for the work. | ||
*/ | ||
void submit(List<LuceneWork> workList, IndexingMonitor monitor); | ||
|
||
/** | ||
* Only invoked when some dynamic parameters are reconfigured | ||
* @param resources the new instance to be used | ||
*/ | ||
void updateResources(LuceneBackendResources resources); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters