You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stormcrawler.apache.org by rz...@apache.org on 2025/04/09 07:11:02 UTC

(incubator-stormcrawler) 01/01: #1516 - Add config options to change the response buffer size in OpenSearch

This is an automated email from the ASF dual-hosted git repository.

rzo1 pushed a commit to branch 1516
in repository https://gitbox.apache.org/repos/asf/incubator-stormcrawler.git

commit 66f48be3099f5851cf7a1aa30c7c4b5999ee5e36
Author: Richard Zowalla <rz...@apache.org>
AuthorDate: Wed Apr 9 09:09:48 2025 +0200

    #1516 - Add config options to change the response buffer size in OpenSearch
---
 external/opensearch/opensearch-conf.yaml                  |  6 ++++++
 .../stormcrawler/opensearch/OpenSearchConnection.java     | 15 ++++++++++++++-
 2 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/external/opensearch/opensearch-conf.yaml b/external/opensearch/opensearch-conf.yaml
index a0a651aa..f7d7b147 100644
--- a/external/opensearch/opensearch-conf.yaml
+++ b/external/opensearch/opensearch-conf.yaml
@@ -40,11 +40,15 @@ config:
   opensearch.indexer.flushInterval: "2s"
   opensearch.indexer.concurrentRequests: 1
   opensearch.indexer.sniff: true
+  # Sets the response buffer to the specified value in MB.
+  # opensearch.indexer.responseBufferSize: 100
 
   # MetricsConsumer
   # opensearch.metrics.addresses: "http://localhost:9200"
   opensearch.metrics.index.name: "metrics"
   opensearch.metrics.sniff: true
+  # Sets the response buffer to the specified value in MB.
+  # opensearch.metrics.responseBufferSize: 100
 
   # Spout and persistence bolt
   opensearch.status.addresses: "http://localhost:9200"
@@ -61,6 +65,8 @@ config:
   opensearch.status.flushInterval: "5s"
   opensearch.status.concurrentRequests: 1
   opensearch.status.sniff: true
+  # Sets the response buffer to the specified value in MB.
+  # opensearch.status.responseBufferSize: 100
 
     # spout config #
     
diff --git a/external/opensearch/src/main/java/org/apache/stormcrawler/opensearch/OpenSearchConnection.java b/external/opensearch/src/main/java/org/apache/stormcrawler/opensearch/OpenSearchConnection.java
index 0db6cd7f..353ae4be 100644
--- a/external/opensearch/src/main/java/org/apache/stormcrawler/opensearch/OpenSearchConnection.java
+++ b/external/opensearch/src/main/java/org/apache/stormcrawler/opensearch/OpenSearchConnection.java
@@ -42,6 +42,7 @@ import org.opensearch.action.DocWriteRequest;
 import org.opensearch.action.bulk.BulkProcessor;
 import org.opensearch.action.bulk.BulkRequest;
 import org.opensearch.action.bulk.BulkResponse;
+import org.opensearch.client.HttpAsyncResponseConsumerFactory;
 import org.opensearch.client.Node;
 import org.opensearch.client.RequestOptions;
 import org.opensearch.client.RestClient;
@@ -170,6 +171,8 @@ public final class OpenSearchConnection {
                                 throw new RuntimeException("Failed to disable TLS validation", e);
                             }
                         }
+
+
                         return httpClientBuilder;
                     });
         }
@@ -275,11 +278,21 @@ public final class OpenSearchConnection {
                 ConfUtils.getInt(
                         stormConf, Constants.PARAMPREFIX, dottedType, "concurrentRequests", 1);
 
+
+        final RequestOptions requestOptions = RequestOptions.DEFAULT;
+        final RequestOptions.Builder requestOptionsBuilder = requestOptions.toBuilder();
+        final int bufferSize =
+                ConfUtils.getInt(
+                        stormConf, Constants.PARAMPREFIX, dottedType, "responseBufferSize", 100);
+
+        requestOptionsBuilder.setHttpAsyncResponseConsumerFactory(
+                new HttpAsyncResponseConsumerFactory.HeapBufferedResponseConsumerFactory(bufferSize * 1024 * 1024));
+
         final BulkProcessor bulkProcessor =
                 BulkProcessor.builder(
                                 (request, bulkListener) ->
                                         client.bulkAsync(
-                                                request, RequestOptions.DEFAULT, bulkListener),
+                                                request, requestOptionsBuilder.build(), bulkListener),
                                 listener)
                         .setFlushInterval(flushInterval)
                         .setBulkActions(bulkActions)