Java Code Examples for org.apache.flink.streaming.connectors.elasticsearch.RequestIndexer#add()
The following examples show how to use
org.apache.flink.streaming.connectors.elasticsearch.RequestIndexer#add() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Elasticsearch6SinkExample.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@Override public void onFailure(ActionRequest action, Throwable failure, int restStatusCode, RequestIndexer indexer) throws Throwable { if (action instanceof IndexRequest) { Map<String, Object> json = new HashMap<>(); json.put("data", ((IndexRequest) action).source()); indexer.add( Requests.indexRequest() .index(index) .type(type) .id(((IndexRequest) action).id()) .source(json)); } else { throw new IllegalStateException("unexpected"); } }
Example 2
Source File: RetryRequestFailureHandler.java From flink-learning with Apache License 2.0 | 6 votes |
@Override public void onFailure(ActionRequest actionRequest, Throwable throwable, int i, RequestIndexer requestIndexer) throws Throwable { if (ExceptionUtils.findThrowable(throwable, EsRejectedExecutionException.class).isPresent()) { requestIndexer.add(new ActionRequest[]{actionRequest}); } else { if (ExceptionUtils.findThrowable(throwable, SocketTimeoutException.class).isPresent()) { return; } else { Optional<IOException> exp = ExceptionUtils.findThrowable(throwable, IOException.class); if (exp.isPresent()) { IOException ioExp = exp.get(); if (ioExp != null && ioExp.getMessage() != null && ioExp.getMessage().contains("max retry timeout")) { log.error(ioExp.getMessage()); return; } } } throw throwable; } }
Example 3
Source File: RetryRequestFailureHandler.java From flink-learning with Apache License 2.0 | 6 votes |
@Override public void onFailure(ActionRequest actionRequest, Throwable throwable, int i, RequestIndexer requestIndexer) throws Throwable { if (ExceptionUtils.findThrowable(throwable, EsRejectedExecutionException.class).isPresent()) { requestIndexer.add(new ActionRequest[]{actionRequest}); } else { if (ExceptionUtils.findThrowable(throwable, SocketTimeoutException.class).isPresent()) { return; } else { Optional<IOException> exp = ExceptionUtils.findThrowable(throwable, IOException.class); if (exp.isPresent()) { IOException ioExp = exp.get(); if (ioExp != null && ioExp.getMessage() != null && ioExp.getMessage().contains("max retry timeout")) { log.error(ioExp.getMessage()); return; } } } throw throwable; } }
Example 4
Source File: RetryRequestFailureHandler.java From flink-learning with Apache License 2.0 | 6 votes |
@Override public void onFailure(ActionRequest actionRequest, Throwable throwable, int i, RequestIndexer requestIndexer) throws Throwable { if (ExceptionUtils.findThrowable(throwable, EsRejectedExecutionException.class).isPresent()) { requestIndexer.add(new ActionRequest[]{actionRequest}); } else { if (ExceptionUtils.findThrowable(throwable, SocketTimeoutException.class).isPresent()) { return; } else { Optional<IOException> exp = ExceptionUtils.findThrowable(throwable, IOException.class); if (exp.isPresent()) { IOException ioExp = exp.get(); if (ioExp != null && ioExp.getMessage() != null && ioExp.getMessage().contains("max retry timeout")) { log.error(ioExp.getMessage()); return; } } } throw throwable; } }
Example 5
Source File: RowElasticsearchSinkFunction.java From flink with Apache License 2.0 | 6 votes |
private void processUpsert(RowData row, RequestIndexer indexer) { final byte[] document = serializationSchema.serialize(row); final String key = createKey.apply(row); if (key != null) { final UpdateRequest updateRequest = requestFactory.createUpdateRequest( indexGenerator.generate(row), docType, key, contentType, document); indexer.add(updateRequest); } else { final IndexRequest indexRequest = requestFactory.createIndexRequest( indexGenerator.generate(row), docType, key, contentType, document); indexer.add(indexRequest); } }
Example 6
Source File: Elasticsearch6SinkExample.java From flink with Apache License 2.0 | 6 votes |
@Override public void onFailure(ActionRequest action, Throwable failure, int restStatusCode, RequestIndexer indexer) throws Throwable { if (action instanceof IndexRequest) { Map<String, Object> json = new HashMap<>(); json.put("data", ((IndexRequest) action).source()); indexer.add( Requests.indexRequest() .index(index) .type(type) .id(((IndexRequest) action).id()) .source(json)); } else { throw new IllegalStateException("unexpected"); } }
Example 7
Source File: ESSink.java From Mastering-Distributed-Tracing with MIT License | 6 votes |
public static ElasticsearchSink<TraceSummary> build() { List<HttpHost> httpHosts = new ArrayList<>(); httpHosts.add(new HttpHost("127.0.0.1", 9200, "http")); ElasticsearchSink.Builder<TraceSummary> esSinkBuilder = new ElasticsearchSink.Builder<>(httpHosts, new ElasticsearchSinkFunction<TraceSummary>() { @Override public void process(TraceSummary summary, RuntimeContext ctx, RequestIndexer indexer) { indexer.add(Requests.indexRequest()// .index("trace-summaries") // .type("trace-summaries") // .id(summary.traceId) // .source(asJson(summary))); } }); // configuration for the bulk requests; this instructs the sink to emit after // every element, otherwise they would be buffered esSinkBuilder.setBulkFlushMaxActions(1); return esSinkBuilder.build(); }
Example 8
Source File: RetryRequestFailureHandler.java From flink-learning with Apache License 2.0 | 6 votes |
@Override public void onFailure(ActionRequest actionRequest, Throwable throwable, int i, RequestIndexer requestIndexer) throws Throwable { if (ExceptionUtils.findThrowable(throwable, EsRejectedExecutionException.class).isPresent()) { requestIndexer.add(new ActionRequest[]{actionRequest}); } else { if (ExceptionUtils.findThrowable(throwable, SocketTimeoutException.class).isPresent()) { return; } else { Optional<IOException> exp = ExceptionUtils.findThrowable(throwable, IOException.class); if (exp.isPresent()) { IOException ioExp = exp.get(); if (ioExp != null && ioExp.getMessage() != null && ioExp.getMessage().contains("max retry timeout")) { log.error(ioExp.getMessage()); return; } } } throw throwable; } }
Example 9
Source File: Elasticsearch6SinkExample.java From flink with Apache License 2.0 | 6 votes |
@Override public void onFailure(ActionRequest action, Throwable failure, int restStatusCode, RequestIndexer indexer) throws Throwable { if (action instanceof IndexRequest) { Map<String, Object> json = new HashMap<>(); json.put("data", ((IndexRequest) action).source()); indexer.add( Requests.indexRequest() .index(index) .type(type) .id(((IndexRequest) action).id()) .source(json)); } else { throw new IllegalStateException("unexpected"); } }
Example 10
Source File: Elasticsearch6SinkFunction.java From alchemy with Apache License 2.0 | 5 votes |
private void processDelete(Row row, RequestIndexer indexer) { final String key = createKey(row); final DeleteRequest deleteRequest = requestFactory.createDeleteRequest( getIndex(row), docType, key); indexer.add(deleteRequest); }
Example 11
Source File: RetryRejectedExecutionFailureHandler.java From flink with Apache License 2.0 | 5 votes |
@Override public void onFailure(ActionRequest action, Throwable failure, int restStatusCode, RequestIndexer indexer) throws Throwable { LOG.error("Failed Elasticsearch item request: {}", failure.getMessage(), failure); if (ExceptionUtils.findThrowable(failure, EsRejectedExecutionException.class).isPresent()) { indexer.add(action); } else { // rethrow all other failures throw failure; } }
Example 12
Source File: RowElasticsearchSinkFunction.java From flink with Apache License 2.0 | 5 votes |
private void processDelete(RowData row, RequestIndexer indexer) { final String key = createKey.apply(row); final DeleteRequest deleteRequest = requestFactory.createDeleteRequest( indexGenerator.generate(row), docType, key); indexer.add(deleteRequest); }
Example 13
Source File: Elasticsearch5TableFunction.java From alchemy with Apache License 2.0 | 5 votes |
@Override public void process(Row row, RuntimeContext runtimeContext, RequestIndexer requestIndexer) { if (row == null) { return; } requestIndexer.add(createIndexRequest(row)); numRecordsOut = createOrGet(numRecordsOut, runtimeContext); numRecordsOut.inc(); }
Example 14
Source File: RetryRejectedExecutionFailureHandler.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Override public void onFailure(ActionRequest action, Throwable failure, int restStatusCode, RequestIndexer indexer) throws Throwable { if (ExceptionUtils.findThrowable(failure, EsRejectedExecutionException.class).isPresent()) { indexer.add(action); } else { // rethrow all other failures throw failure; } }
Example 15
Source File: Elasticsearch7SinkExample.java From flink with Apache License 2.0 | 5 votes |
@Override public void onFailure(ActionRequest action, Throwable failure, int restStatusCode, RequestIndexer indexer) throws Throwable { if (action instanceof IndexRequest) { Map<String, Object> json = new HashMap<>(); json.put("data", ((IndexRequest) action).source()); indexer.add( Requests.indexRequest() .index(index) .id(((IndexRequest) action).id()) .source(json)); } else { throw new IllegalStateException("unexpected"); } }
Example 16
Source File: RetryRejectedExecutionFailureHandler.java From flink with Apache License 2.0 | 5 votes |
@Override public void onFailure(ActionRequest action, Throwable failure, int restStatusCode, RequestIndexer indexer) throws Throwable { if (ExceptionUtils.findThrowable(failure, EsRejectedExecutionException.class).isPresent()) { indexer.add(action); } else { // rethrow all other failures throw failure; } }
Example 17
Source File: SourceSinkDataTestKit.java From flink with Apache License 2.0 | 4 votes |
@Override public void process(Tuple2<Integer, String> element, RuntimeContext ctx, RequestIndexer indexer) { indexer.add(createIndexRequest(element)); }
Example 18
Source File: PravegaAnomalyDetectionProcessor.java From pravega-samples with Apache License 2.0 | 4 votes |
@Override public void process(Result element, RuntimeContext ctx, RequestIndexer indexer) { indexer.add(createIndexRequest(element)); }
Example 19
Source File: SourceSinkDataTestKit.java From flink with Apache License 2.0 | 4 votes |
@Override public void process(Tuple2<Integer, String> element, RuntimeContext ctx, RequestIndexer indexer) { indexer.add(createIndexRequest(element)); }
Example 20
Source File: SourceSinkDataTestKit.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
@Override public void process(Tuple2<Integer, String> element, RuntimeContext ctx, RequestIndexer indexer) { indexer.add(createIndexRequest(element)); }