This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/master by this push: new c6c31cf CAMEL-14263: camel-elasticsearch-rest should use source code generated configurer to avoid reflection configuration. c6c31cf is described below commit c6c31cf6930de915cab830c08f848015e81765e4 Author: Claus Ibsen <claus.ib...@gmail.com> AuthorDate: Sat Dec 7 16:50:45 2019 +0100 CAMEL-14263: camel-elasticsearch-rest should use source code generated configurer to avoid reflection configuration. --- .../main/docs/elasticsearch-rest-component.adoc | 5 +- .../elasticsearch/ElasticsearchComponent.java | 4 +- .../elasticsearch/ElasticsearchConfiguration.java | 11 ++-- .../dsl/ElasticsearchEndpointBuilderFactory.java | 77 ++++++++++++++++++++++ 4 files changed, 90 insertions(+), 7 deletions(-) diff --git a/components/camel-elasticsearch-rest/src/main/docs/elasticsearch-rest-component.adoc b/components/camel-elasticsearch-rest/src/main/docs/elasticsearch-rest-component.adoc index 6185d07..c03c58b 100644 --- a/components/camel-elasticsearch-rest/src/main/docs/elasticsearch-rest-component.adoc +++ b/components/camel-elasticsearch-rest/src/main/docs/elasticsearch-rest-component.adoc @@ -82,7 +82,7 @@ with the following path and query parameters: |=== -=== Query Parameters (14 parameters): +=== Query Parameters (17 parameters): [width="100%",cols="2,5,^1,2",options="header"] @@ -90,6 +90,7 @@ with the following path and query parameters: | Name | Description | Default | Type | *connectionTimeout* (producer) | The time in ms to wait before connection will timeout. | 30000 | int | *disconnect* (producer) | Disconnect after it finish calling the producer | false | boolean +| *enableSniffer* (producer) | Enable automatically discover nodes from a running Elasticsearch cluster | false | boolean | *enableSSL* (producer) | Enable SSL | false | boolean | *hostAddresses* (producer) | *Required* Comma separated list with ip:port formatted remote transport addresses to use. | | String | *indexName* (producer) | The name of the index to act against | | String @@ -97,6 +98,8 @@ with the following path and query parameters: | *maxRetryTimeout* (producer) | The time in ms before retry | 30000 | int | *operation* (producer) | What operation to perform | | ElasticsearchOperation | *scrollKeepAliveMs* (producer) | Time in ms during which elasticsearch will keep search context alive | 60000 | int +| *sniffAfterFailureDelay* (producer) | The delay of a sniff execution scheduled after a failure (in milliseconds) | 60000 | int +| *snifferInterval* (producer) | The interval between consecutive ordinary sniff executions in milliseconds. Will be honoured when sniffOnFailure is disabled or when there are no failures between consecutive sniff executions | 300000 | int | *socketTimeout* (producer) | The timeout in ms to wait before the socket will timeout. | 30000 | int | *useScroll* (producer) | Enable scroll usage | false | boolean | *waitForActiveShards* (producer) | Index creation waits for the write consistency number of shards to be available | 1 | int diff --git a/components/camel-elasticsearch-rest/src/main/java/org/apache/camel/component/elasticsearch/ElasticsearchComponent.java b/components/camel-elasticsearch-rest/src/main/java/org/apache/camel/component/elasticsearch/ElasticsearchComponent.java index 1975c90..e069ac9 100644 --- a/components/camel-elasticsearch-rest/src/main/java/org/apache/camel/component/elasticsearch/ElasticsearchComponent.java +++ b/components/camel-elasticsearch-rest/src/main/java/org/apache/camel/component/elasticsearch/ElasticsearchComponent.java @@ -84,10 +84,10 @@ public class ElasticsearchComponent extends DefaultComponent { config.setSniffAfterFailureDelay(this.getSniffAfterFailureDelay()); config.setClusterName(remaining); - setProperties(config, parameters); + Endpoint endpoint = new ElasticsearchEndpoint(uri, this, config, client); + setProperties(endpoint, parameters); config.setHostAddressesList(parseHostAddresses(config.getHostAddresses(), config)); - Endpoint endpoint = new ElasticsearchEndpoint(uri, this, config, client); return endpoint; } diff --git a/components/camel-elasticsearch-rest/src/main/java/org/apache/camel/component/elasticsearch/ElasticsearchConfiguration.java b/components/camel-elasticsearch-rest/src/main/java/org/apache/camel/component/elasticsearch/ElasticsearchConfiguration.java index 263e4bf..41ba8ad 100644 --- a/components/camel-elasticsearch-rest/src/main/java/org/apache/camel/component/elasticsearch/ElasticsearchConfiguration.java +++ b/components/camel-elasticsearch-rest/src/main/java/org/apache/camel/component/elasticsearch/ElasticsearchConfiguration.java @@ -29,6 +29,9 @@ public class ElasticsearchConfiguration { private List<HttpHost> hostAddressesList; + private String user; + private String password; + @UriPath @Metadata(required = true) private String clusterName; @UriParam @@ -53,13 +56,13 @@ public class ElasticsearchConfiguration { private boolean useScroll; @UriParam(defaultValue = "" + ElasticsearchConstants.DEFAULT_SCROLL_KEEP_ALIVE_MS) private int scrollKeepAliveMs = ElasticsearchConstants.DEFAULT_SCROLL_KEEP_ALIVE_MS; - - private String user; - private String password; - //Sniffer parameter. + @UriParam private boolean enableSniffer; + @UriParam(defaultValue = "" + ElasticsearchConstants.DEFAULT_SNIFFER_INTERVAL) private int snifferInterval = ElasticsearchConstants.DEFAULT_SNIFFER_INTERVAL; + @UriParam(defaultValue = "" + ElasticsearchConstants.DEFAULT_AFTER_FAILURE_DELAY) private int sniffAfterFailureDelay = ElasticsearchConstants.DEFAULT_AFTER_FAILURE_DELAY; + /** * Name of the cluster */ diff --git a/core/camel-endpointdsl/src/main/java/org/apache/camel/builder/endpoint/dsl/ElasticsearchEndpointBuilderFactory.java b/core/camel-endpointdsl/src/main/java/org/apache/camel/builder/endpoint/dsl/ElasticsearchEndpointBuilderFactory.java index 4186afc..0f4059a 100644 --- a/core/camel-endpointdsl/src/main/java/org/apache/camel/builder/endpoint/dsl/ElasticsearchEndpointBuilderFactory.java +++ b/core/camel-endpointdsl/src/main/java/org/apache/camel/builder/endpoint/dsl/ElasticsearchEndpointBuilderFactory.java @@ -87,6 +87,30 @@ public interface ElasticsearchEndpointBuilderFactory { return this; } /** + * Enable automatically discover nodes from a running Elasticsearch + * cluster. + * + * The option is a: <code>boolean</code> type. + * + * Group: producer + */ + default ElasticsearchEndpointBuilder enableSniffer(boolean enableSniffer) { + doSetProperty("enableSniffer", enableSniffer); + return this; + } + /** + * Enable automatically discover nodes from a running Elasticsearch + * cluster. + * + * The option will be converted to a <code>boolean</code> type. + * + * Group: producer + */ + default ElasticsearchEndpointBuilder enableSniffer(String enableSniffer) { + doSetProperty("enableSniffer", enableSniffer); + return this; + } + /** * Enable SSL. * * The option is a: <code>boolean</code> type. @@ -245,6 +269,59 @@ public interface ElasticsearchEndpointBuilderFactory { return this; } /** + * The delay of a sniff execution scheduled after a failure (in + * milliseconds). + * + * The option is a: <code>int</code> type. + * + * Group: producer + */ + default ElasticsearchEndpointBuilder sniffAfterFailureDelay( + int sniffAfterFailureDelay) { + doSetProperty("sniffAfterFailureDelay", sniffAfterFailureDelay); + return this; + } + /** + * The delay of a sniff execution scheduled after a failure (in + * milliseconds). + * + * The option will be converted to a <code>int</code> type. + * + * Group: producer + */ + default ElasticsearchEndpointBuilder sniffAfterFailureDelay( + String sniffAfterFailureDelay) { + doSetProperty("sniffAfterFailureDelay", sniffAfterFailureDelay); + return this; + } + /** + * The interval between consecutive ordinary sniff executions in + * milliseconds. Will be honoured when sniffOnFailure is disabled or + * when there are no failures between consecutive sniff executions. + * + * The option is a: <code>int</code> type. + * + * Group: producer + */ + default ElasticsearchEndpointBuilder snifferInterval(int snifferInterval) { + doSetProperty("snifferInterval", snifferInterval); + return this; + } + /** + * The interval between consecutive ordinary sniff executions in + * milliseconds. Will be honoured when sniffOnFailure is disabled or + * when there are no failures between consecutive sniff executions. + * + * The option will be converted to a <code>int</code> type. + * + * Group: producer + */ + default ElasticsearchEndpointBuilder snifferInterval( + String snifferInterval) { + doSetProperty("snifferInterval", snifferInterval); + return this; + } + /** * The timeout in ms to wait before the socket will timeout. * * The option is a: <code>int</code> type.