public boolean touch(String index) { if (!indexExists(index)) { Response response = execute(PUT, index, false); if (response.hasFailed()) { String msg = null; // try to parse the answer try { msg = parseContent(response.body(), "error"); } catch (Exception ex) { // can't parse message, move on } if (StringUtils.hasText(msg) && !msg.contains("IndexAlreadyExistsException")) { throw new EsHadoopIllegalStateException(msg); } } return response.hasSucceeded(); } return false; }
private void checkResponse(Request request, Response response) { if (response.hasFailed()) { // check error first String msg = null; // try to parse the answer try { EsHadoopException ex = errorExtractor.extractError(this.<Map> parseContent(response.body(), null)); msg = (ex != null) ? ex.toString() : null; if (response.isClientError()) { msg = msg + "\n" + request.body(); } else { msg = errorExtractor.prettify(msg, request.body()); } } catch (Exception ex) { // can't parse message, move on } if (!StringUtils.hasText(msg)) { msg = String.format("[%s] on [%s] failed; server[%s] returned [%s|%s:%s]", request.method().name(), request.path(), response.uri(), response.status(), response.statusDescription(), IOUtils.asStringAlways(response.body())); } throw new EsHadoopInvalidRequest(msg); } }
public boolean touch(String index) { if (!indexExists(index)) { Response response = execute(PUT, index, false); if (response.hasFailed()) { String msg = null; // try to parse the answer try { msg = parseContent(response.body(), "error"); } catch (Exception ex) { // can't parse message, move on } if (StringUtils.hasText(msg) && !msg.contains("IndexAlreadyExistsException")) { throw new EsHadoopIllegalStateException(msg); } } return response.hasSucceeded(); } return false; }
public boolean touch(String index) { if (!indexExists(index)) { Response response = execute(PUT, index, false); if (response.hasFailed()) { String msg = null; // try to parse the answer try { msg = parseContent(response.body(), "error"); } catch (Exception ex) { // can't parse message, move on } if (StringUtils.hasText(msg) && !msg.contains("IndexAlreadyExistsException")) { throw new EsHadoopIllegalStateException(msg); } } return response.hasSucceeded(); } return false; }
public boolean touch(String indexOrType) { if (!exists(indexOrType)) { Response response = execute(PUT, indexOrType, false); if (response.hasFailed()) { String msg = null; // try to parse the answer try { msg = parseContent(response.body(), "error"); } catch (Exception ex) { // can't parse message, move on } if (StringUtils.hasText(msg) && !msg.contains("IndexAlreadyExistsException")) { throw new EsHadoopIllegalStateException(msg); } } return response.hasSucceeded(); } return false; }
public boolean touch(String index) { if (!indexExists(index)) { Response response = execute(PUT, index, false); if (response.hasFailed()) { String msg = null; // try to parse the answer try { msg = parseContent(response.body(), "error"); } catch (Exception ex) { // can't parse message, move on } if (StringUtils.hasText(msg) && !msg.contains("IndexAlreadyExistsException")) { throw new EsHadoopIllegalStateException(msg); } } return response.hasSucceeded(); } return false; }
private void checkResponse(Request request, Response response) { if (response.hasFailed()) { // check error first String msg = null; // try to parse the answer try { msg = extractError(this.<Map> parseContent(response.body(), null)); if (response.isClientError()) { msg = msg + "\n" + request.body(); } else { msg = prettify(msg, request.body()); } } catch (Exception ex) { // can't parse message, move on } if (!StringUtils.hasText(msg)) { msg = String.format("[%s] on [%s] failed; server[%s] returned [%s|%s:%s]", request.method().name(), request.path(), response.uri(), response.status(), response.statusDescription(), IOUtils.asStringAlways(response.body())); } throw new EsHadoopInvalidRequest(msg); } }
private void checkResponse(Request request, Response response) { if (response.hasFailed()) { // check error first String msg = null; // try to parse the answer try { EsHadoopException ex = errorExtractor.extractError(this.<Map> parseContent(response.body(), null)); msg = (ex != null) ? ex.toString() : null; if (response.isClientError()) { msg = msg + "\n" + request.body(); } else { msg = errorExtractor.prettify(msg, request.body()); } } catch (Exception ex) { // can't parse message, move on } if (!StringUtils.hasText(msg)) { msg = String.format("[%s] on [%s] failed; server[%s] returned [%s|%s:%s]", request.method().name(), request.path(), response.uri(), response.status(), response.statusDescription(), IOUtils.asStringAlways(response.body())); } throw new EsHadoopInvalidRequest(msg); } }
private void checkResponse(Request request, Response response) { if (response.hasFailed()) { // check error first String msg = null; // try to parse the answer try { EsHadoopException ex = errorExtractor.extractError(this.<Map> parseContent(response.body(), null)); msg = (ex != null) ? ex.toString() : null; if (response.isClientError()) { msg = msg + "\n" + request.body(); } else { msg = errorExtractor.prettify(msg, request.body()); } } catch (Exception ex) { // can't parse message, move on } if (!StringUtils.hasText(msg)) { msg = String.format("[%s] on [%s] failed; server[%s] returned [%s|%s:%s]", request.method().name(), request.path(), response.uri(), response.status(), response.statusDescription(), IOUtils.asStringAlways(response.body())); } throw new EsHadoopInvalidRequest(msg); } }
private void checkResponse(Request request, Response response) { if (response.hasFailed()) { // check error first String msg = null; // try to parse the answer try { EsHadoopException ex = errorExtractor.extractError(this.<Map> parseContent(response.body(), null)); msg = (ex != null) ? ex.toString() : null; if (response.isClientError()) { msg = msg + "\n" + request.body(); } else { msg = errorExtractor.prettify(msg, request.body()); } } catch (Exception ex) { // can't parse message, move on } if (!StringUtils.hasText(msg)) { msg = String.format("[%s] on [%s] failed; server[%s] returned [%s|%s:%s]", request.method().name(), request.path(), response.uri(), response.status(), response.statusDescription(), IOUtils.asStringAlways(response.body())); } throw new EsHadoopInvalidRequest(msg); } }