看了下es-hadoop插件的源碼:
網(wǎng)站建設哪家好,找成都創(chuàng)新互聯(lián)!專注于網(wǎng)頁設計、網(wǎng)站建設、微信開發(fā)、微信小程序定制開發(fā)、集團企業(yè)網(wǎng)站建設等服務項目。為回饋新老客戶創(chuàng)新互聯(lián)還提供了曹妃甸免費建站歡迎大家使用!
發(fā)現(xiàn)ES導入數(shù)據(jù)重試情況的發(fā)生,除了在es.batch.write.retry.policy參數(shù)默認開啟且es-hadoop插件向ES集群發(fā)送bulk寫入請求接受到503響應碼會重試3次之外。
本身執(zhí)行http請求時,也會存在重試(hadoop/rest/NetworkClient.java):
public Response execute(Request request) {
Response response = null;
boolean newNode;
do {
SimpleRequest routedRequest = new SimpleRequest(request.method(), null, request.path(), request.params(), request.body());
newNode = false;
try {
response = currentTransport.execute(routedRequest);
ByteSequence body = routedRequest.body();
if (body != null) {
stats.bytesSent += body.length();
}
} catch (Exception ex) {
// configuration error - including SSL/PKI - bail out
if (ex instanceof EsHadoopIllegalStateException) {
throw (EsHadoopException) ex;
}
// issues with the SSL handshake, bail out instead of retry, for security reasons
if (ex instanceof javax.net.ssl.SSLException) {
throw new EsHadoopTransportException(ex);
}
// check for fatal, non-recoverable network exceptions
if (ex instanceof BindException) {
throw new EsHadoopTransportException(ex);
}
if (log.isTraceEnabled()) {
log.trace(
String.format(
"Caught exception while performing request [%s][%s] - falling back to the next node in line...",
currentNode, request.path()), ex);
}
String failed = currentNode;
failedNodes.put(failed, ex);
newNode = selectNextNode();
log.error(String.format("Node [%s] failed (%s); "
+ (newNode ? "selected next node [" + currentNode + "]" : "no other nodes left - aborting..."),
failed, ex.getMessage()));
if (!newNode) {
throw new EsHadoopNoNodesLeftException(failedNodes);
}
}
} while (newNode);
return response;
}
當請求出現(xiàn)超時的情況時,es-hadoop插件會再請求一個ES節(jié)點發(fā)送寫入請求。即導入插件認為當前插入節(jié)點超時了(默認是一分鐘)就視為該節(jié)點不可用,就換下一個節(jié)點,其實是ES在一分鐘內(nèi)沒有處理完插入任務。
將超時時間es.http.timeout參數(shù)調(diào)大之后,給ES留下充足的入庫時間,就不會再發(fā)生這個問題了。