@Override public void writeTo(StreamOutput out) throws IOException { out.writeOptionalString(this.getMessage()); out.writeException(this.getCause()); writeStackTraces(this, out); if (out.getVersion().onOrAfter(Version.V_5_3_0)) { out.writeMapOfLists(headers, StreamOutput::writeString, StreamOutput::writeString); out.writeMapOfLists(metadata, StreamOutput::writeString, StreamOutput::writeString); } else { Map<String, List<String>> finalHeaders = new HashMap<>(headers.size() + metadata.size()); finalHeaders.putAll(headers); finalHeaders.putAll(metadata); out.writeMapOfLists(finalHeaders, StreamOutput::writeString, StreamOutput::writeString); } }
@Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { Throwable ex = ExceptionsHelper.unwrapCause(this); if (ex != this) { generateThrowableXContent(builder, params, this); } else { innerToXContent(builder, params, this, getExceptionName(), getMessage(), headers, metadata, getCause()); } return builder; }
ElasticsearchStatusException result = new ElasticsearchStatusException(exception.getMessage(), status, exception.getCause()); for (String header : exception.getHeaderKeys()) { result.addHeader(header, exception.getHeader(header));
final ElasticsearchException ex = new ElasticsearchException(this); final boolean isExecutorShutdown = readBoolean(); return (T) new EsRejectedExecutionException(ex.getMessage(), isExecutorShutdown);
@Override IndexResponse onParticularError(ElasticsearchException e) { if (e instanceof IndexNotFoundException || e.getCause() instanceof IndexNotFoundException) { throw new EsClientException.EsIndexMissingException(e); } if (e instanceof MapperParsingException) { throw new EsClientException.EsSchemaMismatchException(e); } // 既知のExceptionの場合はINFOログ // 新規のExceptionの場合はWARNログ if (e instanceof DocumentAlreadyExistsException) { if (e.getClass() != null) { log.info(e.getClass().getName() + " : " + e.getMessage()); } else { log.info(e.getMessage()); } } else { if (e.getClass() != null) { log.warn(e.getClass().getName() + " : " + e.getMessage()); } else { log.warn(e.getMessage()); } } // 例外が発生した場合でもドキュメントが登録されている可能性がある。 // そのため、登録チェックを行い、データが登録済の場合は正常なレスポンスを返却する。 return checkDocumentCreated(id, data, e); }
@Override public QueryOrSearchResponse executeQuery(final String indexName, final String query, final String[] fields, final int maxRows) { // Find the actual index to search if (!indexSettingsMap.containsKey(indexName)) { throw new IllegalArgumentException("Cannot find settings for index " + indexName); } try { final SearchRequest request = buildSearchRequest(indexSettingsMap.get(indexName).getIndex(), query, fields, maxRows); final SearchResponse response = runQuery(indexName, request); return convertResponse(response); } catch (final ElasticsearchException e) { LOGGER.error("Caught ElasticsearchException :: " + e.getMessage()); return new QueryOrSearchResponse(0, Collections.emptyList()); } catch (IOException e) { throw new RuntimeException(e); } }
@Override public QueryOrSearchResponse executeQuery(final String indexName, final String query, final String[] fields, final int maxRows) { try { final SearchResponse qresponse = proxy.search(buildSearchRequest(indexName, query, fields, maxRows)).actionGet(); return convertResponse(qresponse); } catch (final ElasticsearchException e) { LOGGER.error("Caught ElasticsearchException :: " + e.getMessage()); return new QueryOrSearchResponse(0, Collections.emptyList()); } catch (final IOException exception) { throw new RuntimeException(exception); } }
@Override public void destroy() { try { if (embeddedServer != null) { embeddedServer.destroy(); } if (client != null) { logger.info("Closing ElasticSearch client"); client.close(); } if (node != null) { if (!node.isClosed()) { logger.info("Closing ElasticSearch node"); node.close(); } } } catch (ElasticsearchException e) { logger.error(e.getMessage(), e); } }
public void writeTo(StreamOutput out) throws IOException { out.writeOptionalString(this.getMessage()); out.writeThrowable(this.getCause()); writeStackTraces(this, out); out.writeVInt(headers.size()); for (Map.Entry<String, List<String>> entry : headers.entrySet()) { out.writeString(entry.getKey()); out.writeVInt(entry.getValue().size()); for (String v : entry.getValue()) { out.writeString(v); } } }
@Override public void writeTo(StreamOutput out) throws IOException { out.writeOptionalString(this.getMessage()); out.writeException(this.getCause()); writeStackTraces(this, out); if (out.getVersion().onOrAfter(Version.V_5_3_0)) { out.writeMapOfLists(headers, StreamOutput::writeString, StreamOutput::writeString); out.writeMapOfLists(metadata, StreamOutput::writeString, StreamOutput::writeString); } else { HashMap<String, List<String>> finalHeaders = new HashMap<>(headers.size() + metadata.size()); finalHeaders.putAll(headers); finalHeaders.putAll(metadata); out.writeMapOfLists(finalHeaders, StreamOutput::writeString, StreamOutput::writeString); } }
@Override public void writeTo(StreamOutput out) throws IOException { out.writeOptionalString(this.getMessage()); out.writeException(this.getCause()); writeStackTraces(this, out); if (out.getVersion().onOrAfter(Version.V_5_3_0)) { out.writeMapOfLists(headers, StreamOutput::writeString, StreamOutput::writeString); out.writeMapOfLists(metadata, StreamOutput::writeString, StreamOutput::writeString); } else { Map<String, List<String>> finalHeaders = new HashMap<>(headers.size() + metadata.size()); finalHeaders.putAll(headers); finalHeaders.putAll(metadata); out.writeMapOfLists(finalHeaders, StreamOutput::writeString, StreamOutput::writeString); } }
@Override public void writeTo(StreamOutput out) throws IOException { out.writeOptionalString(this.getMessage()); out.writeException(this.getCause()); writeStackTraces(this, out); if (out.getVersion().onOrAfter(Version.V_5_3_0)) { out.writeMapOfLists(headers, StreamOutput::writeString, StreamOutput::writeString); out.writeMapOfLists(metadata, StreamOutput::writeString, StreamOutput::writeString); } else { Map<String, List<String>> finalHeaders = new HashMap<>(headers.size() + metadata.size()); finalHeaders.putAll(headers); finalHeaders.putAll(metadata); out.writeMapOfLists(finalHeaders, StreamOutput::writeString, StreamOutput::writeString); } }
@Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { Throwable ex = ExceptionsHelper.unwrapCause(this); if (ex != this) { generateThrowableXContent(builder, params, this); } else { innerToXContent(builder, params, this, getExceptionName(), getMessage(), headers, metadata, getCause()); } return builder; }
@Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { Throwable ex = ExceptionsHelper.unwrapCause(this); if (ex != this) { generateThrowableXContent(builder, params, this); } else { innerToXContent(builder, params, this, getExceptionName(), getMessage(), headers, metadata, getCause()); } return builder; }
@Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { Throwable ex = ExceptionsHelper.unwrapCause(this); if (ex != this) { generateThrowableXContent(builder, params, this); } else { innerToXContent(builder, params, this, getExceptionName(), getMessage(), headers, metadata, getCause()); } return builder; }
@Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { Throwable ex = ExceptionsHelper.unwrapCause(this); if (ex != this) { toXContent(builder, params, this); } else { builder.field("type", getExceptionName()); builder.field("reason", getMessage()); for (String key : headers.keySet()) { if (key.startsWith("es.")) { List<String> values = headers.get(key); xContentHeader(builder, key.substring("es.".length()), values); } } innerToXContent(builder, params); renderHeader(builder, params); if (params.paramAsBoolean(REST_EXCEPTION_SKIP_STACK_TRACE, REST_EXCEPTION_SKIP_STACK_TRACE_DEFAULT) == false) { builder.field("stack_trace", ExceptionsHelper.stackTrace(this)); } } return builder; }
} catch (ElasticsearchException e) { logger.debug(MessageFormat.format("Can't perform search: {0}", e.getMessage()));
ElasticsearchStatusException result = new ElasticsearchStatusException(exception.getMessage(), status, exception.getCause()); for (String header : exception.getHeaderKeys()) { result.addHeader(header, exception.getHeader(header));
ElasticsearchStatusException result = new ElasticsearchStatusException(exception.getMessage(), status, exception.getCause()); for (String header : exception.getHeaderKeys()) { result.addHeader(header, exception.getHeader(header));
ElasticsearchStatusException result = new ElasticsearchStatusException(exception.getMessage(), status, exception.getCause()); for (String header : exception.getHeaderKeys()) { result.addHeader(header, exception.getHeader(header));