You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2017/02/02 09:04:54 UTC
[3/5] camel git commit: CAMEL-10766: Adding changes according to
Claus Ibsen comments
CAMEL-10766: Adding changes according to Claus Ibsen comments
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/659255cf
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/659255cf
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/659255cf
Branch: refs/heads/master
Commit: 659255cf05494fbf0835dccd065f1bc0f9c6bbaa
Parents: a537700
Author: Dmitry Volodin <dm...@gmail.com>
Authored: Wed Feb 1 21:27:08 2017 +0300
Committer: Claus Ibsen <da...@apache.org>
Committed: Thu Feb 2 10:04:30 2017 +0100
----------------------------------------------------------------------
components/camel-elasticsearch5/pom.xml | 186 ++++++++---------
.../src/main/docs/elasticsearch5-component.adoc | 29 +--
.../elasticsearch5/ElasticsearchComponent.java | 18 +-
.../ElasticsearchConfiguration.java | 12 +-
.../elasticsearch5/ElasticsearchConstants.java | 15 +-
.../elasticsearch5/ElasticsearchEndpoint.java | 73 +------
.../elasticsearch5/ElasticsearchOperation.java | 58 ++++++
.../elasticsearch5/ElasticsearchProducer.java | 125 ++++++++----
.../elasticsearch5/ElasticsearchBaseTest.java | 12 +-
.../elasticsearch5/ElasticsearchBulkTest.java | 4 +-
.../ElasticsearchClusterBaseTest.java | 11 -
.../ElasticsearchClusterIndexTest.java | 39 +---
...icsearchGetSearchDeleteExistsUpdateTest.java | 50 ++---
.../elasticsearch5/ElasticsearchIndexTest.java | 18 +-
.../src/test/resources/log4j2.properties | 2 +-
components/camel-lucene/pom.xml | 202 +++++++++----------
platforms/catalog-lucene/pom.xml | 39 ++--
...ElasticsearchComponentAutoConfiguration.java | 33 +--
.../ElasticsearchComponentConfiguration.java | 46 -----
.../camel-spring-boot-dependencies/pom.xml | 5 +
20 files changed, 437 insertions(+), 540 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/659255cf/components/camel-elasticsearch5/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-elasticsearch5/pom.xml b/components/camel-elasticsearch5/pom.xml
index e2e4612..ea372e2 100644
--- a/components/camel-elasticsearch5/pom.xml
+++ b/components/camel-elasticsearch5/pom.xml
@@ -1,101 +1,107 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor
- license agreements. See the NOTICE file distributed with this work for additional
- information regarding copyright ownership. The ASF licenses this file to
- You under the Apache License, Version 2.0 (the "License"); you may not use
- this file except in compliance with the License. You may obtain a copy of
- the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required
- by applicable law or agreed to in writing, software distributed under the
- License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
- OF ANY KIND, either express or implied. See the License for the specific
- language governing permissions and limitations under the License. -->
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.apache.camel</groupId>
- <artifactId>components</artifactId>
- <version>2.19.0-SNAPSHOT</version>
- </parent>
+ <parent>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>components</artifactId>
+ <version>2.19.0-SNAPSHOT</version>
+ </parent>
- <artifactId>camel-elasticsearch5</artifactId>
- <packaging>jar</packaging>
- <name>Camel :: ElasticSearch5</name>
- <description>Camel ElasticSearch 5.x support</description>
+ <artifactId>camel-elasticsearch5</artifactId>
+ <packaging>jar</packaging>
+ <name>Camel :: ElasticSearch5</name>
+ <description>Camel ElasticSearch 5.x support</description>
- <properties>
- <elasticsearch.version>5.1.2</elasticsearch.version>
- <camel.osgi.export.pkg>org.apache.camel.component.elasticsearch5.*;${camel.osgi.version}</camel.osgi.export.pkg>
- <camel.osgi.export.service>org.apache.camel.spi.ComponentResolver;component=elasticsearch5</camel.osgi.export.service>
- </properties>
+ <properties>
+ <elasticsearch.version>5.1.2</elasticsearch.version>
+ <camel.osgi.export.pkg>org.apache.camel.component.elasticsearch5.*;${camel.osgi.version}</camel.osgi.export.pkg>
+ <camel.osgi.export.service>org.apache.camel.spi.ComponentResolver;component=elasticsearch5</camel.osgi.export.service>
+ </properties>
- <dependencies>
- <dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-core</artifactId>
- </dependency>
- <dependency>
- <groupId>org.elasticsearch.client</groupId>
- <artifactId>transport</artifactId>
- <version>${elasticsearch5-version}</version>
- </dependency>
- <dependency>
- <groupId>com.fasterxml.jackson.core</groupId>
- <artifactId>jackson-databind</artifactId>
- <version>${jackson2-version}</version>
- </dependency>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.elasticsearch.client</groupId>
+ <artifactId>transport</artifactId>
+ <version>${elasticsearch5-version}</version>
+ </dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-databind</artifactId>
+ <version>${jackson2-version}</version>
+ </dependency>
- <!-- for testing -->
- <dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-test</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.codelibs</groupId>
- <artifactId>elasticsearch-cluster-runner</artifactId>
- <version>${elasticsearch5-cluster-runner-version}</version>
- <scope>test</scope>
- </dependency>
+ <!-- for testing -->
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-test</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.codelibs</groupId>
+ <artifactId>elasticsearch-cluster-runner</artifactId>
+ <version>${elasticsearch5-cluster-runner-version}</version>
+ <scope>test</scope>
+ </dependency>
- <!-- logging -->
- <dependency>
- <groupId>org.apache.logging.log4j</groupId>
- <artifactId>log4j-api</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.logging.log4j</groupId>
- <artifactId>log4j-core</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.logging.log4j</groupId>
- <artifactId>log4j-slf4j-impl</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.logging.log4j</groupId>
- <artifactId>log4j-1.2-api</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
+ <!-- logging -->
+ <dependency>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-api</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-core</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-slf4j-impl</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-1.2-api</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <systemPropertyVariables>
- <es.path.data>target/data</es.path.data>
- </systemPropertyVariables>
- <forkCount>1</forkCount>
- <reuseForks>false</reuseForks>
- </configuration>
- </plugin>
- </plugins>
- </build>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <systemPropertyVariables>
+ <es.path.data>target/data</es.path.data>
+ </systemPropertyVariables>
+ <forkCount>1</forkCount>
+ <reuseForks>false</reuseForks>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
</project>
http://git-wip-us.apache.org/repos/asf/camel/blob/659255cf/components/camel-elasticsearch5/src/main/docs/elasticsearch5-component.adoc
----------------------------------------------------------------------
diff --git a/components/camel-elasticsearch5/src/main/docs/elasticsearch5-component.adoc b/components/camel-elasticsearch5/src/main/docs/elasticsearch5-component.adoc
index 1447dab..e6e41bc 100644
--- a/components/camel-elasticsearch5/src/main/docs/elasticsearch5-component.adoc
+++ b/components/camel-elasticsearch5/src/main/docs/elasticsearch5-component.adoc
@@ -31,17 +31,7 @@ elasticsearch5://clusterName[?options]
// component options: START
-The Elasticsearch5 component supports 1 options which are listed below.
-
-
-
-{% raw %}
-[width="100%",cols="2,1,1m,1m,5",options="header"]
-|=======================================================================
-| Name | Group | Default | Java Type | Description
-| client | advanced | | TransportClient | To use an existing configured Elasticsearch client instead of creating a client per endpoint.
-|=======================================================================
-{% endraw %}
+The Elasticsearch5 component has no options.
// component options: END
@@ -60,10 +50,10 @@ The Elasticsearch5 component supports 10 endpoint options which are listed below
| indexName | producer | | String | The name of the index to act against
| indexType | producer | | String | The type of the index to act against
| ip | producer | | String | The TransportClient remote host ip to use
-| operation | producer | | String | What operation to perform
-| port | producer | | int | The TransportClient remote port to use (defaults to 9300)
+| operation | producer | | ElasticsearchOperation | What operation to perform
+| port | producer | 9300 | int | The TransportClient remote port to use (defaults to 9300)
| transportAddresses | producer | | String | Comma separated list with ip:port formatted remote transport addresses to use. The ip and port options must be left blank for transportAddresses to be considered instead.
-| waitForActiveShards | producer | | int | Index creation waits for the write consistency number of shards to be available
+| waitForActiveShards | producer | 1 | int | Index creation waits for the write consistency number of shards to be available
| synchronous | advanced | false | boolean | Sets whether synchronous processing should be strictly used or Camel is allowed to use asynchronous processing (if supported).
|=======================================================================
{% endraw %}
@@ -81,13 +71,16 @@ other parameters or the message body to be set.
|=======================================================================
|operation |message body |description
-|INDEX |Map, String, byte[] or XContentBuilder content to index |adds content to an index and returns the content's indexId in the body.
+|INDEX |Map, String, byte[] or XContentBuilder content to index |Adds content to an index and returns the content's indexId in the body.
You can set the indexId by setting the message header with
the key "indexId".
-|GET_BY_ID |index id of content to retrieve |retrieves the specified index and returns a GetResult object in the body
+|GET_BY_ID |index id of content to retrieve |Retrieves the specified index and returns a GetResult object in the body
+
+|DELETE |index name and type of content to delete |Deletes the specified indexName and indexType and returns a DeleteResponse object in the
+body
-|DELETE |index id of content to delete |deletes the specified indexId and returns a DeleteResult object in the
+|DELETE_INDEX |index name of content to delete |Deletes the specified indexName and returns a DeleteIndexResponse object in the
body
|BULK_INDEX | a�*List*�or *Collection* of any type that is already accepted
@@ -106,7 +99,7 @@ MultigetRequest and returns a MultigetResponse object in the body
|MULTISEARCH |List of SearchRequest object |Search for parameters specified in MultiSearchRequest and
returns a MultiSearchResponse object in the body
-|EXISTS |Index name as header |Returns a Boolean object in the body
+|EXISTS |Index name as header |Checks the index exists or not and returns a Boolean flag in the body
|UPDATE |Map, String, byte[] or XContentBuilder content to update |Updates content to an index and returns the content's
indexId in the body.
http://git-wip-us.apache.org/repos/asf/camel/blob/659255cf/components/camel-elasticsearch5/src/main/java/org/apache/camel/component/elasticsearch5/ElasticsearchComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-elasticsearch5/src/main/java/org/apache/camel/component/elasticsearch5/ElasticsearchComponent.java b/components/camel-elasticsearch5/src/main/java/org/apache/camel/component/elasticsearch5/ElasticsearchComponent.java
index 1205519..cb3cd6c 100644
--- a/components/camel-elasticsearch5/src/main/java/org/apache/camel/component/elasticsearch5/ElasticsearchComponent.java
+++ b/components/camel-elasticsearch5/src/main/java/org/apache/camel/component/elasticsearch5/ElasticsearchComponent.java
@@ -35,9 +35,6 @@ import org.elasticsearch.common.transport.InetSocketTransportAddress;
*/
public class ElasticsearchComponent extends UriEndpointComponent {
- @Metadata(label = "advanced")
- private TransportClient client;
-
public ElasticsearchComponent() {
super(ElasticsearchEndpoint.class);
}
@@ -53,7 +50,7 @@ public class ElasticsearchComponent extends UriEndpointComponent {
config.setTransportAddressesList(parseTransportAddresses(config.getTransportAddresses(), config));
- Endpoint endpoint = new ElasticsearchEndpoint(uri, this, config, client);
+ Endpoint endpoint = new ElasticsearchEndpoint(uri, this, config);
return endpoint;
}
@@ -76,15 +73,4 @@ public class ElasticsearchComponent extends UriEndpointComponent {
}
return addressesTrAd;
}
-
- public TransportClient getClient() {
- return client;
- }
-
- /**
- * To use an existing configured Elasticsearch client, instead of creating a client per endpoint.
- */
- public void setClient(TransportClient client) {
- this.client = client;
- }
-}
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/659255cf/components/camel-elasticsearch5/src/main/java/org/apache/camel/component/elasticsearch5/ElasticsearchConfiguration.java
----------------------------------------------------------------------
diff --git a/components/camel-elasticsearch5/src/main/java/org/apache/camel/component/elasticsearch5/ElasticsearchConfiguration.java b/components/camel-elasticsearch5/src/main/java/org/apache/camel/component/elasticsearch5/ElasticsearchConfiguration.java
index 308ee83..ca09954 100644
--- a/components/camel-elasticsearch5/src/main/java/org/apache/camel/component/elasticsearch5/ElasticsearchConfiguration.java
+++ b/components/camel-elasticsearch5/src/main/java/org/apache/camel/component/elasticsearch5/ElasticsearchConfiguration.java
@@ -31,19 +31,19 @@ public class ElasticsearchConfiguration {
@UriPath @Metadata(required = "true")
private String clusterName;
- @UriParam(enums = "INDEX, UPDATE, BULK, BULK_INDEX, GET_BY_ID, MULTIGET, DELETE, EXISTS, SEARCH, MULTISEARCH, DELETE_INDEX")
- private String operation;
+ @UriParam
+ private ElasticsearchOperation operation;
@UriParam
private String indexName;
@UriParam
private String indexType;
- @UriParam
+ @UriParam(defaultValue = "" + ElasticsearchConstants.DEFAULT_FOR_WAIT_ACTIVE_SHARDS)
private int waitForActiveShards = ElasticsearchConstants.DEFAULT_FOR_WAIT_ACTIVE_SHARDS;
@UriParam
private String ip;
@UriParam
private String transportAddresses;
- @UriParam
+ @UriParam(defaultValue = "" + ElasticsearchConstants.DEFAULT_PORT)
private int port = ElasticsearchConstants.DEFAULT_PORT;
@UriParam(defaultValue = "true")
private Boolean clientTransportSniff = true;
@@ -62,11 +62,11 @@ public class ElasticsearchConfiguration {
/**
* What operation to perform
*/
- public String getOperation() {
+ public ElasticsearchOperation getOperation() {
return operation;
}
- public void setOperation(String operation) {
+ public void setOperation(ElasticsearchOperation operation) {
this.operation = operation;
}
http://git-wip-us.apache.org/repos/asf/camel/blob/659255cf/components/camel-elasticsearch5/src/main/java/org/apache/camel/component/elasticsearch5/ElasticsearchConstants.java
----------------------------------------------------------------------
diff --git a/components/camel-elasticsearch5/src/main/java/org/apache/camel/component/elasticsearch5/ElasticsearchConstants.java b/components/camel-elasticsearch5/src/main/java/org/apache/camel/component/elasticsearch5/ElasticsearchConstants.java
index ab30a85..6c31173 100644
--- a/components/camel-elasticsearch5/src/main/java/org/apache/camel/component/elasticsearch5/ElasticsearchConstants.java
+++ b/components/camel-elasticsearch5/src/main/java/org/apache/camel/component/elasticsearch5/ElasticsearchConstants.java
@@ -21,17 +21,6 @@ package org.apache.camel.component.elasticsearch5;
public interface ElasticsearchConstants {
String PARAM_OPERATION = "operation";
- String OPERATION_INDEX = "INDEX";
- String OPERATION_UPDATE = "UPDATE";
- String OPERATION_BULK = "BULK";
- String OPERATION_BULK_INDEX = "BULK_INDEX";
- String OPERATION_GET_BY_ID = "GET_BY_ID";
- String OPERATION_MULTIGET = "MULTIGET";
- String OPERATION_DELETE = "DELETE";
- String OPERATION_DELETE_INDEX = "DELETE_INDEX";
- String OPERATION_SEARCH = "SEARCH";
- String OPERATION_MULTISEARCH = "MULTISEARCH";
- String OPERATION_EXISTS = "EXISTS";
String PARAM_INDEX_ID = "indexId";
String PARAM_INDEX_NAME = "indexName";
String PARAM_INDEX_TYPE = "indexType";
@@ -41,8 +30,8 @@ public interface ElasticsearchConstants {
String PROTOCOL = "elasticsearch";
String IP = "ip";
String PORT = "port";
- Integer DEFAULT_PORT = 9300;
- Integer DEFAULT_FOR_WAIT_ACTIVE_SHARDS = 1; // Meaning only wait for the primary shard
+ int DEFAULT_PORT = 9300;
+ int DEFAULT_FOR_WAIT_ACTIVE_SHARDS = 1; // Meaning only wait for the primary shard
String TRANSPORT_ADDRESSES_SEPARATOR_REGEX = ",";
String IP_PORT_SEPARATOR_REGEX = ":";
String ES_QUERY_DSL_PREFIX = "query";
http://git-wip-us.apache.org/repos/asf/camel/blob/659255cf/components/camel-elasticsearch5/src/main/java/org/apache/camel/component/elasticsearch5/ElasticsearchEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-elasticsearch5/src/main/java/org/apache/camel/component/elasticsearch5/ElasticsearchEndpoint.java b/components/camel-elasticsearch5/src/main/java/org/apache/camel/component/elasticsearch5/ElasticsearchEndpoint.java
index f9aad84..f71bca2 100644
--- a/components/camel-elasticsearch5/src/main/java/org/apache/camel/component/elasticsearch5/ElasticsearchEndpoint.java
+++ b/components/camel-elasticsearch5/src/main/java/org/apache/camel/component/elasticsearch5/ElasticsearchEndpoint.java
@@ -16,21 +16,12 @@
*/
package org.apache.camel.component.elasticsearch5;
-import java.net.InetAddress;
-import java.util.ArrayList;
-import java.util.List;
-
import org.apache.camel.Consumer;
import org.apache.camel.Processor;
import org.apache.camel.Producer;
import org.apache.camel.impl.DefaultEndpoint;
import org.apache.camel.spi.UriEndpoint;
import org.apache.camel.spi.UriParam;
-import org.elasticsearch.client.transport.TransportClient;
-import org.elasticsearch.common.settings.Settings;
-import org.elasticsearch.common.transport.InetSocketTransportAddress;
-import org.elasticsearch.common.transport.TransportAddress;
-import org.elasticsearch.transport.client.PreBuiltTransportClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -42,18 +33,16 @@ public class ElasticsearchEndpoint extends DefaultEndpoint {
private static final Logger LOG = LoggerFactory.getLogger(ElasticsearchEndpoint.class);
- private TransportClient client;
@UriParam
- private ElasticsearchConfiguration configuration;
+ protected final ElasticsearchConfiguration configuration;
- public ElasticsearchEndpoint(String uri, ElasticsearchComponent component, ElasticsearchConfiguration config, TransportClient client) throws Exception {
+ public ElasticsearchEndpoint(String uri, ElasticsearchComponent component, ElasticsearchConfiguration config) throws Exception {
super(uri, component);
this.configuration = config;
- this.client = client;
}
public Producer createProducer() throws Exception {
- return new ElasticsearchProducer(this);
+ return new ElasticsearchProducer(this, configuration);
}
public Consumer createConsumer(Processor processor) throws Exception {
@@ -61,60 +50,6 @@ public class ElasticsearchEndpoint extends DefaultEndpoint {
}
public boolean isSingleton() {
- return false;
- }
-
- @Override
- @SuppressWarnings("unchecked")
- protected void doStart() throws Exception {
- super.doStart();
-
- if (client == null) {
- LOG.info("Connecting to the ElasticSearch cluster: " + configuration.getClusterName());
-
- if (configuration.getIp() != null) {
- client = new PreBuiltTransportClient(getSettings())
- .addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName(configuration.getIp()), configuration.getPort()));
- } else if (configuration.getTransportAddressesList() != null
- && !configuration.getTransportAddressesList().isEmpty()) {
- List<TransportAddress> addresses = new ArrayList<TransportAddress>(configuration.getTransportAddressesList().size());
- for (TransportAddress address : configuration.getTransportAddressesList()) {
- addresses.add(address);
- }
- client = new PreBuiltTransportClient(getSettings()).addTransportAddresses(addresses.toArray(new TransportAddress[addresses.size()]));
- } else {
- LOG.info("Incorrect ip address and port parameters settings for ElasticSearch cluster");
- }
- }
- }
-
- private Settings getSettings() {
- return Settings.builder()
- .put("cluster.name", configuration.getClusterName())
- .put("client.transport.ignore_cluster_name", false)
- .put("client.transport.sniff", configuration.getClientTransportSniff())
- .build();
- }
-
- @Override
- protected void doStop() throws Exception {
- if (client != null) {
- LOG.info("Disconnecting from ElasticSearch cluster: " + configuration.getClusterName());
- client.close();
- client = null;
- }
- super.doStop();
- }
-
- public TransportClient getClient() {
- return client;
- }
-
- public ElasticsearchConfiguration getConfig() {
- return configuration;
- }
-
- public void setOperation(String operation) {
- configuration.setOperation(operation);
+ return true;
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/659255cf/components/camel-elasticsearch5/src/main/java/org/apache/camel/component/elasticsearch5/ElasticsearchOperation.java
----------------------------------------------------------------------
diff --git a/components/camel-elasticsearch5/src/main/java/org/apache/camel/component/elasticsearch5/ElasticsearchOperation.java b/components/camel-elasticsearch5/src/main/java/org/apache/camel/component/elasticsearch5/ElasticsearchOperation.java
new file mode 100644
index 0000000..509b30a
--- /dev/null
+++ b/components/camel-elasticsearch5/src/main/java/org/apache/camel/component/elasticsearch5/ElasticsearchOperation.java
@@ -0,0 +1,58 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.elasticsearch5;
+
+/**
+ * The ElasticSearch server operations list which are implemented
+ *
+ * INDEX - Index a document associated with a given index and type
+ * UPDATE - Updates a document based on a script
+ * BULK - Executes a bulk of index / delete operations
+ * BULK_INDEX - Executes a bulk of index / delete operations
+ * GET_BY_ID - Gets the document that was indexed from an index with a type and id
+ * MULTIGET - Multiple get documents
+ * DELETE - Deletes a document from the index based on the index, type and id
+ * DELETE_INDEX - Deletes an index based on the index name
+ * SEARCH - Search across one or more indices and one or more types with a query
+ * MULTISEARCH - Performs multiple search requests
+ * EXISTS - Checks the index exists or not (using search with size=0 and terminate_after=1 parameters)
+ *
+ */
+public enum ElasticsearchOperation {
+ INDEX("INDEX"),
+ UPDATE("UPDATE"),
+ BULK("BULK"),
+ BULK_INDEX("BULK_INDEX"),
+ GET_BY_ID("GET_BY_ID"),
+ MULTIGET("MULTIGET"),
+ DELETE("DELETE"),
+ DELETE_INDEX("DELETE_INDEX"),
+ SEARCH("SEARCH"),
+ MULTISEARCH("MULTISEARCH"),
+ EXISTS("EXISTS");
+
+ private final String text;
+
+ ElasticsearchOperation(final String text) {
+ this.text = text;
+ }
+
+ @Override
+ public String toString() {
+ return text;
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/659255cf/components/camel-elasticsearch5/src/main/java/org/apache/camel/component/elasticsearch5/ElasticsearchProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-elasticsearch5/src/main/java/org/apache/camel/component/elasticsearch5/ElasticsearchProducer.java b/components/camel-elasticsearch5/src/main/java/org/apache/camel/component/elasticsearch5/ElasticsearchProducer.java
index c63aebf..c0aaff9 100644
--- a/components/camel-elasticsearch5/src/main/java/org/apache/camel/component/elasticsearch5/ElasticsearchProducer.java
+++ b/components/camel-elasticsearch5/src/main/java/org/apache/camel/component/elasticsearch5/ElasticsearchProducer.java
@@ -16,6 +16,7 @@
*/
package org.apache.camel.component.elasticsearch5;
+import java.net.InetAddress;
import java.util.ArrayList;
import java.util.List;
@@ -33,23 +34,30 @@ import org.elasticsearch.action.search.MultiSearchRequest;
import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.action.update.UpdateRequest;
import org.elasticsearch.client.transport.TransportClient;
+import org.elasticsearch.common.settings.Settings;
+import org.elasticsearch.common.transport.InetSocketTransportAddress;
+import org.elasticsearch.common.transport.TransportAddress;
import org.elasticsearch.index.IndexNotFoundException;
+import org.elasticsearch.transport.client.PreBuiltTransportClient;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Represents an Elasticsearch producer.
*/
public class ElasticsearchProducer extends DefaultProducer {
-
- public ElasticsearchProducer(ElasticsearchEndpoint endpoint) {
+
+ private static final Logger LOG = LoggerFactory.getLogger(ElasticsearchProducer.class);
+
+ protected final ElasticsearchConfiguration configuration;
+ private TransportClient client;
+
+ public ElasticsearchProducer(ElasticsearchEndpoint endpoint, ElasticsearchConfiguration configuration) {
super(endpoint);
+ this.configuration = configuration;
}
- @Override
- public ElasticsearchEndpoint getEndpoint() {
- return (ElasticsearchEndpoint) super.getEndpoint();
- }
-
- private String resolveOperation(Exchange exchange) {
+ private ElasticsearchOperation resolveOperation(Exchange exchange) {
// 1. Operation can be driven by either (in order of preference):
// a. If the body is an ActionRequest the operation is set by the type
// of request.
@@ -61,35 +69,33 @@ public class ElasticsearchProducer extends DefaultProducer {
// an error.
Object request = exchange.getIn().getBody();
if (request instanceof IndexRequest) {
- return ElasticsearchConstants.OPERATION_INDEX;
+ return ElasticsearchOperation.INDEX;
} else if (request instanceof GetRequest) {
- return ElasticsearchConstants.OPERATION_GET_BY_ID;
+ return ElasticsearchOperation.GET_BY_ID;
} else if (request instanceof MultiGetRequest) {
- return ElasticsearchConstants.OPERATION_MULTIGET;
+ return ElasticsearchOperation.MULTIGET;
} else if (request instanceof UpdateRequest) {
- return ElasticsearchConstants.OPERATION_UPDATE;
+ return ElasticsearchOperation.UPDATE;
} else if (request instanceof BulkRequest) {
// do we want bulk or bulk_index?
- if (ElasticsearchConstants.OPERATION_BULK_INDEX.equals(getEndpoint().getConfig().getOperation())) {
- return ElasticsearchConstants.OPERATION_BULK_INDEX;
+ if (configuration.getOperation() == ElasticsearchOperation.BULK_INDEX) {
+ return configuration.getOperation().BULK_INDEX;
} else {
- return ElasticsearchConstants.OPERATION_BULK;
+ return configuration.getOperation().BULK;
}
} else if (request instanceof DeleteRequest) {
- return ElasticsearchConstants.OPERATION_DELETE;
+ return ElasticsearchOperation.DELETE;
} else if (request instanceof SearchRequest) {
- return ElasticsearchConstants.OPERATION_EXISTS;
- } else if (request instanceof SearchRequest) {
- return ElasticsearchConstants.OPERATION_SEARCH;
+ return ElasticsearchOperation.SEARCH;
} else if (request instanceof MultiSearchRequest) {
- return ElasticsearchConstants.OPERATION_MULTISEARCH;
+ return ElasticsearchOperation.MULTISEARCH;
} else if (request instanceof DeleteIndexRequest) {
- return ElasticsearchConstants.OPERATION_DELETE_INDEX;
+ return ElasticsearchOperation.DELETE_INDEX;
}
- String operationConfig = exchange.getIn().getHeader(ElasticsearchConstants.PARAM_OPERATION, String.class);
+ ElasticsearchOperation operationConfig = exchange.getIn().getHeader(ElasticsearchConstants.PARAM_OPERATION, ElasticsearchOperation.class);
if (operationConfig == null) {
- operationConfig = getEndpoint().getConfig().getOperation();
+ operationConfig = configuration.getOperation();
}
if (operationConfig == null) {
throw new IllegalArgumentException(ElasticsearchConstants.PARAM_OPERATION + " value '" + operationConfig + "' is not supported");
@@ -109,58 +115,57 @@ public class ElasticsearchProducer extends DefaultProducer {
// will throw.
Message message = exchange.getIn();
- final String operation = resolveOperation(exchange);
+ final ElasticsearchOperation operation = resolveOperation(exchange);
// Set the index/type headers on the exchange if necessary. This is used
// for type conversion.
boolean configIndexName = false;
String indexName = message.getHeader(ElasticsearchConstants.PARAM_INDEX_NAME, String.class);
if (indexName == null) {
- message.setHeader(ElasticsearchConstants.PARAM_INDEX_NAME, getEndpoint().getConfig().getIndexName());
+ message.setHeader(ElasticsearchConstants.PARAM_INDEX_NAME, configuration.getIndexName());
configIndexName = true;
}
boolean configIndexType = false;
String indexType = message.getHeader(ElasticsearchConstants.PARAM_INDEX_TYPE, String.class);
if (indexType == null) {
- message.setHeader(ElasticsearchConstants.PARAM_INDEX_TYPE, getEndpoint().getConfig().getIndexType());
+ message.setHeader(ElasticsearchConstants.PARAM_INDEX_TYPE, configuration.getIndexType());
configIndexType = true;
}
boolean configWaitForActiveShards = false;
Integer waitForActiveShards = message.getHeader(ElasticsearchConstants.PARAM_WAIT_FOR_ACTIVE_SHARDS, Integer.class);
if (waitForActiveShards == null) {
- message.setHeader(ElasticsearchConstants.PARAM_WAIT_FOR_ACTIVE_SHARDS, getEndpoint().getConfig().getWaitForActiveShards());
+ message.setHeader(ElasticsearchConstants.PARAM_WAIT_FOR_ACTIVE_SHARDS, configuration.getWaitForActiveShards());
configWaitForActiveShards = true;
}
- TransportClient client = getEndpoint().getClient();
- if (ElasticsearchConstants.OPERATION_INDEX.equals(operation)) {
+ if (operation == ElasticsearchOperation.INDEX) {
IndexRequest indexRequest = message.getBody(IndexRequest.class);
message.setBody(client.index(indexRequest).actionGet().getId());
- } else if (ElasticsearchConstants.OPERATION_UPDATE.equals(operation)) {
+ } else if (operation == ElasticsearchOperation.UPDATE) {
UpdateRequest updateRequest = message.getBody(UpdateRequest.class);
message.setBody(client.update(updateRequest).actionGet().getId());
- } else if (ElasticsearchConstants.OPERATION_GET_BY_ID.equals(operation)) {
+ } else if (operation == ElasticsearchOperation.GET_BY_ID) {
GetRequest getRequest = message.getBody(GetRequest.class);
message.setBody(client.get(getRequest));
- } else if (ElasticsearchConstants.OPERATION_MULTIGET.equals(operation)) {
+ } else if (operation == ElasticsearchOperation.MULTIGET) {
MultiGetRequest multiGetRequest = message.getBody(MultiGetRequest.class);
message.setBody(client.multiGet(multiGetRequest));
- } else if (ElasticsearchConstants.OPERATION_BULK.equals(operation)) {
+ } else if (operation == ElasticsearchOperation.BULK) {
BulkRequest bulkRequest = message.getBody(BulkRequest.class);
message.setBody(client.bulk(bulkRequest).actionGet());
- } else if (ElasticsearchConstants.OPERATION_BULK_INDEX.equals(operation)) {
+ } else if (operation == ElasticsearchOperation.BULK_INDEX) {
BulkRequest bulkRequest = message.getBody(BulkRequest.class);
List<String> indexedIds = new ArrayList<String>();
for (BulkItemResponse response : client.bulk(bulkRequest).actionGet().getItems()) {
indexedIds.add(response.getId());
}
message.setBody(indexedIds);
- } else if (ElasticsearchConstants.OPERATION_DELETE.equals(operation)) {
+ } else if (operation == ElasticsearchOperation.DELETE) {
DeleteRequest deleteRequest = message.getBody(DeleteRequest.class);
message.setBody(client.delete(deleteRequest).actionGet());
- } else if (ElasticsearchConstants.OPERATION_EXISTS.equals(operation)) {
+ } else if (operation == ElasticsearchOperation.EXISTS) {
// ExistsRequest API is deprecated, using SearchRequest instead with size=0 and terminate_after=1
SearchRequest searchRequest = new SearchRequest(exchange.getIn().getHeader(ElasticsearchConstants.PARAM_INDEX_NAME, String.class));
try {
@@ -169,13 +174,13 @@ public class ElasticsearchProducer extends DefaultProducer {
} catch (IndexNotFoundException e) {
message.setBody(false);
}
- } else if (ElasticsearchConstants.OPERATION_SEARCH.equals(operation)) {
+ } else if (operation == ElasticsearchOperation.SEARCH) {
SearchRequest searchRequest = message.getBody(SearchRequest.class);
message.setBody(client.search(searchRequest).actionGet());
- } else if (ElasticsearchConstants.OPERATION_MULTISEARCH.equals(operation)) {
+ } else if (operation == ElasticsearchOperation.MULTISEARCH) {
MultiSearchRequest multiSearchRequest = message.getBody(MultiSearchRequest.class);
message.setBody(client.multiSearch(multiSearchRequest));
- } else if (ElasticsearchConstants.OPERATION_DELETE_INDEX.equals(operation)) {
+ } else if (operation == ElasticsearchOperation.DELETE_INDEX) {
DeleteIndexRequest deleteIndexRequest = message.getBody(DeleteIndexRequest.class);
message.setBody(client.admin().indices().delete(deleteIndexRequest).actionGet());
} else {
@@ -203,4 +208,46 @@ public class ElasticsearchProducer extends DefaultProducer {
}
}
+
+ @Override
+ @SuppressWarnings("unchecked")
+ protected void doStart() throws Exception {
+ super.doStart();
+
+ if (client == null) {
+ LOG.info("Connecting to the ElasticSearch cluster: " + configuration.getClusterName());
+
+ if (configuration.getIp() != null) {
+ client = new PreBuiltTransportClient(getSettings())
+ .addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName(configuration.getIp()), configuration.getPort()));
+ } else if (configuration.getTransportAddressesList() != null
+ && !configuration.getTransportAddressesList().isEmpty()) {
+ List<TransportAddress> addresses = new ArrayList<TransportAddress>(configuration.getTransportAddressesList().size());
+ for (TransportAddress address : configuration.getTransportAddressesList()) {
+ addresses.add(address);
+ }
+ client = new PreBuiltTransportClient(getSettings()).addTransportAddresses(addresses.toArray(new TransportAddress[addresses.size()]));
+ } else {
+ LOG.info("Incorrect ip address and port parameters settings for ElasticSearch cluster");
+ }
+ }
+ }
+
+ private Settings getSettings() {
+ return Settings.builder()
+ .put("cluster.name", configuration.getClusterName())
+ .put("client.transport.ignore_cluster_name", false)
+ .put("client.transport.sniff", configuration.getClientTransportSniff())
+ .build();
+ }
+
+ @Override
+ protected void doStop() throws Exception {
+ if (client != null) {
+ LOG.info("Disconnecting from ElasticSearch cluster: " + configuration.getClusterName());
+ client.close();
+ client = null;
+ }
+ super.doStop();
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/659255cf/components/camel-elasticsearch5/src/test/java/org/apache/camel/component/elasticsearch5/ElasticsearchBaseTest.java
----------------------------------------------------------------------
diff --git a/components/camel-elasticsearch5/src/test/java/org/apache/camel/component/elasticsearch5/ElasticsearchBaseTest.java b/components/camel-elasticsearch5/src/test/java/org/apache/camel/component/elasticsearch5/ElasticsearchBaseTest.java
index a6e5ab9..e70b22b 100644
--- a/components/camel-elasticsearch5/src/test/java/org/apache/camel/component/elasticsearch5/ElasticsearchBaseTest.java
+++ b/components/camel-elasticsearch5/src/test/java/org/apache/camel/component/elasticsearch5/ElasticsearchBaseTest.java
@@ -49,12 +49,14 @@ public class ElasticsearchBaseTest extends CamelTestSupport {
}
@BeforeClass
- public static void cleanupOnce() throws NodeValidationException {
+ public static void cleanupOnce() throws Exception {
deleteDirectory("target/data");
// create an embedded node to resume
node = new PluginConfigurableNode(Settings.builder().put("http.enabled", true).put("path.data", "target/data")
.put("path.home", "target/home").build(), Arrays.asList(Netty4Plugin.class)).start();
+ client = new PreBuiltTransportClient(Settings.EMPTY)
+ .addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("localhost"), 9300));
}
@AfterClass
@@ -76,14 +78,6 @@ public class ElasticsearchBaseTest extends CamelTestSupport {
@Override
protected CamelContext createCamelContext() throws Exception {
CamelContext context = super.createCamelContext();
-
- // reuse existing client
- ElasticsearchComponent es = context.getComponent("elasticsearch5", ElasticsearchComponent.class);
-
- client = new PreBuiltTransportClient(Settings.EMPTY)
- .addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("localhost"), 9300));
- es.setClient(client);
-
return context;
}
http://git-wip-us.apache.org/repos/asf/camel/blob/659255cf/components/camel-elasticsearch5/src/test/java/org/apache/camel/component/elasticsearch5/ElasticsearchBulkTest.java
----------------------------------------------------------------------
diff --git a/components/camel-elasticsearch5/src/test/java/org/apache/camel/component/elasticsearch5/ElasticsearchBulkTest.java b/components/camel-elasticsearch5/src/test/java/org/apache/camel/component/elasticsearch5/ElasticsearchBulkTest.java
index 8c6c3f3..61a0984 100644
--- a/components/camel-elasticsearch5/src/test/java/org/apache/camel/component/elasticsearch5/ElasticsearchBulkTest.java
+++ b/components/camel-elasticsearch5/src/test/java/org/apache/camel/component/elasticsearch5/ElasticsearchBulkTest.java
@@ -87,8 +87,8 @@ public class ElasticsearchBulkTest extends ElasticsearchBaseTest {
return new RouteBuilder() {
@Override
public void configure() {
- from("direct:bulk_index").to("elasticsearch5://elasticsearch?operation=BULK_INDEX&indexName=twitter&indexType=tweet");
- from("direct:bulk").to("elasticsearch5://elasticsearch?operation=BULK&indexName=twitter&indexType=tweet");
+ from("direct:bulk_index").to("elasticsearch5://elasticsearch?operation=BULK_INDEX&indexName=twitter&indexType=tweet&ip=localhost&port=9300");
+ from("direct:bulk").to("elasticsearch5://elasticsearch?operation=BULK&indexName=twitter&indexType=tweet&ip=localhost&port=9300");
}
};
}
http://git-wip-us.apache.org/repos/asf/camel/blob/659255cf/components/camel-elasticsearch5/src/test/java/org/apache/camel/component/elasticsearch5/ElasticsearchClusterBaseTest.java
----------------------------------------------------------------------
diff --git a/components/camel-elasticsearch5/src/test/java/org/apache/camel/component/elasticsearch5/ElasticsearchClusterBaseTest.java b/components/camel-elasticsearch5/src/test/java/org/apache/camel/component/elasticsearch5/ElasticsearchClusterBaseTest.java
index a5dd5d3..2f856ad 100644
--- a/components/camel-elasticsearch5/src/test/java/org/apache/camel/component/elasticsearch5/ElasticsearchClusterBaseTest.java
+++ b/components/camel-elasticsearch5/src/test/java/org/apache/camel/component/elasticsearch5/ElasticsearchClusterBaseTest.java
@@ -94,17 +94,6 @@ public class ElasticsearchClusterBaseTest extends CamelTestSupport {
return true;
}
- @Override
- protected CamelContext createCamelContext() throws Exception {
- CamelContext context = super.createCamelContext();
-
- // reuse existing client
- ElasticsearchComponent es = context.getComponent("elasticsearch5", ElasticsearchComponent.class);
- es.setClient(client);
-
- return context;
- }
-
/**
* As we don't delete the {@code target/data} folder for <b>each</b> test
* below (otherwise they would run much slower), we need to make sure
http://git-wip-us.apache.org/repos/asf/camel/blob/659255cf/components/camel-elasticsearch5/src/test/java/org/apache/camel/component/elasticsearch5/ElasticsearchClusterIndexTest.java
----------------------------------------------------------------------
diff --git a/components/camel-elasticsearch5/src/test/java/org/apache/camel/component/elasticsearch5/ElasticsearchClusterIndexTest.java b/components/camel-elasticsearch5/src/test/java/org/apache/camel/component/elasticsearch5/ElasticsearchClusterIndexTest.java
index 81ca789..f7347d1 100644
--- a/components/camel-elasticsearch5/src/test/java/org/apache/camel/component/elasticsearch5/ElasticsearchClusterIndexTest.java
+++ b/components/camel-elasticsearch5/src/test/java/org/apache/camel/component/elasticsearch5/ElasticsearchClusterIndexTest.java
@@ -25,26 +25,26 @@ import org.junit.Test;
public class ElasticsearchClusterIndexTest extends ElasticsearchClusterBaseTest {
@Test
- public void indexWithIp() throws Exception {
+ public void indexWithIpAndPort() throws Exception {
Map<String, String> map = createIndexedData();
Map<String, Object> headers = new HashMap<String, Object>();
- headers.put(ElasticsearchConstants.PARAM_OPERATION, ElasticsearchConstants.OPERATION_INDEX);
+ headers.put(ElasticsearchConstants.PARAM_OPERATION, ElasticsearchOperation.INDEX);
headers.put(ElasticsearchConstants.PARAM_INDEX_NAME, "twitter");
headers.put(ElasticsearchConstants.PARAM_INDEX_TYPE, "tweet");
headers.put(ElasticsearchConstants.PARAM_INDEX_ID, "1");
- String indexId = template.requestBodyAndHeaders("direct:indexWithIp", map, headers, String.class);
+ String indexId = template.requestBodyAndHeaders("direct:indexWithIpAndPort", map, headers, String.class);
assertNotNull("indexId should be set", indexId);
headers.clear();
- headers.put(ElasticsearchConstants.PARAM_OPERATION, ElasticsearchConstants.OPERATION_INDEX);
+ headers.put(ElasticsearchConstants.PARAM_OPERATION, ElasticsearchOperation.INDEX);
headers.put(ElasticsearchConstants.PARAM_INDEX_NAME, "twitter");
headers.put(ElasticsearchConstants.PARAM_INDEX_TYPE, "status");
headers.put(ElasticsearchConstants.PARAM_INDEX_ID, "2");
- indexId = template.requestBodyAndHeaders("direct:indexWithIp", map, headers, String.class);
+ indexId = template.requestBodyAndHeaders("direct:indexWithIpAndPort", map, headers, String.class);
assertNotNull("indexId should be set", indexId);
assertEquals("Cluster must be of three nodes", runner.getNodeSize(), 3);
@@ -53,26 +53,10 @@ public class ElasticsearchClusterIndexTest extends ElasticsearchClusterBaseTest
}
@Test
- public void indexWithIpAndPort() throws Exception {
- Map<String, String> map = createIndexedData();
- Map<String, Object> headers = new HashMap<String, Object>();
- headers.put(ElasticsearchConstants.PARAM_OPERATION, ElasticsearchConstants.OPERATION_INDEX);
- headers.put(ElasticsearchConstants.PARAM_INDEX_NAME, "instagram");
- headers.put(ElasticsearchConstants.PARAM_INDEX_TYPE, "photo");
- headers.put(ElasticsearchConstants.PARAM_INDEX_ID, "3");
-
- String indexId = template.requestBodyAndHeaders("direct:indexWithIpAndPort", map, headers, String.class);
- assertNotNull("indexId should be set", indexId);
-
- assertEquals("Cluster must be of three nodes", runner.getNodeSize(), 3);
- assertEquals("Index id 3 must exists", true, client.prepareGet("instagram", "photo", "3").get().isExists());
- }
-
- @Test
public void indexWithTransportAddresses() throws Exception {
Map<String, String> map = createIndexedData();
Map<String, Object> headers = new HashMap<String, Object>();
- headers.put(ElasticsearchConstants.PARAM_OPERATION, ElasticsearchConstants.OPERATION_INDEX);
+ headers.put(ElasticsearchConstants.PARAM_OPERATION, ElasticsearchOperation.INDEX);
headers.put(ElasticsearchConstants.PARAM_INDEX_NAME, "facebook");
headers.put(ElasticsearchConstants.PARAM_INDEX_TYPE, "post");
headers.put(ElasticsearchConstants.PARAM_INDEX_ID, "4");
@@ -88,7 +72,7 @@ public class ElasticsearchClusterIndexTest extends ElasticsearchClusterBaseTest
public void indexWithIpAndTransportAddresses() throws Exception {
Map<String, String> map = createIndexedData();
Map<String, Object> headers = new HashMap<String, Object>();
- headers.put(ElasticsearchConstants.PARAM_OPERATION, ElasticsearchConstants.OPERATION_INDEX);
+ headers.put(ElasticsearchConstants.PARAM_OPERATION, ElasticsearchOperation.INDEX);
headers.put(ElasticsearchConstants.PARAM_INDEX_NAME, "ebay");
headers.put(ElasticsearchConstants.PARAM_INDEX_TYPE, "search");
headers.put(ElasticsearchConstants.PARAM_INDEX_ID, "5");
@@ -106,12 +90,11 @@ public class ElasticsearchClusterIndexTest extends ElasticsearchClusterBaseTest
return new RouteBuilder() {
@Override
public void configure() {
- from("direct:indexWithIp").to("elasticsearch5://elasticsearch?operation=INDEX&indexName=twitter&indexType=tweet&port=9301");
- from("direct:indexWithIpAndPort").to("elasticsearch5://elasticsearch?operation=INDEX&indexName=twitter&indexType=tweet&ip=localhost&port=9301");
- from("direct:indexWithTransportAddresses").to("elasticsearch5://elasticsearch?operation=INDEX&indexName=twitter&indexType=tweet&transportAddresses=localhost:9301");
+ from("direct:indexWithIpAndPort").to("elasticsearch5://" + clusterName + "?operation=INDEX&indexName=twitter&indexType=tweet&ip=localhost&port=9301");
+ from("direct:indexWithTransportAddresses").to("elasticsearch5://" + clusterName + "?operation=INDEX&indexName=twitter&indexType=tweet&transportAddresses=localhost:9301");
from("direct:indexWithIpAndTransportAddresses").
- to("elasticsearch5://elasticsearch?operation=INDEX&indexName=twitter&indexType=tweet&ip=localhost&port=9301&transportAddresses=localhost:4444,localhost:5555");
+ to("elasticsearch5://" + clusterName + "?operation=INDEX&indexName=twitter&indexType=tweet&ip=localhost&port=9301&transportAddresses=localhost:4444,localhost:5555");
}
};
}
-}
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/659255cf/components/camel-elasticsearch5/src/test/java/org/apache/camel/component/elasticsearch5/ElasticsearchGetSearchDeleteExistsUpdateTest.java
----------------------------------------------------------------------
diff --git a/components/camel-elasticsearch5/src/test/java/org/apache/camel/component/elasticsearch5/ElasticsearchGetSearchDeleteExistsUpdateTest.java b/components/camel-elasticsearch5/src/test/java/org/apache/camel/component/elasticsearch5/ElasticsearchGetSearchDeleteExistsUpdateTest.java
index 782929d..06e5df8 100644
--- a/components/camel-elasticsearch5/src/test/java/org/apache/camel/component/elasticsearch5/ElasticsearchGetSearchDeleteExistsUpdateTest.java
+++ b/components/camel-elasticsearch5/src/test/java/org/apache/camel/component/elasticsearch5/ElasticsearchGetSearchDeleteExistsUpdateTest.java
@@ -129,14 +129,14 @@ public class ElasticsearchGetSearchDeleteExistsUpdateTest extends ElasticsearchB
//first, INDEX a value
Map<String, String> map = createIndexedData();
Map<String, Object> headers = new HashMap<String, Object>();
- headers.put(ElasticsearchConstants.PARAM_OPERATION, ElasticsearchConstants.OPERATION_INDEX);
+ headers.put(ElasticsearchConstants.PARAM_OPERATION, ElasticsearchOperation.INDEX);
headers.put(ElasticsearchConstants.PARAM_INDEX_NAME, "twitter");
headers.put(ElasticsearchConstants.PARAM_INDEX_TYPE, "tweet");
String indexId = template.requestBodyAndHeaders("direct:start", map, headers, String.class);
//now, verify GET
- headers.put(ElasticsearchConstants.PARAM_OPERATION, ElasticsearchConstants.OPERATION_GET_BY_ID);
+ headers.put(ElasticsearchConstants.PARAM_OPERATION, ElasticsearchOperation.GET_BY_ID);
GetResponse response = template.requestBodyAndHeaders("direct:start", indexId, headers, GetResponse.class);
assertNotNull("response should not be null", response);
assertNotNull("response source should not be null", response.getSource());
@@ -147,14 +147,14 @@ public class ElasticsearchGetSearchDeleteExistsUpdateTest extends ElasticsearchB
//first, INDEX a value
Map<String, String> map = createIndexedData();
Map<String, Object> headers = new HashMap<String, Object>();
- headers.put(ElasticsearchConstants.PARAM_OPERATION, ElasticsearchConstants.OPERATION_INDEX);
+ headers.put(ElasticsearchConstants.PARAM_OPERATION, ElasticsearchOperation.INDEX);
headers.put(ElasticsearchConstants.PARAM_INDEX_NAME, "twitter");
headers.put(ElasticsearchConstants.PARAM_INDEX_TYPE, "tweet");
String indexId = template.requestBodyAndHeaders("direct:start", map, headers, String.class);
//now, verify GET
- headers.put(ElasticsearchConstants.PARAM_OPERATION, ElasticsearchConstants.OPERATION_EXISTS);
+ headers.put(ElasticsearchConstants.PARAM_OPERATION, ElasticsearchOperation.EXISTS);
headers.put(ElasticsearchConstants.PARAM_INDEX_NAME, "twitter");
Boolean exists = template.requestBodyAndHeaders("direct:exists", "", headers, Boolean.class);
assertNotNull("response should not be null", exists);
@@ -166,14 +166,14 @@ public class ElasticsearchGetSearchDeleteExistsUpdateTest extends ElasticsearchB
//first, INDEX a value
Map<String, String> map = createIndexedData();
Map<String, Object> headers = new HashMap<String, Object>();
- headers.put(ElasticsearchConstants.PARAM_OPERATION, ElasticsearchConstants.OPERATION_INDEX);
+ headers.put(ElasticsearchConstants.PARAM_OPERATION, ElasticsearchOperation.INDEX);
headers.put(ElasticsearchConstants.PARAM_INDEX_NAME, "twitter");
headers.put(ElasticsearchConstants.PARAM_INDEX_TYPE, "tweet");
String indexId = template.requestBodyAndHeaders("direct:start", map, headers, String.class);
//now, verify GET
- headers.put(ElasticsearchConstants.PARAM_OPERATION, ElasticsearchConstants.OPERATION_EXISTS);
+ headers.put(ElasticsearchConstants.PARAM_OPERATION, ElasticsearchOperation.EXISTS);
headers.put(ElasticsearchConstants.PARAM_INDEX_NAME, "twitter-tweet");
Boolean exists = template.requestBodyAndHeaders("direct:exists", "", headers, Boolean.class);
assertNotNull("response should not be null", exists);
@@ -185,7 +185,7 @@ public class ElasticsearchGetSearchDeleteExistsUpdateTest extends ElasticsearchB
//first, INDEX two values
Map<String, String> map = createIndexedData();
Map<String, Object> headers = new HashMap<String, Object>();
- headers.put(ElasticsearchConstants.PARAM_OPERATION, ElasticsearchConstants.OPERATION_INDEX);
+ headers.put(ElasticsearchConstants.PARAM_OPERATION, ElasticsearchOperation.INDEX);
headers.put(ElasticsearchConstants.PARAM_INDEX_NAME, "twitter");
headers.put(ElasticsearchConstants.PARAM_INDEX_TYPE, "tweet");
headers.put(ElasticsearchConstants.PARAM_INDEX_ID, "1");
@@ -193,7 +193,7 @@ public class ElasticsearchGetSearchDeleteExistsUpdateTest extends ElasticsearchB
template.requestBodyAndHeaders("direct:start", map, headers, String.class);
headers.clear();
- headers.put(ElasticsearchConstants.PARAM_OPERATION, ElasticsearchConstants.OPERATION_INDEX);
+ headers.put(ElasticsearchConstants.PARAM_OPERATION, ElasticsearchOperation.INDEX);
headers.put(ElasticsearchConstants.PARAM_INDEX_NAME, "facebook");
headers.put(ElasticsearchConstants.PARAM_INDEX_TYPE, "status");
headers.put(ElasticsearchConstants.PARAM_INDEX_ID, "2");
@@ -202,7 +202,7 @@ public class ElasticsearchGetSearchDeleteExistsUpdateTest extends ElasticsearchB
headers.clear();
//now, verify MULTIGET
- headers.put(ElasticsearchConstants.PARAM_OPERATION, ElasticsearchConstants.OPERATION_MULTIGET);
+ headers.put(ElasticsearchConstants.PARAM_OPERATION, ElasticsearchOperation.MULTIGET);
Item item1 = new Item("twitter", "tweet", "1");
Item item2 = new Item("facebook", "status", "2");
Item item3 = new Item("instagram", "latest", "3");
@@ -230,7 +230,7 @@ public class ElasticsearchGetSearchDeleteExistsUpdateTest extends ElasticsearchB
node.client().prepareIndex("test", "type", "2").setSource("field", "yyy").execute().actionGet();
//now, verify MULTISEARCH
- headers.put(ElasticsearchConstants.PARAM_OPERATION, ElasticsearchConstants.OPERATION_MULTISEARCH);
+ headers.put(ElasticsearchConstants.PARAM_OPERATION, ElasticsearchOperation.MULTISEARCH);
SearchRequestBuilder srb1 = node.client().prepareSearch("test").setTypes("type").setQuery(QueryBuilders.termQuery("field", "xxx"));
SearchRequestBuilder srb2 = node.client().prepareSearch("test").setTypes("type").setQuery(QueryBuilders.termQuery("field", "yyy"));
SearchRequestBuilder srb3 = node.client().prepareSearch("instagram")
@@ -253,25 +253,25 @@ public class ElasticsearchGetSearchDeleteExistsUpdateTest extends ElasticsearchB
//first, INDEX a value
Map<String, String> map = createIndexedData();
Map<String, Object> headers = new HashMap<String, Object>();
- headers.put(ElasticsearchConstants.PARAM_OPERATION, ElasticsearchConstants.OPERATION_INDEX);
+ headers.put(ElasticsearchConstants.PARAM_OPERATION, ElasticsearchOperation.INDEX);
headers.put(ElasticsearchConstants.PARAM_INDEX_NAME, "twitter");
headers.put(ElasticsearchConstants.PARAM_INDEX_TYPE, "tweet");
String indexId = template.requestBodyAndHeaders("direct:start", map, headers, String.class);
//now, verify GET
- headers.put(ElasticsearchConstants.PARAM_OPERATION, ElasticsearchConstants.OPERATION_GET_BY_ID);
+ headers.put(ElasticsearchConstants.PARAM_OPERATION, ElasticsearchOperation.GET_BY_ID);
GetResponse response = template.requestBodyAndHeaders("direct:start", indexId, headers, GetResponse.class);
assertNotNull("response should not be null", response);
assertNotNull("response source should not be null", response.getSource());
//now, perform DELETE
- headers.put(ElasticsearchConstants.PARAM_OPERATION, ElasticsearchConstants.OPERATION_DELETE);
+ headers.put(ElasticsearchConstants.PARAM_OPERATION, ElasticsearchOperation.DELETE);
DeleteResponse deleteResponse = template.requestBodyAndHeaders("direct:start", indexId, headers, DeleteResponse.class);
assertNotNull("response should not be null", deleteResponse);
//now, verify GET fails to find the indexed value
- headers.put(ElasticsearchConstants.PARAM_OPERATION, ElasticsearchConstants.OPERATION_GET_BY_ID);
+ headers.put(ElasticsearchConstants.PARAM_OPERATION, ElasticsearchOperation.GET_BY_ID);
response = template.requestBodyAndHeaders("direct:start", indexId, headers, GetResponse.class);
assertNotNull("response should not be null", response);
assertNull("response source should be null", response.getSource());
@@ -281,7 +281,7 @@ public class ElasticsearchGetSearchDeleteExistsUpdateTest extends ElasticsearchB
public void testUpdateWithIDInHeader() throws Exception {
Map<String, String> map = createIndexedData();
Map<String, Object> headers = new HashMap<String, Object>();
- headers.put(ElasticsearchConstants.PARAM_OPERATION, ElasticsearchConstants.OPERATION_INDEX);
+ headers.put(ElasticsearchConstants.PARAM_OPERATION, ElasticsearchOperation.INDEX);
headers.put(ElasticsearchConstants.PARAM_INDEX_NAME, "twitter");
headers.put(ElasticsearchConstants.PARAM_INDEX_TYPE, "tweet");
headers.put(ElasticsearchConstants.PARAM_INDEX_ID, "123");
@@ -290,7 +290,7 @@ public class ElasticsearchGetSearchDeleteExistsUpdateTest extends ElasticsearchB
assertNotNull("indexId should be set", indexId);
assertEquals("indexId should be equals to the provided id", "123", indexId);
- headers.put(ElasticsearchConstants.PARAM_OPERATION, ElasticsearchConstants.OPERATION_UPDATE);
+ headers.put(ElasticsearchConstants.PARAM_OPERATION, ElasticsearchOperation.UPDATE);
indexId = template.requestBodyAndHeaders("direct:start", map, headers, String.class);
assertNotNull("indexId should be set", indexId);
@@ -340,15 +340,15 @@ public class ElasticsearchGetSearchDeleteExistsUpdateTest extends ElasticsearchB
return new RouteBuilder() {
@Override
public void configure() {
- from("direct:start").to("elasticsearch5://elasticsearch?operation=INDEX");
- from("direct:index").to("elasticsearch5://elasticsearch?operation=INDEX&indexName=twitter&indexType=tweet");
- from("direct:get").to("elasticsearch5://elasticsearch?operation=GET_BY_ID&indexName=twitter&indexType=tweet");
- from("direct:multiget").to("elasticsearch5://elasticsearch?operation=MULTIGET&indexName=twitter&indexType=tweet");
- from("direct:delete").to("elasticsearch5://elasticsearch?operation=DELETE&indexName=twitter&indexType=tweet");
- from("direct:search").to("elasticsearch5://elasticsearch?operation=SEARCH&indexName=twitter&indexType=tweet");
- from("direct:update").to("elasticsearch5://elasticsearch?operation=UPDATE&indexName=twitter&indexType=tweet");
- from("direct:exists").to("elasticsearch5://elasticsearch?operation=EXISTS");
- from("direct:multisearch").to("elasticsearch5://elasticsearch?operation=MULTISEARCH&indexName=test");
+ from("direct:start").to("elasticsearch5://elasticsearch?operation=INDEX&ip=localhost&port=9300");
+ from("direct:index").to("elasticsearch5://elasticsearch?operation=INDEX&indexName=twitter&indexType=tweet&ip=localhost&port=9300");
+ from("direct:get").to("elasticsearch5://elasticsearch?operation=GET_BY_ID&indexName=twitter&indexType=tweet&ip=localhost&port=9300");
+ from("direct:multiget").to("elasticsearch5://elasticsearch?operation=MULTIGET&indexName=twitter&indexType=tweet&ip=localhost&port=9300");
+ from("direct:delete").to("elasticsearch5://elasticsearch?operation=DELETE&indexName=twitter&indexType=tweet&ip=localhost&port=9300");
+ from("direct:search").to("elasticsearch5://elasticsearch?operation=SEARCH&indexName=twitter&indexType=tweet&ip=localhost&port=9300");
+ from("direct:update").to("elasticsearch5://elasticsearch?operation=UPDATE&indexName=twitter&indexType=tweet&ip=localhost&port=9300");
+ from("direct:exists").to("elasticsearch5://elasticsearch?operation=EXISTS&ip=localhost&port=9300");
+ from("direct:multisearch").to("elasticsearch5://elasticsearch?operation=MULTISEARCH&indexName=test&ip=localhost&port=9300");
}
};
}
http://git-wip-us.apache.org/repos/asf/camel/blob/659255cf/components/camel-elasticsearch5/src/test/java/org/apache/camel/component/elasticsearch5/ElasticsearchIndexTest.java
----------------------------------------------------------------------
diff --git a/components/camel-elasticsearch5/src/test/java/org/apache/camel/component/elasticsearch5/ElasticsearchIndexTest.java b/components/camel-elasticsearch5/src/test/java/org/apache/camel/component/elasticsearch5/ElasticsearchIndexTest.java
index 4ef3cb5..c48c8e1 100644
--- a/components/camel-elasticsearch5/src/test/java/org/apache/camel/component/elasticsearch5/ElasticsearchIndexTest.java
+++ b/components/camel-elasticsearch5/src/test/java/org/apache/camel/component/elasticsearch5/ElasticsearchIndexTest.java
@@ -39,17 +39,10 @@ public class ElasticsearchIndexTest extends ElasticsearchBaseTest {
}
@Test
- public void testIndexWithWriteConsistency() throws Exception {
- Map<String, String> map = createIndexedData();
- String indexId = template.requestBody("direct:indexWithWriteConsistency", map, String.class);
- assertNotNull("indexId should be set", indexId);
- }
-
- @Test
public void testIndexWithHeaders() throws Exception {
Map<String, String> map = createIndexedData();
Map<String, Object> headers = new HashMap<String, Object>();
- headers.put(ElasticsearchConstants.PARAM_OPERATION, ElasticsearchConstants.OPERATION_INDEX);
+ headers.put(ElasticsearchConstants.PARAM_OPERATION, ElasticsearchOperation.INDEX);
headers.put(ElasticsearchConstants.PARAM_INDEX_NAME, "twitter");
headers.put(ElasticsearchConstants.PARAM_INDEX_TYPE, "tweet");
@@ -61,7 +54,7 @@ public class ElasticsearchIndexTest extends ElasticsearchBaseTest {
public void testIndexWithIDInHeader() throws Exception {
Map<String, String> map = createIndexedData();
Map<String, Object> headers = new HashMap<String, Object>();
- headers.put(ElasticsearchConstants.PARAM_OPERATION, ElasticsearchConstants.OPERATION_INDEX);
+ headers.put(ElasticsearchConstants.PARAM_OPERATION, ElasticsearchOperation.INDEX);
headers.put(ElasticsearchConstants.PARAM_INDEX_NAME, "twitter");
headers.put(ElasticsearchConstants.PARAM_INDEX_TYPE, "tweet");
headers.put(ElasticsearchConstants.PARAM_INDEX_ID, "123");
@@ -76,10 +69,9 @@ public class ElasticsearchIndexTest extends ElasticsearchBaseTest {
return new RouteBuilder() {
@Override
public void configure() {
- from("direct:start").to("elasticsearch5://elasticsearch");
- from("direct:index").to("elasticsearch5://elasticsearch?operation=INDEX&indexName=twitter&indexType=tweet");
- from("direct:indexWithReplication").to("elasticsearch5://elasticsearch?operation=INDEX&indexName=twitter&indexType=tweet");
- from("direct:indexWithWriteConsistency").to("elasticsearch5://elasticsearch?operation=INDEX&indexName=twitter&indexType=tweet");
+ from("direct:start").to("elasticsearch5://elasticsearch?ip=localhost&port=9300");
+ from("direct:index").to("elasticsearch5://elasticsearch?operation=INDEX&indexName=twitter&indexType=tweet&ip=localhost&port=9300");
+ from("direct:indexWithReplication").to("elasticsearch5://elasticsearch?operation=INDEX&indexName=twitter&indexType=tweet&ip=localhost&port=9300");
}
};
}
http://git-wip-us.apache.org/repos/asf/camel/blob/659255cf/components/camel-elasticsearch5/src/test/resources/log4j2.properties
----------------------------------------------------------------------
diff --git a/components/camel-elasticsearch5/src/test/resources/log4j2.properties b/components/camel-elasticsearch5/src/test/resources/log4j2.properties
index 1e56038..6ae1902 100644
--- a/components/camel-elasticsearch5/src/test/resources/log4j2.properties
+++ b/components/camel-elasticsearch5/src/test/resources/log4j2.properties
@@ -17,7 +17,7 @@
appender.file.type = File
appender.file.name = file
-appender.file.fileName = target/camel-elasticsearch-test.log
+appender.file.fileName = target/camel-elasticsearch5-test.log
appender.file.layout.type = PatternLayout
appender.file.layout.pattern = %d [%-15.15t] %-5p %-30.30c{1} - %m%n
appender.stdout.type = Console
http://git-wip-us.apache.org/repos/asf/camel/blob/659255cf/components/camel-lucene/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-lucene/pom.xml b/components/camel-lucene/pom.xml
index e8a8b6b..ae03ad4 100644
--- a/components/camel-lucene/pom.xml
+++ b/components/camel-lucene/pom.xml
@@ -1,111 +1,111 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version
- 2.0 (the "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
- http://www.apache.org/licenses/LICENSE-2.0 Unless required by
- applicable law or agreed to in writing, software distributed under the
- License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
- CONDITIONS OF ANY KIND, either express or implied. See the License for
- the specific language governing permissions and limitations under the
- License.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
+ http://www.apache.org/licenses/LICENSE-2.0
- <parent>
- <groupId>org.apache.camel</groupId>
- <artifactId>components</artifactId>
- <version>2.19.0-SNAPSHOT</version>
- </parent>
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
- <artifactId>camel-lucene</artifactId>
- <packaging>jar</packaging>
- <name>Camel :: Lucene</name>
- <description>Camel Lucene based search component</description>
+ <parent>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>components</artifactId>
+ <version>2.19.0-SNAPSHOT</version>
+ </parent>
- <properties>
- <camel.osgi.export.pkg>
- org.apache.camel.component.lucene.*;${camel.osgi.version},
- org.apache.camel.processor.lucene.*
- </camel.osgi.export.pkg>
- <camel.osgi.import.pkg>
- !org.apache.camel.component.lucene.*,
- !org.apache.camel.processor.lucene.*,
- ${camel.osgi.import.defaults},
- *
- </camel.osgi.import.pkg>
- <camel.osgi.export.service>org.apache.camel.spi.ComponentResolver;component=lucene</camel.osgi.export.service>
- </properties>
+ <artifactId>camel-lucene</artifactId>
+ <packaging>jar</packaging>
+ <name>Camel :: Lucene</name>
+ <description>Camel Lucene based search component</description>
- <dependencies>
-
- <dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-core</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.lucene</groupId>
- <artifactId>lucene-core</artifactId>
- <version>${lucene-version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.lucene</groupId>
- <artifactId>lucene-queryparser</artifactId>
- <version>${lucene-version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.lucene</groupId>
- <artifactId>lucene-analyzers-common</artifactId>
- <version>${lucene-version}</version>
- </dependency>
+ <properties>
+ <camel.osgi.export.pkg>
+ org.apache.camel.component.lucene.*;${camel.osgi.version},
+ org.apache.camel.processor.lucene.*
+ </camel.osgi.export.pkg>
+ <camel.osgi.import.pkg>
+ !org.apache.camel.component.lucene.*,
+ !org.apache.camel.processor.lucene.*,
+ ${camel.osgi.import.defaults},
+ *
+ </camel.osgi.import.pkg>
+ <camel.osgi.export.service>org.apache.camel.spi.ComponentResolver;component=lucene</camel.osgi.export.service>
+ </properties>
- <!-- test dependencies -->
- <dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-test</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.logging.log4j</groupId>
- <artifactId>log4j-api</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.logging.log4j</groupId>
- <artifactId>log4j-core</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.logging.log4j</groupId>
- <artifactId>log4j-slf4j-impl</artifactId>
- <scope>test</scope>
- </dependency>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.lucene</groupId>
+ <artifactId>lucene-core</artifactId>
+ <version>${lucene-version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.lucene</groupId>
+ <artifactId>lucene-queryparser</artifactId>
+ <version>${lucene-version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.lucene</groupId>
+ <artifactId>lucene-analyzers-common</artifactId>
+ <version>${lucene-version}</version>
+ </dependency>
- </dependencies>
+ <!-- test dependencies -->
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-test</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-api</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-core</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-slf4j-impl</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-clean-plugin</artifactId>
- <configuration>
- <filesets>
- <fileset>
- <directory>${basedir}/res</directory>
- </fileset>
- </filesets>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-clean-plugin</artifactId>
+ <configuration>
+ <filesets>
+ <fileset>
+ <directory>${basedir}/res</directory>
+ </fileset>
+ </filesets>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/659255cf/platforms/catalog-lucene/pom.xml
----------------------------------------------------------------------
diff --git a/platforms/catalog-lucene/pom.xml b/platforms/catalog-lucene/pom.xml
index 228e919..3e653f9 100644
--- a/platforms/catalog-lucene/pom.xml
+++ b/platforms/catalog-lucene/pom.xml
@@ -1,21 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
- http://www.apache.org/licenses/LICENSE-2.0
+ http://www.apache.org/licenses/LICENSE-2.0
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- -->
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
@@ -36,7 +37,6 @@
</properties>
<dependencies>
-
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-catalog</artifactId>
@@ -58,7 +58,7 @@
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
-
+
<!-- logging -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
@@ -75,19 +75,16 @@
<artifactId>log4j-slf4j-impl</artifactId>
<scope>test</scope>
</dependency>
-
</dependencies>
<build>
<plugins>
-
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
</plugin>
</plugins>
-
</build>
-</project>
+</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/659255cf/platforms/spring-boot/components-starter/camel-elasticsearch5-starter/src/main/java/org/apache/camel/component/elasticsearch5/springboot/ElasticsearchComponentAutoConfiguration.java
----------------------------------------------------------------------
diff --git a/platforms/spring-boot/components-starter/camel-elasticsearch5-starter/src/main/java/org/apache/camel/component/elasticsearch5/springboot/ElasticsearchComponentAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-elasticsearch5-starter/src/main/java/org/apache/camel/component/elasticsearch5/springboot/ElasticsearchComponentAutoConfiguration.java
index 0edc75e..3e9a70b 100644
--- a/platforms/spring-boot/components-starter/camel-elasticsearch5-starter/src/main/java/org/apache/camel/component/elasticsearch5/springboot/ElasticsearchComponentAutoConfiguration.java
+++ b/platforms/spring-boot/components-starter/camel-elasticsearch5-starter/src/main/java/org/apache/camel/component/elasticsearch5/springboot/ElasticsearchComponentAutoConfiguration.java
@@ -16,11 +16,8 @@
*/
package org.apache.camel.component.elasticsearch5.springboot;
-import java.util.HashMap;
-import java.util.Map;
import org.apache.camel.CamelContext;
import org.apache.camel.component.elasticsearch5.ElasticsearchComponent;
-import org.apache.camel.util.IntrospectionSupport;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionMessage;
import org.springframework.boot.autoconfigure.condition.ConditionOutcome;
@@ -29,7 +26,6 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.SpringBootCondition;
import org.springframework.boot.bind.RelaxedPropertyResolver;
-import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.context.annotation.Conditional;
@@ -44,7 +40,6 @@ import org.springframework.core.type.AnnotatedTypeMetadata;
@ConditionalOnBean(type = "org.apache.camel.spring.boot.CamelAutoConfiguration")
@Conditional(ElasticsearchComponentAutoConfiguration.Condition.class)
@AutoConfigureAfter(name = "org.apache.camel.spring.boot.CamelAutoConfiguration")
-@EnableConfigurationProperties(ElasticsearchComponentConfiguration.class)
public class ElasticsearchComponentAutoConfiguration {
@Lazy
@@ -52,35 +47,9 @@ public class ElasticsearchComponentAutoConfiguration {
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(ElasticsearchComponent.class)
public ElasticsearchComponent configureElasticsearchComponent(
- CamelContext camelContext,
- ElasticsearchComponentConfiguration configuration) throws Exception {
+ CamelContext camelContext) throws Exception {
ElasticsearchComponent component = new ElasticsearchComponent();
component.setCamelContext(camelContext);
- Map<String, Object> parameters = new HashMap<>();
- IntrospectionSupport.getProperties(configuration, parameters, null,
- false);
- for (Map.Entry<String, Object> entry : parameters.entrySet()) {
- Object value = entry.getValue();
- Class<?> paramClass = value.getClass();
- if (paramClass.getName().endsWith("NestedConfiguration")) {
- Class nestedClass = null;
- try {
- nestedClass = (Class) paramClass.getDeclaredField(
- "CAMEL_NESTED_CLASS").get(null);
- HashMap<String, Object> nestedParameters = new HashMap<>();
- IntrospectionSupport.getProperties(value, nestedParameters,
- null, false);
- Object nestedProperty = nestedClass.newInstance();
- IntrospectionSupport.setProperties(camelContext,
- camelContext.getTypeConverter(), nestedProperty,
- nestedParameters);
- entry.setValue(nestedProperty);
- } catch (NoSuchFieldException e) {
- }
- }
- }
- IntrospectionSupport.setProperties(camelContext,
- camelContext.getTypeConverter(), component, parameters);
return component;
}
http://git-wip-us.apache.org/repos/asf/camel/blob/659255cf/platforms/spring-boot/components-starter/camel-elasticsearch5-starter/src/main/java/org/apache/camel/component/elasticsearch5/springboot/ElasticsearchComponentConfiguration.java
----------------------------------------------------------------------
diff --git a/platforms/spring-boot/components-starter/camel-elasticsearch5-starter/src/main/java/org/apache/camel/component/elasticsearch5/springboot/ElasticsearchComponentConfiguration.java b/platforms/spring-boot/components-starter/camel-elasticsearch5-starter/src/main/java/org/apache/camel/component/elasticsearch5/springboot/ElasticsearchComponentConfiguration.java
deleted file mode 100644
index 7864d81..0000000
--- a/platforms/spring-boot/components-starter/camel-elasticsearch5-starter/src/main/java/org/apache/camel/component/elasticsearch5/springboot/ElasticsearchComponentConfiguration.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.component.elasticsearch5.springboot;
-
-import org.elasticsearch.client.transport.TransportClient;
-import org.springframework.boot.context.properties.ConfigurationProperties;
-import org.springframework.boot.context.properties.NestedConfigurationProperty;
-
-/**
- * The elasticsearch component is used for interfacing with ElasticSearch
- * server.
- *
- * Generated by camel-package-maven-plugin - do not edit this file!
- */
-@ConfigurationProperties(prefix = "camel.component.elasticsearch5")
-public class ElasticsearchComponentConfiguration {
-
- /**
- * To use an existing configured Elasticsearch client instead of creating a
- * client per endpoint.
- */
- @NestedConfigurationProperty
- private TransportClient client;
-
- public TransportClient getClient() {
- return client;
- }
-
- public void setClient(TransportClient client) {
- this.client = client;
- }
-}
\ No newline at end of file