Repository: nifi Updated Branches: refs/heads/master 6b34d3bea -> aa947e4d3
http://git-wip-us.apache.org/repos/asf/nifi/blob/aa947e4d/nifi-nar-bundles/nifi-standard-services/nifi-elasticsearch-client-service-api/src/main/java/org/apache/nifi/elasticsearch/ElasticSearchClientService.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-standard-services/nifi-elasticsearch-client-service-api/src/main/java/org/apache/nifi/elasticsearch/ElasticSearchClientService.java b/nifi-nar-bundles/nifi-standard-services/nifi-elasticsearch-client-service-api/src/main/java/org/apache/nifi/elasticsearch/ElasticSearchClientService.java new file mode 100644 index 0000000..1d44bc8 --- /dev/null +++ b/nifi-nar-bundles/nifi-standard-services/nifi-elasticsearch-client-service-api/src/main/java/org/apache/nifi/elasticsearch/ElasticSearchClientService.java @@ -0,0 +1,114 @@ +/* + * 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.nifi.elasticsearch; + +import org.apache.nifi.annotation.documentation.CapabilityDescription; +import org.apache.nifi.annotation.documentation.Tags; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.controller.ControllerService; +import org.apache.nifi.processor.util.StandardValidators; +import org.apache.nifi.ssl.SSLContextService; + +import java.io.IOException; + +@Tags({"elasticsearch", "client"}) +@CapabilityDescription("A controller service for accessing an ElasticSearch client.") +public interface ElasticSearchClientService extends ControllerService { + PropertyDescriptor HTTP_HOSTS = new PropertyDescriptor.Builder() + .name("el-cs-http-hosts") + .displayName("HTTP Hosts") + .description("A comma-separated list of HTTP hosts that host ElasticSearch query nodes.") + .required(true) + .expressionLanguageSupported(true) + .addValidator(StandardValidators.NON_EMPTY_VALIDATOR) + .build(); + PropertyDescriptor PROP_SSL_CONTEXT_SERVICE = new PropertyDescriptor.Builder() + .name("el-cs-ssl-context-service") + .displayName("SSL Context Service") + .description("The SSL Context Service used to provide client certificate information for TLS/SSL " + + "connections. This service only applies if the Elasticsearch endpoint(s) have been secured with TLS/SSL.") + .required(false) + .identifiesControllerService(SSLContextService.class) + .build(); + PropertyDescriptor USERNAME = new PropertyDescriptor.Builder() + .name("el-cs-username") + .displayName("Username") + .description("The username to use with XPack security.") + .required(false) + .expressionLanguageSupported(true) + .addValidator(StandardValidators.NON_EMPTY_VALIDATOR) + .build(); + PropertyDescriptor PASSWORD = new PropertyDescriptor.Builder() + .name("el-cs-password") + .displayName("Password") + .description("The password to use with XPack security.") + .required(false) + .sensitive(true) + .expressionLanguageSupported(true) + .addValidator(StandardValidators.NON_EMPTY_VALIDATOR) + .build(); + PropertyDescriptor CONNECT_TIMEOUT = new PropertyDescriptor.Builder() + .name("el-cs-connect-timeout") + .displayName("Connect timeout") + .description("Controls the amount of time, in milliseconds, before a timeout occurs when trying to connect.") + .required(true) + .defaultValue("5000") + .addValidator(StandardValidators.POSITIVE_INTEGER_VALIDATOR) + .build(); + PropertyDescriptor SOCKET_TIMEOUT = new PropertyDescriptor.Builder() + .name("el-cs-socket-timeout") + .displayName("Read timeout") + .description("Controls the amount of time, in milliseconds, before a timeout occurs when waiting for a response.") + .required(true) + .defaultValue("60000") + .addValidator(StandardValidators.POSITIVE_INTEGER_VALIDATOR) + .build(); + PropertyDescriptor RETRY_TIMEOUT = new PropertyDescriptor.Builder() + .name("el-cs-retry-timeout") + .displayName("Retry timeout") + .description("Controls the amount of time, in milliseconds, before a timeout occurs when retrying the operation.") + .required(true) + .defaultValue("60000") + .addValidator(StandardValidators.POSITIVE_INTEGER_VALIDATOR) + .build(); + PropertyDescriptor CHARSET = new PropertyDescriptor.Builder() + .name("el-cs-charset") + .displayName("Charset") + .description("The charset to use for interpreting the response from ElasticSearch.") + .required(true) + .defaultValue("UTF-8") + .addValidator(StandardValidators.NON_BLANK_VALIDATOR) + .build(); + + /** + * Perform a search using the JSON DSL. + * + * @param query A JSON string reprensenting the query. + * @param index The index to target. Optional. + * @param type The type to target. Optional. Will not be used in future versions of ElasticSearch. + * @return A SearchResponse object if successful. + */ + SearchResponse search(String query, String index, String type) throws IOException; + + /** + * Build a transit URL to use with the provenance reporter. + * @param index Index targeted. Optional. + * @param type Type targeted. Optional + * @return a URL describing the ElasticSearch cluster. + */ + String getTransitUrl(String index, String type); +} http://git-wip-us.apache.org/repos/asf/nifi/blob/aa947e4d/nifi-nar-bundles/nifi-standard-services/nifi-elasticsearch-client-service-api/src/main/java/org/apache/nifi/elasticsearch/SearchResponse.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-standard-services/nifi-elasticsearch-client-service-api/src/main/java/org/apache/nifi/elasticsearch/SearchResponse.java b/nifi-nar-bundles/nifi-standard-services/nifi-elasticsearch-client-service-api/src/main/java/org/apache/nifi/elasticsearch/SearchResponse.java new file mode 100644 index 0000000..725ad41 --- /dev/null +++ b/nifi-nar-bundles/nifi-standard-services/nifi-elasticsearch-client-service-api/src/main/java/org/apache/nifi/elasticsearch/SearchResponse.java @@ -0,0 +1,67 @@ +/* + * 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.nifi.elasticsearch; + +import java.util.List; +import java.util.Map; + +public class SearchResponse { + private List<Map<String, Object>> hits; + private Map<String, Object> aggregations; + private long numberOfHits; + private int took; + private boolean timedOut; + + public SearchResponse(List<Map<String, Object>> hits, Map<String, Object> aggregations, + int numberOfHits, int took, boolean timedOut) { + this.hits = hits; + this.aggregations = aggregations; + this.numberOfHits = numberOfHits; + this.took = took; + this.timedOut = timedOut; + } + + public Map<String, Object> getAggregations() { + return aggregations; + } + + public List<Map<String, Object>> getHits() { + return hits; + } + + public long getNumberOfHits() { + return numberOfHits; + } + + public boolean isTimedOut() { + return timedOut; + } + + public int getTook() { + return took; + } + + @Override + public String toString() { + return "SearchResponse{" + + "hits=" + hits + + ", aggregations=" + aggregations + + ", numberOfHits=" + numberOfHits + + '}'; + } +} http://git-wip-us.apache.org/repos/asf/nifi/blob/aa947e4d/nifi-nar-bundles/nifi-standard-services/nifi-standard-services-api-nar/pom.xml ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-standard-services/nifi-standard-services-api-nar/pom.xml b/nifi-nar-bundles/nifi-standard-services/nifi-standard-services-api-nar/pom.xml index ab5714d..49004b0 100644 --- a/nifi-nar-bundles/nifi-standard-services/nifi-standard-services-api-nar/pom.xml +++ b/nifi-nar-bundles/nifi-standard-services/nifi-standard-services-api-nar/pom.xml @@ -38,6 +38,12 @@ </dependency> <dependency> <groupId>org.apache.nifi</groupId> + <artifactId>nifi-elasticsearch-client-service-api</artifactId> + <version>1.6.0-SNAPSHOT</version> + <scope>compile</scope> + </dependency> + <dependency> + <groupId>org.apache.nifi</groupId> <artifactId>nifi-load-distribution-service-api</artifactId> <scope>compile</scope> </dependency> http://git-wip-us.apache.org/repos/asf/nifi/blob/aa947e4d/nifi-nar-bundles/nifi-standard-services/pom.xml ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-standard-services/pom.xml b/nifi-nar-bundles/nifi-standard-services/pom.xml index fb6c4d5..340ca66 100644 --- a/nifi-nar-bundles/nifi-standard-services/pom.xml +++ b/nifi-nar-bundles/nifi-standard-services/pom.xml @@ -25,6 +25,7 @@ <modules> <module>nifi-distributed-cache-client-service-api</module> <module>nifi-distributed-cache-services-bundle</module> + <module>nifi-elasticsearch-client-service-api</module> <module>nifi-load-distribution-service-api</module> <module>nifi-http-context-map-api</module> <module>nifi-lookup-service-api</module> http://git-wip-us.apache.org/repos/asf/nifi/blob/aa947e4d/pom.xml ---------------------------------------------------------------------- diff --git a/pom.xml b/pom.xml index 7088100..1aa529f 100644 --- a/pom.xml +++ b/pom.xml @@ -139,7 +139,7 @@ that live in the top-level lib directory and will be present in the parent-first classloading of all child nars. Therefore we dont want child nars using different versions anyway.--> - + <!-- javax.servlet-api handling this explicitly Must be in root lib --> <dependency> <groupId>javax.servlet</groupId> @@ -242,7 +242,7 @@ <version>1.3</version> <scope>test</scope> </dependency> - + <!-- These Jetty dependencies are required for the Jetty Web Server all nars extend from it so we dont want this getting overriden --> <dependency> <groupId>org.eclipse.jetty</groupId> @@ -663,18 +663,18 @@ <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-checkstyle-plugin</artifactId> - <executions> - <execution> - <id>check-style</id> - <phase>verify</phase> - <configuration> - <encoding>UTF-8</encoding> - </configuration> - <goals> - <goal>check</goal> - </goals> - </execution> - </executions> + <executions> + <execution> + <id>check-style</id> + <phase>verify</phase> + <configuration> + <encoding>UTF-8</encoding> + </configuration> + <goals> + <goal>check</goal> + </goals> + </execution> + </executions> </plugin> </plugins> </build>
