diff --git standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/PersistenceManagerProvider.java standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/PersistenceManagerProvider.java index dfd7abff85..084ae833bf 100644 --- standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/PersistenceManagerProvider.java +++ standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/PersistenceManagerProvider.java @@ -54,7 +54,6 @@ import javax.sql.DataSource; import java.io.IOException; import java.lang.reflect.Field; -import java.lang.reflect.Method; import java.sql.SQLException; import java.util.Arrays; import java.util.Collections; @@ -225,9 +224,7 @@ public static void updatePmfProperties(Configuration conf) { } private static void initPMF(Configuration conf) { - DataSourceProvider dsp = DataSourceProviderFactory - .hasProviderSpecificConfigurations(conf) ? DataSourceProviderFactory - .getDataSourceProvider(conf) : null; + DataSourceProvider dsp = DataSourceProviderFactory.tryGetDataSourceProviderOrNull(conf); if (dsp == null) { pmf = JDOHelper.getPersistenceManagerFactory(prop); diff --git standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/datasource/BoneCPDataSourceProvider.java standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/datasource/BoneCPDataSourceProvider.java index 7e33c519a8..f3243c540b 100644 --- standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/datasource/BoneCPDataSourceProvider.java +++ standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/datasource/BoneCPDataSourceProvider.java @@ -17,17 +17,27 @@ */ package org.apache.hadoop.hive.metastore.datasource; +import java.sql.SQLException; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; +import java.util.Properties; +import javax.sql.DataSource; + +import com.codahale.metrics.Gauge; +import com.codahale.metrics.Metric; +import com.codahale.metrics.MetricRegistry; +import com.codahale.metrics.MetricSet; import com.jolbox.bonecp.BoneCPConfig; import com.jolbox.bonecp.BoneCPDataSource; +import com.jolbox.bonecp.StatisticsMBean; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hive.metastore.conf.MetastoreConf; +import org.apache.hadoop.hive.metastore.metrics.Metrics; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.sql.DataSource; -import java.sql.SQLException; -import java.util.Properties; - /** * DataSourceProvider for the BoneCP connection pool. */ @@ -61,15 +71,16 @@ public DataSource create(Configuration hdpConfig) throws SQLException { throw new SQLException("Cannot create BoneCP configuration: ", e); } config.setJdbcUrl(driverUrl); - //if we are waiting for connection for a long time, something is really wrong - //better raise an error than hang forever - //see DefaultConnectionStrategy.getConnectionInternal() + // if we are waiting for connection for a long time, something is really wrong + // better raise an error than hang forever + // see DefaultConnectionStrategy.getConnectionInternal() config.setConnectionTimeoutInMs(connectionTimeout); config.setMaxConnectionsPerPartition(maxPoolSize); config.setPartitionCount(Integer.parseInt(partitionCount)); config.setUser(user); config.setPassword(passwd); - return new BoneCPDataSource(config); + + return initMetrics(new BoneCPDataSource(config)); } @Override @@ -79,9 +90,81 @@ public boolean mayReturnClosedConnection() { } @Override - public boolean supports(Configuration configuration) { - String poolingType = MetastoreConf.getVar(configuration, - MetastoreConf.ConfVars.CONNECTION_POOLING_TYPE); - return BONECP.equalsIgnoreCase(poolingType); + public String getPoolingType() { + return BONECP; + } + + private BoneCPDataSource initMetrics(BoneCPDataSource ds) { + final MetricRegistry registry = Metrics.getRegistry(); + if (registry != null) { + registry.registerAll(new BoneCPMetrics(ds)); + } + return ds; + } + + private static class BoneCPMetrics implements MetricSet { + private BoneCPDataSource ds; + private Optional poolName; + + private BoneCPMetrics(final BoneCPDataSource ds) { + this.ds = ds; + this.poolName = Optional.ofNullable(ds.getPoolName()); + } + + private String name(final String gaugeName) { + return poolName.orElse("BoneCP") + ".pool." + gaugeName; + } + + @Override + public Map getMetrics() { + final Map gauges = new HashMap<>(); + + gauges.put(name("TotalConnections"), new Gauge() { + @Override + public Integer getValue() { + if (ds.getPool() != null) { + return ds.getPool().getStatistics().getTotalCreatedConnections(); + } else { + return 0; + } + } + }); + + gauges.put(name("IdleConnections"), new Gauge() { + @Override + public Integer getValue() { + if (ds.getPool() != null) { + return ds.getPool().getStatistics().getTotalFree(); + } else { + return 0; + } + } + }); + + gauges.put(name("ActiveConnections"), new Gauge() { + @Override + public Integer getValue() { + if (ds.getPool() != null) { + return ds.getPool().getStatistics().getTotalLeased(); + } else { + return 0; + } + } + }); + + gauges.put(name("WaitTimeAvg"), new Gauge() { + @Override + public Double getValue() { + if (ds.getPool() != null) { + return ds.getPool().getStatistics().getConnectionWaitTimeAvg(); + } else { + return 0.0; + } + } + }); + + return Collections.unmodifiableMap(gauges); + } } + } diff --git standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/datasource/DataSourceProvider.java standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/datasource/DataSourceProvider.java index 6dc63fb3bc..d71fa7d4ea 100644 --- standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/datasource/DataSourceProvider.java +++ standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/datasource/DataSourceProvider.java @@ -17,14 +17,14 @@ */ package org.apache.hadoop.hive.metastore.datasource; -import com.google.common.collect.Iterables; -import org.apache.hadoop.conf.Configuration; -import org.apache.hadoop.hive.metastore.conf.MetastoreConf; - -import javax.sql.DataSource; import java.io.IOException; import java.sql.SQLException; import java.util.Properties; +import javax.sql.DataSource; + +import com.google.common.collect.Iterables; +import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.hive.metastore.conf.MetastoreConf; public interface DataSourceProvider { @@ -42,11 +42,11 @@ boolean mayReturnClosedConnection(); /** - * @param configuration Hadoop configuration object - * @return factory able to create a connection pool for the implementation - * specified in the configuration + * Get the declared pooling type string. This is used to check against the constant in + * config options. + * @return The pooling type string associated with the data source. */ - boolean supports(Configuration configuration); + String getPoolingType(); /** * @param hdpConfig diff --git standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/datasource/DataSourceProviderFactory.java standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/datasource/DataSourceProviderFactory.java index 5a92e104be..bad12b2341 100644 --- standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/datasource/DataSourceProviderFactory.java +++ standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/datasource/DataSourceProviderFactory.java @@ -27,40 +27,26 @@ * Configuration object. */ public abstract class DataSourceProviderFactory { - - private static final ImmutableList FACTORIES = - ImmutableList.builder().add(new HikariCPDataSourceProvider(), new BoneCPDataSourceProvider(), - new DbCPDataSourceProvider()).build(); + private static final ImmutableList FACTORIES = ImmutableList.of( + new HikariCPDataSourceProvider(), + new BoneCPDataSourceProvider(), + new DbCPDataSourceProvider()); /** + * The data source providers declare if they are supported or not based on the config. + * This function looks through all the data source providers and picks the first one which is + * supported. If no data source provider is found, returns a null. + * * @param hdpConfig hadoop configuration - * @return factory for the configured datanucleus.connectionPoolingType + * @return factory for the configured datanucleus.connectionPoolingType or null if no supported + * data source providers are found. */ - public static DataSourceProvider getDataSourceProvider(Configuration hdpConfig) { - - for (DataSourceProvider factory : FACTORIES) { - - if (factory.supports(hdpConfig)) { - return factory; - } - } - return null; + public static DataSourceProvider tryGetDataSourceProviderOrNull(Configuration hdpConfig) { + final String configuredPoolingType = MetastoreConf.getVar(hdpConfig, + MetastoreConf.ConfVars.CONNECTION_POOLING_TYPE); + return Iterables.tryFind(FACTORIES, factory -> { + String poolingType = factory.getPoolingType(); + return poolingType != null && poolingType.equalsIgnoreCase(configuredPoolingType); + }).orNull(); } - - /** - * @param hdpConfig hadoop configuration - * @return true if the configuration contains settings specifically aimed for one - * of the supported conntection pool implementations. - */ - public static boolean hasProviderSpecificConfigurations(Configuration hdpConfig) { - - String poolingType = MetastoreConf.getVar(hdpConfig, MetastoreConf.ConfVars.CONNECTION_POOLING_TYPE).toLowerCase(); - - return Iterables.any(hdpConfig, entry -> - { - String key = entry.getKey(); - return key != null && (key.startsWith(poolingType)); - }); - } - } diff --git standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/datasource/DbCPDataSourceProvider.java standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/datasource/DbCPDataSourceProvider.java index 7fe487b184..1275e54948 100644 --- standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/datasource/DbCPDataSourceProvider.java +++ standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/datasource/DbCPDataSourceProvider.java @@ -17,6 +17,7 @@ */ package org.apache.hadoop.hive.metastore.datasource; +import com.codahale.metrics.MetricRegistry; import org.apache.commons.dbcp.ConnectionFactory; import org.apache.commons.dbcp.DriverManagerConnectionFactory; import org.apache.commons.dbcp.PoolableConnectionFactory; @@ -109,9 +110,7 @@ public boolean mayReturnClosedConnection() { } @Override - public boolean supports(Configuration configuration) { - String poolingType = MetastoreConf.getVar(configuration, - MetastoreConf.ConfVars.CONNECTION_POOLING_TYPE); - return DBCP.equalsIgnoreCase(poolingType); + public String getPoolingType() { + return DBCP; } } diff --git standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/datasource/HikariCPDataSourceProvider.java standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/datasource/HikariCPDataSourceProvider.java index 8f6ae57e36..7fd78d6734 100644 --- standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/datasource/HikariCPDataSourceProvider.java +++ standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/datasource/HikariCPDataSourceProvider.java @@ -17,10 +17,12 @@ */ package org.apache.hadoop.hive.metastore.datasource; +import com.codahale.metrics.MetricRegistry; import com.zaxxer.hikari.HikariConfig; import com.zaxxer.hikari.HikariDataSource; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hive.metastore.conf.MetastoreConf; +import org.apache.hadoop.hive.metastore.metrics.Metrics; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -35,8 +37,8 @@ private static final Logger LOG = LoggerFactory.getLogger(HikariCPDataSourceProvider.class); - public static final String HIKARI = "hikaricp"; - private static final String CONNECTION_TIMEOUT_PROPERTY= HIKARI + ".connectionTimeout"; + static final String HIKARI = "hikaricp"; + private static final String CONNECTION_TIMEOUT_PROPERTY = HIKARI + ".connectionTimeout"; @Override public DataSource create(Configuration hdpConfig) throws SQLException { @@ -64,7 +66,8 @@ public DataSource create(Configuration hdpConfig) throws SQLException { config.setPassword(passwd); //https://github.com/brettwooldridge/HikariCP config.setConnectionTimeout(connectionTimeout); - return new HikariDataSource(config); + + return new HikariDataSource(initMetrics(config)); } @Override @@ -74,10 +77,8 @@ public boolean mayReturnClosedConnection() { } @Override - public boolean supports(Configuration configuration) { - String poolingType = MetastoreConf.getVar(configuration, - MetastoreConf.ConfVars.CONNECTION_POOLING_TYPE); - return HIKARI.equalsIgnoreCase(poolingType); + public String getPoolingType() { + return HIKARI; } private Properties replacePrefix(Properties props) { @@ -86,4 +87,12 @@ private Properties replacePrefix(Properties props) { newProps.put(key.toString().replaceFirst(HIKARI + ".", ""), value)); return newProps; } + + private static HikariConfig initMetrics(final HikariConfig config) { + final MetricRegistry registry = Metrics.getRegistry(); + if (registry != null) { + config.setMetricRegistry(registry); + } + return config; + } } diff --git standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/metrics/MetricsConstants.java standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/metrics/MetricsConstants.java index 3b188f83af..24c8c4cc3a 100644 --- standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/metrics/MetricsConstants.java +++ standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/metrics/MetricsConstants.java @@ -21,6 +21,8 @@ public static final String ACTIVE_CALLS = "active_calls_"; public static final String API_PREFIX = "api_"; + public static final String TOTAL_API_CALLS = "total_api_calls"; + public static final String CREATE_TOTAL_DATABASES = "create_total_count_dbs"; public static final String CREATE_TOTAL_TABLES = "create_total_count_tables"; public static final String CREATE_TOTAL_PARTITIONS = "create_total_count_partitions"; diff --git standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/metrics/PerfLogger.java standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/metrics/PerfLogger.java index a2def26fc5..c111343701 100644 --- standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/metrics/PerfLogger.java +++ standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/metrics/PerfLogger.java @@ -164,15 +164,19 @@ public Long getDuration(String method) { return ImmutableMap.copyOf(endTimes); } - //Methods for metrics integration. Each thread-local PerfLogger will open/close scope during each perf-log method. - protected transient Map timerContexts = new HashMap<>(); + // Methods for metrics integration. Each thread-local PerfLogger will open/close scope during each perf-log method. + private transient Map timerContexts = new HashMap<>(); + private transient Timer.Context totalApiCallsTimerContext = null; private void beginMetrics(String method) { Timer timer = Metrics.getOrCreateTimer(MetricsConstants.API_PREFIX + method); if (timer != null) { timerContexts.put(method, timer.time()); } - + timer = Metrics.getOrCreateTimer(MetricsConstants.TOTAL_API_CALLS); + if (timer != null) { + totalApiCallsTimerContext = timer.time(); + } } private void endMetrics(String method) { @@ -180,6 +184,9 @@ private void endMetrics(String method) { if (context != null) { context.close(); } + if (totalApiCallsTimerContext != null) { + totalApiCallsTimerContext.close(); + } } /** @@ -190,5 +197,9 @@ public void cleanupPerfLogMetrics() { context.close(); } timerContexts.clear(); + if (totalApiCallsTimerContext != null) { + totalApiCallsTimerContext.close(); + totalApiCallsTimerContext = null; + } } } diff --git standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/txn/TxnHandler.java standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/txn/TxnHandler.java index 2a6290315a..c1616af008 100644 --- standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/txn/TxnHandler.java +++ standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/txn/TxnHandler.java @@ -5026,7 +5026,7 @@ public void countOpenTxns() throws MetaException { } private static synchronized DataSource setupJdbcConnectionPool(Configuration conf, int maxPoolSize, long getConnectionTimeoutMs) throws SQLException { - DataSourceProvider dsp = DataSourceProviderFactory.getDataSourceProvider(conf); + DataSourceProvider dsp = DataSourceProviderFactory.tryGetDataSourceProviderOrNull(conf); if (dsp != null) { doRetryOnConnPool = dsp.mayReturnClosedConnection(); return dsp.create(conf); diff --git standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/datasource/TestDataSourceProviderFactory.java standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/datasource/TestDataSourceProviderFactory.java index 6ae7f50471..f3b6f9f2da 100644 --- standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/datasource/TestDataSourceProviderFactory.java +++ standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/datasource/TestDataSourceProviderFactory.java @@ -50,29 +50,16 @@ public void testNoDataSourceCreatedWithoutProps() throws SQLException { MetastoreConf.setVar(conf, ConfVars.CONNECTION_POOLING_TYPE, "dummy"); - DataSourceProvider dsp = DataSourceProviderFactory.getDataSourceProvider(conf); + DataSourceProvider dsp = DataSourceProviderFactory.tryGetDataSourceProviderOrNull(conf); Assert.assertNull(dsp); } - @Test - public void testCanCreateDataSourceForSpecificProp() throws SQLException { - - Assert.assertFalse( - DataSourceProviderFactory.hasProviderSpecificConfigurations(conf)); - - MetastoreConf.setVar(conf, ConfVars.CONNECTION_POOLING_TYPE, BoneCPDataSourceProvider.BONECP); - conf.set(BoneCPDataSourceProvider.BONECP + ".dummy.var", "dummy"); - - Assert.assertTrue( - DataSourceProviderFactory.hasProviderSpecificConfigurations(conf)); - } - @Test public void testCreateBoneCpDataSource() throws SQLException { MetastoreConf.setVar(conf, ConfVars.CONNECTION_POOLING_TYPE, BoneCPDataSourceProvider.BONECP); - DataSourceProvider dsp = DataSourceProviderFactory.getDataSourceProvider(conf); + DataSourceProvider dsp = DataSourceProviderFactory.tryGetDataSourceProviderOrNull(conf); Assert.assertNotNull(dsp); DataSource ds = dsp.create(conf); @@ -85,7 +72,7 @@ public void testSetBoneCpStringProperty() throws SQLException { MetastoreConf.setVar(conf, ConfVars.CONNECTION_POOLING_TYPE, BoneCPDataSourceProvider.BONECP); conf.set(BoneCPDataSourceProvider.BONECP + ".initSQL", "select 1 from dual"); - DataSourceProvider dsp = DataSourceProviderFactory.getDataSourceProvider(conf); + DataSourceProvider dsp = DataSourceProviderFactory.tryGetDataSourceProviderOrNull(conf); Assert.assertNotNull(dsp); DataSource ds = dsp.create(conf); @@ -99,7 +86,7 @@ public void testSetBoneCpNumberProperty() throws SQLException { MetastoreConf.setVar(conf, ConfVars.CONNECTION_POOLING_TYPE, BoneCPDataSourceProvider.BONECP); conf.set(BoneCPDataSourceProvider.BONECP + ".acquireRetryDelayInMs", "599"); - DataSourceProvider dsp = DataSourceProviderFactory.getDataSourceProvider(conf); + DataSourceProvider dsp = DataSourceProviderFactory.tryGetDataSourceProviderOrNull(conf); Assert.assertNotNull(dsp); DataSource ds = dsp.create(conf); @@ -113,7 +100,7 @@ public void testSetBoneCpBooleanProperty() throws SQLException { MetastoreConf.setVar(conf, ConfVars.CONNECTION_POOLING_TYPE, BoneCPDataSourceProvider.BONECP); conf.set(BoneCPDataSourceProvider.BONECP + ".disableJMX", "true"); - DataSourceProvider dsp = DataSourceProviderFactory.getDataSourceProvider(conf); + DataSourceProvider dsp = DataSourceProviderFactory.tryGetDataSourceProviderOrNull(conf); Assert.assertNotNull(dsp); DataSource ds = dsp.create(conf); @@ -128,7 +115,7 @@ public void testCreateHikariCpDataSource() throws SQLException { // This is needed to prevent the HikariDataSource from trying to connect to the DB conf.set(HikariCPDataSourceProvider.HIKARI + ".initializationFailTimeout", "-1"); - DataSourceProvider dsp = DataSourceProviderFactory.getDataSourceProvider(conf); + DataSourceProvider dsp = DataSourceProviderFactory.tryGetDataSourceProviderOrNull(conf); Assert.assertNotNull(dsp); DataSource ds = dsp.create(conf); @@ -142,7 +129,7 @@ public void testSetHikariCpStringProperty() throws SQLException { conf.set(HikariCPDataSourceProvider.HIKARI + ".connectionInitSql", "select 1 from dual"); conf.set(HikariCPDataSourceProvider.HIKARI + ".initializationFailTimeout", "-1"); - DataSourceProvider dsp = DataSourceProviderFactory.getDataSourceProvider(conf); + DataSourceProvider dsp = DataSourceProviderFactory.tryGetDataSourceProviderOrNull(conf); Assert.assertNotNull(dsp); DataSource ds = dsp.create(conf); @@ -157,7 +144,7 @@ public void testSetHikariCpNumberProperty() throws SQLException { conf.set(HikariCPDataSourceProvider.HIKARI + ".idleTimeout", "59999"); conf.set(HikariCPDataSourceProvider.HIKARI + ".initializationFailTimeout", "-1"); - DataSourceProvider dsp = DataSourceProviderFactory.getDataSourceProvider(conf); + DataSourceProvider dsp = DataSourceProviderFactory.tryGetDataSourceProviderOrNull(conf); Assert.assertNotNull(dsp); DataSource ds = dsp.create(conf); @@ -172,7 +159,7 @@ public void testSetHikariCpBooleanProperty() throws SQLException { conf.set(HikariCPDataSourceProvider.HIKARI + ".allowPoolSuspension", "false"); conf.set(HikariCPDataSourceProvider.HIKARI + ".initializationFailTimeout", "-1"); - DataSourceProvider dsp = DataSourceProviderFactory.getDataSourceProvider(conf); + DataSourceProvider dsp = DataSourceProviderFactory.tryGetDataSourceProviderOrNull(conf); Assert.assertNotNull(dsp); DataSource ds = dsp.create(conf); @@ -185,64 +172,10 @@ public void testCreateDbCpDataSource() throws SQLException { MetastoreConf.setVar(conf, ConfVars.CONNECTION_POOLING_TYPE, DbCPDataSourceProvider.DBCP); - DataSourceProvider dsp = DataSourceProviderFactory.getDataSourceProvider(conf); + DataSourceProvider dsp = DataSourceProviderFactory.tryGetDataSourceProviderOrNull(conf); Assert.assertNotNull(dsp); DataSource ds = dsp.create(conf); Assert.assertTrue(ds instanceof PoolingDataSource); } - - @Test - public void testHasProviderSpecificConfigurationBonecp() throws SQLException { - - MetastoreConf.setVar(conf, ConfVars.CONNECTION_POOLING_TYPE, BoneCPDataSourceProvider.BONECP); - - Assert.assertFalse(DataSourceProviderFactory.hasProviderSpecificConfigurations(conf)); - - conf.set("dbcp.dummyConf", "dummyValue"); - Assert.assertFalse(DataSourceProviderFactory.hasProviderSpecificConfigurations(conf)); - - conf.set("hikaricp.dummyConf", "dummyValue"); - Assert.assertFalse(DataSourceProviderFactory.hasProviderSpecificConfigurations(conf)); - - conf.set("bonecp.dummyConf", "dummyValue"); - Assert.assertTrue(DataSourceProviderFactory.hasProviderSpecificConfigurations(conf)); - - } - - @Test - public void testHasProviderSpecificConfigurationHikaricp() throws SQLException { - - MetastoreConf.setVar(conf, ConfVars.CONNECTION_POOLING_TYPE, HikariCPDataSourceProvider.HIKARI); - - Assert.assertFalse(DataSourceProviderFactory.hasProviderSpecificConfigurations(conf)); - - conf.set("dbcp.dummyConf", "dummyValue"); - Assert.assertFalse(DataSourceProviderFactory.hasProviderSpecificConfigurations(conf)); - - conf.set("bonecp.dummyConf", "dummyValue"); - Assert.assertFalse(DataSourceProviderFactory.hasProviderSpecificConfigurations(conf)); - - conf.set("hikaricp.dummyConf", "dummyValue"); - Assert.assertTrue(DataSourceProviderFactory.hasProviderSpecificConfigurations(conf)); - - } - - @Test - public void testHasProviderSpecificConfigurationDbcp() throws SQLException { - - MetastoreConf.setVar(conf, ConfVars.CONNECTION_POOLING_TYPE, DbCPDataSourceProvider.DBCP); - - Assert.assertFalse(DataSourceProviderFactory.hasProviderSpecificConfigurations(conf)); - - conf.set("hikaricp.dummyConf", "dummyValue"); - Assert.assertFalse(DataSourceProviderFactory.hasProviderSpecificConfigurations(conf)); - - conf.set("bonecp.dummyConf", "dummyValue"); - Assert.assertFalse(DataSourceProviderFactory.hasProviderSpecificConfigurations(conf)); - - conf.set("dbcp.dummyConf", "dummyValue"); - Assert.assertTrue(DataSourceProviderFactory.hasProviderSpecificConfigurations(conf)); - - } }