exceptionfactory commented on a change in pull request #5301: URL: https://github.com/apache/nifi/pull/5301#discussion_r686291672
########## File path: nifi-nar-bundles/nifi-graph-bundle/nifi-neo4j-3x-cypher-service/pom.xml ########## @@ -0,0 +1,104 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <!-- Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with this + work for additional information regarding copyright ownership. The ASF licenses + this file to You under the Apache License, Version 2.0 (the "License"); you + may not use this file except in compliance with the License. You may obtain + a copy of the License at 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. --> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.apache.nifi</groupId> + <artifactId>nifi-graph-bundle</artifactId> + <version>1.15.0-SNAPSHOT</version> + </parent> + <artifactId>nifi-neo4j-3x-cypher-service</artifactId> + <packaging>jar</packaging> + + <dependencies> + <dependency> + <groupId>org.apache.nifi</groupId> + <artifactId>nifi-api</artifactId> + </dependency> + <dependency> + <groupId>org.apache.nifi</groupId> + <artifactId>nifi-processor-utils</artifactId> + <version>1.15.0-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.apache.nifi</groupId> + <artifactId>nifi-lookup-service-api</artifactId> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.apache.nifi</groupId> + <artifactId>nifi-graph-client-service-api</artifactId> + <version>${project.version}</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.apache.nifi</groupId> + <artifactId>nifi-ssl-context-service-api</artifactId> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.apache.nifi</groupId> + <artifactId>nifi-utils</artifactId> + <version>1.15.0-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.apache.nifi</groupId> + <artifactId>nifi-record</artifactId> + </dependency> + <dependency> + <groupId>org.apache.nifi</groupId> + <artifactId>nifi-mock</artifactId> + <version>1.15.0-SNAPSHOT</version> + <scope>test</scope> Review comment: Minor detail, but it would be helpful to move test dependencies after standard dependencies. ########## File path: nifi-nar-bundles/nifi-graph-bundle/nifi-neo4j-3x-cypher-service/src/main/java/org/apache/nifi/graph/Neo4JCypher3xClientService.java ########## @@ -0,0 +1,318 @@ +/* + * 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.graph; + +import org.apache.commons.lang3.StringUtils; +import org.apache.nifi.annotation.documentation.CapabilityDescription; +import org.apache.nifi.annotation.documentation.Tags; +import org.apache.nifi.annotation.lifecycle.OnDisabled; +import org.apache.nifi.annotation.lifecycle.OnEnabled; +import org.apache.nifi.components.AllowableValue; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.controller.AbstractControllerService; +import org.apache.nifi.controller.ConfigurationContext; +import org.apache.nifi.expression.ExpressionLanguageScope; +import org.apache.nifi.processor.exception.ProcessException; +import org.apache.nifi.processor.util.StandardValidators; +import org.apache.nifi.ssl.SSLContextService; +import org.neo4j.driver.internal.InternalNode; +import org.neo4j.driver.v1.AuthTokens; +import org.neo4j.driver.v1.Config; +import org.neo4j.driver.v1.Driver; +import org.neo4j.driver.v1.GraphDatabase; +import org.neo4j.driver.v1.Record; +import org.neo4j.driver.v1.Session; +import org.neo4j.driver.v1.StatementResult; +import org.neo4j.driver.v1.summary.ResultSummary; +import org.neo4j.driver.v1.summary.SummaryCounters; + +import java.io.File; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; + +@Deprecated +@Tags({ "graph", "neo4j", "cypher" }) +@CapabilityDescription("Provides a client service for managing connections to a Neo4J 3.X database. Configuration information for " + + "the Neo4J driver that corresponds to most of the settings for this service can be found here: " + + "https://neo4j.com/docs/driver-manual/current/client-applications/#driver-configuration") +public class Neo4JCypher3xClientService extends AbstractControllerService implements GraphClientService { + public static final PropertyDescriptor CONNECTION_URL = new PropertyDescriptor.Builder() + .name("neo4j-connection-url") + .displayName("Neo4j Connection URL") + .description("Neo4J endpoing to connect to.") + .required(true) + .defaultValue("bolt://localhost:7687") Review comment: This might be a helpful example, but it seems unlikely to have Neo4j running on the same server as NiFi. It seems better to avoid having a default value and perhaps including an example URL in the description. ########## File path: nifi-nar-bundles/nifi-graph-bundle/nifi-neo4j-3x-cypher-service/src/main/java/org/apache/nifi/graph/Neo4JCypher3xClientService.java ########## @@ -0,0 +1,318 @@ +/* + * 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.graph; + +import org.apache.commons.lang3.StringUtils; +import org.apache.nifi.annotation.documentation.CapabilityDescription; +import org.apache.nifi.annotation.documentation.Tags; +import org.apache.nifi.annotation.lifecycle.OnDisabled; +import org.apache.nifi.annotation.lifecycle.OnEnabled; +import org.apache.nifi.components.AllowableValue; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.controller.AbstractControllerService; +import org.apache.nifi.controller.ConfigurationContext; +import org.apache.nifi.expression.ExpressionLanguageScope; +import org.apache.nifi.processor.exception.ProcessException; +import org.apache.nifi.processor.util.StandardValidators; +import org.apache.nifi.ssl.SSLContextService; +import org.neo4j.driver.internal.InternalNode; +import org.neo4j.driver.v1.AuthTokens; +import org.neo4j.driver.v1.Config; +import org.neo4j.driver.v1.Driver; +import org.neo4j.driver.v1.GraphDatabase; +import org.neo4j.driver.v1.Record; +import org.neo4j.driver.v1.Session; +import org.neo4j.driver.v1.StatementResult; +import org.neo4j.driver.v1.summary.ResultSummary; +import org.neo4j.driver.v1.summary.SummaryCounters; + +import java.io.File; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; + +@Deprecated +@Tags({ "graph", "neo4j", "cypher" }) +@CapabilityDescription("Provides a client service for managing connections to a Neo4J 3.X database. Configuration information for " + + "the Neo4J driver that corresponds to most of the settings for this service can be found here: " + + "https://neo4j.com/docs/driver-manual/current/client-applications/#driver-configuration") +public class Neo4JCypher3xClientService extends AbstractControllerService implements GraphClientService { + public static final PropertyDescriptor CONNECTION_URL = new PropertyDescriptor.Builder() + .name("neo4j-connection-url") + .displayName("Neo4j Connection URL") + .description("Neo4J endpoing to connect to.") + .required(true) + .defaultValue("bolt://localhost:7687") + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) + .addValidator(StandardValidators.NON_EMPTY_VALIDATOR) + .build(); + + public static final PropertyDescriptor USERNAME = new PropertyDescriptor.Builder() + .name("neo4j-username") + .displayName("Username") + .description("Username for accessing Neo4J") + .required(true) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) + .addValidator(StandardValidators.NON_BLANK_VALIDATOR) + .build(); + + public static final PropertyDescriptor PASSWORD = new PropertyDescriptor.Builder() + .name("neo4j-password") + .displayName("Password") + .description("Password for Neo4J user. A dummy non-blank password is required even if it disabled on the server.") + .required(true) + .sensitive(true) + .addValidator(StandardValidators.NON_BLANK_VALIDATOR) + .build(); + public static AllowableValue LOAD_BALANCING_STRATEGY_ROUND_ROBIN = new AllowableValue(Config.LoadBalancingStrategy.ROUND_ROBIN.name(), "Round Robin", "Round Robin Strategy"); + + public static AllowableValue LOAD_BALANCING_STRATEGY_LEAST_CONNECTED = new AllowableValue(Config.LoadBalancingStrategy.LEAST_CONNECTED.name(), "Least Connected", "Least Connected Strategy"); + + protected static final PropertyDescriptor LOAD_BALANCING_STRATEGY = new PropertyDescriptor.Builder() + .name("neo4j-load-balancing-strategy") + .displayName("Load Balancing Strategy") + .description("Load Balancing Strategy (Round Robin or Least Connected)") + .required(false) + .defaultValue(LOAD_BALANCING_STRATEGY_ROUND_ROBIN.getValue()) + .allowableValues(LOAD_BALANCING_STRATEGY_ROUND_ROBIN, LOAD_BALANCING_STRATEGY_LEAST_CONNECTED) + .build(); + + public static final PropertyDescriptor CONNECTION_TIMEOUT = new PropertyDescriptor.Builder() + .name("neo4j-max-connection-time-out") + .displayName("Neo4J Max Connection Time Out (seconds)") + .description("The maximum time for establishing connection to the Neo4j") + .defaultValue("5 seconds") + .required(true) + .addValidator(StandardValidators.TIME_PERIOD_VALIDATOR) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) + .sensitive(false) + .build(); + + public static final PropertyDescriptor MAX_CONNECTION_POOL_SIZE = new PropertyDescriptor.Builder() + .name("neo4j-max-connection-pool-size") + .displayName("Neo4J Max Connection Pool Size") + .description("The maximum connection pool size for Neo4j.") + .defaultValue("100") + .required(true) + .addValidator(StandardValidators.POSITIVE_INTEGER_VALIDATOR) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) + .sensitive(false) + .build(); + + public static final PropertyDescriptor MAX_CONNECTION_ACQUISITION_TIMEOUT = new PropertyDescriptor.Builder() + .name("neo4j-max-connection-acquisition-timeout") + .displayName("Neo4J Max Connection Acquisition Timeout") + .description("The maximum connection acquisition timeout.") + .defaultValue("60 second") + .required(true) + .addValidator(StandardValidators.TIME_PERIOD_VALIDATOR) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) + .sensitive(false) + .build(); + + public static final PropertyDescriptor IDLE_TIME_BEFORE_CONNECTION_TEST = new PropertyDescriptor.Builder() + .name("neo4j-idle-time-before-test") + .displayName("Neo4J Idle Time Before Connection Test") + .description("The idle time before connection test.") + .defaultValue("60 seconds") + .required(true) + .addValidator(StandardValidators.TIME_PERIOD_VALIDATOR) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) + .sensitive(false) + .build(); + + public static final PropertyDescriptor MAX_CONNECTION_LIFETIME = new PropertyDescriptor.Builder() + .name("neo4j-max-connection-lifetime") + .displayName("Neo4J Max Connection Lifetime") + .description("The maximum connection lifetime") + .defaultValue("3600 seconds") + .required(true) + .addValidator(StandardValidators.TIME_PERIOD_VALIDATOR) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) + .sensitive(false) + .build(); + + public static final PropertyDescriptor ENCRYPTION = new PropertyDescriptor.Builder() + .name("neo4j-driver-tls-encryption-enabled") + .displayName("Neo4J Driver TLS Encryption") + .description("Is the driver using TLS encryption ?") + .defaultValue("true") + .required(true) + .allowableValues("true","false") + .addValidator(StandardValidators.BOOLEAN_VALIDATOR) + .sensitive(false) + .build(); + + public static final PropertyDescriptor SSL_CONTEXT_SERVICE = new PropertyDescriptor.Builder() + .name("SSL Context Service") + .description("The SSL Context Service used to provide client certificate information for TLS/SSL " + + "connections.") + .required(false) + .identifiesControllerService(SSLContextService.class) + .build(); + + protected Driver neo4JDriver; Review comment: ```suggestion protected Driver neo4jDriver; ``` ########## File path: nifi-nar-bundles/nifi-graph-bundle/nifi-neo4j-3x-cypher-service/src/main/java/org/apache/nifi/graph/Neo4JCypher3xClientService.java ########## @@ -0,0 +1,318 @@ +/* + * 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.graph; + +import org.apache.commons.lang3.StringUtils; +import org.apache.nifi.annotation.documentation.CapabilityDescription; +import org.apache.nifi.annotation.documentation.Tags; +import org.apache.nifi.annotation.lifecycle.OnDisabled; +import org.apache.nifi.annotation.lifecycle.OnEnabled; +import org.apache.nifi.components.AllowableValue; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.controller.AbstractControllerService; +import org.apache.nifi.controller.ConfigurationContext; +import org.apache.nifi.expression.ExpressionLanguageScope; +import org.apache.nifi.processor.exception.ProcessException; +import org.apache.nifi.processor.util.StandardValidators; +import org.apache.nifi.ssl.SSLContextService; +import org.neo4j.driver.internal.InternalNode; +import org.neo4j.driver.v1.AuthTokens; +import org.neo4j.driver.v1.Config; +import org.neo4j.driver.v1.Driver; +import org.neo4j.driver.v1.GraphDatabase; +import org.neo4j.driver.v1.Record; +import org.neo4j.driver.v1.Session; +import org.neo4j.driver.v1.StatementResult; +import org.neo4j.driver.v1.summary.ResultSummary; +import org.neo4j.driver.v1.summary.SummaryCounters; + +import java.io.File; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; + +@Deprecated +@Tags({ "graph", "neo4j", "cypher" }) +@CapabilityDescription("Provides a client service for managing connections to a Neo4J 3.X database. Configuration information for " + Review comment: The official documentation uses `Neo4j` as opposed to `Neo4J`, so recommend updating throughout the class. ```suggestion @CapabilityDescription("Provides a client service for managing connections to a Neo4j 3.X database. Configuration information for " + ``` ########## File path: nifi-nar-bundles/nifi-graph-bundle/nifi-neo4j-3x-cypher-service/src/main/java/org/apache/nifi/graph/Neo4JCypher3xClientService.java ########## @@ -0,0 +1,318 @@ +/* + * 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.graph; + +import org.apache.commons.lang3.StringUtils; +import org.apache.nifi.annotation.documentation.CapabilityDescription; +import org.apache.nifi.annotation.documentation.Tags; +import org.apache.nifi.annotation.lifecycle.OnDisabled; +import org.apache.nifi.annotation.lifecycle.OnEnabled; +import org.apache.nifi.components.AllowableValue; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.controller.AbstractControllerService; +import org.apache.nifi.controller.ConfigurationContext; +import org.apache.nifi.expression.ExpressionLanguageScope; +import org.apache.nifi.processor.exception.ProcessException; +import org.apache.nifi.processor.util.StandardValidators; +import org.apache.nifi.ssl.SSLContextService; +import org.neo4j.driver.internal.InternalNode; +import org.neo4j.driver.v1.AuthTokens; +import org.neo4j.driver.v1.Config; +import org.neo4j.driver.v1.Driver; +import org.neo4j.driver.v1.GraphDatabase; +import org.neo4j.driver.v1.Record; +import org.neo4j.driver.v1.Session; +import org.neo4j.driver.v1.StatementResult; +import org.neo4j.driver.v1.summary.ResultSummary; +import org.neo4j.driver.v1.summary.SummaryCounters; + +import java.io.File; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; + +@Deprecated +@Tags({ "graph", "neo4j", "cypher" }) +@CapabilityDescription("Provides a client service for managing connections to a Neo4J 3.X database. Configuration information for " + + "the Neo4J driver that corresponds to most of the settings for this service can be found here: " + + "https://neo4j.com/docs/driver-manual/current/client-applications/#driver-configuration") +public class Neo4JCypher3xClientService extends AbstractControllerService implements GraphClientService { + public static final PropertyDescriptor CONNECTION_URL = new PropertyDescriptor.Builder() + .name("neo4j-connection-url") + .displayName("Neo4j Connection URL") + .description("Neo4J endpoing to connect to.") + .required(true) + .defaultValue("bolt://localhost:7687") + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) + .addValidator(StandardValidators.NON_EMPTY_VALIDATOR) + .build(); + + public static final PropertyDescriptor USERNAME = new PropertyDescriptor.Builder() + .name("neo4j-username") + .displayName("Username") + .description("Username for accessing Neo4J") + .required(true) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) + .addValidator(StandardValidators.NON_BLANK_VALIDATOR) + .build(); + + public static final PropertyDescriptor PASSWORD = new PropertyDescriptor.Builder() + .name("neo4j-password") + .displayName("Password") + .description("Password for Neo4J user. A dummy non-blank password is required even if it disabled on the server.") + .required(true) + .sensitive(true) + .addValidator(StandardValidators.NON_BLANK_VALIDATOR) + .build(); + public static AllowableValue LOAD_BALANCING_STRATEGY_ROUND_ROBIN = new AllowableValue(Config.LoadBalancingStrategy.ROUND_ROBIN.name(), "Round Robin", "Round Robin Strategy"); + + public static AllowableValue LOAD_BALANCING_STRATEGY_LEAST_CONNECTED = new AllowableValue(Config.LoadBalancingStrategy.LEAST_CONNECTED.name(), "Least Connected", "Least Connected Strategy"); + + protected static final PropertyDescriptor LOAD_BALANCING_STRATEGY = new PropertyDescriptor.Builder() + .name("neo4j-load-balancing-strategy") + .displayName("Load Balancing Strategy") + .description("Load Balancing Strategy (Round Robin or Least Connected)") + .required(false) + .defaultValue(LOAD_BALANCING_STRATEGY_ROUND_ROBIN.getValue()) + .allowableValues(LOAD_BALANCING_STRATEGY_ROUND_ROBIN, LOAD_BALANCING_STRATEGY_LEAST_CONNECTED) + .build(); + + public static final PropertyDescriptor CONNECTION_TIMEOUT = new PropertyDescriptor.Builder() + .name("neo4j-max-connection-time-out") + .displayName("Neo4J Max Connection Time Out (seconds)") Review comment: The timeout can be any acceptable time period, so recommend removing "seconds": ```suggestion .displayName("Neo4j Max Connection Timeout") ``` ########## File path: nifi-nar-bundles/nifi-graph-bundle/nifi-neo4j-3x-cypher-service/src/main/java/org/apache/nifi/graph/Neo4JCypher3xClientService.java ########## @@ -0,0 +1,318 @@ +/* + * 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.graph; + +import org.apache.commons.lang3.StringUtils; +import org.apache.nifi.annotation.documentation.CapabilityDescription; +import org.apache.nifi.annotation.documentation.Tags; +import org.apache.nifi.annotation.lifecycle.OnDisabled; +import org.apache.nifi.annotation.lifecycle.OnEnabled; +import org.apache.nifi.components.AllowableValue; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.controller.AbstractControllerService; +import org.apache.nifi.controller.ConfigurationContext; +import org.apache.nifi.expression.ExpressionLanguageScope; +import org.apache.nifi.processor.exception.ProcessException; +import org.apache.nifi.processor.util.StandardValidators; +import org.apache.nifi.ssl.SSLContextService; +import org.neo4j.driver.internal.InternalNode; +import org.neo4j.driver.v1.AuthTokens; +import org.neo4j.driver.v1.Config; +import org.neo4j.driver.v1.Driver; +import org.neo4j.driver.v1.GraphDatabase; +import org.neo4j.driver.v1.Record; +import org.neo4j.driver.v1.Session; +import org.neo4j.driver.v1.StatementResult; +import org.neo4j.driver.v1.summary.ResultSummary; +import org.neo4j.driver.v1.summary.SummaryCounters; + +import java.io.File; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; + +@Deprecated +@Tags({ "graph", "neo4j", "cypher" }) +@CapabilityDescription("Provides a client service for managing connections to a Neo4J 3.X database. Configuration information for " + + "the Neo4J driver that corresponds to most of the settings for this service can be found here: " + + "https://neo4j.com/docs/driver-manual/current/client-applications/#driver-configuration") +public class Neo4JCypher3xClientService extends AbstractControllerService implements GraphClientService { + public static final PropertyDescriptor CONNECTION_URL = new PropertyDescriptor.Builder() + .name("neo4j-connection-url") + .displayName("Neo4j Connection URL") + .description("Neo4J endpoing to connect to.") + .required(true) + .defaultValue("bolt://localhost:7687") + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) + .addValidator(StandardValidators.NON_EMPTY_VALIDATOR) + .build(); + + public static final PropertyDescriptor USERNAME = new PropertyDescriptor.Builder() + .name("neo4j-username") + .displayName("Username") + .description("Username for accessing Neo4J") + .required(true) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) + .addValidator(StandardValidators.NON_BLANK_VALIDATOR) + .build(); + + public static final PropertyDescriptor PASSWORD = new PropertyDescriptor.Builder() + .name("neo4j-password") + .displayName("Password") + .description("Password for Neo4J user. A dummy non-blank password is required even if it disabled on the server.") + .required(true) + .sensitive(true) + .addValidator(StandardValidators.NON_BLANK_VALIDATOR) + .build(); + public static AllowableValue LOAD_BALANCING_STRATEGY_ROUND_ROBIN = new AllowableValue(Config.LoadBalancingStrategy.ROUND_ROBIN.name(), "Round Robin", "Round Robin Strategy"); + + public static AllowableValue LOAD_BALANCING_STRATEGY_LEAST_CONNECTED = new AllowableValue(Config.LoadBalancingStrategy.LEAST_CONNECTED.name(), "Least Connected", "Least Connected Strategy"); + + protected static final PropertyDescriptor LOAD_BALANCING_STRATEGY = new PropertyDescriptor.Builder() + .name("neo4j-load-balancing-strategy") + .displayName("Load Balancing Strategy") + .description("Load Balancing Strategy (Round Robin or Least Connected)") + .required(false) + .defaultValue(LOAD_BALANCING_STRATEGY_ROUND_ROBIN.getValue()) + .allowableValues(LOAD_BALANCING_STRATEGY_ROUND_ROBIN, LOAD_BALANCING_STRATEGY_LEAST_CONNECTED) + .build(); + + public static final PropertyDescriptor CONNECTION_TIMEOUT = new PropertyDescriptor.Builder() + .name("neo4j-max-connection-time-out") + .displayName("Neo4J Max Connection Time Out (seconds)") + .description("The maximum time for establishing connection to the Neo4j") + .defaultValue("5 seconds") + .required(true) + .addValidator(StandardValidators.TIME_PERIOD_VALIDATOR) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) + .sensitive(false) + .build(); + + public static final PropertyDescriptor MAX_CONNECTION_POOL_SIZE = new PropertyDescriptor.Builder() + .name("neo4j-max-connection-pool-size") + .displayName("Neo4J Max Connection Pool Size") Review comment: ```suggestion .displayName("Neo4j Max Connection Pool Size") ``` ########## File path: nifi-nar-bundles/nifi-graph-bundle/nifi-neo4j-3x-cypher-service/src/main/java/org/apache/nifi/graph/Neo4JCypher3xClientService.java ########## @@ -0,0 +1,318 @@ +/* + * 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.graph; + +import org.apache.commons.lang3.StringUtils; +import org.apache.nifi.annotation.documentation.CapabilityDescription; +import org.apache.nifi.annotation.documentation.Tags; +import org.apache.nifi.annotation.lifecycle.OnDisabled; +import org.apache.nifi.annotation.lifecycle.OnEnabled; +import org.apache.nifi.components.AllowableValue; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.controller.AbstractControllerService; +import org.apache.nifi.controller.ConfigurationContext; +import org.apache.nifi.expression.ExpressionLanguageScope; +import org.apache.nifi.processor.exception.ProcessException; +import org.apache.nifi.processor.util.StandardValidators; +import org.apache.nifi.ssl.SSLContextService; +import org.neo4j.driver.internal.InternalNode; +import org.neo4j.driver.v1.AuthTokens; +import org.neo4j.driver.v1.Config; +import org.neo4j.driver.v1.Driver; +import org.neo4j.driver.v1.GraphDatabase; +import org.neo4j.driver.v1.Record; +import org.neo4j.driver.v1.Session; +import org.neo4j.driver.v1.StatementResult; +import org.neo4j.driver.v1.summary.ResultSummary; +import org.neo4j.driver.v1.summary.SummaryCounters; + +import java.io.File; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; + +@Deprecated +@Tags({ "graph", "neo4j", "cypher" }) +@CapabilityDescription("Provides a client service for managing connections to a Neo4J 3.X database. Configuration information for " + + "the Neo4J driver that corresponds to most of the settings for this service can be found here: " + + "https://neo4j.com/docs/driver-manual/current/client-applications/#driver-configuration") +public class Neo4JCypher3xClientService extends AbstractControllerService implements GraphClientService { + public static final PropertyDescriptor CONNECTION_URL = new PropertyDescriptor.Builder() + .name("neo4j-connection-url") + .displayName("Neo4j Connection URL") + .description("Neo4J endpoing to connect to.") + .required(true) + .defaultValue("bolt://localhost:7687") + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) + .addValidator(StandardValidators.NON_EMPTY_VALIDATOR) + .build(); + + public static final PropertyDescriptor USERNAME = new PropertyDescriptor.Builder() + .name("neo4j-username") + .displayName("Username") + .description("Username for accessing Neo4J") Review comment: ```suggestion .description("Username for accessing Neo4j") ``` ########## File path: nifi-nar-bundles/nifi-graph-bundle/nifi-neo4j-3x-cypher-service/src/main/java/org/apache/nifi/graph/Neo4JCypher3xClientService.java ########## @@ -0,0 +1,318 @@ +/* + * 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.graph; + +import org.apache.commons.lang3.StringUtils; +import org.apache.nifi.annotation.documentation.CapabilityDescription; +import org.apache.nifi.annotation.documentation.Tags; +import org.apache.nifi.annotation.lifecycle.OnDisabled; +import org.apache.nifi.annotation.lifecycle.OnEnabled; +import org.apache.nifi.components.AllowableValue; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.controller.AbstractControllerService; +import org.apache.nifi.controller.ConfigurationContext; +import org.apache.nifi.expression.ExpressionLanguageScope; +import org.apache.nifi.processor.exception.ProcessException; +import org.apache.nifi.processor.util.StandardValidators; +import org.apache.nifi.ssl.SSLContextService; +import org.neo4j.driver.internal.InternalNode; +import org.neo4j.driver.v1.AuthTokens; +import org.neo4j.driver.v1.Config; +import org.neo4j.driver.v1.Driver; +import org.neo4j.driver.v1.GraphDatabase; +import org.neo4j.driver.v1.Record; +import org.neo4j.driver.v1.Session; +import org.neo4j.driver.v1.StatementResult; +import org.neo4j.driver.v1.summary.ResultSummary; +import org.neo4j.driver.v1.summary.SummaryCounters; + +import java.io.File; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; + +@Deprecated +@Tags({ "graph", "neo4j", "cypher" }) +@CapabilityDescription("Provides a client service for managing connections to a Neo4J 3.X database. Configuration information for " + + "the Neo4J driver that corresponds to most of the settings for this service can be found here: " + + "https://neo4j.com/docs/driver-manual/current/client-applications/#driver-configuration") +public class Neo4JCypher3xClientService extends AbstractControllerService implements GraphClientService { + public static final PropertyDescriptor CONNECTION_URL = new PropertyDescriptor.Builder() + .name("neo4j-connection-url") + .displayName("Neo4j Connection URL") + .description("Neo4J endpoing to connect to.") Review comment: Spelling and wording recommendation: ```suggestion .description("Remote URL of Neo4J server") ``` ########## File path: nifi-nar-bundles/nifi-graph-bundle/nifi-neo4j-3x-cypher-service/src/main/java/org/apache/nifi/graph/Neo4JCypher3xClientService.java ########## @@ -0,0 +1,318 @@ +/* + * 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.graph; + +import org.apache.commons.lang3.StringUtils; +import org.apache.nifi.annotation.documentation.CapabilityDescription; +import org.apache.nifi.annotation.documentation.Tags; +import org.apache.nifi.annotation.lifecycle.OnDisabled; +import org.apache.nifi.annotation.lifecycle.OnEnabled; +import org.apache.nifi.components.AllowableValue; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.controller.AbstractControllerService; +import org.apache.nifi.controller.ConfigurationContext; +import org.apache.nifi.expression.ExpressionLanguageScope; +import org.apache.nifi.processor.exception.ProcessException; +import org.apache.nifi.processor.util.StandardValidators; +import org.apache.nifi.ssl.SSLContextService; +import org.neo4j.driver.internal.InternalNode; +import org.neo4j.driver.v1.AuthTokens; +import org.neo4j.driver.v1.Config; +import org.neo4j.driver.v1.Driver; +import org.neo4j.driver.v1.GraphDatabase; +import org.neo4j.driver.v1.Record; +import org.neo4j.driver.v1.Session; +import org.neo4j.driver.v1.StatementResult; +import org.neo4j.driver.v1.summary.ResultSummary; +import org.neo4j.driver.v1.summary.SummaryCounters; + +import java.io.File; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; + +@Deprecated +@Tags({ "graph", "neo4j", "cypher" }) +@CapabilityDescription("Provides a client service for managing connections to a Neo4J 3.X database. Configuration information for " + + "the Neo4J driver that corresponds to most of the settings for this service can be found here: " + + "https://neo4j.com/docs/driver-manual/current/client-applications/#driver-configuration") +public class Neo4JCypher3xClientService extends AbstractControllerService implements GraphClientService { + public static final PropertyDescriptor CONNECTION_URL = new PropertyDescriptor.Builder() + .name("neo4j-connection-url") + .displayName("Neo4j Connection URL") Review comment: Capitalization adjustment to follow the standard usage: ```suggestion .displayName("Neo4J Connection URL") ``` ########## File path: nifi-nar-bundles/nifi-graph-bundle/nifi-neo4j-3x-cypher-service/src/main/java/org/apache/nifi/graph/Neo4JCypher3xClientService.java ########## @@ -0,0 +1,318 @@ +/* + * 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.graph; + +import org.apache.commons.lang3.StringUtils; +import org.apache.nifi.annotation.documentation.CapabilityDescription; +import org.apache.nifi.annotation.documentation.Tags; +import org.apache.nifi.annotation.lifecycle.OnDisabled; +import org.apache.nifi.annotation.lifecycle.OnEnabled; +import org.apache.nifi.components.AllowableValue; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.controller.AbstractControllerService; +import org.apache.nifi.controller.ConfigurationContext; +import org.apache.nifi.expression.ExpressionLanguageScope; +import org.apache.nifi.processor.exception.ProcessException; +import org.apache.nifi.processor.util.StandardValidators; +import org.apache.nifi.ssl.SSLContextService; +import org.neo4j.driver.internal.InternalNode; +import org.neo4j.driver.v1.AuthTokens; +import org.neo4j.driver.v1.Config; +import org.neo4j.driver.v1.Driver; +import org.neo4j.driver.v1.GraphDatabase; +import org.neo4j.driver.v1.Record; +import org.neo4j.driver.v1.Session; +import org.neo4j.driver.v1.StatementResult; +import org.neo4j.driver.v1.summary.ResultSummary; +import org.neo4j.driver.v1.summary.SummaryCounters; + +import java.io.File; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; + +@Deprecated +@Tags({ "graph", "neo4j", "cypher" }) +@CapabilityDescription("Provides a client service for managing connections to a Neo4J 3.X database. Configuration information for " + + "the Neo4J driver that corresponds to most of the settings for this service can be found here: " + + "https://neo4j.com/docs/driver-manual/current/client-applications/#driver-configuration") +public class Neo4JCypher3xClientService extends AbstractControllerService implements GraphClientService { + public static final PropertyDescriptor CONNECTION_URL = new PropertyDescriptor.Builder() + .name("neo4j-connection-url") + .displayName("Neo4j Connection URL") + .description("Neo4J endpoing to connect to.") + .required(true) + .defaultValue("bolt://localhost:7687") + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) + .addValidator(StandardValidators.NON_EMPTY_VALIDATOR) + .build(); + + public static final PropertyDescriptor USERNAME = new PropertyDescriptor.Builder() + .name("neo4j-username") + .displayName("Username") + .description("Username for accessing Neo4J") + .required(true) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) + .addValidator(StandardValidators.NON_BLANK_VALIDATOR) + .build(); + + public static final PropertyDescriptor PASSWORD = new PropertyDescriptor.Builder() + .name("neo4j-password") + .displayName("Password") + .description("Password for Neo4J user. A dummy non-blank password is required even if it disabled on the server.") Review comment: ```suggestion .description("Password for Neo4j. A non-blank password is required even if it disabled on the server.") ``` ########## File path: nifi-nar-bundles/nifi-graph-bundle/nifi-neo4j-3x-cypher-service/src/main/java/org/apache/nifi/graph/Neo4JCypher3xClientService.java ########## @@ -0,0 +1,318 @@ +/* + * 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.graph; + +import org.apache.commons.lang3.StringUtils; +import org.apache.nifi.annotation.documentation.CapabilityDescription; +import org.apache.nifi.annotation.documentation.Tags; +import org.apache.nifi.annotation.lifecycle.OnDisabled; +import org.apache.nifi.annotation.lifecycle.OnEnabled; +import org.apache.nifi.components.AllowableValue; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.controller.AbstractControllerService; +import org.apache.nifi.controller.ConfigurationContext; +import org.apache.nifi.expression.ExpressionLanguageScope; +import org.apache.nifi.processor.exception.ProcessException; +import org.apache.nifi.processor.util.StandardValidators; +import org.apache.nifi.ssl.SSLContextService; +import org.neo4j.driver.internal.InternalNode; +import org.neo4j.driver.v1.AuthTokens; +import org.neo4j.driver.v1.Config; +import org.neo4j.driver.v1.Driver; +import org.neo4j.driver.v1.GraphDatabase; +import org.neo4j.driver.v1.Record; +import org.neo4j.driver.v1.Session; +import org.neo4j.driver.v1.StatementResult; +import org.neo4j.driver.v1.summary.ResultSummary; +import org.neo4j.driver.v1.summary.SummaryCounters; + +import java.io.File; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; + +@Deprecated +@Tags({ "graph", "neo4j", "cypher" }) +@CapabilityDescription("Provides a client service for managing connections to a Neo4J 3.X database. Configuration information for " + + "the Neo4J driver that corresponds to most of the settings for this service can be found here: " + + "https://neo4j.com/docs/driver-manual/current/client-applications/#driver-configuration") +public class Neo4JCypher3xClientService extends AbstractControllerService implements GraphClientService { Review comment: The general convention for other versioned components seems to avoid using `x` associated with versions, so what do you think about renaming this to `Neo4jCypher3ClientService`? ```suggestion public class Neo4jCypher3ClientService extends AbstractControllerService implements GraphClientService { ``` ########## File path: nifi-nar-bundles/nifi-graph-bundle/nifi-neo4j-3x-cypher-service-nar/src/main/resources/META-INF/NOTICE ########## @@ -0,0 +1,152 @@ +nifi-cypher-services-nar +Copyright 2017-2018 The Apache Software Foundation + +This product includes software developed at +The Apache Software Foundation (http://www.apache.org/). + +****************** +Apache Software License v2 +****************** + +The following binary components are provided under the Apache Software License v2 + + (ASLv2) Apache Commons Compress + The following NOTICE information applies: + Apache Commons Compress + Copyright 2002-2017 The Apache Software Foundation + + The files in the package org.apache.commons.compress.archivers.sevenz + were derived from the LZMA SDK, version 9.20 (C/ and CPP/7zip/), + which has been placed in the public domain: + + "LZMA SDK is placed in the public domain." (http://www.7-zip.org/sdk.html) + + (ASLv2) Apache Commons Configuration + The following NOTICE information applies: + Apache Commons Configuration + Copyright 2001-2017 The Apache Software Foundation + + This product includes software developed at + The Apache Software Foundation (http://www.apache.org/). + + (ASLv2) Apache Commons CSV + The following NOTICE information applies: + Apache Commons CSV + Copyright 2005-2016 The Apache Software Foundation + + This product includes software developed at + The Apache Software Foundation (http://www.apache.org/). + + (ASLv2) Apache Commons BeanUtils + The following NOTICE information applies: + Apache Commons BeanUtils + Copyright 2000-2016 The Apache Software Foundation + + This product includes software developed at + The Apache Software Foundation (http://www.apache.org/). + + (ASLv2) Apache Commons Lang + The following NOTICE information applies: + Apache Commons Lang + Copyright 2001-2015 The Apache Software Foundation + + This product includes software from the Spring Framework, + under the Apache License 2.0 (see: StringUtils.containsWhitespace()) + + (ASLv2) Apache Commons Codec + The following NOTICE information applies: + Apache Commons Codec + Copyright 2002-2014 The Apache Software Foundation + + src/test/org/apache/commons/codec/language/DoubleMetaphoneTest.java + contains test data from http://aspell.net/test/orig/batch0.tab. + Copyright (C) 2002 Kevin Atkinson ([email protected]) + + =============================================================================== + + The content of package org.apache.commons.codec.language.bm has been translated + from the original php source code available at http://stevemorse.org/phoneticinfo.htm + with permission from the original authors. + Original source copyright: + Copyright (c) 2008 Alexander Beider & Stephen P. Morse. + + (ASLv2) Apache Commons Logging + The following NOTICE information applies: + Apache Commons Logging + Copyright 2003-2013 The Apache Software Foundation + + (ASLv2) Apache Commons IO + The following NOTICE information applies: + Apache Commons IO + Copyright 2002-2016 The Apache Software Foundation + + (ASLv2) Apache Commons Text + The following NOTICE information applies: + Apache Commons Text + Copyright 2001-2018 The Apache Software Foundation + + (ASLv2) Caffeine + The following NOTICE information applies: + Caffeine (caching library) + Copyright Ben Manes + + (ASLv2) Jackson JSON processor + The following NOTICE information applies: + # Jackson JSON processor + + Jackson is a high-performance, Free/Open Source JSON processing library. + It was originally written by Tatu Saloranta ([email protected]), and has + been in development since 2007. + It is currently developed by a community of developers, as well as supported + commercially by FasterXML.com. + + ## Licensing + + Jackson core and extension components may licensed under different licenses. + To find the details that apply to this artifact see the accompanying LICENSE file. + For more information, including possible other licensing options, contact + FasterXML.com (http://fasterxml.com). + + ## Credits + + A list of contributors may be found from CREDITS file, which is included + in some artifacts (usually source distributions); but is always available + from the source code management (SCM) system project uses. + + (ASL2 License) + (ASLv2) Neo4j Java Driver + Neo4j + Copyright © 20022018 Neo4j Sweden AB (referred to in this notice as "Neo4j") + [http://neo4j.com] + + + (ASLv2) Snappy Java + The following NOTICE information applies: + This product includes software developed by Google + Snappy: http://code.google.com/p/snappy/ (New BSD License) + + This product includes software developed by Apache + PureJavaCrc32C from apache-hadoop-common http://hadoop.apache.org/ + (Apache 2.0 license) + + This library containd statically linked libstdc++. This inclusion is allowed by + "GCC RUntime Library Exception" + http://gcc.gnu.org/onlinedocs/libstdc++/manual/license.html + + +***************** +Public Domain +***************** + +The following binary components are provided to the 'Public Domain'. See project link for details. + + (Public Domain) XZ for Java (org.tukaani:xz:jar:1.5 - http://tukaani.org/xz/java.html + + +************************ +Creative Commons Attribution-ShareAlike 3.0 +************************ + +The following binary components are provided under the Creative Commons Attribution-ShareAlike 3.0. See project link for details. + + (CCAS 3.0) MaxMind DB (https://github.com/maxmind/MaxMind-DB) Review comment: Is this library included in this NAR? ########## File path: nifi-nar-bundles/nifi-graph-bundle/nifi-neo4j-3x-cypher-service/src/main/java/org/apache/nifi/graph/Neo4JCypher3xClientService.java ########## @@ -0,0 +1,318 @@ +/* + * 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.graph; + +import org.apache.commons.lang3.StringUtils; +import org.apache.nifi.annotation.documentation.CapabilityDescription; +import org.apache.nifi.annotation.documentation.Tags; +import org.apache.nifi.annotation.lifecycle.OnDisabled; +import org.apache.nifi.annotation.lifecycle.OnEnabled; +import org.apache.nifi.components.AllowableValue; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.controller.AbstractControllerService; +import org.apache.nifi.controller.ConfigurationContext; +import org.apache.nifi.expression.ExpressionLanguageScope; +import org.apache.nifi.processor.exception.ProcessException; +import org.apache.nifi.processor.util.StandardValidators; +import org.apache.nifi.ssl.SSLContextService; +import org.neo4j.driver.internal.InternalNode; +import org.neo4j.driver.v1.AuthTokens; +import org.neo4j.driver.v1.Config; +import org.neo4j.driver.v1.Driver; +import org.neo4j.driver.v1.GraphDatabase; +import org.neo4j.driver.v1.Record; +import org.neo4j.driver.v1.Session; +import org.neo4j.driver.v1.StatementResult; +import org.neo4j.driver.v1.summary.ResultSummary; +import org.neo4j.driver.v1.summary.SummaryCounters; + +import java.io.File; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; + +@Deprecated +@Tags({ "graph", "neo4j", "cypher" }) +@CapabilityDescription("Provides a client service for managing connections to a Neo4J 3.X database. Configuration information for " + + "the Neo4J driver that corresponds to most of the settings for this service can be found here: " + + "https://neo4j.com/docs/driver-manual/current/client-applications/#driver-configuration") +public class Neo4JCypher3xClientService extends AbstractControllerService implements GraphClientService { + public static final PropertyDescriptor CONNECTION_URL = new PropertyDescriptor.Builder() + .name("neo4j-connection-url") + .displayName("Neo4j Connection URL") + .description("Neo4J endpoing to connect to.") + .required(true) + .defaultValue("bolt://localhost:7687") + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) + .addValidator(StandardValidators.NON_EMPTY_VALIDATOR) + .build(); + + public static final PropertyDescriptor USERNAME = new PropertyDescriptor.Builder() + .name("neo4j-username") + .displayName("Username") + .description("Username for accessing Neo4J") + .required(true) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) + .addValidator(StandardValidators.NON_BLANK_VALIDATOR) + .build(); + + public static final PropertyDescriptor PASSWORD = new PropertyDescriptor.Builder() + .name("neo4j-password") + .displayName("Password") + .description("Password for Neo4J user. A dummy non-blank password is required even if it disabled on the server.") + .required(true) + .sensitive(true) + .addValidator(StandardValidators.NON_BLANK_VALIDATOR) + .build(); + public static AllowableValue LOAD_BALANCING_STRATEGY_ROUND_ROBIN = new AllowableValue(Config.LoadBalancingStrategy.ROUND_ROBIN.name(), "Round Robin", "Round Robin Strategy"); + + public static AllowableValue LOAD_BALANCING_STRATEGY_LEAST_CONNECTED = new AllowableValue(Config.LoadBalancingStrategy.LEAST_CONNECTED.name(), "Least Connected", "Least Connected Strategy"); + + protected static final PropertyDescriptor LOAD_BALANCING_STRATEGY = new PropertyDescriptor.Builder() + .name("neo4j-load-balancing-strategy") + .displayName("Load Balancing Strategy") + .description("Load Balancing Strategy (Round Robin or Least Connected)") + .required(false) + .defaultValue(LOAD_BALANCING_STRATEGY_ROUND_ROBIN.getValue()) + .allowableValues(LOAD_BALANCING_STRATEGY_ROUND_ROBIN, LOAD_BALANCING_STRATEGY_LEAST_CONNECTED) + .build(); + + public static final PropertyDescriptor CONNECTION_TIMEOUT = new PropertyDescriptor.Builder() + .name("neo4j-max-connection-time-out") + .displayName("Neo4J Max Connection Time Out (seconds)") + .description("The maximum time for establishing connection to the Neo4j") + .defaultValue("5 seconds") + .required(true) + .addValidator(StandardValidators.TIME_PERIOD_VALIDATOR) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) + .sensitive(false) + .build(); + + public static final PropertyDescriptor MAX_CONNECTION_POOL_SIZE = new PropertyDescriptor.Builder() + .name("neo4j-max-connection-pool-size") + .displayName("Neo4J Max Connection Pool Size") + .description("The maximum connection pool size for Neo4j.") + .defaultValue("100") + .required(true) + .addValidator(StandardValidators.POSITIVE_INTEGER_VALIDATOR) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) + .sensitive(false) + .build(); + + public static final PropertyDescriptor MAX_CONNECTION_ACQUISITION_TIMEOUT = new PropertyDescriptor.Builder() + .name("neo4j-max-connection-acquisition-timeout") + .displayName("Neo4J Max Connection Acquisition Timeout") + .description("The maximum connection acquisition timeout.") + .defaultValue("60 second") + .required(true) + .addValidator(StandardValidators.TIME_PERIOD_VALIDATOR) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) + .sensitive(false) + .build(); + + public static final PropertyDescriptor IDLE_TIME_BEFORE_CONNECTION_TEST = new PropertyDescriptor.Builder() + .name("neo4j-idle-time-before-test") + .displayName("Neo4J Idle Time Before Connection Test") + .description("The idle time before connection test.") + .defaultValue("60 seconds") + .required(true) + .addValidator(StandardValidators.TIME_PERIOD_VALIDATOR) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) + .sensitive(false) + .build(); + + public static final PropertyDescriptor MAX_CONNECTION_LIFETIME = new PropertyDescriptor.Builder() + .name("neo4j-max-connection-lifetime") + .displayName("Neo4J Max Connection Lifetime") + .description("The maximum connection lifetime") + .defaultValue("3600 seconds") + .required(true) + .addValidator(StandardValidators.TIME_PERIOD_VALIDATOR) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) + .sensitive(false) + .build(); + + public static final PropertyDescriptor ENCRYPTION = new PropertyDescriptor.Builder() Review comment: Is this property necessary, or can it be inferred based on the presence or absence of the SSL Context Service? ########## File path: nifi-nar-bundles/nifi-graph-bundle/nifi-neo4j-3x-cypher-service/src/main/java/org/apache/nifi/graph/Neo4JCypher3xClientService.java ########## @@ -0,0 +1,318 @@ +/* + * 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.graph; + +import org.apache.commons.lang3.StringUtils; +import org.apache.nifi.annotation.documentation.CapabilityDescription; +import org.apache.nifi.annotation.documentation.Tags; +import org.apache.nifi.annotation.lifecycle.OnDisabled; +import org.apache.nifi.annotation.lifecycle.OnEnabled; +import org.apache.nifi.components.AllowableValue; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.controller.AbstractControllerService; +import org.apache.nifi.controller.ConfigurationContext; +import org.apache.nifi.expression.ExpressionLanguageScope; +import org.apache.nifi.processor.exception.ProcessException; +import org.apache.nifi.processor.util.StandardValidators; +import org.apache.nifi.ssl.SSLContextService; +import org.neo4j.driver.internal.InternalNode; +import org.neo4j.driver.v1.AuthTokens; +import org.neo4j.driver.v1.Config; +import org.neo4j.driver.v1.Driver; +import org.neo4j.driver.v1.GraphDatabase; +import org.neo4j.driver.v1.Record; +import org.neo4j.driver.v1.Session; +import org.neo4j.driver.v1.StatementResult; +import org.neo4j.driver.v1.summary.ResultSummary; +import org.neo4j.driver.v1.summary.SummaryCounters; + +import java.io.File; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; + +@Deprecated +@Tags({ "graph", "neo4j", "cypher" }) +@CapabilityDescription("Provides a client service for managing connections to a Neo4J 3.X database. Configuration information for " + + "the Neo4J driver that corresponds to most of the settings for this service can be found here: " + + "https://neo4j.com/docs/driver-manual/current/client-applications/#driver-configuration") +public class Neo4JCypher3xClientService extends AbstractControllerService implements GraphClientService { + public static final PropertyDescriptor CONNECTION_URL = new PropertyDescriptor.Builder() + .name("neo4j-connection-url") + .displayName("Neo4j Connection URL") + .description("Neo4J endpoing to connect to.") + .required(true) + .defaultValue("bolt://localhost:7687") + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) + .addValidator(StandardValidators.NON_EMPTY_VALIDATOR) + .build(); + + public static final PropertyDescriptor USERNAME = new PropertyDescriptor.Builder() + .name("neo4j-username") + .displayName("Username") + .description("Username for accessing Neo4J") + .required(true) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) + .addValidator(StandardValidators.NON_BLANK_VALIDATOR) + .build(); + + public static final PropertyDescriptor PASSWORD = new PropertyDescriptor.Builder() + .name("neo4j-password") + .displayName("Password") + .description("Password for Neo4J user. A dummy non-blank password is required even if it disabled on the server.") + .required(true) + .sensitive(true) + .addValidator(StandardValidators.NON_BLANK_VALIDATOR) + .build(); + public static AllowableValue LOAD_BALANCING_STRATEGY_ROUND_ROBIN = new AllowableValue(Config.LoadBalancingStrategy.ROUND_ROBIN.name(), "Round Robin", "Round Robin Strategy"); + + public static AllowableValue LOAD_BALANCING_STRATEGY_LEAST_CONNECTED = new AllowableValue(Config.LoadBalancingStrategy.LEAST_CONNECTED.name(), "Least Connected", "Least Connected Strategy"); + + protected static final PropertyDescriptor LOAD_BALANCING_STRATEGY = new PropertyDescriptor.Builder() + .name("neo4j-load-balancing-strategy") + .displayName("Load Balancing Strategy") + .description("Load Balancing Strategy (Round Robin or Least Connected)") + .required(false) + .defaultValue(LOAD_BALANCING_STRATEGY_ROUND_ROBIN.getValue()) + .allowableValues(LOAD_BALANCING_STRATEGY_ROUND_ROBIN, LOAD_BALANCING_STRATEGY_LEAST_CONNECTED) + .build(); + + public static final PropertyDescriptor CONNECTION_TIMEOUT = new PropertyDescriptor.Builder() + .name("neo4j-max-connection-time-out") + .displayName("Neo4J Max Connection Time Out (seconds)") + .description("The maximum time for establishing connection to the Neo4j") + .defaultValue("5 seconds") + .required(true) + .addValidator(StandardValidators.TIME_PERIOD_VALIDATOR) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) + .sensitive(false) + .build(); + + public static final PropertyDescriptor MAX_CONNECTION_POOL_SIZE = new PropertyDescriptor.Builder() + .name("neo4j-max-connection-pool-size") + .displayName("Neo4J Max Connection Pool Size") + .description("The maximum connection pool size for Neo4j.") + .defaultValue("100") + .required(true) + .addValidator(StandardValidators.POSITIVE_INTEGER_VALIDATOR) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) + .sensitive(false) + .build(); + + public static final PropertyDescriptor MAX_CONNECTION_ACQUISITION_TIMEOUT = new PropertyDescriptor.Builder() + .name("neo4j-max-connection-acquisition-timeout") + .displayName("Neo4J Max Connection Acquisition Timeout") + .description("The maximum connection acquisition timeout.") + .defaultValue("60 second") + .required(true) + .addValidator(StandardValidators.TIME_PERIOD_VALIDATOR) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) + .sensitive(false) + .build(); + + public static final PropertyDescriptor IDLE_TIME_BEFORE_CONNECTION_TEST = new PropertyDescriptor.Builder() + .name("neo4j-idle-time-before-test") + .displayName("Neo4J Idle Time Before Connection Test") + .description("The idle time before connection test.") + .defaultValue("60 seconds") + .required(true) + .addValidator(StandardValidators.TIME_PERIOD_VALIDATOR) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) + .sensitive(false) + .build(); + + public static final PropertyDescriptor MAX_CONNECTION_LIFETIME = new PropertyDescriptor.Builder() + .name("neo4j-max-connection-lifetime") + .displayName("Neo4J Max Connection Lifetime") + .description("The maximum connection lifetime") + .defaultValue("3600 seconds") + .required(true) + .addValidator(StandardValidators.TIME_PERIOD_VALIDATOR) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) + .sensitive(false) + .build(); + + public static final PropertyDescriptor ENCRYPTION = new PropertyDescriptor.Builder() + .name("neo4j-driver-tls-encryption-enabled") + .displayName("Neo4J Driver TLS Encryption") + .description("Is the driver using TLS encryption ?") + .defaultValue("true") + .required(true) + .allowableValues("true","false") + .addValidator(StandardValidators.BOOLEAN_VALIDATOR) + .sensitive(false) + .build(); + + public static final PropertyDescriptor SSL_CONTEXT_SERVICE = new PropertyDescriptor.Builder() + .name("SSL Context Service") + .description("The SSL Context Service used to provide client certificate information for TLS/SSL " + + "connections.") + .required(false) + .identifiesControllerService(SSLContextService.class) + .build(); + + protected Driver neo4JDriver; + protected String username; + protected String password; + protected String connectionUrl; + + private static final List<PropertyDescriptor> DESCRIPTORS; + static { + List<PropertyDescriptor> _temp = new ArrayList<>(); + _temp.add(CONNECTION_URL); + _temp.add(USERNAME); + _temp.add(PASSWORD); + _temp.add(LOAD_BALANCING_STRATEGY); + _temp.add(CONNECTION_TIMEOUT); + _temp.add(MAX_CONNECTION_POOL_SIZE); + _temp.add(MAX_CONNECTION_ACQUISITION_TIMEOUT); + _temp.add(IDLE_TIME_BEFORE_CONNECTION_TEST); + _temp.add(MAX_CONNECTION_LIFETIME); + _temp.add(ENCRYPTION); + _temp.add(SSL_CONTEXT_SERVICE); + + DESCRIPTORS = Collections.unmodifiableList(_temp); + } + + @Override + public List<PropertyDescriptor> getSupportedPropertyDescriptors() { + return DESCRIPTORS; + } + + protected Driver getDriver(ConfigurationContext context) { + connectionUrl = context.getProperty(CONNECTION_URL).evaluateAttributeExpressions().getValue(); + username = context.getProperty(USERNAME).evaluateAttributeExpressions().getValue(); + password = context.getProperty(PASSWORD).getValue(); + + Config.ConfigBuilder configBuilder = Config.build(); + String loadBalancingStrategyValue = context.getProperty(LOAD_BALANCING_STRATEGY).getValue(); + if ( ! StringUtils.isBlank(loadBalancingStrategyValue) ) { + configBuilder = configBuilder.withLoadBalancingStrategy( + Config.LoadBalancingStrategy.valueOf(loadBalancingStrategyValue)); + } + + configBuilder.withMaxConnectionPoolSize(context.getProperty(MAX_CONNECTION_POOL_SIZE).evaluateAttributeExpressions().asInteger()); + + configBuilder.withConnectionTimeout(context.getProperty(CONNECTION_TIMEOUT).evaluateAttributeExpressions().asTimePeriod(TimeUnit.SECONDS), TimeUnit.SECONDS); + + configBuilder.withConnectionAcquisitionTimeout(context.getProperty(MAX_CONNECTION_ACQUISITION_TIMEOUT).evaluateAttributeExpressions().asTimePeriod(TimeUnit.SECONDS), TimeUnit.SECONDS); + + configBuilder.withMaxConnectionLifetime(context.getProperty(MAX_CONNECTION_LIFETIME).evaluateAttributeExpressions().asTimePeriod(TimeUnit.SECONDS), TimeUnit.SECONDS); + + configBuilder.withConnectionLivenessCheckTimeout(context.getProperty(IDLE_TIME_BEFORE_CONNECTION_TEST).evaluateAttributeExpressions().asTimePeriod(TimeUnit.SECONDS), TimeUnit.SECONDS); + + if ( context.getProperty(ENCRYPTION).asBoolean() ) { + configBuilder.withEncryption(); + } else { + configBuilder.withoutEncryption(); + } + + final SSLContextService sslService = context.getProperty(SSL_CONTEXT_SERVICE).asControllerService(SSLContextService.class); + if (sslService != null) { + if ( sslService.isTrustStoreConfigured()) { + configBuilder.withTrustStrategy(Config.TrustStrategy.trustCustomCertificateSignedBy(new File( + sslService.getTrustStoreFile()))); + } else { + configBuilder.withTrustStrategy(Config.TrustStrategy.trustSystemCertificates()); + } + } + + return GraphDatabase.driver( connectionUrl, AuthTokens.basic( username, password), + configBuilder.toConfig()); + } + + /** + * Helper method to help testability + * @return Driver instance + */ + protected Driver getNeo4JDriver() { + return neo4JDriver; + } + + @OnEnabled + public void onEnabled(final ConfigurationContext context) { + try { + neo4JDriver = getDriver(context); + } catch(Exception e) { + getLogger().error("Error while getting connection " + e.getLocalizedMessage(),e); Review comment: Log statements should use placeholders, but is it necessary to log an error as well as throw an exception here? ```suggestion getLogger().error("Connection Failed: {} ", e.getLocalizedMessage(), e); ``` ########## File path: nifi-nar-bundles/nifi-graph-bundle/nifi-neo4j-3x-cypher-service/src/main/java/org/apache/nifi/graph/Neo4JCypher3xClientService.java ########## @@ -0,0 +1,318 @@ +/* + * 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.graph; + +import org.apache.commons.lang3.StringUtils; +import org.apache.nifi.annotation.documentation.CapabilityDescription; +import org.apache.nifi.annotation.documentation.Tags; +import org.apache.nifi.annotation.lifecycle.OnDisabled; +import org.apache.nifi.annotation.lifecycle.OnEnabled; +import org.apache.nifi.components.AllowableValue; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.controller.AbstractControllerService; +import org.apache.nifi.controller.ConfigurationContext; +import org.apache.nifi.expression.ExpressionLanguageScope; +import org.apache.nifi.processor.exception.ProcessException; +import org.apache.nifi.processor.util.StandardValidators; +import org.apache.nifi.ssl.SSLContextService; +import org.neo4j.driver.internal.InternalNode; +import org.neo4j.driver.v1.AuthTokens; +import org.neo4j.driver.v1.Config; +import org.neo4j.driver.v1.Driver; +import org.neo4j.driver.v1.GraphDatabase; +import org.neo4j.driver.v1.Record; +import org.neo4j.driver.v1.Session; +import org.neo4j.driver.v1.StatementResult; +import org.neo4j.driver.v1.summary.ResultSummary; +import org.neo4j.driver.v1.summary.SummaryCounters; + +import java.io.File; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; + +@Deprecated +@Tags({ "graph", "neo4j", "cypher" }) +@CapabilityDescription("Provides a client service for managing connections to a Neo4J 3.X database. Configuration information for " + + "the Neo4J driver that corresponds to most of the settings for this service can be found here: " + + "https://neo4j.com/docs/driver-manual/current/client-applications/#driver-configuration") +public class Neo4JCypher3xClientService extends AbstractControllerService implements GraphClientService { + public static final PropertyDescriptor CONNECTION_URL = new PropertyDescriptor.Builder() + .name("neo4j-connection-url") + .displayName("Neo4j Connection URL") + .description("Neo4J endpoing to connect to.") + .required(true) + .defaultValue("bolt://localhost:7687") + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) + .addValidator(StandardValidators.NON_EMPTY_VALIDATOR) + .build(); + + public static final PropertyDescriptor USERNAME = new PropertyDescriptor.Builder() + .name("neo4j-username") + .displayName("Username") + .description("Username for accessing Neo4J") + .required(true) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) + .addValidator(StandardValidators.NON_BLANK_VALIDATOR) + .build(); + + public static final PropertyDescriptor PASSWORD = new PropertyDescriptor.Builder() + .name("neo4j-password") + .displayName("Password") + .description("Password for Neo4J user. A dummy non-blank password is required even if it disabled on the server.") + .required(true) + .sensitive(true) + .addValidator(StandardValidators.NON_BLANK_VALIDATOR) + .build(); + public static AllowableValue LOAD_BALANCING_STRATEGY_ROUND_ROBIN = new AllowableValue(Config.LoadBalancingStrategy.ROUND_ROBIN.name(), "Round Robin", "Round Robin Strategy"); + + public static AllowableValue LOAD_BALANCING_STRATEGY_LEAST_CONNECTED = new AllowableValue(Config.LoadBalancingStrategy.LEAST_CONNECTED.name(), "Least Connected", "Least Connected Strategy"); + + protected static final PropertyDescriptor LOAD_BALANCING_STRATEGY = new PropertyDescriptor.Builder() + .name("neo4j-load-balancing-strategy") + .displayName("Load Balancing Strategy") + .description("Load Balancing Strategy (Round Robin or Least Connected)") + .required(false) + .defaultValue(LOAD_BALANCING_STRATEGY_ROUND_ROBIN.getValue()) + .allowableValues(LOAD_BALANCING_STRATEGY_ROUND_ROBIN, LOAD_BALANCING_STRATEGY_LEAST_CONNECTED) + .build(); + + public static final PropertyDescriptor CONNECTION_TIMEOUT = new PropertyDescriptor.Builder() + .name("neo4j-max-connection-time-out") Review comment: ```suggestion .name("neo4j-max-connection-timeout") ``` ########## File path: nifi-nar-bundles/nifi-graph-bundle/nifi-neo4j-3x-cypher-service/src/main/java/org/apache/nifi/graph/Neo4JCypher3xClientService.java ########## @@ -0,0 +1,318 @@ +/* + * 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.graph; + +import org.apache.commons.lang3.StringUtils; +import org.apache.nifi.annotation.documentation.CapabilityDescription; +import org.apache.nifi.annotation.documentation.Tags; +import org.apache.nifi.annotation.lifecycle.OnDisabled; +import org.apache.nifi.annotation.lifecycle.OnEnabled; +import org.apache.nifi.components.AllowableValue; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.controller.AbstractControllerService; +import org.apache.nifi.controller.ConfigurationContext; +import org.apache.nifi.expression.ExpressionLanguageScope; +import org.apache.nifi.processor.exception.ProcessException; +import org.apache.nifi.processor.util.StandardValidators; +import org.apache.nifi.ssl.SSLContextService; +import org.neo4j.driver.internal.InternalNode; +import org.neo4j.driver.v1.AuthTokens; +import org.neo4j.driver.v1.Config; +import org.neo4j.driver.v1.Driver; +import org.neo4j.driver.v1.GraphDatabase; +import org.neo4j.driver.v1.Record; +import org.neo4j.driver.v1.Session; +import org.neo4j.driver.v1.StatementResult; +import org.neo4j.driver.v1.summary.ResultSummary; +import org.neo4j.driver.v1.summary.SummaryCounters; + +import java.io.File; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; + +@Deprecated +@Tags({ "graph", "neo4j", "cypher" }) +@CapabilityDescription("Provides a client service for managing connections to a Neo4J 3.X database. Configuration information for " + + "the Neo4J driver that corresponds to most of the settings for this service can be found here: " + + "https://neo4j.com/docs/driver-manual/current/client-applications/#driver-configuration") +public class Neo4JCypher3xClientService extends AbstractControllerService implements GraphClientService { + public static final PropertyDescriptor CONNECTION_URL = new PropertyDescriptor.Builder() + .name("neo4j-connection-url") + .displayName("Neo4j Connection URL") + .description("Neo4J endpoing to connect to.") + .required(true) + .defaultValue("bolt://localhost:7687") + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) + .addValidator(StandardValidators.NON_EMPTY_VALIDATOR) + .build(); + + public static final PropertyDescriptor USERNAME = new PropertyDescriptor.Builder() + .name("neo4j-username") + .displayName("Username") + .description("Username for accessing Neo4J") + .required(true) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) + .addValidator(StandardValidators.NON_BLANK_VALIDATOR) + .build(); + + public static final PropertyDescriptor PASSWORD = new PropertyDescriptor.Builder() + .name("neo4j-password") + .displayName("Password") + .description("Password for Neo4J user. A dummy non-blank password is required even if it disabled on the server.") + .required(true) + .sensitive(true) + .addValidator(StandardValidators.NON_BLANK_VALIDATOR) + .build(); + public static AllowableValue LOAD_BALANCING_STRATEGY_ROUND_ROBIN = new AllowableValue(Config.LoadBalancingStrategy.ROUND_ROBIN.name(), "Round Robin", "Round Robin Strategy"); + + public static AllowableValue LOAD_BALANCING_STRATEGY_LEAST_CONNECTED = new AllowableValue(Config.LoadBalancingStrategy.LEAST_CONNECTED.name(), "Least Connected", "Least Connected Strategy"); + + protected static final PropertyDescriptor LOAD_BALANCING_STRATEGY = new PropertyDescriptor.Builder() + .name("neo4j-load-balancing-strategy") + .displayName("Load Balancing Strategy") + .description("Load Balancing Strategy (Round Robin or Least Connected)") + .required(false) + .defaultValue(LOAD_BALANCING_STRATEGY_ROUND_ROBIN.getValue()) + .allowableValues(LOAD_BALANCING_STRATEGY_ROUND_ROBIN, LOAD_BALANCING_STRATEGY_LEAST_CONNECTED) + .build(); + + public static final PropertyDescriptor CONNECTION_TIMEOUT = new PropertyDescriptor.Builder() + .name("neo4j-max-connection-time-out") + .displayName("Neo4J Max Connection Time Out (seconds)") + .description("The maximum time for establishing connection to the Neo4j") + .defaultValue("5 seconds") + .required(true) + .addValidator(StandardValidators.TIME_PERIOD_VALIDATOR) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) + .sensitive(false) + .build(); + + public static final PropertyDescriptor MAX_CONNECTION_POOL_SIZE = new PropertyDescriptor.Builder() + .name("neo4j-max-connection-pool-size") + .displayName("Neo4J Max Connection Pool Size") + .description("The maximum connection pool size for Neo4j.") + .defaultValue("100") + .required(true) + .addValidator(StandardValidators.POSITIVE_INTEGER_VALIDATOR) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) + .sensitive(false) + .build(); + + public static final PropertyDescriptor MAX_CONNECTION_ACQUISITION_TIMEOUT = new PropertyDescriptor.Builder() + .name("neo4j-max-connection-acquisition-timeout") + .displayName("Neo4J Max Connection Acquisition Timeout") + .description("The maximum connection acquisition timeout.") + .defaultValue("60 second") + .required(true) + .addValidator(StandardValidators.TIME_PERIOD_VALIDATOR) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) + .sensitive(false) + .build(); + + public static final PropertyDescriptor IDLE_TIME_BEFORE_CONNECTION_TEST = new PropertyDescriptor.Builder() + .name("neo4j-idle-time-before-test") + .displayName("Neo4J Idle Time Before Connection Test") + .description("The idle time before connection test.") + .defaultValue("60 seconds") + .required(true) + .addValidator(StandardValidators.TIME_PERIOD_VALIDATOR) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) + .sensitive(false) + .build(); + + public static final PropertyDescriptor MAX_CONNECTION_LIFETIME = new PropertyDescriptor.Builder() + .name("neo4j-max-connection-lifetime") + .displayName("Neo4J Max Connection Lifetime") + .description("The maximum connection lifetime") + .defaultValue("3600 seconds") + .required(true) + .addValidator(StandardValidators.TIME_PERIOD_VALIDATOR) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) + .sensitive(false) + .build(); + + public static final PropertyDescriptor ENCRYPTION = new PropertyDescriptor.Builder() + .name("neo4j-driver-tls-encryption-enabled") + .displayName("Neo4J Driver TLS Encryption") + .description("Is the driver using TLS encryption ?") + .defaultValue("true") + .required(true) + .allowableValues("true","false") + .addValidator(StandardValidators.BOOLEAN_VALIDATOR) + .sensitive(false) + .build(); + + public static final PropertyDescriptor SSL_CONTEXT_SERVICE = new PropertyDescriptor.Builder() + .name("SSL Context Service") + .description("The SSL Context Service used to provide client certificate information for TLS/SSL " + + "connections.") + .required(false) + .identifiesControllerService(SSLContextService.class) + .build(); + + protected Driver neo4JDriver; + protected String username; + protected String password; + protected String connectionUrl; + + private static final List<PropertyDescriptor> DESCRIPTORS; + static { + List<PropertyDescriptor> _temp = new ArrayList<>(); + _temp.add(CONNECTION_URL); + _temp.add(USERNAME); + _temp.add(PASSWORD); + _temp.add(LOAD_BALANCING_STRATEGY); + _temp.add(CONNECTION_TIMEOUT); + _temp.add(MAX_CONNECTION_POOL_SIZE); + _temp.add(MAX_CONNECTION_ACQUISITION_TIMEOUT); + _temp.add(IDLE_TIME_BEFORE_CONNECTION_TEST); + _temp.add(MAX_CONNECTION_LIFETIME); + _temp.add(ENCRYPTION); + _temp.add(SSL_CONTEXT_SERVICE); + + DESCRIPTORS = Collections.unmodifiableList(_temp); + } + + @Override + public List<PropertyDescriptor> getSupportedPropertyDescriptors() { + return DESCRIPTORS; + } + + protected Driver getDriver(ConfigurationContext context) { + connectionUrl = context.getProperty(CONNECTION_URL).evaluateAttributeExpressions().getValue(); + username = context.getProperty(USERNAME).evaluateAttributeExpressions().getValue(); + password = context.getProperty(PASSWORD).getValue(); + + Config.ConfigBuilder configBuilder = Config.build(); + String loadBalancingStrategyValue = context.getProperty(LOAD_BALANCING_STRATEGY).getValue(); + if ( ! StringUtils.isBlank(loadBalancingStrategyValue) ) { + configBuilder = configBuilder.withLoadBalancingStrategy( + Config.LoadBalancingStrategy.valueOf(loadBalancingStrategyValue)); + } + + configBuilder.withMaxConnectionPoolSize(context.getProperty(MAX_CONNECTION_POOL_SIZE).evaluateAttributeExpressions().asInteger()); + + configBuilder.withConnectionTimeout(context.getProperty(CONNECTION_TIMEOUT).evaluateAttributeExpressions().asTimePeriod(TimeUnit.SECONDS), TimeUnit.SECONDS); + + configBuilder.withConnectionAcquisitionTimeout(context.getProperty(MAX_CONNECTION_ACQUISITION_TIMEOUT).evaluateAttributeExpressions().asTimePeriod(TimeUnit.SECONDS), TimeUnit.SECONDS); + + configBuilder.withMaxConnectionLifetime(context.getProperty(MAX_CONNECTION_LIFETIME).evaluateAttributeExpressions().asTimePeriod(TimeUnit.SECONDS), TimeUnit.SECONDS); + + configBuilder.withConnectionLivenessCheckTimeout(context.getProperty(IDLE_TIME_BEFORE_CONNECTION_TEST).evaluateAttributeExpressions().asTimePeriod(TimeUnit.SECONDS), TimeUnit.SECONDS); + + if ( context.getProperty(ENCRYPTION).asBoolean() ) { + configBuilder.withEncryption(); + } else { + configBuilder.withoutEncryption(); + } + + final SSLContextService sslService = context.getProperty(SSL_CONTEXT_SERVICE).asControllerService(SSLContextService.class); + if (sslService != null) { + if ( sslService.isTrustStoreConfigured()) { + configBuilder.withTrustStrategy(Config.TrustStrategy.trustCustomCertificateSignedBy(new File( + sslService.getTrustStoreFile()))); + } else { + configBuilder.withTrustStrategy(Config.TrustStrategy.trustSystemCertificates()); + } + } + + return GraphDatabase.driver( connectionUrl, AuthTokens.basic( username, password), + configBuilder.toConfig()); + } + + /** + * Helper method to help testability + * @return Driver instance + */ + protected Driver getNeo4JDriver() { + return neo4JDriver; + } + + @OnEnabled + public void onEnabled(final ConfigurationContext context) { + try { + neo4JDriver = getDriver(context); + } catch(Exception e) { + getLogger().error("Error while getting connection " + e.getLocalizedMessage(),e); + throw new ProcessException("Error while getting connection" + e.getLocalizedMessage(),e); + } + getLogger().info("Neo4JCypherExecutor connection created for url {}", + new Object[] {connectionUrl}); + } + + @OnDisabled + public void close() { + getLogger().info("Closing driver"); Review comment: ```suggestion getLogger().debug("Closing Connection {}", connectionUrl); ``` ########## File path: nifi-nar-bundles/nifi-graph-bundle/nifi-neo4j-3x-cypher-service/src/main/java/org/apache/nifi/graph/Neo4JCypher3xClientService.java ########## @@ -0,0 +1,318 @@ +/* + * 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.graph; + +import org.apache.commons.lang3.StringUtils; +import org.apache.nifi.annotation.documentation.CapabilityDescription; +import org.apache.nifi.annotation.documentation.Tags; +import org.apache.nifi.annotation.lifecycle.OnDisabled; +import org.apache.nifi.annotation.lifecycle.OnEnabled; +import org.apache.nifi.components.AllowableValue; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.controller.AbstractControllerService; +import org.apache.nifi.controller.ConfigurationContext; +import org.apache.nifi.expression.ExpressionLanguageScope; +import org.apache.nifi.processor.exception.ProcessException; +import org.apache.nifi.processor.util.StandardValidators; +import org.apache.nifi.ssl.SSLContextService; +import org.neo4j.driver.internal.InternalNode; +import org.neo4j.driver.v1.AuthTokens; +import org.neo4j.driver.v1.Config; +import org.neo4j.driver.v1.Driver; +import org.neo4j.driver.v1.GraphDatabase; +import org.neo4j.driver.v1.Record; +import org.neo4j.driver.v1.Session; +import org.neo4j.driver.v1.StatementResult; +import org.neo4j.driver.v1.summary.ResultSummary; +import org.neo4j.driver.v1.summary.SummaryCounters; + +import java.io.File; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; + +@Deprecated +@Tags({ "graph", "neo4j", "cypher" }) +@CapabilityDescription("Provides a client service for managing connections to a Neo4J 3.X database. Configuration information for " + + "the Neo4J driver that corresponds to most of the settings for this service can be found here: " + + "https://neo4j.com/docs/driver-manual/current/client-applications/#driver-configuration") +public class Neo4JCypher3xClientService extends AbstractControllerService implements GraphClientService { + public static final PropertyDescriptor CONNECTION_URL = new PropertyDescriptor.Builder() + .name("neo4j-connection-url") + .displayName("Neo4j Connection URL") + .description("Neo4J endpoing to connect to.") + .required(true) + .defaultValue("bolt://localhost:7687") + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) + .addValidator(StandardValidators.NON_EMPTY_VALIDATOR) + .build(); + + public static final PropertyDescriptor USERNAME = new PropertyDescriptor.Builder() + .name("neo4j-username") + .displayName("Username") + .description("Username for accessing Neo4J") + .required(true) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) + .addValidator(StandardValidators.NON_BLANK_VALIDATOR) + .build(); + + public static final PropertyDescriptor PASSWORD = new PropertyDescriptor.Builder() + .name("neo4j-password") + .displayName("Password") + .description("Password for Neo4J user. A dummy non-blank password is required even if it disabled on the server.") + .required(true) + .sensitive(true) + .addValidator(StandardValidators.NON_BLANK_VALIDATOR) + .build(); + public static AllowableValue LOAD_BALANCING_STRATEGY_ROUND_ROBIN = new AllowableValue(Config.LoadBalancingStrategy.ROUND_ROBIN.name(), "Round Robin", "Round Robin Strategy"); + + public static AllowableValue LOAD_BALANCING_STRATEGY_LEAST_CONNECTED = new AllowableValue(Config.LoadBalancingStrategy.LEAST_CONNECTED.name(), "Least Connected", "Least Connected Strategy"); + + protected static final PropertyDescriptor LOAD_BALANCING_STRATEGY = new PropertyDescriptor.Builder() + .name("neo4j-load-balancing-strategy") + .displayName("Load Balancing Strategy") + .description("Load Balancing Strategy (Round Robin or Least Connected)") + .required(false) + .defaultValue(LOAD_BALANCING_STRATEGY_ROUND_ROBIN.getValue()) + .allowableValues(LOAD_BALANCING_STRATEGY_ROUND_ROBIN, LOAD_BALANCING_STRATEGY_LEAST_CONNECTED) + .build(); + + public static final PropertyDescriptor CONNECTION_TIMEOUT = new PropertyDescriptor.Builder() + .name("neo4j-max-connection-time-out") + .displayName("Neo4J Max Connection Time Out (seconds)") + .description("The maximum time for establishing connection to the Neo4j") + .defaultValue("5 seconds") + .required(true) + .addValidator(StandardValidators.TIME_PERIOD_VALIDATOR) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) + .sensitive(false) + .build(); + + public static final PropertyDescriptor MAX_CONNECTION_POOL_SIZE = new PropertyDescriptor.Builder() + .name("neo4j-max-connection-pool-size") + .displayName("Neo4J Max Connection Pool Size") + .description("The maximum connection pool size for Neo4j.") + .defaultValue("100") + .required(true) + .addValidator(StandardValidators.POSITIVE_INTEGER_VALIDATOR) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) + .sensitive(false) + .build(); + + public static final PropertyDescriptor MAX_CONNECTION_ACQUISITION_TIMEOUT = new PropertyDescriptor.Builder() + .name("neo4j-max-connection-acquisition-timeout") + .displayName("Neo4J Max Connection Acquisition Timeout") + .description("The maximum connection acquisition timeout.") + .defaultValue("60 second") + .required(true) + .addValidator(StandardValidators.TIME_PERIOD_VALIDATOR) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) + .sensitive(false) + .build(); + + public static final PropertyDescriptor IDLE_TIME_BEFORE_CONNECTION_TEST = new PropertyDescriptor.Builder() + .name("neo4j-idle-time-before-test") + .displayName("Neo4J Idle Time Before Connection Test") + .description("The idle time before connection test.") + .defaultValue("60 seconds") + .required(true) + .addValidator(StandardValidators.TIME_PERIOD_VALIDATOR) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) + .sensitive(false) + .build(); + + public static final PropertyDescriptor MAX_CONNECTION_LIFETIME = new PropertyDescriptor.Builder() + .name("neo4j-max-connection-lifetime") + .displayName("Neo4J Max Connection Lifetime") + .description("The maximum connection lifetime") + .defaultValue("3600 seconds") + .required(true) + .addValidator(StandardValidators.TIME_PERIOD_VALIDATOR) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) + .sensitive(false) + .build(); + + public static final PropertyDescriptor ENCRYPTION = new PropertyDescriptor.Builder() + .name("neo4j-driver-tls-encryption-enabled") + .displayName("Neo4J Driver TLS Encryption") + .description("Is the driver using TLS encryption ?") + .defaultValue("true") + .required(true) + .allowableValues("true","false") + .addValidator(StandardValidators.BOOLEAN_VALIDATOR) + .sensitive(false) + .build(); + + public static final PropertyDescriptor SSL_CONTEXT_SERVICE = new PropertyDescriptor.Builder() + .name("SSL Context Service") + .description("The SSL Context Service used to provide client certificate information for TLS/SSL " + + "connections.") + .required(false) + .identifiesControllerService(SSLContextService.class) + .build(); + + protected Driver neo4JDriver; + protected String username; + protected String password; + protected String connectionUrl; + + private static final List<PropertyDescriptor> DESCRIPTORS; + static { + List<PropertyDescriptor> _temp = new ArrayList<>(); + _temp.add(CONNECTION_URL); + _temp.add(USERNAME); + _temp.add(PASSWORD); + _temp.add(LOAD_BALANCING_STRATEGY); + _temp.add(CONNECTION_TIMEOUT); + _temp.add(MAX_CONNECTION_POOL_SIZE); + _temp.add(MAX_CONNECTION_ACQUISITION_TIMEOUT); + _temp.add(IDLE_TIME_BEFORE_CONNECTION_TEST); + _temp.add(MAX_CONNECTION_LIFETIME); + _temp.add(ENCRYPTION); + _temp.add(SSL_CONTEXT_SERVICE); + + DESCRIPTORS = Collections.unmodifiableList(_temp); + } + + @Override + public List<PropertyDescriptor> getSupportedPropertyDescriptors() { + return DESCRIPTORS; + } + + protected Driver getDriver(ConfigurationContext context) { + connectionUrl = context.getProperty(CONNECTION_URL).evaluateAttributeExpressions().getValue(); + username = context.getProperty(USERNAME).evaluateAttributeExpressions().getValue(); + password = context.getProperty(PASSWORD).getValue(); + + Config.ConfigBuilder configBuilder = Config.build(); + String loadBalancingStrategyValue = context.getProperty(LOAD_BALANCING_STRATEGY).getValue(); + if ( ! StringUtils.isBlank(loadBalancingStrategyValue) ) { + configBuilder = configBuilder.withLoadBalancingStrategy( + Config.LoadBalancingStrategy.valueOf(loadBalancingStrategyValue)); + } + + configBuilder.withMaxConnectionPoolSize(context.getProperty(MAX_CONNECTION_POOL_SIZE).evaluateAttributeExpressions().asInteger()); + + configBuilder.withConnectionTimeout(context.getProperty(CONNECTION_TIMEOUT).evaluateAttributeExpressions().asTimePeriod(TimeUnit.SECONDS), TimeUnit.SECONDS); + + configBuilder.withConnectionAcquisitionTimeout(context.getProperty(MAX_CONNECTION_ACQUISITION_TIMEOUT).evaluateAttributeExpressions().asTimePeriod(TimeUnit.SECONDS), TimeUnit.SECONDS); + + configBuilder.withMaxConnectionLifetime(context.getProperty(MAX_CONNECTION_LIFETIME).evaluateAttributeExpressions().asTimePeriod(TimeUnit.SECONDS), TimeUnit.SECONDS); + + configBuilder.withConnectionLivenessCheckTimeout(context.getProperty(IDLE_TIME_BEFORE_CONNECTION_TEST).evaluateAttributeExpressions().asTimePeriod(TimeUnit.SECONDS), TimeUnit.SECONDS); + + if ( context.getProperty(ENCRYPTION).asBoolean() ) { + configBuilder.withEncryption(); + } else { + configBuilder.withoutEncryption(); + } + + final SSLContextService sslService = context.getProperty(SSL_CONTEXT_SERVICE).asControllerService(SSLContextService.class); + if (sslService != null) { + if ( sslService.isTrustStoreConfigured()) { + configBuilder.withTrustStrategy(Config.TrustStrategy.trustCustomCertificateSignedBy(new File( + sslService.getTrustStoreFile()))); + } else { + configBuilder.withTrustStrategy(Config.TrustStrategy.trustSystemCertificates()); + } + } + + return GraphDatabase.driver( connectionUrl, AuthTokens.basic( username, password), + configBuilder.toConfig()); + } + + /** + * Helper method to help testability + * @return Driver instance + */ + protected Driver getNeo4JDriver() { + return neo4JDriver; + } + + @OnEnabled + public void onEnabled(final ConfigurationContext context) { + try { + neo4JDriver = getDriver(context); + } catch(Exception e) { + getLogger().error("Error while getting connection " + e.getLocalizedMessage(),e); + throw new ProcessException("Error while getting connection" + e.getLocalizedMessage(),e); + } + getLogger().info("Neo4JCypherExecutor connection created for url {}", + new Object[] {connectionUrl}); Review comment: The `Object[]` wrapper is no longer necessary, and it seems like this would be better as a debug log. ```suggestion getLogger().debug("Connection Created {}", connectionUrl); ``` ########## File path: nifi-nar-bundles/nifi-graph-bundle/nifi-neo4j-3x-cypher-service/src/main/java/org/apache/nifi/graph/Neo4JCypher3xClientService.java ########## @@ -0,0 +1,318 @@ +/* + * 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.graph; + +import org.apache.commons.lang3.StringUtils; +import org.apache.nifi.annotation.documentation.CapabilityDescription; +import org.apache.nifi.annotation.documentation.Tags; +import org.apache.nifi.annotation.lifecycle.OnDisabled; +import org.apache.nifi.annotation.lifecycle.OnEnabled; +import org.apache.nifi.components.AllowableValue; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.controller.AbstractControllerService; +import org.apache.nifi.controller.ConfigurationContext; +import org.apache.nifi.expression.ExpressionLanguageScope; +import org.apache.nifi.processor.exception.ProcessException; +import org.apache.nifi.processor.util.StandardValidators; +import org.apache.nifi.ssl.SSLContextService; +import org.neo4j.driver.internal.InternalNode; +import org.neo4j.driver.v1.AuthTokens; +import org.neo4j.driver.v1.Config; +import org.neo4j.driver.v1.Driver; +import org.neo4j.driver.v1.GraphDatabase; +import org.neo4j.driver.v1.Record; +import org.neo4j.driver.v1.Session; +import org.neo4j.driver.v1.StatementResult; +import org.neo4j.driver.v1.summary.ResultSummary; +import org.neo4j.driver.v1.summary.SummaryCounters; + +import java.io.File; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; + +@Deprecated +@Tags({ "graph", "neo4j", "cypher" }) +@CapabilityDescription("Provides a client service for managing connections to a Neo4J 3.X database. Configuration information for " + + "the Neo4J driver that corresponds to most of the settings for this service can be found here: " + + "https://neo4j.com/docs/driver-manual/current/client-applications/#driver-configuration") +public class Neo4JCypher3xClientService extends AbstractControllerService implements GraphClientService { + public static final PropertyDescriptor CONNECTION_URL = new PropertyDescriptor.Builder() + .name("neo4j-connection-url") + .displayName("Neo4j Connection URL") + .description("Neo4J endpoing to connect to.") + .required(true) + .defaultValue("bolt://localhost:7687") + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) + .addValidator(StandardValidators.NON_EMPTY_VALIDATOR) + .build(); + + public static final PropertyDescriptor USERNAME = new PropertyDescriptor.Builder() + .name("neo4j-username") + .displayName("Username") + .description("Username for accessing Neo4J") + .required(true) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) + .addValidator(StandardValidators.NON_BLANK_VALIDATOR) + .build(); + + public static final PropertyDescriptor PASSWORD = new PropertyDescriptor.Builder() + .name("neo4j-password") + .displayName("Password") + .description("Password for Neo4J user. A dummy non-blank password is required even if it disabled on the server.") + .required(true) + .sensitive(true) + .addValidator(StandardValidators.NON_BLANK_VALIDATOR) + .build(); + public static AllowableValue LOAD_BALANCING_STRATEGY_ROUND_ROBIN = new AllowableValue(Config.LoadBalancingStrategy.ROUND_ROBIN.name(), "Round Robin", "Round Robin Strategy"); + + public static AllowableValue LOAD_BALANCING_STRATEGY_LEAST_CONNECTED = new AllowableValue(Config.LoadBalancingStrategy.LEAST_CONNECTED.name(), "Least Connected", "Least Connected Strategy"); + + protected static final PropertyDescriptor LOAD_BALANCING_STRATEGY = new PropertyDescriptor.Builder() + .name("neo4j-load-balancing-strategy") + .displayName("Load Balancing Strategy") + .description("Load Balancing Strategy (Round Robin or Least Connected)") + .required(false) + .defaultValue(LOAD_BALANCING_STRATEGY_ROUND_ROBIN.getValue()) + .allowableValues(LOAD_BALANCING_STRATEGY_ROUND_ROBIN, LOAD_BALANCING_STRATEGY_LEAST_CONNECTED) + .build(); + + public static final PropertyDescriptor CONNECTION_TIMEOUT = new PropertyDescriptor.Builder() + .name("neo4j-max-connection-time-out") + .displayName("Neo4J Max Connection Time Out (seconds)") + .description("The maximum time for establishing connection to the Neo4j") + .defaultValue("5 seconds") + .required(true) + .addValidator(StandardValidators.TIME_PERIOD_VALIDATOR) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) + .sensitive(false) + .build(); + + public static final PropertyDescriptor MAX_CONNECTION_POOL_SIZE = new PropertyDescriptor.Builder() + .name("neo4j-max-connection-pool-size") + .displayName("Neo4J Max Connection Pool Size") + .description("The maximum connection pool size for Neo4j.") + .defaultValue("100") + .required(true) + .addValidator(StandardValidators.POSITIVE_INTEGER_VALIDATOR) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) + .sensitive(false) + .build(); + + public static final PropertyDescriptor MAX_CONNECTION_ACQUISITION_TIMEOUT = new PropertyDescriptor.Builder() + .name("neo4j-max-connection-acquisition-timeout") + .displayName("Neo4J Max Connection Acquisition Timeout") + .description("The maximum connection acquisition timeout.") + .defaultValue("60 second") + .required(true) + .addValidator(StandardValidators.TIME_PERIOD_VALIDATOR) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) + .sensitive(false) + .build(); + + public static final PropertyDescriptor IDLE_TIME_BEFORE_CONNECTION_TEST = new PropertyDescriptor.Builder() + .name("neo4j-idle-time-before-test") + .displayName("Neo4J Idle Time Before Connection Test") + .description("The idle time before connection test.") + .defaultValue("60 seconds") + .required(true) + .addValidator(StandardValidators.TIME_PERIOD_VALIDATOR) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) + .sensitive(false) + .build(); + + public static final PropertyDescriptor MAX_CONNECTION_LIFETIME = new PropertyDescriptor.Builder() + .name("neo4j-max-connection-lifetime") + .displayName("Neo4J Max Connection Lifetime") + .description("The maximum connection lifetime") + .defaultValue("3600 seconds") + .required(true) + .addValidator(StandardValidators.TIME_PERIOD_VALIDATOR) + .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) + .sensitive(false) + .build(); + + public static final PropertyDescriptor ENCRYPTION = new PropertyDescriptor.Builder() + .name("neo4j-driver-tls-encryption-enabled") + .displayName("Neo4J Driver TLS Encryption") + .description("Is the driver using TLS encryption ?") + .defaultValue("true") + .required(true) + .allowableValues("true","false") + .addValidator(StandardValidators.BOOLEAN_VALIDATOR) + .sensitive(false) + .build(); + + public static final PropertyDescriptor SSL_CONTEXT_SERVICE = new PropertyDescriptor.Builder() + .name("SSL Context Service") + .description("The SSL Context Service used to provide client certificate information for TLS/SSL " + + "connections.") + .required(false) + .identifiesControllerService(SSLContextService.class) + .build(); + + protected Driver neo4JDriver; + protected String username; + protected String password; + protected String connectionUrl; + + private static final List<PropertyDescriptor> DESCRIPTORS; + static { + List<PropertyDescriptor> _temp = new ArrayList<>(); + _temp.add(CONNECTION_URL); + _temp.add(USERNAME); + _temp.add(PASSWORD); + _temp.add(LOAD_BALANCING_STRATEGY); + _temp.add(CONNECTION_TIMEOUT); + _temp.add(MAX_CONNECTION_POOL_SIZE); + _temp.add(MAX_CONNECTION_ACQUISITION_TIMEOUT); + _temp.add(IDLE_TIME_BEFORE_CONNECTION_TEST); + _temp.add(MAX_CONNECTION_LIFETIME); + _temp.add(ENCRYPTION); + _temp.add(SSL_CONTEXT_SERVICE); + + DESCRIPTORS = Collections.unmodifiableList(_temp); + } + + @Override + public List<PropertyDescriptor> getSupportedPropertyDescriptors() { + return DESCRIPTORS; + } + + protected Driver getDriver(ConfigurationContext context) { + connectionUrl = context.getProperty(CONNECTION_URL).evaluateAttributeExpressions().getValue(); + username = context.getProperty(USERNAME).evaluateAttributeExpressions().getValue(); + password = context.getProperty(PASSWORD).getValue(); + + Config.ConfigBuilder configBuilder = Config.build(); + String loadBalancingStrategyValue = context.getProperty(LOAD_BALANCING_STRATEGY).getValue(); + if ( ! StringUtils.isBlank(loadBalancingStrategyValue) ) { + configBuilder = configBuilder.withLoadBalancingStrategy( + Config.LoadBalancingStrategy.valueOf(loadBalancingStrategyValue)); + } + + configBuilder.withMaxConnectionPoolSize(context.getProperty(MAX_CONNECTION_POOL_SIZE).evaluateAttributeExpressions().asInteger()); + + configBuilder.withConnectionTimeout(context.getProperty(CONNECTION_TIMEOUT).evaluateAttributeExpressions().asTimePeriod(TimeUnit.SECONDS), TimeUnit.SECONDS); + + configBuilder.withConnectionAcquisitionTimeout(context.getProperty(MAX_CONNECTION_ACQUISITION_TIMEOUT).evaluateAttributeExpressions().asTimePeriod(TimeUnit.SECONDS), TimeUnit.SECONDS); + + configBuilder.withMaxConnectionLifetime(context.getProperty(MAX_CONNECTION_LIFETIME).evaluateAttributeExpressions().asTimePeriod(TimeUnit.SECONDS), TimeUnit.SECONDS); + + configBuilder.withConnectionLivenessCheckTimeout(context.getProperty(IDLE_TIME_BEFORE_CONNECTION_TEST).evaluateAttributeExpressions().asTimePeriod(TimeUnit.SECONDS), TimeUnit.SECONDS); + + if ( context.getProperty(ENCRYPTION).asBoolean() ) { + configBuilder.withEncryption(); + } else { + configBuilder.withoutEncryption(); + } + + final SSLContextService sslService = context.getProperty(SSL_CONTEXT_SERVICE).asControllerService(SSLContextService.class); + if (sslService != null) { + if ( sslService.isTrustStoreConfigured()) { + configBuilder.withTrustStrategy(Config.TrustStrategy.trustCustomCertificateSignedBy(new File( + sslService.getTrustStoreFile()))); + } else { + configBuilder.withTrustStrategy(Config.TrustStrategy.trustSystemCertificates()); + } + } + + return GraphDatabase.driver( connectionUrl, AuthTokens.basic( username, password), + configBuilder.toConfig()); + } + + /** + * Helper method to help testability + * @return Driver instance + */ + protected Driver getNeo4JDriver() { + return neo4JDriver; + } + + @OnEnabled + public void onEnabled(final ConfigurationContext context) { + try { + neo4JDriver = getDriver(context); + } catch(Exception e) { + getLogger().error("Error while getting connection " + e.getLocalizedMessage(),e); + throw new ProcessException("Error while getting connection" + e.getLocalizedMessage(),e); + } + getLogger().info("Neo4JCypherExecutor connection created for url {}", + new Object[] {connectionUrl}); + } + + @OnDisabled + public void close() { + getLogger().info("Closing driver"); + if ( neo4JDriver != null ) { + neo4JDriver.close(); + neo4JDriver = null; + } + } + + private Map<String, Object> handleInternalNode(Map<String, Object> recordMap) { + if (recordMap.size() == 1) { + String key = recordMap.keySet().iterator().next(); + Object value = recordMap.get(key); + if (value instanceof InternalNode) { + return ((InternalNode)value).asMap(); + } + } + + return recordMap; + } + + @Override + public Map<String, String> executeQuery(String query, Map<String, Object> parameters, GraphQueryResultCallback handler) { + try (Session session = neo4JDriver.session()) { + StatementResult result = session.run(query, parameters); + long count = 0; + while (result.hasNext()) { + Record record = result.next(); + Map<String, Object> asMap = handleInternalNode(record.asMap()); + handler.process(asMap, result.hasNext()); + count++; + } + + ResultSummary summary = result.summary(); + SummaryCounters counters = summary.counters(); + + Map<String,String> resultAttributes = new HashMap<>(); + resultAttributes.put(NODES_CREATED,String.valueOf(counters.nodesCreated())); + resultAttributes.put(RELATIONS_CREATED,String.valueOf(counters.relationshipsCreated())); + resultAttributes.put(LABELS_ADDED,String.valueOf(counters.labelsAdded())); + resultAttributes.put(NODES_DELETED,String.valueOf(counters.nodesDeleted())); + resultAttributes.put(RELATIONS_DELETED,String.valueOf(counters.relationshipsDeleted())); + resultAttributes.put(PROPERTIES_SET, String.valueOf(counters.propertiesSet())); + resultAttributes.put(ROWS_RETURNED, String.valueOf(count)); + + return resultAttributes; + } catch (Exception ex) { + getLogger().error("", ex); + throw new ProcessException(ex); Review comment: Recommend removing the log and adding details to the exception message: ```suggestion throw new ProcessException("Query Failed", ex); ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
