优化生成索引mapping日志
This commit is contained in:
parent
aa185c8bd2
commit
b1bdd9b8a5
@ -29,7 +29,6 @@ import org.springframework.beans.factory.annotation.Qualifier;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.concurrent.CountDownLatch;
|
import java.util.concurrent.CountDownLatch;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author paulG
|
* @author paulG
|
||||||
@ -343,20 +342,20 @@ public abstract class BaseElasticsearchService {
|
|||||||
PutMappingRequest request = new PutMappingRequest(index)
|
PutMappingRequest request = new PutMappingRequest(index)
|
||||||
.source(source, XContentType.JSON);
|
.source(source, XContentType.JSON);
|
||||||
CountDownLatch latch = new CountDownLatch(1);
|
CountDownLatch latch = new CountDownLatch(1);
|
||||||
AtomicReference<AcknowledgedResponse> response = new AtomicReference<>();
|
|
||||||
client.indices().putMappingAsync(
|
client.indices().putMappingAsync(
|
||||||
request,
|
request,
|
||||||
RequestOptions.DEFAULT,
|
RequestOptions.DEFAULT,
|
||||||
new ActionListener<AcknowledgedResponse>() {
|
new ActionListener<AcknowledgedResponse>() {
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(AcknowledgedResponse r) {
|
public void onResponse(AcknowledgedResponse r) {
|
||||||
response.set(r);
|
|
||||||
latch.countDown();
|
latch.countDown();
|
||||||
|
log.info("创建索引mapping成功:{}", r);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(Exception e) {
|
public void onFailure(Exception e) {
|
||||||
latch.countDown();
|
latch.countDown();
|
||||||
|
log.error("创建索引mapping失败", e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
latch.await(10, TimeUnit.SECONDS);
|
latch.await(10, TimeUnit.SECONDS);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user