You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by GitBox <gi...@apache.org> on 2022/12/05 14:16:51 UTC

[GitHub] [nifi] Lehel44 commented on a diff in pull request #6756: NIFI-10945: Create a PostgreSQL Controller Service

Lehel44 commented on code in PR #6756:
URL: https://github.com/apache/nifi/pull/6756#discussion_r1039656518


##########
nifi-nar-bundles/nifi-dbcp-services-bundle/nifi-postgres-dbcp-service/src/main/java/org/apache/nifi/service/PostgreSQLConnectionPool.java:
##########
@@ -0,0 +1,255 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.nifi.service;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.nifi.annotation.behavior.RequiresInstanceClassLoading;
+import org.apache.nifi.annotation.documentation.CapabilityDescription;
+import org.apache.nifi.annotation.documentation.Tags;
+import org.apache.nifi.components.PropertyDescriptor;
+import org.apache.nifi.components.ValidationContext;
+import org.apache.nifi.components.ValidationResult;
+import org.apache.nifi.controller.ConfigurationContext;
+import org.apache.nifi.dbcp.AbstractDBCPConnectionPool;
+import org.apache.nifi.dbcp.KerberosContext;
+import org.apache.nifi.expression.ExpressionLanguageScope;
+import org.apache.nifi.kerberos.KerberosCredentialsService;
+import org.apache.nifi.kerberos.KerberosUserService;
+import org.apache.nifi.processor.exception.ProcessException;
+import org.apache.nifi.processor.util.StandardValidators;
+
+import java.sql.Driver;
+import java.sql.DriverManager;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+import static org.apache.nifi.service.JdbcUrlFormat.FULL_URL;
+import static org.apache.nifi.service.JdbcUrlFormat.PARAMETERS;
+import static org.apache.nifi.service.JdbcUrlFormat.POSTGRESQL_BASIC_URI;
+
+/**
+ * Implementation of Database Connection Pooling Service for PostgreSQL with built-in JDBC driver.
+ * Apache DBCP is used for connection pooling functionality.
+ */
+@Tags({"postgres", "postgresql", "dbcp", "jdbc", "database", "connection", "pooling", "store"})
+@CapabilityDescription("Provides PostgreSQL Connection Pooling Service with built-in JDBC driver." +
+        " Connections can be requested from the pool and returned once they have been used.")
+@RequiresInstanceClassLoading
+public class PostgreSQLConnectionPool extends AbstractDBCPConnectionPool {
+
+    public static final PropertyDescriptor CONNECTION_URL_FORMAT = new PropertyDescriptor.Builder()
+            .name("connection-url-format")
+            .displayName("Connection URL Format")
+            .description("The format of the connection URL.")
+            .allowableValues(JdbcUrlFormat.class)
+            .required(true)
+            .defaultValue(FULL_URL.getValue())
+            .build();
+
+    public static final PropertyDescriptor POSTGRES_DATABASE_URL = new PropertyDescriptor.Builder()
+            .fromPropertyDescriptor(DATABASE_URL)
+            .dependsOn(CONNECTION_URL_FORMAT, FULL_URL)
+            .build();
+
+    public static final PropertyDescriptor DATABASE_NAME = new PropertyDescriptor.Builder()
+            .name("database-name")
+            .displayName("Database Name")
+            .description("The name of the database to connect.")
+            .required(false)
+            .dependsOn(CONNECTION_URL_FORMAT, PARAMETERS)
+            .addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
+            .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY)
+            .build();
+
+    public static final PropertyDescriptor DATABASE_HOSTNAME = new PropertyDescriptor.Builder()
+            .name("database-hostname")
+            .displayName("Database Hostname")
+            .description("The hostname of the database to connect.")
+            .required(false)
+            .dependsOn(CONNECTION_URL_FORMAT, PARAMETERS)
+            .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY)
+            .build();
+
+    public static final PropertyDescriptor DATABASE_PORT = new PropertyDescriptor.Builder()
+            .name("database-port")
+            .displayName("Database Port")
+            .description("The port of the database to connect.")
+            .required(false)
+            .dependsOn(CONNECTION_URL_FORMAT, PARAMETERS)
+            .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY)
+            .build();
+
+    public static final PropertyDescriptor KERBEROS_AUTH = new PropertyDescriptor.Builder()
+            .name("kerberos-auth")
+            .displayName("Kerberos Authentication")
+            .description("Use Kerberos authentication.")
+            .allowableValues("true", "false")
+            .defaultValue("false")
+            .build();
+
+    public static final PropertyDescriptor POSTGRES_KERBEROS_USER_SERVICE = new PropertyDescriptor.Builder()
+            .fromPropertyDescriptor(KERBEROS_USER_SERVICE)
+            .dependsOn(KERBEROS_AUTH, "true")
+            .build();
+
+    public static final PropertyDescriptor POSTGRES_KERBEROS_CREDENTIALS_SERVICE = new PropertyDescriptor.Builder()
+            .fromPropertyDescriptor(KERBEROS_CREDENTIALS_SERVICE)
+            .dependsOn(KERBEROS_AUTH, "true")
+            .build();

Review Comment:
   That's a good idea, thanks!



-- 
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: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org