@RequiresInstanceClassLoading @Tags(value={"hive","dbcp","jdbc","database","connection","pooling","store"}) @CapabilityDescription(value="Provides Database Connection Pooling Service for Apache Hive. Connections can be asked from pool and returned after usage.") @DeprecationNotice(classNames="org.apache.nifi.dbcp.hive.Hive3ConnectionPool") public class HiveConnectionPool extends AbstractControllerService implements HiveDBCPService
| Modifier and Type | Field and Description |
|---|---|
private static String |
ALLOW_EXPLICIT_KEYTAB |
private String |
connectionUrl |
static PropertyDescriptor |
DATABASE_URL |
private org.apache.commons.dbcp2.BasicDataSource |
dataSource |
static PropertyDescriptor |
DB_PASSWORD |
static PropertyDescriptor |
DB_USER |
private static String |
DEFAULT_MAX_CONN_LIFETIME |
static PropertyDescriptor |
HIVE_CONFIGURATION_RESOURCES |
private HiveConfigurator |
hiveConfigurator |
(package private) static PropertyDescriptor |
KERBEROS_CREDENTIALS_SERVICE |
private File |
kerberosConfigFile |
private KerberosProperties |
kerberosProperties |
private AtomicReference<KerberosUser> |
kerberosUserReference |
static PropertyDescriptor |
MAX_CONN_LIFETIME |
static PropertyDescriptor |
MAX_TOTAL_CONNECTIONS |
static PropertyDescriptor |
MAX_WAIT_TIME |
private List<PropertyDescriptor> |
properties |
private org.apache.hadoop.security.UserGroupInformation |
ugi |
static PropertyDescriptor |
VALIDATION_QUERY |
private AtomicReference<ValidationResources> |
validationResourceHolder |
| Constructor and Description |
|---|
HiveConnectionPool() |
| Modifier and Type | Method and Description |
|---|---|
protected Collection<ValidationResult> |
customValidate(ValidationContext validationContext) |
private long |
extractMillisWithInfinite(PropertyValue prop) |
Connection |
getConnection() |
String |
getConnectionURL() |
protected List<PropertyDescriptor> |
getSupportedPropertyDescriptors() |
protected void |
init(ControllerServiceInitializationContext context) |
(package private) boolean |
isAllowExplicitKeytab() |
void |
onConfigured(ConfigurationContext context)
Configures connection pool by creating an instance of the
BasicDataSource based on configuration provided with
ConfigurationContext. |
void |
shutdown()
Shutdown pool, close all open connections.
|
String |
toString() |
abstractClearConfigContext, abstractStoreConfigContext, disabled, enabled, getConfigurationContext, getControllerServiceLookup, getIdentifier, getLogger, getNodeTypeProvider, getProperty, getStateManager, initialize, isEnabledequals, getPropertyDescriptor, getPropertyDescriptors, getSupportedDynamicPropertyDescriptor, hashCode, onPropertyModified, validateclone, finalize, getClass, notify, notifyAll, wait, wait, waitgetConnection, getFlowFileFilter, getFlowFileFilterinitialize, isStatefulgetIdentifier, getPropertyDescriptor, getPropertyDescriptors, onPropertyModified, validateprivate static final String ALLOW_EXPLICIT_KEYTAB
private static final String DEFAULT_MAX_CONN_LIFETIME
public static final PropertyDescriptor DATABASE_URL
public static final PropertyDescriptor HIVE_CONFIGURATION_RESOURCES
public static final PropertyDescriptor DB_USER
public static final PropertyDescriptor DB_PASSWORD
public static final PropertyDescriptor MAX_WAIT_TIME
public static final PropertyDescriptor MAX_TOTAL_CONNECTIONS
public static final PropertyDescriptor MAX_CONN_LIFETIME
public static final PropertyDescriptor VALIDATION_QUERY
static final PropertyDescriptor KERBEROS_CREDENTIALS_SERVICE
private List<PropertyDescriptor> properties
private String connectionUrl
private final AtomicReference<ValidationResources> validationResourceHolder
private volatile org.apache.commons.dbcp2.BasicDataSource dataSource
private volatile HiveConfigurator hiveConfigurator
private volatile org.apache.hadoop.security.UserGroupInformation ugi
private final AtomicReference<KerberosUser> kerberosUserReference
private volatile File kerberosConfigFile
private volatile KerberosProperties kerberosProperties
protected void init(ControllerServiceInitializationContext context)
init in class AbstractControllerServiceprotected List<PropertyDescriptor> getSupportedPropertyDescriptors()
getSupportedPropertyDescriptors in class AbstractConfigurableComponentprotected Collection<ValidationResult> customValidate(ValidationContext validationContext)
customValidate in class AbstractConfigurableComponent@OnEnabled public void onConfigured(ConfigurationContext context) throws InitializationException
BasicDataSource based on configuration provided with
ConfigurationContext.
This operation makes no guarantees that the actual connection could be made since the underlying system may still go off-line during normal operation of the connection pool.
As of Apache NiFi 1.5.0, due to changes made toSecurityUtil.loginKerberos(Configuration, String, String), which is used by this class invoking
HiveConfigurator.authenticate(Configuration, String, String)
to authenticate a principal with Kerberos, Hive controller services no longer use a separate thread to
relogin, and instead call UserGroupInformation.checkTGTAndReloginFromKeytab() from
getConnection(). The relogin request is performed in a synchronized block to prevent
threads from requesting concurrent relogins. For more information, please read the documentation for
SecurityUtil.loginKerberos(Configuration, String, String).
In previous versions of NiFi, a KerberosTicketRenewer was started by
HiveConfigurator.authenticate(Configuration, String, String, long) when the Hive
controller service was enabled. The use of a separate thread to explicitly relogin could cause race conditions
with the implicit relogin attempts made by hadoop/Hive code on a thread that references the same
UserGroupInformation instance. One of these threads could leave the
Subject in UserGroupInformation to be cleared or in an unexpected state
while the other thread is attempting to use the Subject, resulting in failed
authentication attempts that would leave the Hive controller service in an unrecoverable state.context - the configuration contextInitializationException - if unable to create a database connectionSecurityUtil.loginKerberos(Configuration, String, String),
HiveConfigurator.authenticate(Configuration, String, String),
HiveConfigurator.authenticate(Configuration, String, String, long)@OnDisabled public void shutdown()
public Connection getConnection() throws ProcessException
getConnection in interface DBCPServiceProcessExceptionpublic String toString()
toString in class AbstractConfigurableComponentpublic String getConnectionURL()
getConnectionURL in interface HiveDBCPServiceboolean isAllowExplicitKeytab()
private long extractMillisWithInfinite(PropertyValue prop)
Copyright © 2023 Apache NiFi Project. All rights reserved.