[GitHub] nifi pull request #2615: NIFI-5051 Created ElasticSearch lookup service.
Github user asfgit closed the pull request at: https://github.com/apache/nifi/pull/2615 ---
[GitHub] nifi pull request #2615: NIFI-5051 Created ElasticSearch lookup service.
Github user MikeThomsen commented on a diff in the pull request: https://github.com/apache/nifi/pull/2615#discussion_r218170885 --- Diff: nifi-nar-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-client-service/src/main/java/org/apache/nifi/elasticsearch/ElasticSearchLookupService.java --- @@ -0,0 +1,258 @@ +/* + * 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 com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.nifi.annotation.lifecycle.OnEnabled; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.controller.ConfigurationContext; +import org.apache.nifi.expression.ExpressionLanguageScope; +import org.apache.nifi.lookup.LookupFailureException; +import org.apache.nifi.lookup.LookupService; +import org.apache.nifi.processor.util.StandardValidators; +import org.apache.nifi.schema.access.SchemaNotFoundException; +import org.apache.nifi.serialization.JsonInferenceSchemaRegistryService; +import org.apache.nifi.serialization.record.MapRecord; +import org.apache.nifi.serialization.record.Record; +import org.apache.nifi.serialization.record.RecordSchema; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.Set; +import java.util.stream.Collectors; + +public class ElasticSearchLookupService extends JsonInferenceSchemaRegistryService implements LookupService { +public static final PropertyDescriptor CLIENT_SERVICE = new PropertyDescriptor.Builder() +.name("el-rest-client-service") +.displayName("Client Service") +.description("An ElasticSearch client service to use for running queries.") +.identifiesControllerService(ElasticSearchClientService.class) +.required(true) +.build(); +public static final PropertyDescriptor INDEX = new PropertyDescriptor.Builder() +.name("el-lookup-index") +.displayName("Index") +.description("The name of the index to read from") +.required(true) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) +.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) +.build(); + +public static final PropertyDescriptor TYPE = new PropertyDescriptor.Builder() +.name("el-lookup-type") +.displayName("Type") +.description("The type of this document (used by Elasticsearch for indexing and searching)") +.required(false) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) +.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) +.build(); + +private ElasticSearchClientService clientService; + +private String index; +private String type; +private ObjectMapper mapper; + +private final List DESCRIPTORS; + +public ElasticSearchLookupService() { +List _desc = new ArrayList<>(); +_desc.addAll(super.getSupportedPropertyDescriptors()); +_desc.add(CLIENT_SERVICE); +_desc.add(INDEX); +_desc.add(TYPE); +DESCRIPTORS = Collections.unmodifiableList(_desc); +} + +@Override +@OnEnabled +public void onEnabled(final ConfigurationContext context) { +clientService = context.getProperty(CLIENT_SERVICE).asControllerService(ElasticSearchClientService.class); +index = context.getProperty(INDEX).evaluateAttributeExpressions().getValue(); +type = context.getProperty(TYPE).evaluateAttributeExpressions().getValue(); +mapper = new ObjectMapper(); + +super.onEnabled(context); +} + +@Override +protected List getSupportedPropertyDescriptors() { +return DESCRIPTORS; +
[GitHub] nifi pull request #2615: NIFI-5051 Created ElasticSearch lookup service.
Github user mattyb149 commented on a diff in the pull request: https://github.com/apache/nifi/pull/2615#discussion_r218162804 --- Diff: nifi-nar-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-client-service/src/main/java/org/apache/nifi/elasticsearch/ElasticSearchLookupService.java --- @@ -0,0 +1,258 @@ +/* + * 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 com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.nifi.annotation.lifecycle.OnEnabled; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.controller.ConfigurationContext; +import org.apache.nifi.expression.ExpressionLanguageScope; +import org.apache.nifi.lookup.LookupFailureException; +import org.apache.nifi.lookup.LookupService; +import org.apache.nifi.processor.util.StandardValidators; +import org.apache.nifi.schema.access.SchemaNotFoundException; +import org.apache.nifi.serialization.JsonInferenceSchemaRegistryService; +import org.apache.nifi.serialization.record.MapRecord; +import org.apache.nifi.serialization.record.Record; +import org.apache.nifi.serialization.record.RecordSchema; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.Set; +import java.util.stream.Collectors; + +public class ElasticSearchLookupService extends JsonInferenceSchemaRegistryService implements LookupService { +public static final PropertyDescriptor CLIENT_SERVICE = new PropertyDescriptor.Builder() +.name("el-rest-client-service") +.displayName("Client Service") +.description("An ElasticSearch client service to use for running queries.") +.identifiesControllerService(ElasticSearchClientService.class) +.required(true) +.build(); +public static final PropertyDescriptor INDEX = new PropertyDescriptor.Builder() +.name("el-lookup-index") +.displayName("Index") +.description("The name of the index to read from") +.required(true) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) +.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) +.build(); + +public static final PropertyDescriptor TYPE = new PropertyDescriptor.Builder() +.name("el-lookup-type") +.displayName("Type") +.description("The type of this document (used by Elasticsearch for indexing and searching)") +.required(false) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) +.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) +.build(); + +private ElasticSearchClientService clientService; + +private String index; +private String type; +private ObjectMapper mapper; + +private final List DESCRIPTORS; + +public ElasticSearchLookupService() { +List _desc = new ArrayList<>(); +_desc.addAll(super.getSupportedPropertyDescriptors()); +_desc.add(CLIENT_SERVICE); +_desc.add(INDEX); +_desc.add(TYPE); +DESCRIPTORS = Collections.unmodifiableList(_desc); +} + +@Override +@OnEnabled +public void onEnabled(final ConfigurationContext context) { +clientService = context.getProperty(CLIENT_SERVICE).asControllerService(ElasticSearchClientService.class); +index = context.getProperty(INDEX).evaluateAttributeExpressions().getValue(); +type = context.getProperty(TYPE).evaluateAttributeExpressions().getValue(); +mapper = new ObjectMapper(); + +super.onEnabled(context); +} + +@Override +protected List getSupportedPropertyDescriptors() { +return DESCRIPTORS; +
[GitHub] nifi pull request #2615: NIFI-5051 Created ElasticSearch lookup service.
Github user MikeThomsen commented on a diff in the pull request: https://github.com/apache/nifi/pull/2615#discussion_r217899955 --- Diff: nifi-nar-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-client-service/src/main/java/org/apache/nifi/elasticsearch/ElasticSearchLookupService.java --- @@ -0,0 +1,258 @@ +/* + * 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 com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.nifi.annotation.lifecycle.OnEnabled; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.controller.ConfigurationContext; +import org.apache.nifi.expression.ExpressionLanguageScope; +import org.apache.nifi.lookup.LookupFailureException; +import org.apache.nifi.lookup.LookupService; +import org.apache.nifi.processor.util.StandardValidators; +import org.apache.nifi.schema.access.SchemaNotFoundException; +import org.apache.nifi.serialization.JsonInferenceSchemaRegistryService; +import org.apache.nifi.serialization.record.MapRecord; +import org.apache.nifi.serialization.record.Record; +import org.apache.nifi.serialization.record.RecordSchema; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.Set; +import java.util.stream.Collectors; + +public class ElasticSearchLookupService extends JsonInferenceSchemaRegistryService implements LookupService { +public static final PropertyDescriptor CLIENT_SERVICE = new PropertyDescriptor.Builder() +.name("el-rest-client-service") +.displayName("Client Service") +.description("An ElasticSearch client service to use for running queries.") +.identifiesControllerService(ElasticSearchClientService.class) +.required(true) +.build(); +public static final PropertyDescriptor INDEX = new PropertyDescriptor.Builder() +.name("el-lookup-index") +.displayName("Index") +.description("The name of the index to read from") +.required(true) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) +.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) +.build(); + +public static final PropertyDescriptor TYPE = new PropertyDescriptor.Builder() +.name("el-lookup-type") +.displayName("Type") +.description("The type of this document (used by Elasticsearch for indexing and searching)") +.required(false) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) +.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) +.build(); + +private ElasticSearchClientService clientService; + +private String index; +private String type; +private ObjectMapper mapper; + +private final List DESCRIPTORS; + +public ElasticSearchLookupService() { +List _desc = new ArrayList<>(); +_desc.addAll(super.getSupportedPropertyDescriptors()); +_desc.add(CLIENT_SERVICE); +_desc.add(INDEX); +_desc.add(TYPE); +DESCRIPTORS = Collections.unmodifiableList(_desc); +} + +@Override +@OnEnabled +public void onEnabled(final ConfigurationContext context) { +clientService = context.getProperty(CLIENT_SERVICE).asControllerService(ElasticSearchClientService.class); +index = context.getProperty(INDEX).evaluateAttributeExpressions().getValue(); +type = context.getProperty(TYPE).evaluateAttributeExpressions().getValue(); +mapper = new ObjectMapper(); + +super.onEnabled(context); +} + +@Override +protected List getSupportedPropertyDescriptors() { +return DESCRIPTORS; +
[GitHub] nifi pull request #2615: NIFI-5051 Created ElasticSearch lookup service.
Github user MikeThomsen commented on a diff in the pull request: https://github.com/apache/nifi/pull/2615#discussion_r217899033 --- Diff: nifi-nar-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-client-service/src/main/java/org/apache/nifi/elasticsearch/ElasticSearchLookupService.java --- @@ -0,0 +1,258 @@ +/* + * 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 com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.nifi.annotation.lifecycle.OnEnabled; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.controller.ConfigurationContext; +import org.apache.nifi.expression.ExpressionLanguageScope; +import org.apache.nifi.lookup.LookupFailureException; +import org.apache.nifi.lookup.LookupService; +import org.apache.nifi.processor.util.StandardValidators; +import org.apache.nifi.schema.access.SchemaNotFoundException; +import org.apache.nifi.serialization.JsonInferenceSchemaRegistryService; +import org.apache.nifi.serialization.record.MapRecord; +import org.apache.nifi.serialization.record.Record; +import org.apache.nifi.serialization.record.RecordSchema; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.Set; +import java.util.stream.Collectors; + +public class ElasticSearchLookupService extends JsonInferenceSchemaRegistryService implements LookupService { +public static final PropertyDescriptor CLIENT_SERVICE = new PropertyDescriptor.Builder() +.name("el-rest-client-service") +.displayName("Client Service") +.description("An ElasticSearch client service to use for running queries.") +.identifiesControllerService(ElasticSearchClientService.class) +.required(true) +.build(); +public static final PropertyDescriptor INDEX = new PropertyDescriptor.Builder() +.name("el-lookup-index") +.displayName("Index") +.description("The name of the index to read from") +.required(true) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) +.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) +.build(); + +public static final PropertyDescriptor TYPE = new PropertyDescriptor.Builder() +.name("el-lookup-type") +.displayName("Type") +.description("The type of this document (used by Elasticsearch for indexing and searching)") +.required(false) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) +.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) +.build(); + +private ElasticSearchClientService clientService; + +private String index; +private String type; +private ObjectMapper mapper; + +private final List DESCRIPTORS; + +public ElasticSearchLookupService() { +List _desc = new ArrayList<>(); +_desc.addAll(super.getSupportedPropertyDescriptors()); +_desc.add(CLIENT_SERVICE); +_desc.add(INDEX); +_desc.add(TYPE); +DESCRIPTORS = Collections.unmodifiableList(_desc); +} + +@Override +@OnEnabled +public void onEnabled(final ConfigurationContext context) { +clientService = context.getProperty(CLIENT_SERVICE).asControllerService(ElasticSearchClientService.class); +index = context.getProperty(INDEX).evaluateAttributeExpressions().getValue(); +type = context.getProperty(TYPE).evaluateAttributeExpressions().getValue(); +mapper = new ObjectMapper(); + +super.onEnabled(context); +} + +@Override +protected List getSupportedPropertyDescriptors() { +return DESCRIPTORS; +
[GitHub] nifi pull request #2615: NIFI-5051 Created ElasticSearch lookup service.
Github user MikeThomsen commented on a diff in the pull request: https://github.com/apache/nifi/pull/2615#discussion_r217898996 --- Diff: nifi-nar-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-client-service/pom.xml --- @@ -150,6 +172,7 @@ 9400 5.6.2 90 + src/test/resources/setup.script --- End diff -- Resolved. ---
[GitHub] nifi pull request #2615: NIFI-5051 Created ElasticSearch lookup service.
Github user MikeThomsen commented on a diff in the pull request: https://github.com/apache/nifi/pull/2615#discussion_r217884483 --- Diff: nifi-nar-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-client-service/pom.xml --- @@ -150,6 +172,7 @@ 9400 5.6.2 90 + src/test/resources/setup.script --- End diff -- Verified that's the case. Going to have to look into that. ---
[GitHub] nifi pull request #2615: NIFI-5051 Created ElasticSearch lookup service.
Github user MikeThomsen commented on a diff in the pull request: https://github.com/apache/nifi/pull/2615#discussion_r217884439 --- Diff: nifi-nar-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-client-service/src/main/java/org/apache/nifi/elasticsearch/ElasticSearchLookupService.java --- @@ -0,0 +1,258 @@ +/* + * 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 com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.nifi.annotation.lifecycle.OnEnabled; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.controller.ConfigurationContext; +import org.apache.nifi.expression.ExpressionLanguageScope; +import org.apache.nifi.lookup.LookupFailureException; +import org.apache.nifi.lookup.LookupService; +import org.apache.nifi.processor.util.StandardValidators; +import org.apache.nifi.schema.access.SchemaNotFoundException; +import org.apache.nifi.serialization.JsonInferenceSchemaRegistryService; +import org.apache.nifi.serialization.record.MapRecord; +import org.apache.nifi.serialization.record.Record; +import org.apache.nifi.serialization.record.RecordSchema; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.Set; +import java.util.stream.Collectors; + +public class ElasticSearchLookupService extends JsonInferenceSchemaRegistryService implements LookupService { +public static final PropertyDescriptor CLIENT_SERVICE = new PropertyDescriptor.Builder() +.name("el-rest-client-service") +.displayName("Client Service") +.description("An ElasticSearch client service to use for running queries.") +.identifiesControllerService(ElasticSearchClientService.class) +.required(true) +.build(); +public static final PropertyDescriptor INDEX = new PropertyDescriptor.Builder() +.name("el-lookup-index") +.displayName("Index") +.description("The name of the index to read from") +.required(true) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) +.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) +.build(); + +public static final PropertyDescriptor TYPE = new PropertyDescriptor.Builder() +.name("el-lookup-type") +.displayName("Type") +.description("The type of this document (used by Elasticsearch for indexing and searching)") +.required(false) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) +.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) +.build(); + +private ElasticSearchClientService clientService; + +private String index; +private String type; +private ObjectMapper mapper; + +private final List DESCRIPTORS; + +public ElasticSearchLookupService() { +List _desc = new ArrayList<>(); +_desc.addAll(super.getSupportedPropertyDescriptors()); +_desc.add(CLIENT_SERVICE); +_desc.add(INDEX); +_desc.add(TYPE); +DESCRIPTORS = Collections.unmodifiableList(_desc); +} + +@Override +@OnEnabled +public void onEnabled(final ConfigurationContext context) { +clientService = context.getProperty(CLIENT_SERVICE).asControllerService(ElasticSearchClientService.class); +index = context.getProperty(INDEX).evaluateAttributeExpressions().getValue(); +type = context.getProperty(TYPE).evaluateAttributeExpressions().getValue(); +mapper = new ObjectMapper(); + +super.onEnabled(context); +} + +@Override +protected List getSupportedPropertyDescriptors() { +return DESCRIPTORS; +
[GitHub] nifi pull request #2615: NIFI-5051 Created ElasticSearch lookup service.
Github user mattyb149 commented on a diff in the pull request: https://github.com/apache/nifi/pull/2615#discussion_r217869883 --- Diff: nifi-nar-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-client-service/pom.xml --- @@ -150,6 +172,7 @@ 9400 5.6.2 90 + src/test/resources/setup.script --- End diff -- I don't think this works if you run -Pintegration-tests from the bundle level, but it does from the client-service level ---
[GitHub] nifi pull request #2615: NIFI-5051 Created ElasticSearch lookup service.
Github user mattyb149 commented on a diff in the pull request: https://github.com/apache/nifi/pull/2615#discussion_r217870054 --- Diff: nifi-nar-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-client-service/src/main/java/org/apache/nifi/elasticsearch/ElasticSearchLookupService.java --- @@ -0,0 +1,258 @@ +/* + * 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 com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.nifi.annotation.lifecycle.OnEnabled; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.controller.ConfigurationContext; +import org.apache.nifi.expression.ExpressionLanguageScope; +import org.apache.nifi.lookup.LookupFailureException; +import org.apache.nifi.lookup.LookupService; +import org.apache.nifi.processor.util.StandardValidators; +import org.apache.nifi.schema.access.SchemaNotFoundException; +import org.apache.nifi.serialization.JsonInferenceSchemaRegistryService; +import org.apache.nifi.serialization.record.MapRecord; +import org.apache.nifi.serialization.record.Record; +import org.apache.nifi.serialization.record.RecordSchema; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.Set; +import java.util.stream.Collectors; + +public class ElasticSearchLookupService extends JsonInferenceSchemaRegistryService implements LookupService { +public static final PropertyDescriptor CLIENT_SERVICE = new PropertyDescriptor.Builder() +.name("el-rest-client-service") +.displayName("Client Service") +.description("An ElasticSearch client service to use for running queries.") +.identifiesControllerService(ElasticSearchClientService.class) +.required(true) +.build(); +public static final PropertyDescriptor INDEX = new PropertyDescriptor.Builder() +.name("el-lookup-index") +.displayName("Index") +.description("The name of the index to read from") +.required(true) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) +.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) +.build(); + +public static final PropertyDescriptor TYPE = new PropertyDescriptor.Builder() +.name("el-lookup-type") +.displayName("Type") +.description("The type of this document (used by Elasticsearch for indexing and searching)") +.required(false) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) +.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) +.build(); + +private ElasticSearchClientService clientService; + +private String index; +private String type; +private ObjectMapper mapper; + +private final List DESCRIPTORS; + +public ElasticSearchLookupService() { +List _desc = new ArrayList<>(); +_desc.addAll(super.getSupportedPropertyDescriptors()); +_desc.add(CLIENT_SERVICE); +_desc.add(INDEX); +_desc.add(TYPE); +DESCRIPTORS = Collections.unmodifiableList(_desc); +} + +@Override +@OnEnabled +public void onEnabled(final ConfigurationContext context) { +clientService = context.getProperty(CLIENT_SERVICE).asControllerService(ElasticSearchClientService.class); +index = context.getProperty(INDEX).evaluateAttributeExpressions().getValue(); +type = context.getProperty(TYPE).evaluateAttributeExpressions().getValue(); +mapper = new ObjectMapper(); + +super.onEnabled(context); +} + +@Override +protected List getSupportedPropertyDescriptors() { +return DESCRIPTORS; +
[GitHub] nifi pull request #2615: NIFI-5051 Created ElasticSearch lookup service.
Github user MikeThomsen commented on a diff in the pull request: https://github.com/apache/nifi/pull/2615#discussion_r217756404 --- Diff: nifi-nar-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-client-service/src/main/java/org/apache/nifi/elasticsearch/ElasticSearchLookupService.java --- @@ -0,0 +1,258 @@ +/* + * 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 com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.nifi.annotation.lifecycle.OnEnabled; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.controller.ConfigurationContext; +import org.apache.nifi.expression.ExpressionLanguageScope; +import org.apache.nifi.lookup.LookupFailureException; +import org.apache.nifi.lookup.LookupService; +import org.apache.nifi.processor.util.StandardValidators; +import org.apache.nifi.schema.access.SchemaNotFoundException; +import org.apache.nifi.serialization.JsonInferenceSchemaRegistryService; +import org.apache.nifi.serialization.record.MapRecord; +import org.apache.nifi.serialization.record.Record; +import org.apache.nifi.serialization.record.RecordSchema; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.Set; +import java.util.stream.Collectors; + +public class ElasticSearchLookupService extends JsonInferenceSchemaRegistryService implements LookupService { +public static final PropertyDescriptor CLIENT_SERVICE = new PropertyDescriptor.Builder() +.name("el-rest-client-service") +.displayName("Client Service") +.description("An ElasticSearch client service to use for running queries.") +.identifiesControllerService(ElasticSearchClientService.class) +.required(true) +.build(); +public static final PropertyDescriptor INDEX = new PropertyDescriptor.Builder() +.name("el-lookup-index") +.displayName("Index") +.description("The name of the index to read from") +.required(true) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) +.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) +.build(); + +public static final PropertyDescriptor TYPE = new PropertyDescriptor.Builder() +.name("el-lookup-type") +.displayName("Type") +.description("The type of this document (used by Elasticsearch for indexing and searching)") +.required(false) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) +.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) +.build(); + +private ElasticSearchClientService clientService; + +private String index; +private String type; +private ObjectMapper mapper; + +private final List DESCRIPTORS; + +ElasticSearchLookupService() { --- End diff -- Done. NiFi is able to load it and assign it as the lookupservice for lookuprecord. ---
[GitHub] nifi pull request #2615: NIFI-5051 Created ElasticSearch lookup service.
Github user MikeThomsen commented on a diff in the pull request: https://github.com/apache/nifi/pull/2615#discussion_r217751008 --- Diff: nifi-nar-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-client-service/src/main/java/org/apache/nifi/elasticsearch/ElasticSearchLookupService.java --- @@ -0,0 +1,258 @@ +/* + * 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 com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.nifi.annotation.lifecycle.OnEnabled; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.controller.ConfigurationContext; +import org.apache.nifi.expression.ExpressionLanguageScope; +import org.apache.nifi.lookup.LookupFailureException; +import org.apache.nifi.lookup.LookupService; +import org.apache.nifi.processor.util.StandardValidators; +import org.apache.nifi.schema.access.SchemaNotFoundException; +import org.apache.nifi.serialization.JsonInferenceSchemaRegistryService; +import org.apache.nifi.serialization.record.MapRecord; +import org.apache.nifi.serialization.record.Record; +import org.apache.nifi.serialization.record.RecordSchema; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.Set; +import java.util.stream.Collectors; + +public class ElasticSearchLookupService extends JsonInferenceSchemaRegistryService implements LookupService { +public static final PropertyDescriptor CLIENT_SERVICE = new PropertyDescriptor.Builder() +.name("el-rest-client-service") +.displayName("Client Service") +.description("An ElasticSearch client service to use for running queries.") +.identifiesControllerService(ElasticSearchClientService.class) +.required(true) +.build(); +public static final PropertyDescriptor INDEX = new PropertyDescriptor.Builder() +.name("el-lookup-index") +.displayName("Index") +.description("The name of the index to read from") +.required(true) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) +.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) +.build(); + +public static final PropertyDescriptor TYPE = new PropertyDescriptor.Builder() +.name("el-lookup-type") +.displayName("Type") +.description("The type of this document (used by Elasticsearch for indexing and searching)") +.required(false) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) +.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) +.build(); + +private ElasticSearchClientService clientService; + +private String index; +private String type; +private ObjectMapper mapper; + +private final List DESCRIPTORS; + +ElasticSearchLookupService() { --- End diff -- *facepalm* One fix, coming right up... ---
[GitHub] nifi pull request #2615: NIFI-5051 Created ElasticSearch lookup service.
Github user mattyb149 commented on a diff in the pull request: https://github.com/apache/nifi/pull/2615#discussion_r217746687 --- Diff: nifi-nar-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-client-service/src/main/java/org/apache/nifi/elasticsearch/ElasticSearchLookupService.java --- @@ -0,0 +1,258 @@ +/* + * 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 com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.nifi.annotation.lifecycle.OnEnabled; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.controller.ConfigurationContext; +import org.apache.nifi.expression.ExpressionLanguageScope; +import org.apache.nifi.lookup.LookupFailureException; +import org.apache.nifi.lookup.LookupService; +import org.apache.nifi.processor.util.StandardValidators; +import org.apache.nifi.schema.access.SchemaNotFoundException; +import org.apache.nifi.serialization.JsonInferenceSchemaRegistryService; +import org.apache.nifi.serialization.record.MapRecord; +import org.apache.nifi.serialization.record.Record; +import org.apache.nifi.serialization.record.RecordSchema; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.Set; +import java.util.stream.Collectors; + +public class ElasticSearchLookupService extends JsonInferenceSchemaRegistryService implements LookupService { +public static final PropertyDescriptor CLIENT_SERVICE = new PropertyDescriptor.Builder() +.name("el-rest-client-service") +.displayName("Client Service") +.description("An ElasticSearch client service to use for running queries.") +.identifiesControllerService(ElasticSearchClientService.class) +.required(true) +.build(); +public static final PropertyDescriptor INDEX = new PropertyDescriptor.Builder() +.name("el-lookup-index") +.displayName("Index") +.description("The name of the index to read from") +.required(true) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) +.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) +.build(); + +public static final PropertyDescriptor TYPE = new PropertyDescriptor.Builder() +.name("el-lookup-type") +.displayName("Type") +.description("The type of this document (used by Elasticsearch for indexing and searching)") +.required(false) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) +.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) +.build(); + +private ElasticSearchClientService clientService; + +private String index; +private String type; +private ObjectMapper mapper; + +private final List DESCRIPTORS; + +ElasticSearchLookupService() { --- End diff -- I think this has to be public for ServiceLoader to find it, I'm getting errors when trying to load it into NiFi. ---
[GitHub] nifi pull request #2615: NIFI-5051 Created ElasticSearch lookup service.
Github user MikeThomsen commented on a diff in the pull request: https://github.com/apache/nifi/pull/2615#discussion_r210070170 --- Diff: nifi-nar-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-client-service/pom.xml --- @@ -127,8 +133,113 @@ 5.6.8 compile + +org.apache.nifi +nifi-avro-record-utils +1.7.0-SNAPSHOT +compile + + +org.apache.nifi +nifi-schema-registry-service-api +compile + + +org.mockito +mockito-all +test + + --- End diff -- @alopresto thanks for explaining that. I just added a .gitignore file into src/test/java and that did the trick. ---
[GitHub] nifi pull request #2615: NIFI-5051 Created ElasticSearch lookup service.
Github user alopresto commented on a diff in the pull request: https://github.com/apache/nifi/pull/2615#discussion_r210029087 --- Diff: nifi-nar-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-client-service/pom.xml --- @@ -127,8 +133,113 @@ 5.6.8 compile + +org.apache.nifi +nifi-avro-record-utils +1.7.0-SNAPSHOT +compile + + +org.apache.nifi +nifi-schema-registry-service-api +compile + + +org.mockito +mockito-all +test + + --- End diff -- If there is nothing in `src/test/java`, the Groovy tests won't be detected unless a plugin references them directly. In this case, the `build-helper-maven-plugin` is accomplishing that. In other locations, the `maven-compiler-plugin` is set to use `groovy-eclipse-compiler` to achieve the same result. ---
[GitHub] nifi pull request #2615: NIFI-5051 Created ElasticSearch lookup service.
Github user MikeThomsen commented on a diff in the pull request: https://github.com/apache/nifi/pull/2615#discussion_r209966944 --- Diff: nifi-nar-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-client-service/src/main/java/org/apache/nifi/elasticsearch/ElasticSearchLookupService.java --- @@ -0,0 +1,253 @@ +/* + * 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 com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.nifi.annotation.lifecycle.OnEnabled; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.components.Validator; +import org.apache.nifi.controller.ConfigurationContext; +import org.apache.nifi.expression.ExpressionLanguageScope; +import org.apache.nifi.lookup.LookupFailureException; +import org.apache.nifi.lookup.LookupService; +import org.apache.nifi.processor.util.StandardValidators; +import org.apache.nifi.reporting.InitializationException; +import org.apache.nifi.schema.access.SchemaNotFoundException; +import org.apache.nifi.serialization.SchemaRegistryService; +import org.apache.nifi.serialization.SimpleRecordSchema; +import org.apache.nifi.serialization.record.MapRecord; +import org.apache.nifi.serialization.record.Record; +import org.apache.nifi.serialization.record.RecordField; +import org.apache.nifi.serialization.record.RecordFieldType; +import org.apache.nifi.serialization.record.RecordSchema; +import org.apache.nifi.serialization.record.type.RecordDataType; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.Set; +import java.util.stream.Collectors; + +public class ElasticSearchLookupService extends SchemaRegistryService implements LookupService { +public static final PropertyDescriptor CLIENT_SERVICE = new PropertyDescriptor.Builder() +.name("el-rest-client-service") +.displayName("Client Service") +.description("An ElasticSearch client service to use for running queries.") +.identifiesControllerService(ElasticSearchClientService.class) +.required(true) +.build(); +public static final PropertyDescriptor INDEX = new PropertyDescriptor.Builder() +.name("el-lookup-index") +.displayName("Index") +.description("The name of the index to read from") +.required(true) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) +.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) +.build(); + +public static final PropertyDescriptor TYPE = new PropertyDescriptor.Builder() +.name("el-lookup-type") +.displayName("Type") +.description("The type of this document (used by Elasticsearch for indexing and searching)") +.required(false) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) +.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) +.build(); + + +public static final PropertyDescriptor RECORD_SCHEMA_NAME = new PropertyDescriptor.Builder() +.name("el-lookup-record-schema-name") +.displayName("Record Schema Name") +.description("If specified, the value will be used to lookup a schema in the configured schema registry.") +.required(false) +.addValidator(Validator.VALID) +.build(); + +private ElasticSearchClientService clientService; + +private String index; +private String type; +private ObjectMapper mapper; + +@OnEnabled +public void onEnabled(final ConfigurationContext context) throws InitializationException { +clientService = context.getProperty(CLIENT_SERVICE).asControllerService(ElasticSearchClientService.class);
[GitHub] nifi pull request #2615: NIFI-5051 Created ElasticSearch lookup service.
Github user MikeThomsen commented on a diff in the pull request: https://github.com/apache/nifi/pull/2615#discussion_r209707403 --- Diff: nifi-nar-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-client-service/src/main/java/org/apache/nifi/elasticsearch/ElasticSearchLookupService.java --- @@ -0,0 +1,253 @@ +/* + * 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 com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.nifi.annotation.lifecycle.OnEnabled; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.components.Validator; +import org.apache.nifi.controller.ConfigurationContext; +import org.apache.nifi.expression.ExpressionLanguageScope; +import org.apache.nifi.lookup.LookupFailureException; +import org.apache.nifi.lookup.LookupService; +import org.apache.nifi.processor.util.StandardValidators; +import org.apache.nifi.reporting.InitializationException; +import org.apache.nifi.schema.access.SchemaNotFoundException; +import org.apache.nifi.serialization.SchemaRegistryService; +import org.apache.nifi.serialization.SimpleRecordSchema; +import org.apache.nifi.serialization.record.MapRecord; +import org.apache.nifi.serialization.record.Record; +import org.apache.nifi.serialization.record.RecordField; +import org.apache.nifi.serialization.record.RecordFieldType; +import org.apache.nifi.serialization.record.RecordSchema; +import org.apache.nifi.serialization.record.type.RecordDataType; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.Set; +import java.util.stream.Collectors; + +public class ElasticSearchLookupService extends SchemaRegistryService implements LookupService { +public static final PropertyDescriptor CLIENT_SERVICE = new PropertyDescriptor.Builder() +.name("el-rest-client-service") +.displayName("Client Service") +.description("An ElasticSearch client service to use for running queries.") +.identifiesControllerService(ElasticSearchClientService.class) +.required(true) +.build(); +public static final PropertyDescriptor INDEX = new PropertyDescriptor.Builder() +.name("el-lookup-index") +.displayName("Index") +.description("The name of the index to read from") +.required(true) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) +.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) +.build(); + +public static final PropertyDescriptor TYPE = new PropertyDescriptor.Builder() +.name("el-lookup-type") +.displayName("Type") +.description("The type of this document (used by Elasticsearch for indexing and searching)") +.required(false) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) +.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) +.build(); + + +public static final PropertyDescriptor RECORD_SCHEMA_NAME = new PropertyDescriptor.Builder() +.name("el-lookup-record-schema-name") +.displayName("Record Schema Name") +.description("If specified, the value will be used to lookup a schema in the configured schema registry.") +.required(false) +.addValidator(Validator.VALID) +.build(); + +private ElasticSearchClientService clientService; + +private String index; +private String type; +private ObjectMapper mapper; + +@OnEnabled +public void onEnabled(final ConfigurationContext context) throws InitializationException { +clientService = context.getProperty(CLIENT_SERVICE).asControllerService(ElasticSearchClientService.class);
[GitHub] nifi pull request #2615: NIFI-5051 Created ElasticSearch lookup service.
Github user MikeThomsen commented on a diff in the pull request: https://github.com/apache/nifi/pull/2615#discussion_r209707241 --- Diff: nifi-nar-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-client-service/src/test/groovy/org/apache/nifi/elasticsearch/integration/ElasticSearch5ClientService_IT.groovy --- @@ -0,0 +1,147 @@ +/* + * 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.integration + +import org.apache.nifi.elasticsearch.DeleteOperationResponse +import org.apache.nifi.elasticsearch.ElasticSearchClientService +import org.apache.nifi.elasticsearch.ElasticSearchClientServiceImpl +import org.apache.nifi.elasticsearch.SearchResponse +import org.apache.nifi.util.TestRunner +import org.apache.nifi.util.TestRunners +import org.junit.After +import org.junit.Assert +import org.junit.Before +import org.junit.Test + +import static groovy.json.JsonOutput.* --- End diff -- Manually fixed that. ---
[GitHub] nifi pull request #2615: NIFI-5051 Created ElasticSearch lookup service.
Github user MikeThomsen commented on a diff in the pull request: https://github.com/apache/nifi/pull/2615#discussion_r209699519 --- Diff: nifi-nar-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-client-service/src/main/java/org/apache/nifi/elasticsearch/ElasticSearchLookupService.java --- @@ -0,0 +1,255 @@ +/* + * 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 com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.nifi.annotation.lifecycle.OnEnabled; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.controller.ConfigurationContext; +import org.apache.nifi.expression.ExpressionLanguageScope; +import org.apache.nifi.lookup.LookupFailureException; +import org.apache.nifi.lookup.LookupService; +import org.apache.nifi.processor.util.StandardValidators; +import org.apache.nifi.reporting.InitializationException; +import org.apache.nifi.schema.access.SchemaNotFoundException; +import org.apache.nifi.serialization.SchemaRegistryService; +import org.apache.nifi.serialization.SimpleRecordSchema; +import org.apache.nifi.serialization.record.MapRecord; +import org.apache.nifi.serialization.record.Record; +import org.apache.nifi.serialization.record.RecordField; +import org.apache.nifi.serialization.record.RecordFieldType; +import org.apache.nifi.serialization.record.RecordSchema; +import org.apache.nifi.serialization.record.type.RecordDataType; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.Set; +import java.util.stream.Collectors; + +public class ElasticSearchLookupService extends SchemaRegistryService implements LookupService { +public static final PropertyDescriptor CLIENT_SERVICE = new PropertyDescriptor.Builder() +.name("el-rest-client-service") +.displayName("Client Service") +.description("An ElasticSearch client service to use for running queries.") +.identifiesControllerService(ElasticSearchClientService.class) +.required(true) +.build(); +public static final PropertyDescriptor INDEX = new PropertyDescriptor.Builder() +.name("el-lookup-index") +.displayName("Index") +.description("The name of the index to read from") +.required(true) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) +.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) +.build(); + +public static final PropertyDescriptor TYPE = new PropertyDescriptor.Builder() +.name("el-lookup-type") +.displayName("Type") +.description("The type of this document (used by Elasticsearch for indexing and searching)") +.required(false) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) +.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) +.build(); + +private ElasticSearchClientService clientService; + +private String index; +private String type; +private ObjectMapper mapper; + +@OnEnabled +public void onEnabled(final ConfigurationContext context) throws InitializationException { +clientService = context.getProperty(CLIENT_SERVICE).asControllerService(ElasticSearchClientService.class); +index = context.getProperty(INDEX).evaluateAttributeExpressions().getValue(); +type = context.getProperty(TYPE).evaluateAttributeExpressions().getValue(); +mapper = new ObjectMapper(); +} + +@Override +protected List getSupportedPropertyDescriptors() { +List _desc = new ArrayList<>(); --- End diff -- Done. ---
[GitHub] nifi pull request #2615: NIFI-5051 Created ElasticSearch lookup service.
Github user MikeThomsen commented on a diff in the pull request: https://github.com/apache/nifi/pull/2615#discussion_r209698134 --- Diff: nifi-nar-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-client-service/pom.xml --- @@ -127,8 +133,113 @@ 5.6.8 compile + +org.apache.nifi +nifi-avro-record-utils +1.7.0-SNAPSHOT +compile + + +org.apache.nifi +nifi-schema-registry-service-api +compile + + +org.mockito +mockito-all +test + + --- End diff -- I'm leaving in the helper plugin for now because for some reason, it won't even detect the groovy test source without it. I'll remove it if you have any suggestions on how to fix that. ---
[GitHub] nifi pull request #2615: NIFI-5051 Created ElasticSearch lookup service.
Github user MikeThomsen commented on a diff in the pull request: https://github.com/apache/nifi/pull/2615#discussion_r209696028 --- Diff: nifi-nar-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-client-service/pom.xml --- @@ -127,8 +133,113 @@ 5.6.8 compile + +org.apache.nifi +nifi-avro-record-utils +1.7.0-SNAPSHOT --- End diff -- Done. ---
[GitHub] nifi pull request #2615: NIFI-5051 Created ElasticSearch lookup service.
Github user mattyb149 commented on a diff in the pull request: https://github.com/apache/nifi/pull/2615#discussion_r209658892 --- Diff: nifi-nar-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-client-service/src/test/groovy/org/apache/nifi/elasticsearch/integration/ElasticSearch5ClientService_IT.groovy --- @@ -0,0 +1,147 @@ +/* + * 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.integration + +import org.apache.nifi.elasticsearch.DeleteOperationResponse +import org.apache.nifi.elasticsearch.ElasticSearchClientService +import org.apache.nifi.elasticsearch.ElasticSearchClientServiceImpl +import org.apache.nifi.elasticsearch.SearchResponse +import org.apache.nifi.util.TestRunner +import org.apache.nifi.util.TestRunners +import org.junit.After +import org.junit.Assert +import org.junit.Before +import org.junit.Test + +import static groovy.json.JsonOutput.* --- End diff -- This shouldn't pass CheckStyle as we don't allow star imports in Java, we probably just don't have an existing (or complete) CheckStyle rule for Groovy files. ---
[GitHub] nifi pull request #2615: NIFI-5051 Created ElasticSearch lookup service.
Github user mattyb149 commented on a diff in the pull request: https://github.com/apache/nifi/pull/2615#discussion_r209658506 --- Diff: nifi-nar-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-client-service/src/main/java/org/apache/nifi/elasticsearch/ElasticSearchLookupService.java --- @@ -0,0 +1,253 @@ +/* + * 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 com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.nifi.annotation.lifecycle.OnEnabled; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.components.Validator; +import org.apache.nifi.controller.ConfigurationContext; +import org.apache.nifi.expression.ExpressionLanguageScope; +import org.apache.nifi.lookup.LookupFailureException; +import org.apache.nifi.lookup.LookupService; +import org.apache.nifi.processor.util.StandardValidators; +import org.apache.nifi.reporting.InitializationException; +import org.apache.nifi.schema.access.SchemaNotFoundException; +import org.apache.nifi.serialization.SchemaRegistryService; +import org.apache.nifi.serialization.SimpleRecordSchema; +import org.apache.nifi.serialization.record.MapRecord; +import org.apache.nifi.serialization.record.Record; +import org.apache.nifi.serialization.record.RecordField; +import org.apache.nifi.serialization.record.RecordFieldType; +import org.apache.nifi.serialization.record.RecordSchema; +import org.apache.nifi.serialization.record.type.RecordDataType; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.Set; +import java.util.stream.Collectors; + +public class ElasticSearchLookupService extends SchemaRegistryService implements LookupService { +public static final PropertyDescriptor CLIENT_SERVICE = new PropertyDescriptor.Builder() +.name("el-rest-client-service") +.displayName("Client Service") +.description("An ElasticSearch client service to use for running queries.") +.identifiesControllerService(ElasticSearchClientService.class) +.required(true) +.build(); +public static final PropertyDescriptor INDEX = new PropertyDescriptor.Builder() +.name("el-lookup-index") +.displayName("Index") +.description("The name of the index to read from") +.required(true) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) +.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) +.build(); + +public static final PropertyDescriptor TYPE = new PropertyDescriptor.Builder() +.name("el-lookup-type") +.displayName("Type") +.description("The type of this document (used by Elasticsearch for indexing and searching)") +.required(false) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) +.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) +.build(); + + +public static final PropertyDescriptor RECORD_SCHEMA_NAME = new PropertyDescriptor.Builder() +.name("el-lookup-record-schema-name") +.displayName("Record Schema Name") +.description("If specified, the value will be used to lookup a schema in the configured schema registry.") +.required(false) +.addValidator(Validator.VALID) +.build(); + +private ElasticSearchClientService clientService; + +private String index; +private String type; +private ObjectMapper mapper; + +@OnEnabled +public void onEnabled(final ConfigurationContext context) throws InitializationException { +clientService = context.getProperty(CLIENT_SERVICE).asControllerService(ElasticSearchClientService.class); +
[GitHub] nifi pull request #2615: NIFI-5051 Created ElasticSearch lookup service.
Github user mattyb149 commented on a diff in the pull request: https://github.com/apache/nifi/pull/2615#discussion_r209658382 --- Diff: nifi-nar-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-client-service/src/main/java/org/apache/nifi/elasticsearch/ElasticSearchLookupService.java --- @@ -0,0 +1,255 @@ +/* + * 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 com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.nifi.annotation.lifecycle.OnEnabled; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.controller.ConfigurationContext; +import org.apache.nifi.expression.ExpressionLanguageScope; +import org.apache.nifi.lookup.LookupFailureException; +import org.apache.nifi.lookup.LookupService; +import org.apache.nifi.processor.util.StandardValidators; +import org.apache.nifi.reporting.InitializationException; +import org.apache.nifi.schema.access.SchemaNotFoundException; +import org.apache.nifi.serialization.SchemaRegistryService; +import org.apache.nifi.serialization.SimpleRecordSchema; +import org.apache.nifi.serialization.record.MapRecord; +import org.apache.nifi.serialization.record.Record; +import org.apache.nifi.serialization.record.RecordField; +import org.apache.nifi.serialization.record.RecordFieldType; +import org.apache.nifi.serialization.record.RecordSchema; +import org.apache.nifi.serialization.record.type.RecordDataType; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.Set; +import java.util.stream.Collectors; + +public class ElasticSearchLookupService extends SchemaRegistryService implements LookupService { +public static final PropertyDescriptor CLIENT_SERVICE = new PropertyDescriptor.Builder() +.name("el-rest-client-service") +.displayName("Client Service") +.description("An ElasticSearch client service to use for running queries.") +.identifiesControllerService(ElasticSearchClientService.class) +.required(true) +.build(); +public static final PropertyDescriptor INDEX = new PropertyDescriptor.Builder() +.name("el-lookup-index") +.displayName("Index") +.description("The name of the index to read from") +.required(true) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) +.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) +.build(); + +public static final PropertyDescriptor TYPE = new PropertyDescriptor.Builder() +.name("el-lookup-type") +.displayName("Type") +.description("The type of this document (used by Elasticsearch for indexing and searching)") +.required(false) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) +.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) +.build(); + +private ElasticSearchClientService clientService; + +private String index; +private String type; +private ObjectMapper mapper; + +@OnEnabled +public void onEnabled(final ConfigurationContext context) throws InitializationException { +clientService = context.getProperty(CLIENT_SERVICE).asControllerService(ElasticSearchClientService.class); +index = context.getProperty(INDEX).evaluateAttributeExpressions().getValue(); +type = context.getProperty(TYPE).evaluateAttributeExpressions().getValue(); +mapper = new ObjectMapper(); +} + +@Override +protected List getSupportedPropertyDescriptors() { +List _desc = new ArrayList<>(); --- End diff -- Just a style nitpick, these can be set up in the constructor or a static block (I think the
[GitHub] nifi pull request #2615: NIFI-5051 Created ElasticSearch lookup service.
Github user mattyb149 commented on a diff in the pull request: https://github.com/apache/nifi/pull/2615#discussion_r209657628 --- Diff: nifi-nar-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-client-service/pom.xml --- @@ -127,8 +133,113 @@ 5.6.8 compile + +org.apache.nifi +nifi-avro-record-utils +1.7.0-SNAPSHOT +compile + + +org.apache.nifi +nifi-schema-registry-service-api +compile + + +org.mockito +mockito-all +test + + --- End diff -- Probably best to remove the groovy and Jacoco stuff, let's get a discussion going on the dev mailing list about code coverage? ---
[GitHub] nifi pull request #2615: NIFI-5051 Created ElasticSearch lookup service.
Github user mattyb149 commented on a diff in the pull request: https://github.com/apache/nifi/pull/2615#discussion_r209656707 --- Diff: nifi-nar-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-client-service/pom.xml --- @@ -127,8 +133,113 @@ 5.6.8 compile + +org.apache.nifi +nifi-avro-record-utils +1.7.0-SNAPSHOT --- End diff -- This one should be 1.8.0-SNAPSHOT now, sorry it's taken so long to get through ---
[GitHub] nifi pull request #2615: NIFI-5051 Created ElasticSearch lookup service.
Github user MikeThomsen commented on a diff in the pull request: https://github.com/apache/nifi/pull/2615#discussion_r192169823 --- Diff: nifi-nar-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-client-service/pom.xml --- @@ -212,6 +212,31 @@ + + +org.jacoco --- End diff -- I'm not sure how well that would work at root level because there are plenty of integration tests that have to be run to get a full sense of code coverage. So maybe I should back this out or one of you can drop it when rebasing for a merge if you think it makes more sense to add a root level profile for code coverage. ---
[GitHub] nifi pull request #2615: NIFI-5051 Created ElasticSearch lookup service.
Github user mattyb149 commented on a diff in the pull request: https://github.com/apache/nifi/pull/2615#discussion_r192083397 --- Diff: nifi-nar-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-client-service/pom.xml --- @@ -212,6 +212,31 @@ + + +org.jacoco --- End diff -- If we were to add a code coverage plugin to Maven, this is probably something that should be added to the root-level pom (and disabled by default?) What was the impetus for including it in a single bundle? ---
[GitHub] nifi pull request #2615: NIFI-5051 Created ElasticSearch lookup service.
Github user MikeThomsen commented on a diff in the pull request: https://github.com/apache/nifi/pull/2615#discussion_r192050876 --- Diff: nifi-nar-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-client-service/src/main/java/org/apache/nifi/elasticsearch/ElasticSearchLookupService.java --- @@ -0,0 +1,266 @@ +/* + * 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 com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.nifi.annotation.lifecycle.OnEnabled; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.components.Validator; +import org.apache.nifi.controller.ConfigurationContext; +import org.apache.nifi.expression.ExpressionLanguageScope; +import org.apache.nifi.lookup.LookupFailureException; +import org.apache.nifi.lookup.LookupService; +import org.apache.nifi.processor.util.StandardValidators; +import org.apache.nifi.reporting.InitializationException; +import org.apache.nifi.schema.access.SchemaNotFoundException; +import org.apache.nifi.serialization.SchemaRegistryService; +import org.apache.nifi.serialization.SimpleRecordSchema; +import org.apache.nifi.serialization.record.MapRecord; +import org.apache.nifi.serialization.record.Record; +import org.apache.nifi.serialization.record.RecordField; +import org.apache.nifi.serialization.record.RecordFieldType; +import org.apache.nifi.serialization.record.RecordSchema; +import org.apache.nifi.serialization.record.type.RecordDataType; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.Set; +import java.util.stream.Collectors; + +public class ElasticSearchLookupService extends SchemaRegistryService implements LookupService { +public static final PropertyDescriptor CLIENT_SERVICE = new PropertyDescriptor.Builder() +.name("el-rest-client-service") +.displayName("Client Service") +.description("An ElasticSearch client service to use for running queries.") +.identifiesControllerService(ElasticSearchClientService.class) +.required(true) +.build(); +public static final PropertyDescriptor INDEX = new PropertyDescriptor.Builder() +.name("el-lookup-index") +.displayName("Index") +.description("The name of the index to read from") +.required(true) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) +.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) +.build(); + +public static final PropertyDescriptor TYPE = new PropertyDescriptor.Builder() +.name("el-lookup-type") +.displayName("Type") +.description("The type of this document (used by Elasticsearch for indexing and searching)") +.required(false) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) +.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) +.build(); + + +public static final PropertyDescriptor RECORD_SCHEMA_NAME = new PropertyDescriptor.Builder() +.name("el-lookup-record-schema-name") +.displayName("Record Schema Name") +.description("If specified, the value will be used to lookup a schema in the configured schema registry.") +.required(false) +.addValidator(Validator.VALID) +.build(); + +private ElasticSearchClientService clientService; + +private String index; +private String type; +private ObjectMapper mapper; + +@OnEnabled +public void onEnabled(final ConfigurationContext context) throws InitializationException { +clientService = context.getProperty(CLIENT_SERVICE).asControllerService(ElasticSearchClientService.class);
[GitHub] nifi pull request #2615: NIFI-5051 Created ElasticSearch lookup service.
Github user MikeThomsen commented on a diff in the pull request: https://github.com/apache/nifi/pull/2615#discussion_r192050863 --- Diff: nifi-nar-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-client-service/src/main/java/org/apache/nifi/elasticsearch/ElasticSearchLookupService.java --- @@ -0,0 +1,266 @@ +/* + * 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 com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.nifi.annotation.lifecycle.OnEnabled; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.components.Validator; +import org.apache.nifi.controller.ConfigurationContext; +import org.apache.nifi.expression.ExpressionLanguageScope; +import org.apache.nifi.lookup.LookupFailureException; +import org.apache.nifi.lookup.LookupService; +import org.apache.nifi.processor.util.StandardValidators; +import org.apache.nifi.reporting.InitializationException; +import org.apache.nifi.schema.access.SchemaNotFoundException; +import org.apache.nifi.serialization.SchemaRegistryService; +import org.apache.nifi.serialization.SimpleRecordSchema; +import org.apache.nifi.serialization.record.MapRecord; +import org.apache.nifi.serialization.record.Record; +import org.apache.nifi.serialization.record.RecordField; +import org.apache.nifi.serialization.record.RecordFieldType; +import org.apache.nifi.serialization.record.RecordSchema; +import org.apache.nifi.serialization.record.type.RecordDataType; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.Set; +import java.util.stream.Collectors; + +public class ElasticSearchLookupService extends SchemaRegistryService implements LookupService { +public static final PropertyDescriptor CLIENT_SERVICE = new PropertyDescriptor.Builder() +.name("el-rest-client-service") +.displayName("Client Service") +.description("An ElasticSearch client service to use for running queries.") +.identifiesControllerService(ElasticSearchClientService.class) +.required(true) +.build(); +public static final PropertyDescriptor INDEX = new PropertyDescriptor.Builder() +.name("el-lookup-index") +.displayName("Index") +.description("The name of the index to read from") +.required(true) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) +.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) +.build(); + +public static final PropertyDescriptor TYPE = new PropertyDescriptor.Builder() +.name("el-lookup-type") +.displayName("Type") +.description("The type of this document (used by Elasticsearch for indexing and searching)") +.required(false) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) +.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) +.build(); + + +public static final PropertyDescriptor RECORD_SCHEMA_NAME = new PropertyDescriptor.Builder() +.name("el-lookup-record-schema-name") +.displayName("Record Schema Name") +.description("If specified, the value will be used to lookup a schema in the configured schema registry.") +.required(false) +.addValidator(Validator.VALID) +.build(); + +private ElasticSearchClientService clientService; + +private String index; +private String type; +private ObjectMapper mapper; + +@OnEnabled +public void onEnabled(final ConfigurationContext context) throws InitializationException { +clientService = context.getProperty(CLIENT_SERVICE).asControllerService(ElasticSearchClientService.class);
[GitHub] nifi pull request #2615: NIFI-5051 Created ElasticSearch lookup service.
Github user MikeThomsen commented on a diff in the pull request: https://github.com/apache/nifi/pull/2615#discussion_r192050600 --- Diff: nifi-nar-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-client-service/pom.xml --- @@ -127,8 +133,104 @@ 5.6.8 compile + +org.apache.nifi +nifi-avro-record-utils +1.7.0-SNAPSHOT +compile + + +org.apache.nifi +nifi-schema-registry-service-api +compile + + +org.mockito +mockito-all +test + + +org.apache.nifi +nifi-avro-record-utils +1.7.0-SNAPSHOT +compile + + +org.apache.nifi +nifi-avro-record-utils +1.7.0-SNAPSHOT +compile + + + + +org.apache.maven.plugins +maven-compiler-plugin + + + +groovy-tests + +testCompile + + + groovy-eclipse-compiler + + + + +1.8 --- End diff -- Probably not. Removed. ---
[GitHub] nifi pull request #2615: NIFI-5051 Created ElasticSearch lookup service.
Github user MikeThomsen commented on a diff in the pull request: https://github.com/apache/nifi/pull/2615#discussion_r192050258 --- Diff: nifi-nar-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-client-service/pom.xml --- @@ -120,6 +132,22 @@ 1.7.0-SNAPSHOT provided + +org.apache.nifi +nifi-avro-record-utils +1.7.0-SNAPSHOT +compile + + +org.apache.nifi +nifi-avro-record-utils --- End diff -- Done. ---
[GitHub] nifi pull request #2615: NIFI-5051 Created ElasticSearch lookup service.
Github user MikeThomsen commented on a diff in the pull request: https://github.com/apache/nifi/pull/2615#discussion_r192049919 --- Diff: nifi-nar-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-client-service/src/main/java/org/apache/nifi/elasticsearch/ElasticSearchLookupService.java --- @@ -0,0 +1,253 @@ +/* + * 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 com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.nifi.annotation.lifecycle.OnEnabled; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.components.Validator; +import org.apache.nifi.controller.ConfigurationContext; +import org.apache.nifi.expression.ExpressionLanguageScope; +import org.apache.nifi.lookup.LookupFailureException; +import org.apache.nifi.lookup.LookupService; +import org.apache.nifi.processor.util.StandardValidators; +import org.apache.nifi.reporting.InitializationException; +import org.apache.nifi.schema.access.SchemaNotFoundException; +import org.apache.nifi.serialization.SchemaRegistryService; +import org.apache.nifi.serialization.SimpleRecordSchema; +import org.apache.nifi.serialization.record.MapRecord; +import org.apache.nifi.serialization.record.Record; +import org.apache.nifi.serialization.record.RecordField; +import org.apache.nifi.serialization.record.RecordFieldType; +import org.apache.nifi.serialization.record.RecordSchema; +import org.apache.nifi.serialization.record.type.RecordDataType; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.Set; +import java.util.stream.Collectors; + +public class ElasticSearchLookupService extends SchemaRegistryService implements LookupService { +public static final PropertyDescriptor CLIENT_SERVICE = new PropertyDescriptor.Builder() +.name("el-rest-client-service") +.displayName("Client Service") +.description("An ElasticSearch client service to use for running queries.") +.identifiesControllerService(ElasticSearchClientService.class) +.required(true) +.build(); +public static final PropertyDescriptor INDEX = new PropertyDescriptor.Builder() +.name("el-lookup-index") +.displayName("Index") +.description("The name of the index to read from") +.required(true) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) +.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) +.build(); + +public static final PropertyDescriptor TYPE = new PropertyDescriptor.Builder() +.name("el-lookup-type") +.displayName("Type") +.description("The type of this document (used by Elasticsearch for indexing and searching)") +.required(false) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) +.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) +.build(); + + +public static final PropertyDescriptor RECORD_SCHEMA_NAME = new PropertyDescriptor.Builder() --- End diff -- Done. ---
[GitHub] nifi pull request #2615: NIFI-5051 Created ElasticSearch lookup service.
Github user pvillard31 commented on a diff in the pull request: https://github.com/apache/nifi/pull/2615#discussion_r191744098 --- Diff: nifi-nar-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-client-service/src/main/java/org/apache/nifi/elasticsearch/ElasticSearchLookupService.java --- @@ -0,0 +1,266 @@ +/* + * 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 com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.nifi.annotation.lifecycle.OnEnabled; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.components.Validator; +import org.apache.nifi.controller.ConfigurationContext; +import org.apache.nifi.expression.ExpressionLanguageScope; +import org.apache.nifi.lookup.LookupFailureException; +import org.apache.nifi.lookup.LookupService; +import org.apache.nifi.processor.util.StandardValidators; +import org.apache.nifi.reporting.InitializationException; +import org.apache.nifi.schema.access.SchemaNotFoundException; +import org.apache.nifi.serialization.SchemaRegistryService; +import org.apache.nifi.serialization.SimpleRecordSchema; +import org.apache.nifi.serialization.record.MapRecord; +import org.apache.nifi.serialization.record.Record; +import org.apache.nifi.serialization.record.RecordField; +import org.apache.nifi.serialization.record.RecordFieldType; +import org.apache.nifi.serialization.record.RecordSchema; +import org.apache.nifi.serialization.record.type.RecordDataType; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.Set; +import java.util.stream.Collectors; + +public class ElasticSearchLookupService extends SchemaRegistryService implements LookupService { +public static final PropertyDescriptor CLIENT_SERVICE = new PropertyDescriptor.Builder() +.name("el-rest-client-service") +.displayName("Client Service") +.description("An ElasticSearch client service to use for running queries.") +.identifiesControllerService(ElasticSearchClientService.class) +.required(true) +.build(); +public static final PropertyDescriptor INDEX = new PropertyDescriptor.Builder() +.name("el-lookup-index") +.displayName("Index") +.description("The name of the index to read from") +.required(true) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) +.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) +.build(); + +public static final PropertyDescriptor TYPE = new PropertyDescriptor.Builder() +.name("el-lookup-type") +.displayName("Type") +.description("The type of this document (used by Elasticsearch for indexing and searching)") +.required(false) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) +.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) +.build(); + + +public static final PropertyDescriptor RECORD_SCHEMA_NAME = new PropertyDescriptor.Builder() +.name("el-lookup-record-schema-name") +.displayName("Record Schema Name") +.description("If specified, the value will be used to lookup a schema in the configured schema registry.") +.required(false) +.addValidator(Validator.VALID) +.build(); + +private ElasticSearchClientService clientService; + +private String index; +private String type; +private ObjectMapper mapper; + +@OnEnabled +public void onEnabled(final ConfigurationContext context) throws InitializationException { +clientService = context.getProperty(CLIENT_SERVICE).asControllerService(ElasticSearchClientService.class);
[GitHub] nifi pull request #2615: NIFI-5051 Created ElasticSearch lookup service.
Github user pvillard31 commented on a diff in the pull request: https://github.com/apache/nifi/pull/2615#discussion_r191741767 --- Diff: nifi-nar-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-client-service/pom.xml --- @@ -120,6 +132,22 @@ 1.7.0-SNAPSHOT provided + +org.apache.nifi +nifi-avro-record-utils +1.7.0-SNAPSHOT +compile + + +org.apache.nifi +nifi-avro-record-utils --- End diff -- Comment is still valid @MikeThomsen ---
[GitHub] nifi pull request #2615: NIFI-5051 Created ElasticSearch lookup service.
Github user pvillard31 commented on a diff in the pull request: https://github.com/apache/nifi/pull/2615#discussion_r191742961 --- Diff: nifi-nar-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-client-service/src/main/java/org/apache/nifi/elasticsearch/ElasticSearchLookupService.java --- @@ -0,0 +1,253 @@ +/* + * 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 com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.nifi.annotation.lifecycle.OnEnabled; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.components.Validator; +import org.apache.nifi.controller.ConfigurationContext; +import org.apache.nifi.expression.ExpressionLanguageScope; +import org.apache.nifi.lookup.LookupFailureException; +import org.apache.nifi.lookup.LookupService; +import org.apache.nifi.processor.util.StandardValidators; +import org.apache.nifi.reporting.InitializationException; +import org.apache.nifi.schema.access.SchemaNotFoundException; +import org.apache.nifi.serialization.SchemaRegistryService; +import org.apache.nifi.serialization.SimpleRecordSchema; +import org.apache.nifi.serialization.record.MapRecord; +import org.apache.nifi.serialization.record.Record; +import org.apache.nifi.serialization.record.RecordField; +import org.apache.nifi.serialization.record.RecordFieldType; +import org.apache.nifi.serialization.record.RecordSchema; +import org.apache.nifi.serialization.record.type.RecordDataType; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.Set; +import java.util.stream.Collectors; + +public class ElasticSearchLookupService extends SchemaRegistryService implements LookupService { +public static final PropertyDescriptor CLIENT_SERVICE = new PropertyDescriptor.Builder() +.name("el-rest-client-service") +.displayName("Client Service") +.description("An ElasticSearch client service to use for running queries.") +.identifiesControllerService(ElasticSearchClientService.class) +.required(true) +.build(); +public static final PropertyDescriptor INDEX = new PropertyDescriptor.Builder() +.name("el-lookup-index") +.displayName("Index") +.description("The name of the index to read from") +.required(true) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) +.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) +.build(); + +public static final PropertyDescriptor TYPE = new PropertyDescriptor.Builder() +.name("el-lookup-type") +.displayName("Type") +.description("The type of this document (used by Elasticsearch for indexing and searching)") +.required(false) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) +.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) +.build(); + + +public static final PropertyDescriptor RECORD_SCHEMA_NAME = new PropertyDescriptor.Builder() --- End diff -- Do you want to remove it @MikeThomsen ? ---
[GitHub] nifi pull request #2615: NIFI-5051 Created ElasticSearch lookup service.
Github user pvillard31 commented on a diff in the pull request: https://github.com/apache/nifi/pull/2615#discussion_r191742124 --- Diff: nifi-nar-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-client-service/pom.xml --- @@ -127,8 +133,104 @@ 5.6.8 compile + +org.apache.nifi +nifi-avro-record-utils +1.7.0-SNAPSHOT +compile + + +org.apache.nifi +nifi-schema-registry-service-api +compile + + +org.mockito +mockito-all +test + + +org.apache.nifi +nifi-avro-record-utils +1.7.0-SNAPSHOT +compile + + +org.apache.nifi +nifi-avro-record-utils +1.7.0-SNAPSHOT +compile + + + + +org.apache.maven.plugins +maven-compiler-plugin + + + +groovy-tests + +testCompile + + + groovy-eclipse-compiler + + + + +1.8 --- End diff -- Do we want to have this kind of configuration in low-level poms? Wondering if it'd be an issue with current modifications to support Java 9/10 ---
[GitHub] nifi pull request #2615: NIFI-5051 Created ElasticSearch lookup service.
Github user pvillard31 commented on a diff in the pull request: https://github.com/apache/nifi/pull/2615#discussion_r191744175 --- Diff: nifi-nar-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-client-service/src/main/java/org/apache/nifi/elasticsearch/ElasticSearchLookupService.java --- @@ -0,0 +1,266 @@ +/* + * 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 com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.nifi.annotation.lifecycle.OnEnabled; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.components.Validator; +import org.apache.nifi.controller.ConfigurationContext; +import org.apache.nifi.expression.ExpressionLanguageScope; +import org.apache.nifi.lookup.LookupFailureException; +import org.apache.nifi.lookup.LookupService; +import org.apache.nifi.processor.util.StandardValidators; +import org.apache.nifi.reporting.InitializationException; +import org.apache.nifi.schema.access.SchemaNotFoundException; +import org.apache.nifi.serialization.SchemaRegistryService; +import org.apache.nifi.serialization.SimpleRecordSchema; +import org.apache.nifi.serialization.record.MapRecord; +import org.apache.nifi.serialization.record.Record; +import org.apache.nifi.serialization.record.RecordField; +import org.apache.nifi.serialization.record.RecordFieldType; +import org.apache.nifi.serialization.record.RecordSchema; +import org.apache.nifi.serialization.record.type.RecordDataType; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.Set; +import java.util.stream.Collectors; + +public class ElasticSearchLookupService extends SchemaRegistryService implements LookupService { +public static final PropertyDescriptor CLIENT_SERVICE = new PropertyDescriptor.Builder() +.name("el-rest-client-service") +.displayName("Client Service") +.description("An ElasticSearch client service to use for running queries.") +.identifiesControllerService(ElasticSearchClientService.class) +.required(true) +.build(); +public static final PropertyDescriptor INDEX = new PropertyDescriptor.Builder() +.name("el-lookup-index") +.displayName("Index") +.description("The name of the index to read from") +.required(true) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) +.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) +.build(); + +public static final PropertyDescriptor TYPE = new PropertyDescriptor.Builder() +.name("el-lookup-type") +.displayName("Type") +.description("The type of this document (used by Elasticsearch for indexing and searching)") +.required(false) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) +.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) +.build(); + + +public static final PropertyDescriptor RECORD_SCHEMA_NAME = new PropertyDescriptor.Builder() +.name("el-lookup-record-schema-name") +.displayName("Record Schema Name") +.description("If specified, the value will be used to lookup a schema in the configured schema registry.") +.required(false) +.addValidator(Validator.VALID) +.build(); + +private ElasticSearchClientService clientService; + +private String index; +private String type; +private ObjectMapper mapper; + +@OnEnabled +public void onEnabled(final ConfigurationContext context) throws InitializationException { +clientService = context.getProperty(CLIENT_SERVICE).asControllerService(ElasticSearchClientService.class);
[GitHub] nifi pull request #2615: NIFI-5051 Created ElasticSearch lookup service.
Github user MikeThomsen commented on a diff in the pull request: https://github.com/apache/nifi/pull/2615#discussion_r189753159 --- Diff: nifi-nar-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-client-service/src/main/java/org/apache/nifi/elasticsearch/ElasticSearchLookupService.java --- @@ -0,0 +1,253 @@ +/* + * 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 com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.nifi.annotation.lifecycle.OnEnabled; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.components.Validator; +import org.apache.nifi.controller.ConfigurationContext; +import org.apache.nifi.expression.ExpressionLanguageScope; +import org.apache.nifi.lookup.LookupFailureException; +import org.apache.nifi.lookup.LookupService; +import org.apache.nifi.processor.util.StandardValidators; +import org.apache.nifi.reporting.InitializationException; +import org.apache.nifi.schema.access.SchemaNotFoundException; +import org.apache.nifi.serialization.SchemaRegistryService; +import org.apache.nifi.serialization.SimpleRecordSchema; +import org.apache.nifi.serialization.record.MapRecord; +import org.apache.nifi.serialization.record.Record; +import org.apache.nifi.serialization.record.RecordField; +import org.apache.nifi.serialization.record.RecordFieldType; +import org.apache.nifi.serialization.record.RecordSchema; +import org.apache.nifi.serialization.record.type.RecordDataType; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.Set; +import java.util.stream.Collectors; + +public class ElasticSearchLookupService extends SchemaRegistryService implements LookupService { +public static final PropertyDescriptor CLIENT_SERVICE = new PropertyDescriptor.Builder() +.name("el-rest-client-service") +.displayName("Client Service") +.description("An ElasticSearch client service to use for running queries.") +.identifiesControllerService(ElasticSearchClientService.class) +.required(true) +.build(); +public static final PropertyDescriptor INDEX = new PropertyDescriptor.Builder() +.name("el-lookup-index") +.displayName("Index") +.description("The name of the index to read from") +.required(true) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) +.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) +.build(); + +public static final PropertyDescriptor TYPE = new PropertyDescriptor.Builder() +.name("el-lookup-type") +.displayName("Type") +.description("The type of this document (used by Elasticsearch for indexing and searching)") +.required(false) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) +.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) +.build(); + + +public static final PropertyDescriptor RECORD_SCHEMA_NAME = new PropertyDescriptor.Builder() +.name("el-lookup-record-schema-name") +.displayName("Record Schema Name") +.description("If specified, the value will be used to lookup a schema in the configured schema registry.") +.required(false) +.addValidator(Validator.VALID) +.build(); + +private ElasticSearchClientService clientService; + +private String index; +private String type; +private ObjectMapper mapper; + +@OnEnabled +public void onEnabled(final ConfigurationContext context) throws InitializationException { +clientService = context.getProperty(CLIENT_SERVICE).asControllerService(ElasticSearchClientService.class);
[GitHub] nifi pull request #2615: NIFI-5051 Created ElasticSearch lookup service.
Github user MikeThomsen commented on a diff in the pull request: https://github.com/apache/nifi/pull/2615#discussion_r189727653 --- Diff: nifi-nar-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-client-service/src/main/java/org/apache/nifi/elasticsearch/ElasticSearchLookupService.java --- @@ -0,0 +1,253 @@ +/* + * 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 com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.nifi.annotation.lifecycle.OnEnabled; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.components.Validator; +import org.apache.nifi.controller.ConfigurationContext; +import org.apache.nifi.expression.ExpressionLanguageScope; +import org.apache.nifi.lookup.LookupFailureException; +import org.apache.nifi.lookup.LookupService; +import org.apache.nifi.processor.util.StandardValidators; +import org.apache.nifi.reporting.InitializationException; +import org.apache.nifi.schema.access.SchemaNotFoundException; +import org.apache.nifi.serialization.SchemaRegistryService; +import org.apache.nifi.serialization.SimpleRecordSchema; +import org.apache.nifi.serialization.record.MapRecord; +import org.apache.nifi.serialization.record.Record; +import org.apache.nifi.serialization.record.RecordField; +import org.apache.nifi.serialization.record.RecordFieldType; +import org.apache.nifi.serialization.record.RecordSchema; +import org.apache.nifi.serialization.record.type.RecordDataType; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.Set; +import java.util.stream.Collectors; + +public class ElasticSearchLookupService extends SchemaRegistryService implements LookupService { +public static final PropertyDescriptor CLIENT_SERVICE = new PropertyDescriptor.Builder() +.name("el-rest-client-service") +.displayName("Client Service") +.description("An ElasticSearch client service to use for running queries.") +.identifiesControllerService(ElasticSearchClientService.class) +.required(true) +.build(); +public static final PropertyDescriptor INDEX = new PropertyDescriptor.Builder() +.name("el-lookup-index") +.displayName("Index") +.description("The name of the index to read from") +.required(true) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) +.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) +.build(); + +public static final PropertyDescriptor TYPE = new PropertyDescriptor.Builder() +.name("el-lookup-type") +.displayName("Type") +.description("The type of this document (used by Elasticsearch for indexing and searching)") +.required(false) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) +.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) +.build(); + + +public static final PropertyDescriptor RECORD_SCHEMA_NAME = new PropertyDescriptor.Builder() +.name("el-lookup-record-schema-name") +.displayName("Record Schema Name") +.description("If specified, the value will be used to lookup a schema in the configured schema registry.") +.required(false) +.addValidator(Validator.VALID) +.build(); + +private ElasticSearchClientService clientService; + +private String index; +private String type; +private ObjectMapper mapper; + +@OnEnabled +public void onEnabled(final ConfigurationContext context) throws InitializationException { +clientService = context.getProperty(CLIENT_SERVICE).asControllerService(ElasticSearchClientService.class);
[GitHub] nifi pull request #2615: NIFI-5051 Created ElasticSearch lookup service.
Github user MikeThomsen commented on a diff in the pull request: https://github.com/apache/nifi/pull/2615#discussion_r189727019 --- Diff: nifi-nar-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-client-service/src/main/java/org/apache/nifi/elasticsearch/ElasticSearchLookupService.java --- @@ -0,0 +1,253 @@ +/* + * 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 com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.nifi.annotation.lifecycle.OnEnabled; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.components.Validator; +import org.apache.nifi.controller.ConfigurationContext; +import org.apache.nifi.expression.ExpressionLanguageScope; +import org.apache.nifi.lookup.LookupFailureException; +import org.apache.nifi.lookup.LookupService; +import org.apache.nifi.processor.util.StandardValidators; +import org.apache.nifi.reporting.InitializationException; +import org.apache.nifi.schema.access.SchemaNotFoundException; +import org.apache.nifi.serialization.SchemaRegistryService; +import org.apache.nifi.serialization.SimpleRecordSchema; +import org.apache.nifi.serialization.record.MapRecord; +import org.apache.nifi.serialization.record.Record; +import org.apache.nifi.serialization.record.RecordField; +import org.apache.nifi.serialization.record.RecordFieldType; +import org.apache.nifi.serialization.record.RecordSchema; +import org.apache.nifi.serialization.record.type.RecordDataType; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.Set; +import java.util.stream.Collectors; + +public class ElasticSearchLookupService extends SchemaRegistryService implements LookupService { +public static final PropertyDescriptor CLIENT_SERVICE = new PropertyDescriptor.Builder() +.name("el-rest-client-service") +.displayName("Client Service") +.description("An ElasticSearch client service to use for running queries.") +.identifiesControllerService(ElasticSearchClientService.class) +.required(true) +.build(); +public static final PropertyDescriptor INDEX = new PropertyDescriptor.Builder() +.name("el-lookup-index") +.displayName("Index") +.description("The name of the index to read from") +.required(true) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) +.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) +.build(); + +public static final PropertyDescriptor TYPE = new PropertyDescriptor.Builder() +.name("el-lookup-type") +.displayName("Type") +.description("The type of this document (used by Elasticsearch for indexing and searching)") +.required(false) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) +.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) +.build(); + + +public static final PropertyDescriptor RECORD_SCHEMA_NAME = new PropertyDescriptor.Builder() +.name("el-lookup-record-schema-name") +.displayName("Record Schema Name") +.description("If specified, the value will be used to lookup a schema in the configured schema registry.") +.required(false) +.addValidator(Validator.VALID) +.build(); + +private ElasticSearchClientService clientService; + +private String index; +private String type; +private ObjectMapper mapper; + +@OnEnabled +public void onEnabled(final ConfigurationContext context) throws InitializationException { +clientService = context.getProperty(CLIENT_SERVICE).asControllerService(ElasticSearchClientService.class);
[GitHub] nifi pull request #2615: NIFI-5051 Created ElasticSearch lookup service.
Github user MikeThomsen commented on a diff in the pull request: https://github.com/apache/nifi/pull/2615#discussion_r189705031 --- Diff: nifi-nar-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-client-service/src/main/java/org/apache/nifi/elasticsearch/ElasticSearchLookupService.java --- @@ -0,0 +1,253 @@ +/* + * 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 com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.nifi.annotation.lifecycle.OnEnabled; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.components.Validator; +import org.apache.nifi.controller.ConfigurationContext; +import org.apache.nifi.expression.ExpressionLanguageScope; +import org.apache.nifi.lookup.LookupFailureException; +import org.apache.nifi.lookup.LookupService; +import org.apache.nifi.processor.util.StandardValidators; +import org.apache.nifi.reporting.InitializationException; +import org.apache.nifi.schema.access.SchemaNotFoundException; +import org.apache.nifi.serialization.SchemaRegistryService; +import org.apache.nifi.serialization.SimpleRecordSchema; +import org.apache.nifi.serialization.record.MapRecord; +import org.apache.nifi.serialization.record.Record; +import org.apache.nifi.serialization.record.RecordField; +import org.apache.nifi.serialization.record.RecordFieldType; +import org.apache.nifi.serialization.record.RecordSchema; +import org.apache.nifi.serialization.record.type.RecordDataType; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.Set; +import java.util.stream.Collectors; + +public class ElasticSearchLookupService extends SchemaRegistryService implements LookupService { +public static final PropertyDescriptor CLIENT_SERVICE = new PropertyDescriptor.Builder() +.name("el-rest-client-service") +.displayName("Client Service") +.description("An ElasticSearch client service to use for running queries.") +.identifiesControllerService(ElasticSearchClientService.class) +.required(true) +.build(); +public static final PropertyDescriptor INDEX = new PropertyDescriptor.Builder() +.name("el-lookup-index") +.displayName("Index") +.description("The name of the index to read from") +.required(true) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) +.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) +.build(); + +public static final PropertyDescriptor TYPE = new PropertyDescriptor.Builder() +.name("el-lookup-type") +.displayName("Type") +.description("The type of this document (used by Elasticsearch for indexing and searching)") +.required(false) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) +.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) +.build(); + + +public static final PropertyDescriptor RECORD_SCHEMA_NAME = new PropertyDescriptor.Builder() --- End diff -- Thought I removed that. ---
[GitHub] nifi pull request #2615: NIFI-5051 Created ElasticSearch lookup service.
Github user mattyb149 commented on a diff in the pull request: https://github.com/apache/nifi/pull/2615#discussion_r189665908 --- Diff: nifi-nar-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-client-service/pom.xml --- @@ -120,6 +132,22 @@ 1.7.0-SNAPSHOT provided + +org.apache.nifi +nifi-avro-record-utils +1.7.0-SNAPSHOT +compile + + +org.apache.nifi +nifi-avro-record-utils --- End diff -- Still twice, I can remove on merge ---
[GitHub] nifi pull request #2615: NIFI-5051 Created ElasticSearch lookup service.
Github user mattyb149 commented on a diff in the pull request: https://github.com/apache/nifi/pull/2615#discussion_r189696292 --- Diff: nifi-nar-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-client-service/src/main/java/org/apache/nifi/elasticsearch/ElasticSearchLookupService.java --- @@ -0,0 +1,253 @@ +/* + * 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 com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.nifi.annotation.lifecycle.OnEnabled; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.components.Validator; +import org.apache.nifi.controller.ConfigurationContext; +import org.apache.nifi.expression.ExpressionLanguageScope; +import org.apache.nifi.lookup.LookupFailureException; +import org.apache.nifi.lookup.LookupService; +import org.apache.nifi.processor.util.StandardValidators; +import org.apache.nifi.reporting.InitializationException; +import org.apache.nifi.schema.access.SchemaNotFoundException; +import org.apache.nifi.serialization.SchemaRegistryService; +import org.apache.nifi.serialization.SimpleRecordSchema; +import org.apache.nifi.serialization.record.MapRecord; +import org.apache.nifi.serialization.record.Record; +import org.apache.nifi.serialization.record.RecordField; +import org.apache.nifi.serialization.record.RecordFieldType; +import org.apache.nifi.serialization.record.RecordSchema; +import org.apache.nifi.serialization.record.type.RecordDataType; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.Set; +import java.util.stream.Collectors; + +public class ElasticSearchLookupService extends SchemaRegistryService implements LookupService { +public static final PropertyDescriptor CLIENT_SERVICE = new PropertyDescriptor.Builder() +.name("el-rest-client-service") +.displayName("Client Service") +.description("An ElasticSearch client service to use for running queries.") +.identifiesControllerService(ElasticSearchClientService.class) +.required(true) +.build(); +public static final PropertyDescriptor INDEX = new PropertyDescriptor.Builder() +.name("el-lookup-index") +.displayName("Index") +.description("The name of the index to read from") +.required(true) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) +.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) +.build(); + +public static final PropertyDescriptor TYPE = new PropertyDescriptor.Builder() +.name("el-lookup-type") +.displayName("Type") +.description("The type of this document (used by Elasticsearch for indexing and searching)") +.required(false) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) +.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) +.build(); + + +public static final PropertyDescriptor RECORD_SCHEMA_NAME = new PropertyDescriptor.Builder() +.name("el-lookup-record-schema-name") +.displayName("Record Schema Name") +.description("If specified, the value will be used to lookup a schema in the configured schema registry.") +.required(false) +.addValidator(Validator.VALID) +.build(); + +private ElasticSearchClientService clientService; + +private String index; +private String type; +private ObjectMapper mapper; + +@OnEnabled +public void onEnabled(final ConfigurationContext context) throws InitializationException { +clientService = context.getProperty(CLIENT_SERVICE).asControllerService(ElasticSearchClientService.class); +
[GitHub] nifi pull request #2615: NIFI-5051 Created ElasticSearch lookup service.
Github user mattyb149 commented on a diff in the pull request: https://github.com/apache/nifi/pull/2615#discussion_r189676414 --- Diff: nifi-nar-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-client-service/src/main/java/org/apache/nifi/elasticsearch/ElasticSearchLookupService.java --- @@ -0,0 +1,253 @@ +/* + * 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 com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.nifi.annotation.lifecycle.OnEnabled; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.components.Validator; +import org.apache.nifi.controller.ConfigurationContext; +import org.apache.nifi.expression.ExpressionLanguageScope; +import org.apache.nifi.lookup.LookupFailureException; +import org.apache.nifi.lookup.LookupService; +import org.apache.nifi.processor.util.StandardValidators; +import org.apache.nifi.reporting.InitializationException; +import org.apache.nifi.schema.access.SchemaNotFoundException; +import org.apache.nifi.serialization.SchemaRegistryService; +import org.apache.nifi.serialization.SimpleRecordSchema; +import org.apache.nifi.serialization.record.MapRecord; +import org.apache.nifi.serialization.record.Record; +import org.apache.nifi.serialization.record.RecordField; +import org.apache.nifi.serialization.record.RecordFieldType; +import org.apache.nifi.serialization.record.RecordSchema; +import org.apache.nifi.serialization.record.type.RecordDataType; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.Set; +import java.util.stream.Collectors; + +public class ElasticSearchLookupService extends SchemaRegistryService implements LookupService { +public static final PropertyDescriptor CLIENT_SERVICE = new PropertyDescriptor.Builder() +.name("el-rest-client-service") +.displayName("Client Service") +.description("An ElasticSearch client service to use for running queries.") +.identifiesControllerService(ElasticSearchClientService.class) +.required(true) +.build(); +public static final PropertyDescriptor INDEX = new PropertyDescriptor.Builder() +.name("el-lookup-index") +.displayName("Index") +.description("The name of the index to read from") +.required(true) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) +.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) +.build(); + +public static final PropertyDescriptor TYPE = new PropertyDescriptor.Builder() +.name("el-lookup-type") +.displayName("Type") +.description("The type of this document (used by Elasticsearch for indexing and searching)") +.required(false) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) +.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) +.build(); + + +public static final PropertyDescriptor RECORD_SCHEMA_NAME = new PropertyDescriptor.Builder() --- End diff -- You don't need this property anymore, as you get one from SchemaRegistryService ---
[GitHub] nifi pull request #2615: NIFI-5051 Created ElasticSearch lookup service.
Github user MikeThomsen commented on a diff in the pull request: https://github.com/apache/nifi/pull/2615#discussion_r184851636 --- Diff: nifi-nar-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-client-service/src/main/java/org/apache/nifi/elasticsearch/ElasticSearchLookupService.java --- @@ -0,0 +1,290 @@ +/* + * 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 com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.nifi.annotation.lifecycle.OnEnabled; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.components.PropertyValue; +import org.apache.nifi.components.ValidationContext; +import org.apache.nifi.components.ValidationResult; +import org.apache.nifi.components.Validator; +import org.apache.nifi.controller.AbstractControllerService; +import org.apache.nifi.controller.ConfigurationContext; +import org.apache.nifi.expression.ExpressionLanguageScope; +import org.apache.nifi.lookup.LookupFailureException; +import org.apache.nifi.lookup.LookupService; +import org.apache.nifi.processor.util.StandardValidators; +import org.apache.nifi.reporting.InitializationException; +import org.apache.nifi.schemaregistry.services.SchemaRegistry; +import org.apache.nifi.serialization.SimpleRecordSchema; +import org.apache.nifi.serialization.record.MapRecord; +import org.apache.nifi.serialization.record.Record; +import org.apache.nifi.serialization.record.RecordField; +import org.apache.nifi.serialization.record.RecordFieldType; +import org.apache.nifi.serialization.record.RecordSchema; +import org.apache.nifi.serialization.record.SchemaIdentifier; +import org.apache.nifi.serialization.record.type.RecordDataType; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.Set; + +public class ElasticSearchLookupService extends AbstractControllerService implements LookupService { +public static final PropertyDescriptor CLIENT_SERVICE = new PropertyDescriptor.Builder() +.name("el-rest-client-service") +.displayName("Client Service") +.description("An ElasticSearch client service to use for running queries.") +.identifiesControllerService(ElasticSearchClientService.class) +.required(true) +.build(); +public static final PropertyDescriptor INDEX = new PropertyDescriptor.Builder() +.name("el-lookup-index") +.displayName("Index") +.description("The name of the index to read from") +.required(true) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) +.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) +.build(); + +public static final PropertyDescriptor TYPE = new PropertyDescriptor.Builder() +.name("el-lookup-type") +.displayName("Type") +.description("The type of this document (used by Elasticsearch for indexing and searching)") +.required(false) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) +.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) +.build(); + +public static final PropertyDescriptor SCHEMA_REGISTRY = new PropertyDescriptor.Builder() +.name("el-lookup-schema-registry") +.displayName("Schema Registry") +.description("If specified, this avro schema will be used for all objects loaded from MongoDB using this service. If left blank, " + +"the service will attempt to determine the schema from the results.") +.required(false) +.identifiesControllerService(SchemaRegistry.class) +.build(); + +public static final PropertyDescriptor RECORD_SC
[GitHub] nifi pull request #2615: NIFI-5051 Created ElasticSearch lookup service.
Github user MikeThomsen commented on a diff in the pull request: https://github.com/apache/nifi/pull/2615#discussion_r184770080 --- Diff: nifi-nar-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-client-service/src/main/java/org/apache/nifi/elasticsearch/ElasticSearchLookupService.java --- @@ -0,0 +1,290 @@ +/* + * 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 com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.nifi.annotation.lifecycle.OnEnabled; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.components.PropertyValue; +import org.apache.nifi.components.ValidationContext; +import org.apache.nifi.components.ValidationResult; +import org.apache.nifi.components.Validator; +import org.apache.nifi.controller.AbstractControllerService; +import org.apache.nifi.controller.ConfigurationContext; +import org.apache.nifi.expression.ExpressionLanguageScope; +import org.apache.nifi.lookup.LookupFailureException; +import org.apache.nifi.lookup.LookupService; +import org.apache.nifi.processor.util.StandardValidators; +import org.apache.nifi.reporting.InitializationException; +import org.apache.nifi.schemaregistry.services.SchemaRegistry; +import org.apache.nifi.serialization.SimpleRecordSchema; +import org.apache.nifi.serialization.record.MapRecord; +import org.apache.nifi.serialization.record.Record; +import org.apache.nifi.serialization.record.RecordField; +import org.apache.nifi.serialization.record.RecordFieldType; +import org.apache.nifi.serialization.record.RecordSchema; +import org.apache.nifi.serialization.record.SchemaIdentifier; +import org.apache.nifi.serialization.record.type.RecordDataType; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.Set; + +public class ElasticSearchLookupService extends AbstractControllerService implements LookupService { +public static final PropertyDescriptor CLIENT_SERVICE = new PropertyDescriptor.Builder() +.name("el-rest-client-service") +.displayName("Client Service") +.description("An ElasticSearch client service to use for running queries.") +.identifiesControllerService(ElasticSearchClientService.class) +.required(true) +.build(); +public static final PropertyDescriptor INDEX = new PropertyDescriptor.Builder() +.name("el-lookup-index") +.displayName("Index") +.description("The name of the index to read from") +.required(true) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) +.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) +.build(); + +public static final PropertyDescriptor TYPE = new PropertyDescriptor.Builder() +.name("el-lookup-type") +.displayName("Type") +.description("The type of this document (used by Elasticsearch for indexing and searching)") +.required(false) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) +.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) +.build(); + +public static final PropertyDescriptor SCHEMA_REGISTRY = new PropertyDescriptor.Builder() +.name("el-lookup-schema-registry") +.displayName("Schema Registry") +.description("If specified, this avro schema will be used for all objects loaded from MongoDB using this service. If left blank, " + +"the service will attempt to determine the schema from the results.") +.required(false) +.identifiesControllerService(SchemaRegistry.class) +.build(); + +public static final PropertyDescriptor RECORD_SC
[GitHub] nifi pull request #2615: NIFI-5051 Created ElasticSearch lookup service.
Github user mattyb149 commented on a diff in the pull request: https://github.com/apache/nifi/pull/2615#discussion_r184746728 --- Diff: nifi-nar-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-client-service/src/main/java/org/apache/nifi/elasticsearch/ElasticSearchLookupService.java --- @@ -0,0 +1,290 @@ +/* + * 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 com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.nifi.annotation.lifecycle.OnEnabled; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.components.PropertyValue; +import org.apache.nifi.components.ValidationContext; +import org.apache.nifi.components.ValidationResult; +import org.apache.nifi.components.Validator; +import org.apache.nifi.controller.AbstractControllerService; +import org.apache.nifi.controller.ConfigurationContext; +import org.apache.nifi.expression.ExpressionLanguageScope; +import org.apache.nifi.lookup.LookupFailureException; +import org.apache.nifi.lookup.LookupService; +import org.apache.nifi.processor.util.StandardValidators; +import org.apache.nifi.reporting.InitializationException; +import org.apache.nifi.schemaregistry.services.SchemaRegistry; +import org.apache.nifi.serialization.SimpleRecordSchema; +import org.apache.nifi.serialization.record.MapRecord; +import org.apache.nifi.serialization.record.Record; +import org.apache.nifi.serialization.record.RecordField; +import org.apache.nifi.serialization.record.RecordFieldType; +import org.apache.nifi.serialization.record.RecordSchema; +import org.apache.nifi.serialization.record.SchemaIdentifier; +import org.apache.nifi.serialization.record.type.RecordDataType; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.Set; + +public class ElasticSearchLookupService extends AbstractControllerService implements LookupService { +public static final PropertyDescriptor CLIENT_SERVICE = new PropertyDescriptor.Builder() +.name("el-rest-client-service") +.displayName("Client Service") +.description("An ElasticSearch client service to use for running queries.") +.identifiesControllerService(ElasticSearchClientService.class) +.required(true) +.build(); +public static final PropertyDescriptor INDEX = new PropertyDescriptor.Builder() +.name("el-lookup-index") +.displayName("Index") +.description("The name of the index to read from") +.required(true) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) +.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) +.build(); + +public static final PropertyDescriptor TYPE = new PropertyDescriptor.Builder() +.name("el-lookup-type") +.displayName("Type") +.description("The type of this document (used by Elasticsearch for indexing and searching)") +.required(false) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) +.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) +.build(); + +public static final PropertyDescriptor SCHEMA_REGISTRY = new PropertyDescriptor.Builder() +.name("el-lookup-schema-registry") +.displayName("Schema Registry") +.description("If specified, this avro schema will be used for all objects loaded from MongoDB using this service. If left blank, " + +"the service will attempt to determine the schema from the results.") +.required(false) +.identifiesControllerService(SchemaRegistry.class) +.build(); + +public static final PropertyDescriptor RECORD_SCHE
[GitHub] nifi pull request #2615: NIFI-5051 Created ElasticSearch lookup service.
Github user MikeThomsen commented on a diff in the pull request: https://github.com/apache/nifi/pull/2615#discussion_r184690560 --- Diff: nifi-nar-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-client-service/src/test/java/org/apache/nifi/elasticsearch/integration/ElasticSearchLookupService_IT.java --- @@ -0,0 +1,246 @@ +/* + * 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.integration; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.nifi.elasticsearch.ElasticSearchClientService; +import org.apache.nifi.elasticsearch.ElasticSearchClientServiceImpl; +import org.apache.nifi.elasticsearch.ElasticSearchLookupService; +import org.apache.nifi.lookup.LookupFailureException; +import org.apache.nifi.schemaregistry.services.SchemaRegistry; +import org.apache.nifi.serialization.record.Record; +import org.apache.nifi.serialization.record.RecordSchema; +import org.apache.nifi.serialization.record.type.RecordDataType; +import org.apache.nifi.util.TestRunner; +import org.apache.nifi.util.TestRunners; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; + +public class ElasticSearchLookupService_IT { --- End diff -- Ok, I'll add some. ---
[GitHub] nifi pull request #2615: NIFI-5051 Created ElasticSearch lookup service.
Github user MikeThomsen commented on a diff in the pull request: https://github.com/apache/nifi/pull/2615#discussion_r184690426 --- Diff: nifi-nar-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-client-service/src/main/java/org/apache/nifi/elasticsearch/ElasticSearchLookupService.java --- @@ -0,0 +1,290 @@ +/* + * 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 com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.nifi.annotation.lifecycle.OnEnabled; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.components.PropertyValue; +import org.apache.nifi.components.ValidationContext; +import org.apache.nifi.components.ValidationResult; +import org.apache.nifi.components.Validator; +import org.apache.nifi.controller.AbstractControllerService; +import org.apache.nifi.controller.ConfigurationContext; +import org.apache.nifi.expression.ExpressionLanguageScope; +import org.apache.nifi.lookup.LookupFailureException; +import org.apache.nifi.lookup.LookupService; +import org.apache.nifi.processor.util.StandardValidators; +import org.apache.nifi.reporting.InitializationException; +import org.apache.nifi.schemaregistry.services.SchemaRegistry; +import org.apache.nifi.serialization.SimpleRecordSchema; +import org.apache.nifi.serialization.record.MapRecord; +import org.apache.nifi.serialization.record.Record; +import org.apache.nifi.serialization.record.RecordField; +import org.apache.nifi.serialization.record.RecordFieldType; +import org.apache.nifi.serialization.record.RecordSchema; +import org.apache.nifi.serialization.record.SchemaIdentifier; +import org.apache.nifi.serialization.record.type.RecordDataType; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.Set; + +public class ElasticSearchLookupService extends AbstractControllerService implements LookupService { +public static final PropertyDescriptor CLIENT_SERVICE = new PropertyDescriptor.Builder() +.name("el-rest-client-service") +.displayName("Client Service") +.description("An ElasticSearch client service to use for running queries.") +.identifiesControllerService(ElasticSearchClientService.class) +.required(true) +.build(); +public static final PropertyDescriptor INDEX = new PropertyDescriptor.Builder() +.name("el-lookup-index") +.displayName("Index") +.description("The name of the index to read from") +.required(true) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) --- End diff -- I could definitely see some value to that, but since this is a LookupService implementation, we should discuss it in that context. NIFI-5121 only describes one particular interface, and LookupService is more expansive in use. ---
[GitHub] nifi pull request #2615: NIFI-5051 Created ElasticSearch lookup service.
Github user MikeThomsen commented on a diff in the pull request: https://github.com/apache/nifi/pull/2615#discussion_r184689922 --- Diff: nifi-nar-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-client-service/pom.xml --- @@ -57,6 +57,18 @@ provided + +org.apache.nifi +nifi-lookup-service-api +provided + + + +org.apache.avro +avro +1.8.2 --- End diff -- TBH I think that might have just been IntelliJ acting up. ---
[GitHub] nifi pull request #2615: NIFI-5051 Created ElasticSearch lookup service.
Github user MikeThomsen commented on a diff in the pull request: https://github.com/apache/nifi/pull/2615#discussion_r184689786 --- Diff: nifi-nar-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-client-service/src/main/java/org/apache/nifi/elasticsearch/ElasticSearchLookupService.java --- @@ -0,0 +1,290 @@ +/* + * 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 com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.nifi.annotation.lifecycle.OnEnabled; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.components.PropertyValue; +import org.apache.nifi.components.ValidationContext; +import org.apache.nifi.components.ValidationResult; +import org.apache.nifi.components.Validator; +import org.apache.nifi.controller.AbstractControllerService; +import org.apache.nifi.controller.ConfigurationContext; +import org.apache.nifi.expression.ExpressionLanguageScope; +import org.apache.nifi.lookup.LookupFailureException; +import org.apache.nifi.lookup.LookupService; +import org.apache.nifi.processor.util.StandardValidators; +import org.apache.nifi.reporting.InitializationException; +import org.apache.nifi.schemaregistry.services.SchemaRegistry; +import org.apache.nifi.serialization.SimpleRecordSchema; +import org.apache.nifi.serialization.record.MapRecord; +import org.apache.nifi.serialization.record.Record; +import org.apache.nifi.serialization.record.RecordField; +import org.apache.nifi.serialization.record.RecordFieldType; +import org.apache.nifi.serialization.record.RecordSchema; +import org.apache.nifi.serialization.record.SchemaIdentifier; +import org.apache.nifi.serialization.record.type.RecordDataType; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.Set; + +public class ElasticSearchLookupService extends AbstractControllerService implements LookupService { +public static final PropertyDescriptor CLIENT_SERVICE = new PropertyDescriptor.Builder() +.name("el-rest-client-service") +.displayName("Client Service") +.description("An ElasticSearch client service to use for running queries.") +.identifiesControllerService(ElasticSearchClientService.class) +.required(true) +.build(); +public static final PropertyDescriptor INDEX = new PropertyDescriptor.Builder() +.name("el-lookup-index") +.displayName("Index") +.description("The name of the index to read from") +.required(true) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) +.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) +.build(); + +public static final PropertyDescriptor TYPE = new PropertyDescriptor.Builder() +.name("el-lookup-type") +.displayName("Type") +.description("The type of this document (used by Elasticsearch for indexing and searching)") +.required(false) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) +.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) +.build(); + +public static final PropertyDescriptor SCHEMA_REGISTRY = new PropertyDescriptor.Builder() +.name("el-lookup-schema-registry") +.displayName("Schema Registry") +.description("If specified, this avro schema will be used for all objects loaded from MongoDB using this service. If left blank, " + +"the service will attempt to determine the schema from the results.") +.required(false) +.identifiesControllerService(SchemaRegistry.class) +.build(); + +public static final PropertyDescriptor RECORD_SC
[GitHub] nifi pull request #2615: NIFI-5051 Created ElasticSearch lookup service.
Github user mattyb149 commented on a diff in the pull request: https://github.com/apache/nifi/pull/2615#discussion_r184407808 --- Diff: nifi-nar-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-client-service/src/main/java/org/apache/nifi/elasticsearch/ElasticSearchLookupService.java --- @@ -0,0 +1,290 @@ +/* + * 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 com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.nifi.annotation.lifecycle.OnEnabled; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.components.PropertyValue; +import org.apache.nifi.components.ValidationContext; +import org.apache.nifi.components.ValidationResult; +import org.apache.nifi.components.Validator; +import org.apache.nifi.controller.AbstractControllerService; +import org.apache.nifi.controller.ConfigurationContext; +import org.apache.nifi.expression.ExpressionLanguageScope; +import org.apache.nifi.lookup.LookupFailureException; +import org.apache.nifi.lookup.LookupService; +import org.apache.nifi.processor.util.StandardValidators; +import org.apache.nifi.reporting.InitializationException; +import org.apache.nifi.schemaregistry.services.SchemaRegistry; +import org.apache.nifi.serialization.SimpleRecordSchema; +import org.apache.nifi.serialization.record.MapRecord; +import org.apache.nifi.serialization.record.Record; +import org.apache.nifi.serialization.record.RecordField; +import org.apache.nifi.serialization.record.RecordFieldType; +import org.apache.nifi.serialization.record.RecordSchema; +import org.apache.nifi.serialization.record.SchemaIdentifier; +import org.apache.nifi.serialization.record.type.RecordDataType; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.Set; + +public class ElasticSearchLookupService extends AbstractControllerService implements LookupService { +public static final PropertyDescriptor CLIENT_SERVICE = new PropertyDescriptor.Builder() +.name("el-rest-client-service") +.displayName("Client Service") +.description("An ElasticSearch client service to use for running queries.") +.identifiesControllerService(ElasticSearchClientService.class) +.required(true) +.build(); +public static final PropertyDescriptor INDEX = new PropertyDescriptor.Builder() +.name("el-lookup-index") +.displayName("Index") +.description("The name of the index to read from") +.required(true) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) +.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) +.build(); + +public static final PropertyDescriptor TYPE = new PropertyDescriptor.Builder() +.name("el-lookup-type") +.displayName("Type") +.description("The type of this document (used by Elasticsearch for indexing and searching)") +.required(false) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) +.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) +.build(); + +public static final PropertyDescriptor SCHEMA_REGISTRY = new PropertyDescriptor.Builder() +.name("el-lookup-schema-registry") +.displayName("Schema Registry") +.description("If specified, this avro schema will be used for all objects loaded from MongoDB using this service. If left blank, " + +"the service will attempt to determine the schema from the results.") +.required(false) +.identifiesControllerService(SchemaRegistry.class) +.build(); + +public static final PropertyDescriptor RECORD_SCHE
[GitHub] nifi pull request #2615: NIFI-5051 Created ElasticSearch lookup service.
Github user mattyb149 commented on a diff in the pull request: https://github.com/apache/nifi/pull/2615#discussion_r184396268 --- Diff: nifi-nar-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-client-service/pom.xml --- @@ -57,6 +57,18 @@ provided + +org.apache.nifi +nifi-lookup-service-api +provided + + + +org.apache.avro +avro +1.8.2 --- End diff -- Won't nifi-avro-record-utils bring in the Avro library? ---
[GitHub] nifi pull request #2615: NIFI-5051 Created ElasticSearch lookup service.
Github user mattyb149 commented on a diff in the pull request: https://github.com/apache/nifi/pull/2615#discussion_r184394354 --- Diff: nifi-nar-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-client-service/src/main/java/org/apache/nifi/elasticsearch/ElasticSearchLookupService.java --- @@ -0,0 +1,290 @@ +/* + * 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 com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.nifi.annotation.lifecycle.OnEnabled; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.components.PropertyValue; +import org.apache.nifi.components.ValidationContext; +import org.apache.nifi.components.ValidationResult; +import org.apache.nifi.components.Validator; +import org.apache.nifi.controller.AbstractControllerService; +import org.apache.nifi.controller.ConfigurationContext; +import org.apache.nifi.expression.ExpressionLanguageScope; +import org.apache.nifi.lookup.LookupFailureException; +import org.apache.nifi.lookup.LookupService; +import org.apache.nifi.processor.util.StandardValidators; +import org.apache.nifi.reporting.InitializationException; +import org.apache.nifi.schemaregistry.services.SchemaRegistry; +import org.apache.nifi.serialization.SimpleRecordSchema; +import org.apache.nifi.serialization.record.MapRecord; +import org.apache.nifi.serialization.record.Record; +import org.apache.nifi.serialization.record.RecordField; +import org.apache.nifi.serialization.record.RecordFieldType; +import org.apache.nifi.serialization.record.RecordSchema; +import org.apache.nifi.serialization.record.SchemaIdentifier; +import org.apache.nifi.serialization.record.type.RecordDataType; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.Set; + +public class ElasticSearchLookupService extends AbstractControllerService implements LookupService { +public static final PropertyDescriptor CLIENT_SERVICE = new PropertyDescriptor.Builder() +.name("el-rest-client-service") +.displayName("Client Service") +.description("An ElasticSearch client service to use for running queries.") +.identifiesControllerService(ElasticSearchClientService.class) +.required(true) +.build(); +public static final PropertyDescriptor INDEX = new PropertyDescriptor.Builder() +.name("el-lookup-index") +.displayName("Index") +.description("The name of the index to read from") +.required(true) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) +.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) +.build(); + +public static final PropertyDescriptor TYPE = new PropertyDescriptor.Builder() +.name("el-lookup-type") +.displayName("Type") +.description("The type of this document (used by Elasticsearch for indexing and searching)") +.required(false) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) +.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) +.build(); + +public static final PropertyDescriptor SCHEMA_REGISTRY = new PropertyDescriptor.Builder() +.name("el-lookup-schema-registry") +.displayName("Schema Registry") +.description("If specified, this avro schema will be used for all objects loaded from MongoDB using this service. If left blank, " + +"the service will attempt to determine the schema from the results.") +.required(false) +.identifiesControllerService(SchemaRegistry.class) +.build(); + +public static final PropertyDescriptor RECORD_SCHE
[GitHub] nifi pull request #2615: NIFI-5051 Created ElasticSearch lookup service.
Github user mattyb149 commented on a diff in the pull request: https://github.com/apache/nifi/pull/2615#discussion_r184392070 --- Diff: nifi-nar-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-client-service/src/main/java/org/apache/nifi/elasticsearch/ElasticSearchLookupService.java --- @@ -0,0 +1,290 @@ +/* + * 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 com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.nifi.annotation.lifecycle.OnEnabled; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.components.PropertyValue; +import org.apache.nifi.components.ValidationContext; +import org.apache.nifi.components.ValidationResult; +import org.apache.nifi.components.Validator; +import org.apache.nifi.controller.AbstractControllerService; +import org.apache.nifi.controller.ConfigurationContext; +import org.apache.nifi.expression.ExpressionLanguageScope; +import org.apache.nifi.lookup.LookupFailureException; +import org.apache.nifi.lookup.LookupService; +import org.apache.nifi.processor.util.StandardValidators; +import org.apache.nifi.reporting.InitializationException; +import org.apache.nifi.schemaregistry.services.SchemaRegistry; +import org.apache.nifi.serialization.SimpleRecordSchema; +import org.apache.nifi.serialization.record.MapRecord; +import org.apache.nifi.serialization.record.Record; +import org.apache.nifi.serialization.record.RecordField; +import org.apache.nifi.serialization.record.RecordFieldType; +import org.apache.nifi.serialization.record.RecordSchema; +import org.apache.nifi.serialization.record.SchemaIdentifier; +import org.apache.nifi.serialization.record.type.RecordDataType; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.Set; + +public class ElasticSearchLookupService extends AbstractControllerService implements LookupService { +public static final PropertyDescriptor CLIENT_SERVICE = new PropertyDescriptor.Builder() +.name("el-rest-client-service") +.displayName("Client Service") +.description("An ElasticSearch client service to use for running queries.") +.identifiesControllerService(ElasticSearchClientService.class) +.required(true) +.build(); +public static final PropertyDescriptor INDEX = new PropertyDescriptor.Builder() +.name("el-lookup-index") +.displayName("Index") +.description("The name of the index to read from") +.required(true) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) --- End diff -- Since the lookup is performed on an incoming flow file, is there any reason the Index, Type, etc. properties couldn't support attributes coming from the flow file? If it is this way because the ES Client Service CS can't use them, perhaps we should write up a separate improvement Jira to do something like NIFI-5121. ---
[GitHub] nifi pull request #2615: NIFI-5051 Created ElasticSearch lookup service.
Github user mattyb149 commented on a diff in the pull request: https://github.com/apache/nifi/pull/2615#discussion_r184390680 --- Diff: nifi-nar-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-client-service/pom.xml --- @@ -120,6 +132,22 @@ 1.7.0-SNAPSHOT provided + +org.apache.nifi +nifi-avro-record-utils +1.7.0-SNAPSHOT +compile + + +org.apache.nifi +nifi-avro-record-utils --- End diff -- This is included twice ---
[GitHub] nifi pull request #2615: NIFI-5051 Created ElasticSearch lookup service.
Github user mattyb149 commented on a diff in the pull request: https://github.com/apache/nifi/pull/2615#discussion_r184395918 --- Diff: nifi-nar-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-client-service/src/test/java/org/apache/nifi/elasticsearch/integration/ElasticSearchLookupService_IT.java --- @@ -0,0 +1,246 @@ +/* + * 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.integration; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.nifi.elasticsearch.ElasticSearchClientService; +import org.apache.nifi.elasticsearch.ElasticSearchClientServiceImpl; +import org.apache.nifi.elasticsearch.ElasticSearchLookupService; +import org.apache.nifi.lookup.LookupFailureException; +import org.apache.nifi.schemaregistry.services.SchemaRegistry; +import org.apache.nifi.serialization.record.Record; +import org.apache.nifi.serialization.record.RecordSchema; +import org.apache.nifi.serialization.record.type.RecordDataType; +import org.apache.nifi.util.TestRunner; +import org.apache.nifi.util.TestRunners; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; + +public class ElasticSearchLookupService_IT { --- End diff -- It would be nice to have some unit tests as well, since the integration tests do not get run as part of any automated build. I think you could mock the ES Client Service or something? There appears to be something similar in TestFetchElasticsearchHttp (and the other ES processor unit tests). ---
[GitHub] nifi pull request #2615: NIFI-5051 Created ElasticSearch lookup service.
Github user mattyb149 commented on a diff in the pull request: https://github.com/apache/nifi/pull/2615#discussion_r184393411 --- Diff: nifi-nar-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-client-service/src/main/java/org/apache/nifi/elasticsearch/ElasticSearchLookupService.java --- @@ -0,0 +1,290 @@ +/* + * 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 com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.nifi.annotation.lifecycle.OnEnabled; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.components.PropertyValue; +import org.apache.nifi.components.ValidationContext; +import org.apache.nifi.components.ValidationResult; +import org.apache.nifi.components.Validator; +import org.apache.nifi.controller.AbstractControllerService; +import org.apache.nifi.controller.ConfigurationContext; +import org.apache.nifi.expression.ExpressionLanguageScope; +import org.apache.nifi.lookup.LookupFailureException; +import org.apache.nifi.lookup.LookupService; +import org.apache.nifi.processor.util.StandardValidators; +import org.apache.nifi.reporting.InitializationException; +import org.apache.nifi.schemaregistry.services.SchemaRegistry; +import org.apache.nifi.serialization.SimpleRecordSchema; +import org.apache.nifi.serialization.record.MapRecord; +import org.apache.nifi.serialization.record.Record; +import org.apache.nifi.serialization.record.RecordField; +import org.apache.nifi.serialization.record.RecordFieldType; +import org.apache.nifi.serialization.record.RecordSchema; +import org.apache.nifi.serialization.record.SchemaIdentifier; +import org.apache.nifi.serialization.record.type.RecordDataType; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.Set; + +public class ElasticSearchLookupService extends AbstractControllerService implements LookupService { +public static final PropertyDescriptor CLIENT_SERVICE = new PropertyDescriptor.Builder() +.name("el-rest-client-service") +.displayName("Client Service") +.description("An ElasticSearch client service to use for running queries.") +.identifiesControllerService(ElasticSearchClientService.class) +.required(true) +.build(); +public static final PropertyDescriptor INDEX = new PropertyDescriptor.Builder() +.name("el-lookup-index") +.displayName("Index") +.description("The name of the index to read from") +.required(true) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) +.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) +.build(); + +public static final PropertyDescriptor TYPE = new PropertyDescriptor.Builder() +.name("el-lookup-type") +.displayName("Type") +.description("The type of this document (used by Elasticsearch for indexing and searching)") +.required(false) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) +.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) +.build(); + +public static final PropertyDescriptor SCHEMA_REGISTRY = new PropertyDescriptor.Builder() +.name("el-lookup-schema-registry") +.displayName("Schema Registry") +.description("If specified, this avro schema will be used for all objects loaded from MongoDB using this service. If left blank, " + +"the service will attempt to determine the schema from the results.") +.required(false) +.identifiesControllerService(SchemaRegistry.class) +.build(); + +public static final PropertyDescriptor RECORD_SCHE
[GitHub] nifi pull request #2615: NIFI-5051 Created ElasticSearch lookup service.
GitHub user MikeThomsen opened a pull request: https://github.com/apache/nifi/pull/2615 NIFI-5051 Created ElasticSearch lookup service. Thank you for submitting a contribution to Apache NiFi. In order to streamline the review of the contribution we ask you to ensure the following steps have been taken: ### For all changes: - [ ] Is there a JIRA ticket associated with this PR? Is it referenced in the commit message? - [ ] Does your PR title start with NIFI- where is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character. - [ ] Has your PR been rebased against the latest commit within the target branch (typically master)? - [ ] Is your initial contribution a single, squashed commit? ### For code changes: - [ ] Have you ensured that the full suite of tests is executed via mvn -Pcontrib-check clean install at the root nifi folder? - [ ] Have you written or updated unit tests to verify your changes? - [ ] If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under [ASF 2.0](http://www.apache.org/legal/resolved.html#category-a)? - [ ] If applicable, have you updated the LICENSE file, including the main LICENSE file under nifi-assembly? - [ ] If applicable, have you updated the NOTICE file, including the main NOTICE file found under nifi-assembly? - [ ] If adding new Properties, have you added .displayName in addition to .name (programmatic access) for each of the new properties? ### For documentation related changes: - [ ] Have you ensured that format looks appropriate for the output in which it is rendered? ### Note: Please ensure that once the PR is submitted, you check travis-ci for build issues and submit an update to your PR as soon as possible. You can merge this pull request into a Git repository by running: $ git pull https://github.com/MikeThomsen/nifi NIFI-5051 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/nifi/pull/2615.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #2615 commit dd7176ded6c359b78ab1265789b6567b2d574c8f Author: Mike Thomsen Date: 2018-04-07T01:38:07Z NIFI-5051 Created ElasticSearch lookup service. ---