This is an automated email from the ASF dual-hosted git repository. acosentino pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel.git
commit f6d9327972b04005ad9cd1bfcdcdf773e9a3a211 Author: Andrea Cosentino <anco...@gmail.com> AuthorDate: Thu Mar 22 09:55:30 2018 +0100 CAMEL-12391 - Camel-Elasticsearch-rest: Add info operation to producer --- .../elasticsearch/ElasticsearchOperation.java | 3 +- .../elasticsearch/ElasticsearchProducer.java | 2 ++ .../elasticsearch/ElasticsearchInfoTest.java | 41 ++++++++++++++++++++++ 3 files changed, 45 insertions(+), 1 deletion(-) diff --git a/components/camel-elasticsearch-rest/src/main/java/org/apache/camel/component/elasticsearch/ElasticsearchOperation.java b/components/camel-elasticsearch-rest/src/main/java/org/apache/camel/component/elasticsearch/ElasticsearchOperation.java index 07d47fe..c7e538f 100644 --- a/components/camel-elasticsearch-rest/src/main/java/org/apache/camel/component/elasticsearch/ElasticsearchOperation.java +++ b/components/camel-elasticsearch-rest/src/main/java/org/apache/camel/component/elasticsearch/ElasticsearchOperation.java @@ -41,7 +41,8 @@ public enum ElasticsearchOperation { DeleteIndex("DeleteIndex"), Search("Search"), Exists("Exists"), - Ping("Ping"); + Ping("Ping"), + Info("Info"); private final String text; diff --git a/components/camel-elasticsearch-rest/src/main/java/org/apache/camel/component/elasticsearch/ElasticsearchProducer.java b/components/camel-elasticsearch-rest/src/main/java/org/apache/camel/component/elasticsearch/ElasticsearchProducer.java index 52c7afa..d2adc19 100644 --- a/components/camel-elasticsearch-rest/src/main/java/org/apache/camel/component/elasticsearch/ElasticsearchProducer.java +++ b/components/camel-elasticsearch-rest/src/main/java/org/apache/camel/component/elasticsearch/ElasticsearchProducer.java @@ -203,6 +203,8 @@ public class ElasticsearchProducer extends DefaultProducer { message.setBody(restHighLevelClient.search(searchRequest).getHits()); } else if (operation == ElasticsearchOperation.Ping) { message.setBody(restHighLevelClient.ping()); + } else if (operation == ElasticsearchOperation.Info) { + message.setBody(restHighLevelClient.info()); } else { throw new IllegalArgumentException(ElasticsearchConstants.PARAM_OPERATION + " value '" + operation + "' is not supported"); } diff --git a/components/camel-elasticsearch-rest/src/test/java/org/apache/camel/component/elasticsearch/ElasticsearchInfoTest.java b/components/camel-elasticsearch-rest/src/test/java/org/apache/camel/component/elasticsearch/ElasticsearchInfoTest.java new file mode 100644 index 0000000..6e49091 --- /dev/null +++ b/components/camel-elasticsearch-rest/src/test/java/org/apache/camel/component/elasticsearch/ElasticsearchInfoTest.java @@ -0,0 +1,41 @@ +/** + * 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.builder.RouteBuilder; +import org.elasticsearch.action.main.MainResponse; +import org.junit.Test; + +public class ElasticsearchInfoTest extends ElasticsearchBaseTest { + + @Test + public void testInfo() throws Exception { + MainResponse infoResult = template.requestBody("direct:info", "test", MainResponse.class); + assertNotNull(infoResult.getClusterName()); + assertNotNull(infoResult.getNodeName()); + } + + @Override + protected RouteBuilder createRouteBuilder() throws Exception { + return new RouteBuilder() { + @Override + public void configure() { + from("direct:info").to("elasticsearch-rest://elasticsearch?operation=Info&hostAddresses=localhost:" + ES_BASE_HTTP_PORT); + } + }; + } +} -- To stop receiving notification emails like this one, please contact acosent...@apache.org.