You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by bo...@apache.org on 2012/08/02 01:34:16 UTC
svn commit: r1368312 - in /camel/trunk: apache-camel/
apache-camel/src/main/descriptors/ components/
components/camel-elasticsearch/ components/camel-elasticsearch/src/
components/camel-elasticsearch/src/main/
components/camel-elasticsearch/src/main/ja...
Author: boday
Date: Wed Aug 1 23:34:14 2012
New Revision: 1368312
URL: http://svn.apache.org/viewvc?rev=1368312&view=rev
Log:
CAMEL-5219 initial checkin of camel-elasticsearch…thanks to Cedric Vidal for contribution (coming soon…OSGI support, docs, more features)
Added:
camel/trunk/components/camel-elasticsearch/
camel/trunk/components/camel-elasticsearch/pom.xml
camel/trunk/components/camel-elasticsearch/src/
camel/trunk/components/camel-elasticsearch/src/main/
camel/trunk/components/camel-elasticsearch/src/main/java/
camel/trunk/components/camel-elasticsearch/src/main/java/org/
camel/trunk/components/camel-elasticsearch/src/main/java/org/apache/
camel/trunk/components/camel-elasticsearch/src/main/java/org/apache/camel/
camel/trunk/components/camel-elasticsearch/src/main/java/org/apache/camel/component/
camel/trunk/components/camel-elasticsearch/src/main/java/org/apache/camel/component/elasticsearch/
camel/trunk/components/camel-elasticsearch/src/main/java/org/apache/camel/component/elasticsearch/ElasticsearchComponent.java
camel/trunk/components/camel-elasticsearch/src/main/java/org/apache/camel/component/elasticsearch/ElasticsearchConfiguration.java
camel/trunk/components/camel-elasticsearch/src/main/java/org/apache/camel/component/elasticsearch/ElasticsearchEndpoint.java
camel/trunk/components/camel-elasticsearch/src/main/java/org/apache/camel/component/elasticsearch/ElasticsearchProducer.java
camel/trunk/components/camel-elasticsearch/src/main/resources/
camel/trunk/components/camel-elasticsearch/src/main/resources/META-INF/
camel/trunk/components/camel-elasticsearch/src/main/resources/META-INF/services/
camel/trunk/components/camel-elasticsearch/src/main/resources/META-INF/services/org/
camel/trunk/components/camel-elasticsearch/src/main/resources/META-INF/services/org/apache/
camel/trunk/components/camel-elasticsearch/src/main/resources/META-INF/services/org/apache/camel/
camel/trunk/components/camel-elasticsearch/src/main/resources/META-INF/services/org/apache/camel/component/
camel/trunk/components/camel-elasticsearch/src/main/resources/META-INF/services/org/apache/camel/component/elasticsearch
camel/trunk/components/camel-elasticsearch/src/main/resources/log4j.properties
camel/trunk/components/camel-elasticsearch/src/test/
camel/trunk/components/camel-elasticsearch/src/test/java/
camel/trunk/components/camel-elasticsearch/src/test/java/org/
camel/trunk/components/camel-elasticsearch/src/test/java/org/apache/
camel/trunk/components/camel-elasticsearch/src/test/java/org/apache/camel/
camel/trunk/components/camel-elasticsearch/src/test/java/org/apache/camel/component/
camel/trunk/components/camel-elasticsearch/src/test/java/org/apache/camel/component/elasticsearch/
camel/trunk/components/camel-elasticsearch/src/test/java/org/apache/camel/component/elasticsearch/ElasticsearchComponentTest.java
camel/trunk/components/camel-elasticsearch/src/test/java/org/apache/camel/component/elasticsearch/ElasticsearchConfigurationTest.java
camel/trunk/components/camel-elasticsearch/src/test/java/org/apache/camel/component/elasticsearch/ElasticsearchIndexNameAndTypeInHeaderComponentTest.java
camel/trunk/components/camel-elasticsearch/src/test/java/org/apache/camel/component/elasticsearch/SpringElasticsearchTest.java (contents, props changed)
- copied, changed from r1363177, camel/trunk/components/camel-solr/src/test/java/org/apache/camel/component/solr/SolrSpringTest.java
camel/trunk/components/camel-elasticsearch/src/test/resources/
camel/trunk/components/camel-elasticsearch/src/test/resources/SpringElasticsearchTest.xml (contents, props changed)
- copied, changed from r1363177, camel/trunk/components/camel-solr/src/test/resources/SolrSpringTest-context.xml
Modified:
camel/trunk/apache-camel/pom.xml
camel/trunk/apache-camel/src/main/descriptors/common-bin.xml
camel/trunk/components/pom.xml
camel/trunk/parent/pom.xml
camel/trunk/platforms/karaf/features/pom.xml
camel/trunk/platforms/karaf/features/src/main/resources/features.xml
Modified: camel/trunk/apache-camel/pom.xml
URL: http://svn.apache.org/viewvc/camel/trunk/apache-camel/pom.xml?rev=1368312&r1=1368311&r2=1368312&view=diff
==============================================================================
--- camel/trunk/apache-camel/pom.xml (original)
+++ camel/trunk/apache-camel/pom.xml Wed Aug 1 23:34:14 2012
@@ -149,6 +149,10 @@
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
+ <artifactId>camel-elasticsearch</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
<artifactId>camel-eventadmin</artifactId>
</dependency>
<dependency>
Modified: camel/trunk/apache-camel/src/main/descriptors/common-bin.xml
URL: http://svn.apache.org/viewvc/camel/trunk/apache-camel/src/main/descriptors/common-bin.xml?rev=1368312&r1=1368311&r2=1368312&view=diff
==============================================================================
--- camel/trunk/apache-camel/src/main/descriptors/common-bin.xml (original)
+++ camel/trunk/apache-camel/src/main/descriptors/common-bin.xml Wed Aug 1 23:34:14 2012
@@ -60,6 +60,7 @@
<include>org.apache.camel:camel-dozer</include>
<include>org.apache.camel:camel-eclipse</include>
<include>org.apache.camel:camel-ejb</include>
+ <include>org.apache.camel:camel-elasticsearch</include>
<include>org.apache.camel:camel-eventadmin</include>
<include>org.apache.camel:camel-exec</include>
<include>org.apache.camel:camel-flatpack</include>
Added: camel/trunk/components/camel-elasticsearch/pom.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-elasticsearch/pom.xml?rev=1368312&view=auto
==============================================================================
--- camel/trunk/components/camel-elasticsearch/pom.xml (added)
+++ camel/trunk/components/camel-elasticsearch/pom.xml Wed Aug 1 23:34:14 2012
@@ -0,0 +1,100 @@
+<?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.
+-->
+<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>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-parent</artifactId>
+ <version>2.11-SNAPSHOT</version>
+ <relativePath>../../parent</relativePath>
+ </parent>
+
+ <artifactId>camel-elasticsearch</artifactId>
+ <packaging>bundle</packaging>
+ <name>Camel :: ElasticSearch</name>
+ <description>Camel Elasticsearch support</description>
+
+ <properties>
+ <camel.osgi.export.pkg>org.apache.camel.component.elasticsearch.*;${camel.osgi.version}</camel.osgi.export.pkg>
+ </properties>
+
+ <repositories>
+ <repository>
+ <id>sonatype-oss</id>
+ <name>Sonatype OSS</name>
+ <url>http://oss.sonatype.org/content/repositories/releases/</url>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ </repository>
+ </repositories>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-core</artifactId>
+ </dependency>
+
+ <!-- for testing -->
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-core-xml</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-test</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-test-spring</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-context</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-test</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <!-- logging -->
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.elasticsearch</groupId>
+ <artifactId>elasticsearch</artifactId>
+ <version>${elasticsearch-version}</version>
+ <type>jar</type>
+ </dependency>
+ </dependencies>
+
+</project>
Added: camel/trunk/components/camel-elasticsearch/src/main/java/org/apache/camel/component/elasticsearch/ElasticsearchComponent.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-elasticsearch/src/main/java/org/apache/camel/component/elasticsearch/ElasticsearchComponent.java?rev=1368312&view=auto
==============================================================================
--- camel/trunk/components/camel-elasticsearch/src/main/java/org/apache/camel/component/elasticsearch/ElasticsearchComponent.java (added)
+++ camel/trunk/components/camel-elasticsearch/src/main/java/org/apache/camel/component/elasticsearch/ElasticsearchComponent.java Wed Aug 1 23:34:14 2012
@@ -0,0 +1,49 @@
+/**
+ * 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.elasticsearch;
+
+import java.net.URI;
+import java.util.Map;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.Endpoint;
+import org.apache.camel.impl.DefaultComponent;
+
+/**
+ * Represents the component that manages {@link ElasticsearchEndpoint}.
+ */
+public class ElasticsearchComponent extends DefaultComponent {
+
+ private ElasticsearchConfiguration config;
+
+ public ElasticsearchComponent() {
+ super();
+ config = new ElasticsearchConfiguration();
+ }
+
+ public ElasticsearchComponent(CamelContext context) {
+ super(context);
+ config = new ElasticsearchConfiguration();
+ }
+
+ protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
+ config.parseURI(new URI(uri), parameters, this);
+ Endpoint endpoint = new ElasticsearchEndpoint(uri, this, config);
+ setProperties(endpoint, parameters);
+ return endpoint;
+ }
+}
Added: camel/trunk/components/camel-elasticsearch/src/main/java/org/apache/camel/component/elasticsearch/ElasticsearchConfiguration.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-elasticsearch/src/main/java/org/apache/camel/component/elasticsearch/ElasticsearchConfiguration.java?rev=1368312&view=auto
==============================================================================
--- camel/trunk/components/camel-elasticsearch/src/main/java/org/apache/camel/component/elasticsearch/ElasticsearchConfiguration.java (added)
+++ camel/trunk/components/camel-elasticsearch/src/main/java/org/apache/camel/component/elasticsearch/ElasticsearchConfiguration.java Wed Aug 1 23:34:14 2012
@@ -0,0 +1,181 @@
+/**
+ * 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.elasticsearch;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.Map;
+
+import org.elasticsearch.node.Node;
+import org.elasticsearch.node.NodeBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import static org.elasticsearch.node.NodeBuilder.nodeBuilder;
+
+public class ElasticsearchConfiguration {
+
+ public static final String PARAM_DATA = "data";
+ public static final String PARAM_INDEX_NAME = "indexName";
+ public static final String PARAM_INDEX_TYPE = "indexType";
+ public static final String PROTOCOL = "elasticsearch";
+ private static final Logger LOG = LoggerFactory.getLogger(ElasticsearchConfiguration.class);
+ private static final String LOCAL_NAME = "local";
+
+ private URI uri;
+ private String protocolType;
+ private String authority;
+ private String clusterName;
+ private String indexName;
+ private String indexType;
+ private boolean local;
+ private Boolean data;
+
+ public ElasticsearchConfiguration() {
+ }
+
+ public ElasticsearchConfiguration(URI uri) throws Exception {
+ this();
+ this.uri = uri;
+ }
+
+ public void parseURI(URI uri, Map<String, Object> parameters, ElasticsearchComponent component) throws Exception {
+ String protocol = uri.getScheme();
+
+ if (!protocol.equalsIgnoreCase(PROTOCOL)) {
+ throw new IllegalArgumentException("unrecognized elasticsearch protocol: " + protocol + " for uri: " + uri);
+ }
+ setUri(uri);
+ setAuthority(uri.getAuthority());
+ if (!isValidAuthority()) {
+ throw new URISyntaxException(uri.toASCIIString(), "incorrect URI syntax specified for the elasticsearch endpoint."
+ + "please specify the syntax as \"elasticsearch:[Cluster Name | 'local']?[Query]\"");
+ }
+
+ if (LOCAL_NAME.equals(getAuthority())) {
+ setLocal(true);
+ setClusterName(null);
+ } else {
+ setLocal(false);
+ setClusterName(getAuthority());
+ }
+
+ data = toBoolean(parameters.remove(PARAM_DATA));
+
+ if (data == null) {
+ data = local;
+ }
+
+ if (local && !data) {
+ throw new IllegalArgumentException("invalid to use local node without data");
+ }
+
+ indexName = (String)parameters.remove(PARAM_INDEX_NAME);
+ indexType = (String)parameters.remove(PARAM_INDEX_TYPE);
+ }
+
+ protected Boolean toBoolean(Object string) {
+ if ("true".equals(string)) {
+ return true;
+ } else if ("false".equals(string)) {
+ return false;
+ } else {
+ return null;
+ }
+ }
+
+ public Node buildNode() {
+ NodeBuilder builder = nodeBuilder().local(isLocal()).data(isData());
+ if (!isLocal() && getClusterName() != null) {
+ builder.clusterName(getClusterName());
+ }
+ return builder.node();
+ }
+
+ private boolean isValidAuthority() throws URISyntaxException {
+ if (authority.contains(":")) {
+ return false;
+ }
+ return true;
+
+ }
+
+ public URI getUri() {
+ return uri;
+ }
+
+ public void setUri(URI uri) {
+ this.uri = uri;
+ }
+
+ public String getProtocolType() {
+ return protocolType;
+ }
+
+ public void setProtocolType(String protocolType) {
+ this.protocolType = protocolType;
+ }
+
+ public String getClusterName() {
+ return clusterName;
+ }
+
+ public void setClusterName(String clusterName) {
+ this.clusterName = clusterName;
+ }
+
+ public String getAuthority() {
+ return authority;
+ }
+
+ public void setAuthority(String authority) {
+ this.authority = authority;
+ }
+
+ public String getIndexName() {
+ return indexName;
+ }
+
+ public void setIndexName(String indexName) {
+ this.indexName = indexName;
+ }
+
+ public String getIndexType() {
+ return indexType;
+ }
+
+ public void setIndexType(String indexType) {
+ this.indexType = indexType;
+ }
+
+ public boolean isLocal() {
+ return local;
+ }
+
+ public void setLocal(boolean local) {
+ this.local = local;
+ }
+
+ public boolean isData() {
+ return data;
+ }
+
+ public void setData(boolean data) {
+ this.data = data;
+ }
+
+}
Added: camel/trunk/components/camel-elasticsearch/src/main/java/org/apache/camel/component/elasticsearch/ElasticsearchEndpoint.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-elasticsearch/src/main/java/org/apache/camel/component/elasticsearch/ElasticsearchEndpoint.java?rev=1368312&view=auto
==============================================================================
--- camel/trunk/components/camel-elasticsearch/src/main/java/org/apache/camel/component/elasticsearch/ElasticsearchEndpoint.java (added)
+++ camel/trunk/components/camel-elasticsearch/src/main/java/org/apache/camel/component/elasticsearch/ElasticsearchEndpoint.java Wed Aug 1 23:34:14 2012
@@ -0,0 +1,94 @@
+/**
+ * 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.elasticsearch;
+
+import org.apache.camel.Consumer;
+import org.apache.camel.Processor;
+import org.apache.camel.Producer;
+import org.apache.camel.RuntimeCamelException;
+import org.apache.camel.impl.DefaultEndpoint;
+import org.elasticsearch.client.Client;
+import org.elasticsearch.node.Node;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Represents an Elasticsearch endpoint.
+ */
+public class ElasticsearchEndpoint extends DefaultEndpoint {
+
+ private static final Logger LOG = LoggerFactory.getLogger(ElasticsearchEndpoint.class);
+
+ private Node node;
+ private Client client;
+ private ElasticsearchConfiguration config;
+
+ public ElasticsearchEndpoint(String uri, ElasticsearchComponent component, ElasticsearchConfiguration config) {
+ super(uri, component);
+ this.config = config;
+ }
+
+ public Producer createProducer() throws Exception {
+ return new ElasticsearchProducer(this);
+ }
+
+ public Consumer createConsumer(Processor processor) throws Exception {
+ throw new RuntimeCamelException("Cannot consume to a ElasticsearchEndpoint: " + getEndpointUri());
+ }
+
+ public boolean isSingleton() {
+ return true;
+ }
+
+ @Override
+ protected void doStart() throws Exception {
+ super.doStart();
+ if (config.isLocal()) {
+ LOG.info("Starting local ElasticSearch server");
+ } else {
+ LOG.info("Joining ElasticSearch cluster " + config.getClusterName());
+ }
+ node = config.buildNode();
+ client = node.client();
+ }
+
+ @Override
+ protected void doStop() throws Exception {
+ if (config.isLocal()) {
+ LOG.info("Stopping local ElasticSearch server");
+ } else {
+ LOG.info("Leaving ElasticSearch cluster " + config.getClusterName());
+ }
+ node.close();
+ super.doStop();
+ }
+
+ @Override
+ protected void doShutdown() throws Exception {
+ // TODO Auto-generated method stub
+ super.doShutdown();
+ }
+
+ public Client getClient() {
+ return client;
+ }
+
+ public ElasticsearchConfiguration getConfig() {
+ return config;
+ }
+
+}
Added: camel/trunk/components/camel-elasticsearch/src/main/java/org/apache/camel/component/elasticsearch/ElasticsearchProducer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-elasticsearch/src/main/java/org/apache/camel/component/elasticsearch/ElasticsearchProducer.java?rev=1368312&view=auto
==============================================================================
--- camel/trunk/components/camel-elasticsearch/src/main/java/org/apache/camel/component/elasticsearch/ElasticsearchProducer.java (added)
+++ camel/trunk/components/camel-elasticsearch/src/main/java/org/apache/camel/component/elasticsearch/ElasticsearchProducer.java Wed Aug 1 23:34:14 2012
@@ -0,0 +1,93 @@
+/**
+ * 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.elasticsearch;
+
+import java.util.Map;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.ExpectedBodyTypeException;
+import org.apache.camel.Message;
+import org.apache.camel.impl.DefaultProducer;
+import org.elasticsearch.action.ListenableActionFuture;
+import org.elasticsearch.action.index.IndexRequestBuilder;
+import org.elasticsearch.action.index.IndexResponse;
+import org.elasticsearch.client.Client;
+import org.elasticsearch.common.xcontent.XContentBuilder;
+
+/**
+ * Represents an Elasticsearch producer.
+ */
+public class ElasticsearchProducer extends DefaultProducer {
+
+ private ElasticsearchEndpoint endpoint;
+
+ public ElasticsearchProducer(ElasticsearchEndpoint endpoint) {
+ super(endpoint);
+ this.endpoint = endpoint;
+ }
+
+ public void process(Exchange exchange) throws Exception {
+ Client client = endpoint.getClient();
+ log.debug("indexing " + exchange);
+
+ String indexName = exchange.getIn().getHeader(ElasticsearchConfiguration.PARAM_INDEX_NAME, String.class);
+ if (indexName == null) {
+ indexName = endpoint.getConfig().getIndexName();
+ }
+
+ String indexType = exchange.getIn().getHeader(ElasticsearchConfiguration.PARAM_INDEX_TYPE, String.class);
+ if (indexType == null) {
+ indexType = endpoint.getConfig().getIndexType();
+ }
+
+ IndexRequestBuilder prepareIndex = client.prepareIndex(indexName, indexType);
+ if (!setIndexRequestSource(exchange.getIn(), prepareIndex)) {
+ throw new ExpectedBodyTypeException(exchange, XContentBuilder.class);
+ }
+ ListenableActionFuture<IndexResponse> future = prepareIndex.execute();
+ IndexResponse response = future.actionGet();
+ }
+
+ private boolean setIndexRequestSource(Message msg, IndexRequestBuilder builder) {
+ Object body = null;
+ boolean converted = false;
+
+ // order is important
+ Class<?>[] types = new Class[] {XContentBuilder.class, Map.class, byte[].class, String.class};
+
+ for (int i = 0; i < types.length && body == null; i++) {
+ Class<?> type = types[i];
+ body = msg.getBody(type);
+ }
+
+ if (body != null) {
+ converted = true;
+ if (body instanceof byte[]) {
+ builder.setSource((byte[])body);
+ } else if (body instanceof Map) {
+ builder.setSource((Map<String, Object>)body);
+ } else if (body instanceof String) {
+ builder.setSource((String)body);
+ } else if (body instanceof XContentBuilder) {
+ builder.setSource((XContentBuilder)body);
+ } else {
+ converted = false;
+ }
+ }
+ return converted;
+ }
+}
Added: camel/trunk/components/camel-elasticsearch/src/main/resources/META-INF/services/org/apache/camel/component/elasticsearch
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-elasticsearch/src/main/resources/META-INF/services/org/apache/camel/component/elasticsearch?rev=1368312&view=auto
==============================================================================
--- camel/trunk/components/camel-elasticsearch/src/main/resources/META-INF/services/org/apache/camel/component/elasticsearch (added)
+++ camel/trunk/components/camel-elasticsearch/src/main/resources/META-INF/services/org/apache/camel/component/elasticsearch Wed Aug 1 23:34:14 2012
@@ -0,0 +1,18 @@
+#
+# 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.
+#
+
+class=org.apache.camel.component.elasticsearch.ElasticsearchComponent
Added: camel/trunk/components/camel-elasticsearch/src/main/resources/log4j.properties
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-elasticsearch/src/main/resources/log4j.properties?rev=1368312&view=auto
==============================================================================
--- camel/trunk/components/camel-elasticsearch/src/main/resources/log4j.properties (added)
+++ camel/trunk/components/camel-elasticsearch/src/main/resources/log4j.properties Wed Aug 1 23:34:14 2012
@@ -0,0 +1,40 @@
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+
+#
+# The logging properties used during tests
+#
+log4j.rootLogger=INFO, file
+log4j.logger.org.springframework=WARN
+
+# uncomment this to turn on debug of camel
+#log4j.logger.org.apache.camel=DEBUG
+#log4j.logger.org.apache.camel.component.elasticsearch=TRACE
+
+# CONSOLE appender not used by default
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
+
+# File appender
+log4j.appender.file=org.apache.log4j.FileAppender
+log4j.appender.file.layout=org.apache.log4j.PatternLayout
+log4j.appender.file.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
+log4j.appender.file.file=target/camel-elasticsearch-test.log
+log4j.appender.file.append=true
+
+log4j.throwableRenderer=org.apache.log4j.EnhancedThrowableRenderer
Added: camel/trunk/components/camel-elasticsearch/src/test/java/org/apache/camel/component/elasticsearch/ElasticsearchComponentTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-elasticsearch/src/test/java/org/apache/camel/component/elasticsearch/ElasticsearchComponentTest.java?rev=1368312&view=auto
==============================================================================
--- camel/trunk/components/camel-elasticsearch/src/test/java/org/apache/camel/component/elasticsearch/ElasticsearchComponentTest.java (added)
+++ camel/trunk/components/camel-elasticsearch/src/test/java/org/apache/camel/component/elasticsearch/ElasticsearchComponentTest.java Wed Aug 1 23:34:14 2012
@@ -0,0 +1,48 @@
+/**
+ * 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.elasticsearch;
+
+import java.util.HashMap;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+
+public class ElasticsearchComponentTest extends CamelTestSupport {
+
+ @Test
+ public void testIndex() throws Exception {
+ MockEndpoint mock = getMockEndpoint("mock:result");
+ mock.expectedMinimumMessageCount(1);
+ sendBody("direct:index", new HashMap<String, String>() {
+ {
+ put("content", "test");
+ }
+ });
+ assertMockEndpointsSatisfied();
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ public void configure() {
+ from("direct:index").to("elasticsearch://local?indexName=twitter&indexType=tweet").to("mock:result");
+ }
+ };
+ }
+}
Added: camel/trunk/components/camel-elasticsearch/src/test/java/org/apache/camel/component/elasticsearch/ElasticsearchConfigurationTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-elasticsearch/src/test/java/org/apache/camel/component/elasticsearch/ElasticsearchConfigurationTest.java?rev=1368312&view=auto
==============================================================================
--- camel/trunk/components/camel-elasticsearch/src/test/java/org/apache/camel/component/elasticsearch/ElasticsearchConfigurationTest.java (added)
+++ camel/trunk/components/camel-elasticsearch/src/test/java/org/apache/camel/component/elasticsearch/ElasticsearchConfigurationTest.java Wed Aug 1 23:34:14 2012
@@ -0,0 +1,87 @@
+/**
+ * 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.elasticsearch;
+
+import java.net.URI;
+import java.util.Map;
+
+import org.apache.camel.util.URISupport;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+public class ElasticsearchConfigurationTest {
+
+ @Test
+ public void localNode() throws Exception {
+ ElasticsearchConfiguration conf = new ElasticsearchConfiguration();
+ URI uri = new URI("elasticsearch://local?indexName=twitter&indexType=tweet");
+ Map<String, Object> parameters = URISupport.parseParameters(uri);
+ conf.parseURI(uri, parameters, null);
+ assertTrue(conf.isLocal());
+ assertEquals("twitter", conf.getIndexName());
+ assertEquals("tweet", conf.getIndexType());
+ assertTrue(conf.isData());
+ assertNull(conf.getClusterName());
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void localNonDataNodeThrowsIllegalArgumentException() throws Exception {
+ ElasticsearchConfiguration conf = new ElasticsearchConfiguration();
+ URI uri = new URI("elasticsearch://local?indexName=twitter&indexType=tweet&data=false");
+ Map<String, Object> parameters = URISupport.parseParameters(uri);
+ conf.parseURI(uri, parameters, null);
+ }
+
+ @Test
+ public void localConfDefaultsToDataNode() throws Exception {
+ ElasticsearchConfiguration conf = new ElasticsearchConfiguration();
+ URI uri = new URI("elasticsearch://local?indexName=twitter&indexType=tweet");
+ Map<String, Object> parameters = URISupport.parseParameters(uri);
+ conf.parseURI(uri, parameters, null);
+ assertTrue(conf.isLocal());
+ assertTrue(conf.isData());
+ }
+
+ @Test
+ public void clusterConfDefaultsToNonDataNode() throws Exception {
+ ElasticsearchConfiguration conf = new ElasticsearchConfiguration();
+ URI uri = new URI("elasticsearch://clustername?indexName=twitter&indexType=tweet");
+ Map<String, Object> parameters = URISupport.parseParameters(uri);
+ conf.parseURI(uri, parameters, null);
+ assertEquals("clustername", conf.getClusterName());
+ assertFalse(conf.isLocal());
+ assertFalse(conf.isData());
+ }
+
+ @Test
+ public void localDataNode() throws Exception {
+ ElasticsearchConfiguration conf = new ElasticsearchConfiguration();
+ URI uri = new URI("elasticsearch://local?indexName=twitter&indexType=tweet&data=true");
+ Map<String, Object> parameters = URISupport.parseParameters(uri);
+ conf.parseURI(uri, parameters, null);
+ assertTrue(conf.isLocal());
+ assertEquals("twitter", conf.getIndexName());
+ assertEquals("tweet", conf.getIndexType());
+ assertTrue(conf.isData());
+ assertNull(conf.getClusterName());
+ }
+
+}
Added: camel/trunk/components/camel-elasticsearch/src/test/java/org/apache/camel/component/elasticsearch/ElasticsearchIndexNameAndTypeInHeaderComponentTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-elasticsearch/src/test/java/org/apache/camel/component/elasticsearch/ElasticsearchIndexNameAndTypeInHeaderComponentTest.java?rev=1368312&view=auto
==============================================================================
--- camel/trunk/components/camel-elasticsearch/src/test/java/org/apache/camel/component/elasticsearch/ElasticsearchIndexNameAndTypeInHeaderComponentTest.java (added)
+++ camel/trunk/components/camel-elasticsearch/src/test/java/org/apache/camel/component/elasticsearch/ElasticsearchIndexNameAndTypeInHeaderComponentTest.java Wed Aug 1 23:34:14 2012
@@ -0,0 +1,53 @@
+/**
+ * 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.elasticsearch;
+
+import java.util.HashMap;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+
+public class ElasticsearchIndexNameAndTypeInHeaderComponentTest extends CamelTestSupport {
+
+ @Test
+ public void testIndexWithHeaders() throws Exception {
+ MockEndpoint mock = getMockEndpoint("mock:result");
+ mock.expectedMinimumMessageCount(1);
+ sendBody("direct:index", new HashMap<String, String>() {
+ {
+ put("content", "test");
+ }
+ }, new HashMap() {
+ {
+ put(ElasticsearchConfiguration.PARAM_INDEX_NAME, "twitter");
+ put(ElasticsearchConfiguration.PARAM_INDEX_TYPE, "tweet");
+ }
+ });
+ assertMockEndpointsSatisfied();
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ public void configure() {
+ from("direct:index").to("elasticsearch://local").to("mock:result");
+ }
+ };
+ }
+}
Copied: camel/trunk/components/camel-elasticsearch/src/test/java/org/apache/camel/component/elasticsearch/SpringElasticsearchTest.java (from r1363177, camel/trunk/components/camel-solr/src/test/java/org/apache/camel/component/solr/SolrSpringTest.java)
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-elasticsearch/src/test/java/org/apache/camel/component/elasticsearch/SpringElasticsearchTest.java?p2=camel/trunk/components/camel-elasticsearch/src/test/java/org/apache/camel/component/elasticsearch/SpringElasticsearchTest.java&p1=camel/trunk/components/camel-solr/src/test/java/org/apache/camel/component/solr/SolrSpringTest.java&r1=1363177&r2=1368312&rev=1368312&view=diff
==============================================================================
--- camel/trunk/components/camel-solr/src/test/java/org/apache/camel/component/solr/SolrSpringTest.java (original)
+++ camel/trunk/components/camel-elasticsearch/src/test/java/org/apache/camel/component/elasticsearch/SpringElasticsearchTest.java Wed Aug 1 23:34:14 2012
@@ -14,170 +14,53 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.camel.component.solr;
+package org.apache.camel.component.elasticsearch;
-import java.io.File;
-import java.util.Arrays;
-import static junit.framework.Assert.assertEquals;
+import java.util.HashMap;
+import org.apache.camel.EndpointInject;
import org.apache.camel.Produce;
import org.apache.camel.ProducerTemplate;
-import org.apache.solr.client.solrj.SolrQuery;
-import org.apache.solr.client.solrj.SolrServerException;
-import org.apache.solr.client.solrj.embedded.JettySolrRunner;
-import org.apache.solr.client.solrj.impl.CommonsHttpSolrServer;
-import org.apache.solr.client.solrj.response.QueryResponse;
-import org.apache.solr.client.solrj.util.ClientUtils;
-import org.apache.solr.common.SolrDocument;
-import org.apache.solr.common.SolrInputDocument;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
+import org.apache.camel.component.mock.MockEndpoint;
import org.junit.Test;
-import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests;
-@ContextConfiguration (locations = {"/SolrSpringTest-context.xml"})
-public class SolrSpringTest extends AbstractJUnit4SpringContextTests {
+@ContextConfiguration(locations = {"/SpringElasticsearchTest.xml"})
+public class SpringElasticsearchTest extends AbstractJUnit4SpringContextTests {
- static {
- System.setProperty("SolrServer.Port", Integer.toString(SolrComponentTestSupport.PORT));
- }
-
- private static JettySolrRunner solrRunner;
- private static CommonsHttpSolrServer solrServer;
-
- @Produce(uri = "direct:direct-xml-start")
- protected ProducerTemplate directXmlRoute;
-
- @Produce(uri = "direct:xml-start")
- protected ProducerTemplate xmlRoute;
-
- @Produce(uri = "direct:xml-start-streaming")
- protected ProducerTemplate xmlRouteStreaming;
+ @Produce(uri = "direct:index")
+ protected ProducerTemplate producer;
- @Produce(uri = "direct:pdf-start")
- protected ProducerTemplate pdfRoute;
+ @EndpointInject(uri = "mock:result")
+ protected MockEndpoint mock;
- @Produce(uri = "direct:pdf-start-streaming")
- protected ProducerTemplate pdfRouteStreaming;
-
-
- @DirtiesContext
@Test
- public void endToEndIndexDirectXML() throws Exception {
- SolrInputDocument doc = new SolrInputDocument();
- doc.addField("id", "MA147LL/A", 1.0f);
- String docAsXml = ClientUtils.toXML(doc);
- directXmlRoute.sendBody(docAsXml);
-
- QueryResponse response = executeSolrQuery("id:MA147LL/A");
- assertEquals(0, response.getStatus());
- assertEquals(1, response.getResults().getNumFound());
- }
-
- @DirtiesContext
- @Test
- public void endToEndIndexXMLDocuments() throws Exception {
- xmlRoute.sendBody(new File("src/test/resources/data/books.xml"));
-
- // Check things were indexed.
- QueryResponse response = executeSolrQuery("*:*");
-
- assertEquals(0, response.getStatus());
- assertEquals(4, response.getResults().getNumFound());
-
- // Check fields were indexed correctly.
- response = executeSolrQuery("title:Learning XML");
-
- SolrDocument doc = response.getResults().get(0);
- assertEquals("Learning XML", doc.getFieldValue("id"));
- assertEquals(Arrays.asList("Web", "Technology", "Computers"), doc.getFieldValue("cat"));
- }
-
-
- @DirtiesContext
- @Test
- public void endToEndIndexXMLDocumentsStreaming() throws Exception {
- xmlRouteStreaming.sendBody(new File("src/test/resources/data/books.xml"));
-
- // Check things were indexed.
- QueryResponse response = executeSolrQuery("*:*");
-
- assertEquals(0, response.getStatus());
- assertEquals(4, response.getResults().getNumFound());
+ public void testSendBody() throws Exception {
- // Check fields were indexed correctly.
- response = executeSolrQuery("title:Learning XML");
+ mock.expectedMinimumMessageCount(1);
- SolrDocument doc = response.getResults().get(0);
- assertEquals("Learning XML", doc.getFieldValue("id"));
- assertEquals(Arrays.asList("Web", "Technology", "Computers"), doc.getFieldValue("cat"));
+ producer.sendBody(new HashMap<String, String>() {
+ {
+ put("content", "test");
+ }
+ });
+ mock.assertIsSatisfied();
}
- @DirtiesContext
@Test
- public void endToEndIndexPDFDocument() throws Exception {
- pdfRoute.sendBody(new File("src/test/resources/data/tutorial.pdf"));
-
- QueryResponse response = executeSolrQuery("*:*");
-
- assertEquals(0, response.getStatus());
- assertEquals(1, response.getResults().getNumFound());
-
- SolrDocument doc = response.getResults().get(0);
- assertEquals("Solr", doc.getFieldValue("subject"));
- assertEquals("tutorial.pdf", doc.getFieldValue("id"));
- assertEquals(Arrays.asList("application/pdf"), doc.getFieldValue("content_type"));
- }
-
- @DirtiesContext
- @Test
- public void endToEndIndexPDFDocumentStreaming() throws Exception {
- pdfRouteStreaming.sendBody(new File("src/test/resources/data/tutorial.pdf"));
-
- QueryResponse response = executeSolrQuery("*:*");
-
- assertEquals(0, response.getStatus());
- assertEquals(1, response.getResults().getNumFound());
-
- SolrDocument doc = response.getResults().get(0);
- assertEquals("Solr", doc.getFieldValue("subject"));
- assertEquals("tutorial.pdf", doc.getFieldValue("id"));
- assertEquals(Arrays.asList("application/pdf"), doc.getFieldValue("content_type"));
- }
-
- @BeforeClass
- public static void beforeClass() throws Exception {
- // Set appropriate paths for Solr to use.
- System.setProperty("solr.solr.home", "src/test/resources/solr");
- System.setProperty("solr.data.dir", "target/test-classes/solr/data");
-
- // Instruct Solr to keep the index in memory, for faster testing.
- System.setProperty("solr.directoryFactory", "solr.RAMDirectoryFactory");
-
- // Start a Solr instance.
- solrRunner = new JettySolrRunner("/solr", SolrComponentTestSupport.PORT);
- solrRunner.start();
-
- solrServer = new CommonsHttpSolrServer("http://localhost:" + SolrComponentTestSupport.PORT + "/solr");
- }
-
- @AfterClass
- public static void afterClass() throws Exception {
- solrRunner.stop();
- }
-
- @Before
- public void clearIndex() throws Exception {
- // Clear the Solr index.
- solrServer.deleteByQuery("*:*");
- solrServer.commit();
- }
-
- private QueryResponse executeSolrQuery(String query) throws SolrServerException {
- SolrQuery solrQuery = new SolrQuery();
- solrQuery.setQuery(query);
- return solrServer.query(solrQuery);
+ public void testSendBodyAndHeaders() throws Exception {
+ mock.expectedMinimumMessageCount(1);
+ producer.sendBodyAndHeaders(new HashMap<String, String>() {
+ {
+ put("content", "test");
+ }
+ }, new HashMap() {
+ {
+ put(ElasticsearchConfiguration.PARAM_INDEX_NAME, "twitter");
+ put(ElasticsearchConfiguration.PARAM_INDEX_TYPE, "tweet");
+ }
+ }
+ );
+ mock.assertIsSatisfied();
}
}
Propchange: camel/trunk/components/camel-elasticsearch/src/test/java/org/apache/camel/component/elasticsearch/SpringElasticsearchTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Copied: camel/trunk/components/camel-elasticsearch/src/test/resources/SpringElasticsearchTest.xml (from r1363177, camel/trunk/components/camel-solr/src/test/resources/SolrSpringTest-context.xml)
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-elasticsearch/src/test/resources/SpringElasticsearchTest.xml?p2=camel/trunk/components/camel-elasticsearch/src/test/resources/SpringElasticsearchTest.xml&p1=camel/trunk/components/camel-solr/src/test/resources/SolrSpringTest-context.xml&r1=1363177&r2=1368312&rev=1368312&view=diff
==============================================================================
--- camel/trunk/components/camel-solr/src/test/resources/SolrSpringTest-context.xml (original)
+++ camel/trunk/components/camel-elasticsearch/src/test/resources/SpringElasticsearchTest.xml Wed Aug 1 23:34:14 2012
@@ -4,109 +4,12 @@
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
- <bean id="properties" class="org.apache.camel.component.properties.PropertiesComponent"/>
-
<camelContext xmlns="http://camel.apache.org/schema/spring">
- <route id="DirectXMLRoute">
- <from uri="direct:direct-xml-start" />
- <setHeader headerName="SolrOperation">
- <constant>INSERT</constant>
- </setHeader>
- <to uri="solr://localhost:{{SolrServer.Port}}/solr"/>
- <setHeader headerName="SolrOperation">
- <constant>COMMIT</constant>
- </setHeader>
- <to uri="solr://localhost:{{SolrServer.Port}}/solr"/>
- </route>
-
- <route id="XMLRoute">
- <from uri="direct:xml-start" />
- <split>
- <xpath>/bookstore/book</xpath>
- <convertBodyTo type="java.lang.String"/>
- <setHeader headerName="SolrOperation">
- <constant>INSERT</constant>
- </setHeader>
- <setHeader headerName="SolrField.id">
- <xpath resultType="java.lang.String">//title/text()</xpath>
- </setHeader>
- <setHeader headerName="SolrField.title">
- <xpath resultType="java.lang.String">//title/text()</xpath>
- </setHeader>
- <setHeader headerName="SolrField.cat">
- <groovy>
- def book = new XmlParser().parseText(request.body)
- book.cat.collect{ it.text() } as String[]
- </groovy>
- </setHeader>
- <to uri="solr://localhost:{{SolrServer.Port}}/solr"/>
- </split>
- <setHeader headerName="SolrOperation">
- <constant>COMMIT</constant>
- </setHeader>
- <to uri="solr://localhost:{{SolrServer.Port}}/solr"/>
- </route>
-
- <route id="XMLRoute-Streaming">
- <from uri="direct:xml-start-streaming" />
- <split>
- <xpath>/bookstore/book</xpath>
- <convertBodyTo type="java.lang.String"/>
- <setHeader headerName="SolrOperation">
- <constant>INSERT_STREAMING</constant>
- </setHeader>
- <setHeader headerName="SolrField.id">
- <xpath resultType="java.lang.String">//title/text()</xpath>
- </setHeader>
- <setHeader headerName="SolrField.title">
- <xpath resultType="java.lang.String">//title/text()</xpath>
- </setHeader>
- <setHeader headerName="SolrField.cat">
- <groovy>
- def book = new XmlParser().parseText(request.body)
- book.cat.collect{ it.text() } as String[]
- </groovy>
- </setHeader>
- <to uri="solr://localhost:{{SolrServer.Port}}/solr"/>
- </split>
- <delay><constant>500</constant></delay>
- <setHeader headerName="SolrOperation">
- <constant>COMMIT</constant>
- </setHeader>
- <to uri="solr://localhost:{{SolrServer.Port}}/solr"/>
+ <route>
+ <from uri="direct:index" />
+ <to uri="elasticsearch://local?indexName=twitter&indexType=tweet"/>
+ <to uri="mock:result"/>
</route>
-
- <route id="PDFRoute">
- <from uri="direct:pdf-start" />
- <setHeader headerName="SolrOperation">
- <constant>INSERT</constant>
- </setHeader>
- <setHeader headerName="SolrParam.literal.id">
- <simple>${body.name}</simple>
- </setHeader>
- <to uri="solr://localhost:{{SolrServer.Port}}/solr?requestHandler=/update/extract" />
- <setHeader headerName="SolrOperation">
- <constant>COMMIT</constant>
- </setHeader>
- <to uri="solr://localhost:{{SolrServer.Port}}/solr"/>
- </route>
-
- <route id="PDFRoute-Streaming">
- <from uri="direct:pdf-start-streaming" />
- <setHeader headerName="SolrOperation">
- <constant>INSERT_STREAMING</constant>
- </setHeader>
- <setHeader headerName="SolrParam.literal.id">
- <simple>${body.name}</simple>
- </setHeader>
- <to uri="solr://localhost:{{SolrServer.Port}}/solr?requestHandler=/update/extract" />
- <delay><constant>500</constant></delay>
- <setHeader headerName="SolrOperation">
- <constant>COMMIT</constant>
- </setHeader>
- <to uri="solr://localhost:{{SolrServer.Port}}/solr"/>
- </route>
-
</camelContext>
</beans>
Propchange: camel/trunk/components/camel-elasticsearch/src/test/resources/SpringElasticsearchTest.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/components/camel-elasticsearch/src/test/resources/SpringElasticsearchTest.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Modified: camel/trunk/components/pom.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/pom.xml?rev=1368312&r1=1368311&r2=1368312&view=diff
==============================================================================
--- camel/trunk/components/pom.xml (original)
+++ camel/trunk/components/pom.xml Wed Aug 1 23:34:14 2012
@@ -74,6 +74,7 @@
<module>camel-dozer</module>
<module>camel-eclipse</module>
<module>camel-ejb</module>
+ <module>camel-elasticsearch</module>
<module>camel-eventadmin</module>
<module>camel-exec</module>
<module>camel-flatpack</module>
Modified: camel/trunk/parent/pom.xml
URL: http://svn.apache.org/viewvc/camel/trunk/parent/pom.xml?rev=1368312&r1=1368311&r2=1368312&view=diff
==============================================================================
--- camel/trunk/parent/pom.xml (original)
+++ camel/trunk/parent/pom.xml Wed Aug 1 23:34:14 2012
@@ -71,6 +71,7 @@
<dozer-version>5.3.2</dozer-version>
<easymock-version>3.0</easymock-version>
<ehcache-bundle-version>2.5.2_1</ehcache-bundle-version>
+ <elasticsearch-version>0.19.8</elasticsearch-version>
<flatpack-version>3.2.0_2</flatpack-version>
<fop-version>1.0</fop-version>
<ftpserver-version>1.0.6</ftpserver-version>
@@ -400,6 +401,11 @@
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
+ <artifactId>camel-elasticsearch</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
<artifactId>camel-eventadmin</artifactId>
<version>${project.version}</version>
</dependency>
Modified: camel/trunk/platforms/karaf/features/pom.xml
URL: http://svn.apache.org/viewvc/camel/trunk/platforms/karaf/features/pom.xml?rev=1368312&r1=1368311&r2=1368312&view=diff
==============================================================================
--- camel/trunk/platforms/karaf/features/pom.xml (original)
+++ camel/trunk/platforms/karaf/features/pom.xml Wed Aug 1 23:34:14 2012
@@ -58,6 +58,7 @@
<commons-lang-version-xmljson>2.5</commons-lang-version-xmljson>
<dom4j-bundle-version>1.6.1_5</dom4j-bundle-version>
<el-api-1.0-version>1.0.1</el-api-1.0-version>
+ <elasticsearch-bundle-version>0.19.8_1-SNAPSHOT</elasticsearch-bundle-version>
<ezmorph-bundle-version>1.0.6_1</ezmorph-bundle-version>
<fastinfoset-version>1.2.7_4</fastinfoset-version>
<features.file>features.xml</features.file>
@@ -66,6 +67,7 @@
<felix-framework-version>2.0.5</felix-framework-version>
<fop-bundle-version>1.0_2</fop-bundle-version>
<freemarker-bundle-version>2.3.19_1</freemarker-bundle-version>
+ <google-guava-bundle-version>11_1</google-guava-bundle-version>
<geronimo-el-version>1.0.1</geronimo-el-version>
<geronimo-ws-metadata-spec-version>1.1.3</geronimo-ws-metadata-spec-version>
<gernimo-annotation-spec-version>1.1.1</gernimo-annotation-spec-version>
Modified: camel/trunk/platforms/karaf/features/src/main/resources/features.xml
URL: http://svn.apache.org/viewvc/camel/trunk/platforms/karaf/features/src/main/resources/features.xml?rev=1368312&r1=1368311&r2=1368312&view=diff
==============================================================================
--- camel/trunk/platforms/karaf/features/src/main/resources/features.xml (original)
+++ camel/trunk/platforms/karaf/features/src/main/resources/features.xml Wed Aug 1 23:34:14 2012
@@ -286,6 +286,19 @@
<bundle dependency='true'>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.commons-beanutils/${commons-beanutils-bundle-version}</bundle>
<bundle>mvn:org.apache.camel/camel-dozer/${project.version}</bundle>
</feature>
+ <feature name="camel-elasticsearch" version="${project.version}" resolver="(obr)" start-level="50">
+ <feature>http</feature>
+ <bundle dependency="true">mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.guava/${google-guava-bundle-version}</bundle>
+ <bundle dependency="true">mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.protobuf-java/${protobuf-java-bundle-version}</bundle>
+ <bundle dependency="true">mvn:org.codehaus.jackson/jackson-core-asl/${jackson-version}</bundle>
+ <bundle dependency="true">mvn:org.codehaus.jackson/jackson-mapper-asl/${jackson-version}</bundle>
+ <bundle dependency="true">mvn:org.codehaus.jackson/jackson-smile/${jackson-version}</bundle>
+ <bundle dependency="true">mvn:joda-time/joda-time/${jodatime-bundle-version}</bundle>
+ <bundle dependency="true">mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.mvel/${mvel-bundle-version}</bundle>
+ <bundle dependency='true'>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.lucene/${lucene-bundle-version}</bundle>
+ <bundle dependency='true'>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.elasticsearch/${elasticsearch-bundle-version}</bundle>
+ <bundle>mvn:org.apache.camel/camel-elasticsearch/${project.version}</bundle>
+ </feature>
<feature name='camel-eventadmin' version='${project.version}' resolver='(obr)' start-level='50'>
<feature>eventadmin</feature>
<feature version='${project.version}'>camel-core</feature>