-
Notifications
You must be signed in to change notification settings - Fork 242
/
ElasticsearchBatchedWork.java
33 lines (27 loc) · 1.1 KB
/
ElasticsearchBatchedWork.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/*
* 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.elasticsearch.orchestration.impl;
import java.util.concurrent.CompletableFuture;
import org.hibernate.search.backend.elasticsearch.work.impl.ElasticsearchWork;
import org.hibernate.search.engine.backend.orchestration.spi.BatchedWork;
import org.hibernate.search.util.common.impl.Futures;
class ElasticsearchBatchedWork<T> implements BatchedWork<ElasticsearchBatchedWorkProcessor> {
private final ElasticsearchWork<T> work;
private final CompletableFuture<T> future;
ElasticsearchBatchedWork(ElasticsearchWork<T> work, CompletableFuture<T> future) {
this.work = work;
this.future = future;
}
@Override
public void submitTo(ElasticsearchBatchedWorkProcessor delegate) {
delegate.submit( work ).whenComplete( Futures.copyHandler( future ) );
}
@Override
public void markAsFailed(Throwable t) {
future.completeExceptionally( t );
}
}