Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
e56be6cf
Commit
e56be6cf
authored
Sep 01, 2014
by
Phillip Webb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DataSourceMetadata -> DataSourcePoolMetadata
Rename DataSourceMetadata to DataSourcePoolMetadata
parent
e17769fc
Changes
17
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
222 additions
and
145 deletions
+222
-145
DataSourceMetricsAutoConfiguration.java
...ate/autoconfigure/DataSourceMetricsAutoConfiguration.java
+4
-4
HealthIndicatorAutoConfiguration.java
...tuate/autoconfigure/HealthIndicatorAutoConfiguration.java
+20
-17
DataSourcePublicMetrics.java
...mework/boot/actuate/endpoint/DataSourcePublicMetrics.java
+13
-13
HealthIndicatorAutoConfigurationTests.java
.../autoconfigure/HealthIndicatorAutoConfigurationTests.java
+2
-2
AbstractDataSourcePoolMetadata.java
...ot/autoconfigure/jdbc/AbstractDataSourcePoolMetadata.java
+7
-7
CommonsDbcpDataSourcePoolMetadata.java
...autoconfigure/jdbc/CommonsDbcpDataSourcePoolMetadata.java
+7
-7
CompositeDataSourcePoolMetadataProvider.java
...nfigure/jdbc/CompositeDataSourcePoolMetadataProvider.java
+70
-0
DataSourcePoolMetadata.java
...ework/boot/autoconfigure/jdbc/DataSourcePoolMetadata.java
+7
-7
DataSourcePoolMetadataProvider.java
...ot/autoconfigure/jdbc/DataSourcePoolMetadataProvider.java
+4
-4
DataSourcePoolMetadataProvidersConfiguration.java
...re/jdbc/DataSourcePoolMetadataProvidersConfiguration.java
+21
-17
HikariDataSourcePoolMetadata.java
...boot/autoconfigure/jdbc/HikariDataSourcePoolMetadata.java
+7
-7
TomcatDataSourcePoolMetadata.java
...boot/autoconfigure/jdbc/TomcatDataSourcePoolMetadata.java
+6
-6
AbstractDataSourcePoolMetadataTests.java
...toconfigure/jdbc/AbstractDataSourcePoolMetadataTests.java
+10
-10
CommonsDbcpDataSourcePoolMetadataTests.java
...onfigure/jdbc/CommonsDbcpDataSourcePoolMetadataTests.java
+16
-16
CompositeDataSourceMetadataProviderTests.java
...figure/jdbc/CompositeDataSourceMetadataProviderTests.java
+14
-14
HikariDataSourcePoolMetadataTests.java
...autoconfigure/jdbc/HikariDataSourcePoolMetadataTests.java
+7
-7
TomcatDataSourcePoolMetadataTests.java
...autoconfigure/jdbc/TomcatDataSourcePoolMetadataTests.java
+7
-7
No files found.
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/DataSourceMetricsAutoConfiguration.java
View file @
e56be6cf
...
...
@@ -24,8 +24,8 @@ import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnBean
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
;
import
org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration
;
import
org.springframework.boot.autoconfigure.jdbc.DataSourceMetadataProvider
;
import
org.springframework.boot.autoconfigure.jdbc.DataSourceMetadataProvidersConfiguration
;
import
org.springframework.boot.autoconfigure.jdbc.DataSource
Pool
MetadataProvider
;
import
org.springframework.boot.autoconfigure.jdbc.DataSource
Pool
MetadataProvidersConfiguration
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Import
;
...
...
@@ -38,11 +38,11 @@ import org.springframework.context.annotation.Import;
*/
@ConditionalOnBean
(
DataSource
.
class
)
@AutoConfigureAfter
(
DataSourceAutoConfiguration
.
class
)
@Import
(
DataSourceMetadataProvidersConfiguration
.
class
)
@Import
(
DataSource
Pool
MetadataProvidersConfiguration
.
class
)
public
class
DataSourceMetricsAutoConfiguration
{
@Bean
@ConditionalOnBean
(
DataSourceMetadataProvider
.
class
)
@ConditionalOnBean
(
DataSource
Pool
MetadataProvider
.
class
)
@ConditionalOnMissingBean
public
DataSourcePublicMetrics
dataSourcePublicMetrics
()
{
return
new
DataSourcePublicMetrics
();
...
...
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/HealthIndicatorAutoConfiguration.java
View file @
e56be6cf
...
...
@@ -27,6 +27,7 @@ import org.apache.solr.client.solrj.SolrServer;
import
org.springframework.amqp.rabbit.core.RabbitTemplate
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.boot.actuate.health.ApplicationHealthIndicator
;
import
org.springframework.boot.actuate.health.CompositeHealthIndicator
;
import
org.springframework.boot.actuate.health.DataSourceHealthIndicator
;
import
org.springframework.boot.actuate.health.HealthAggregator
;
...
...
@@ -36,7 +37,6 @@ import org.springframework.boot.actuate.health.OrderedHealthAggregator;
import
org.springframework.boot.actuate.health.RabbitHealthIndicator
;
import
org.springframework.boot.actuate.health.RedisHealthIndicator
;
import
org.springframework.boot.actuate.health.SolrHealthIndicator
;
import
org.springframework.boot.actuate.health.ApplicationHealthIndicator
;
import
org.springframework.boot.autoconfigure.AutoConfigureAfter
;
import
org.springframework.boot.autoconfigure.AutoConfigureBefore
;
import
org.springframework.boot.autoconfigure.EnableAutoConfiguration
;
...
...
@@ -44,10 +44,10 @@ import org.springframework.boot.autoconfigure.amqp.RabbitAutoConfiguration;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnBean
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnExpression
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
;
import
org.springframework.boot.autoconfigure.jdbc.CompositeDataSourceMetadataProvider
;
import
org.springframework.boot.autoconfigure.jdbc.CompositeDataSource
Pool
MetadataProvider
;
import
org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration
;
import
org.springframework.boot.autoconfigure.jdbc.DataSource
Metadata
;
import
org.springframework.boot.autoconfigure.jdbc.DataSource
MetadataProvider
;
import
org.springframework.boot.autoconfigure.jdbc.DataSource
PoolMetadataProvider
;
import
org.springframework.boot.autoconfigure.jdbc.DataSource
PoolMetadata
;
import
org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration
;
import
org.springframework.boot.autoconfigure.mongo.MongoDataAutoConfiguration
;
import
org.springframework.boot.autoconfigure.redis.RedisAutoConfiguration
;
...
...
@@ -103,33 +103,36 @@ public class HealthIndicatorAutoConfiguration {
private
Map
<
String
,
DataSource
>
dataSources
;
@Autowired
(
required
=
false
)
private
Collection
<
DataSourceMetadataProvider
>
metadataProviders
=
Collections
.
emptyList
();
private
Collection
<
DataSourcePoolMetadataProvider
>
metadataProviders
=
Collections
.
emptyList
();
@Bean
@ConditionalOnMissingBean
(
name
=
"dbHealthIndicator"
)
public
HealthIndicator
dbHealthIndicator
()
{
DataSource
MetadataProvider
metadataProvider
=
new
CompositeDataSourceMetadataProvider
(
this
.
metadataProviders
);
DataSource
PoolMetadataProvider
metadataProvider
=
new
CompositeDataSourcePoolMetadataProvider
(
this
.
metadataProviders
);
if
(
this
.
dataSources
.
size
()
==
1
)
{
return
createDataSourceHealthIndicator
(
metadataProvider
,
this
.
dataSources
.
values
().
iterator
().
next
());
return
createDataSourceHealthIndicator
(
metadataProvider
,
this
.
dataSources
.
values
().
iterator
().
next
());
}
CompositeHealthIndicator
composite
=
new
CompositeHealthIndicator
(
this
.
healthAggregator
);
for
(
Map
.
Entry
<
String
,
DataSource
>
entry
:
this
.
dataSources
.
entrySet
())
{
composite
.
addHealthIndicator
(
entry
.
getKey
(),
createDataSourceHealthIndicator
(
metadataProvider
,
entry
.
getValue
()));
composite
.
addHealthIndicator
(
entry
.
getKey
(),
createDataSourceHealthIndicator
(
metadataProvider
,
entry
.
getValue
()));
}
return
composite
;
}
private
DataSourceHealthIndicator
createDataSourceHealthIndicator
(
DataSourceMetadataProvider
provider
,
DataSource
dataSource
)
{
private
DataSourceHealthIndicator
createDataSourceHealthIndicator
(
DataSourcePoolMetadataProvider
provider
,
DataSource
dataSource
)
{
String
validationQuery
=
null
;
DataSourceMetadata
dataSourceMetadata
=
provider
.
getDataSourceMetadata
(
dataSource
);
if
(
dataSourceMetadata
!=
null
)
{
validationQuery
=
dataSourceMetadata
.
getValidationQuery
();
DataSourcePoolMetadata
poolMetadata
=
provider
.
getDataSourcePoolMetadata
(
dataSource
);
if
(
poolMetadata
!=
null
)
{
validationQuery
=
poolMetadata
.
getValidationQuery
();
}
return
new
DataSourceHealthIndicator
(
dataSource
,
validationQuery
);
}
...
...
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/DataSourcePublicMetrics.java
View file @
e56be6cf
...
...
@@ -28,9 +28,9 @@ import javax.sql.DataSource;
import
org.springframework.beans.factory.NoSuchBeanDefinitionException
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.actuate.metrics.Metric
;
import
org.springframework.boot.autoconfigure.jdbc.CompositeDataSourceMetadataProvider
;
import
org.springframework.boot.autoconfigure.jdbc.DataSourceMetadata
;
import
org.springframework.boot.autoconfigure.jdbc.DataSourceMetadataProvider
;
import
org.springframework.boot.autoconfigure.jdbc.CompositeDataSource
Pool
MetadataProvider
;
import
org.springframework.boot.autoconfigure.jdbc.DataSource
Pool
Metadata
;
import
org.springframework.boot.autoconfigure.jdbc.DataSource
Pool
MetadataProvider
;
import
org.springframework.context.ApplicationContext
;
import
org.springframework.context.annotation.Primary
;
...
...
@@ -48,23 +48,23 @@ public class DataSourcePublicMetrics implements PublicMetrics {
private
ApplicationContext
applicationContext
;
@Autowired
private
Collection
<
DataSourceMetadataProvider
>
providers
;
private
Collection
<
DataSource
Pool
MetadataProvider
>
providers
;
private
final
Map
<
String
,
DataSource
Metadata
>
metadataByPrefix
=
new
HashMap
<
String
,
DataSource
Metadata
>();
private
final
Map
<
String
,
DataSource
PoolMetadata
>
metadataByPrefix
=
new
HashMap
<
String
,
DataSourcePool
Metadata
>();
@PostConstruct
public
void
initialize
()
{
DataSource
primaryDataSource
=
getPrimaryDataSource
();
DataSource
MetadataProvider
provider
=
new
CompositeDataSource
MetadataProvider
(
DataSource
PoolMetadataProvider
provider
=
new
CompositeDataSourcePool
MetadataProvider
(
this
.
providers
);
for
(
Map
.
Entry
<
String
,
DataSource
>
entry
:
this
.
applicationContext
.
getBeansOfType
(
DataSource
.
class
).
entrySet
())
{
String
beanName
=
entry
.
getKey
();
DataSource
bean
=
entry
.
getValue
();
String
prefix
=
createPrefix
(
beanName
,
bean
,
bean
.
equals
(
primaryDataSource
));
DataSource
Metadata
dataSourceMetadata
=
provider
.
getDataSource
Metadata
(
bean
);
if
(
dataSource
Metadata
!=
null
)
{
this
.
metadataByPrefix
.
put
(
prefix
,
dataSource
Metadata
);
DataSource
PoolMetadata
poolMetadata
=
provider
.
getDataSourcePool
Metadata
(
bean
);
if
(
pool
Metadata
!=
null
)
{
this
.
metadataByPrefix
.
put
(
prefix
,
pool
Metadata
);
}
}
}
...
...
@@ -72,13 +72,13 @@ public class DataSourcePublicMetrics implements PublicMetrics {
@Override
public
Collection
<
Metric
<?>>
metrics
()
{
Set
<
Metric
<?>>
metrics
=
new
LinkedHashSet
<
Metric
<?>>();
for
(
Map
.
Entry
<
String
,
DataSourceMetadata
>
entry
:
this
.
metadataByPrefix
for
(
Map
.
Entry
<
String
,
DataSource
Pool
Metadata
>
entry
:
this
.
metadataByPrefix
.
entrySet
())
{
String
prefix
=
entry
.
getKey
();
prefix
=
(
prefix
.
endsWith
(
"."
)
?
prefix
:
prefix
+
"."
);
DataSourceMetadata
dataSourceMetadata
=
entry
.
getValue
();
addMetric
(
metrics
,
prefix
+
"active"
,
dataSourceMetadata
.
get
PoolSiz
e
());
addMetric
(
metrics
,
prefix
+
"usage"
,
dataSourceMetadata
.
get
Pool
Usage
());
DataSource
Pool
Metadata
dataSourceMetadata
=
entry
.
getValue
();
addMetric
(
metrics
,
prefix
+
"active"
,
dataSourceMetadata
.
get
Activ
e
());
addMetric
(
metrics
,
prefix
+
"usage"
,
dataSourceMetadata
.
getUsage
());
}
return
metrics
;
}
...
...
spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/HealthIndicatorAutoConfigurationTests.java
View file @
e56be6cf
...
...
@@ -33,7 +33,7 @@ import org.springframework.boot.actuate.health.ApplicationHealthIndicator;
import
org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration
;
import
org.springframework.boot.autoconfigure.amqp.RabbitAutoConfiguration
;
import
org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder
;
import
org.springframework.boot.autoconfigure.jdbc.DataSourceMetadataProvidersConfiguration
;
import
org.springframework.boot.autoconfigure.jdbc.DataSource
Pool
MetadataProvidersConfiguration
;
import
org.springframework.boot.autoconfigure.jdbc.DataSourceProperties
;
import
org.springframework.boot.autoconfigure.jdbc.EmbeddedDataSourceConfiguration
;
import
org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration
;
...
...
@@ -167,7 +167,7 @@ public class HealthIndicatorAutoConfigurationTests {
public
void
dataSourceHealthIndicatorWithCustomValidationQuery
()
{
this
.
context
=
new
AnnotationConfigApplicationContext
();
this
.
context
.
register
(
PropertyPlaceholderAutoConfiguration
.
class
,
DataSourceProperties
.
class
,
DataSourceConfig
.
class
,
DataSourceMetadataProvidersConfiguration
.
class
,
DataSourceConfig
.
class
,
DataSource
Pool
MetadataProvidersConfiguration
.
class
,
HealthIndicatorAutoConfiguration
.
class
);
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
"spring.datasource.validation-query:SELECT from FOOBAR"
);
this
.
context
.
refresh
();
...
...
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/AbstractDataSourceMetadata.java
→
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/AbstractDataSource
Pool
Metadata.java
View file @
e56be6cf
...
...
@@ -19,27 +19,27 @@ package org.springframework.boot.autoconfigure.jdbc;
import
javax.sql.DataSource
;
/**
* A base {@link DataSourceMetadata} implementation.
* A base {@link DataSource
Pool
Metadata} implementation.
*
* @author Stephane Nicoll
* @since 1.2.0
*/
public
abstract
class
AbstractDataSourceMetadata
<
T
extends
DataSource
>
implements
DataSourceMetadata
{
public
abstract
class
AbstractDataSource
Pool
Metadata
<
T
extends
DataSource
>
implements
DataSource
Pool
Metadata
{
private
final
T
dataSource
;
/**
* Create an instance with the data source to use.
*/
protected
AbstractDataSourceMetadata
(
T
dataSource
)
{
protected
AbstractDataSource
Pool
Metadata
(
T
dataSource
)
{
this
.
dataSource
=
dataSource
;
}
@Override
public
Float
get
Pool
Usage
()
{
Integer
maxSize
=
getMax
PoolSize
();
Integer
currentSize
=
get
PoolSiz
e
();
public
Float
getUsage
()
{
Integer
maxSize
=
getMax
();
Integer
currentSize
=
get
Activ
e
();
if
(
maxSize
==
null
||
currentSize
==
null
)
{
return
null
;
}
...
...
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/CommonsDbcpDataSourceMetadata.java
→
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/CommonsDbcpDataSource
Pool
Metadata.java
View file @
e56be6cf
...
...
@@ -21,30 +21,30 @@ import javax.sql.DataSource;
import
org.apache.commons.dbcp.BasicDataSource
;
/**
* {@link DataSourceMetadata} for a Apache Commons DBCP {@link DataSource}.
* {@link DataSource
Pool
Metadata} for a Apache Commons DBCP {@link DataSource}.
*
* @author Stephane Nicoll
* @since 1.2.0
*/
public
class
CommonsDbcpDataSourceMetadata
extends
AbstractDataSourceMetadata
<
BasicDataSource
>
{
public
class
CommonsDbcpDataSource
Pool
Metadata
extends
AbstractDataSource
Pool
Metadata
<
BasicDataSource
>
{
public
CommonsDbcpDataSourceMetadata
(
BasicDataSource
dataSource
)
{
public
CommonsDbcpDataSource
Pool
Metadata
(
BasicDataSource
dataSource
)
{
super
(
dataSource
);
}
@Override
public
Integer
get
PoolSiz
e
()
{
public
Integer
get
Activ
e
()
{
return
getDataSource
().
getNumActive
();
}
@Override
public
Integer
getMax
PoolSize
()
{
public
Integer
getMax
()
{
return
getDataSource
().
getMaxActive
();
}
@Override
public
Integer
getMin
PoolSize
()
{
public
Integer
getMin
()
{
return
getDataSource
().
getMinIdle
();
}
...
...
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/CompositeDataSourceMetadataProvider.java
→
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/CompositeDataSource
Pool
MetadataProvider.java
View file @
e56be6cf
...
...
@@ -23,36 +23,36 @@ import java.util.List;
import
javax.sql.DataSource
;
/**
* A {@link DataSourceMetadataProvider} implementation that returns the first
* {@link DataSourceMetadata} that is found by one of its delegate.
* A {@link DataSource
Pool
MetadataProvider} implementation that returns the first
* {@link DataSource
Pool
Metadata} that is found by one of its delegate.
*
* @author Stephane Nicoll
* @since 1.2.0
*/
public
class
CompositeDataSource
MetadataProvider
implements
DataSource
MetadataProvider
{
public
class
CompositeDataSource
PoolMetadataProvider
implements
DataSourcePool
MetadataProvider
{
private
final
List
<
DataSourceMetadataProvider
>
providers
;
private
final
List
<
DataSource
Pool
MetadataProvider
>
providers
;
/**
* Create a {@link CompositeDataSourceMetadataProvider} instance with no delegate.
* Create a {@link CompositeDataSource
Pool
MetadataProvider} instance with no delegate.
*/
public
CompositeDataSourceMetadataProvider
()
{
this
(
new
ArrayList
<
DataSourceMetadataProvider
>());
public
CompositeDataSource
Pool
MetadataProvider
()
{
this
(
new
ArrayList
<
DataSource
Pool
MetadataProvider
>());
}
/**
* Create a {@link CompositeDataSourceMetadataProvider} instance with an initial
* Create a {@link CompositeDataSource
Pool
MetadataProvider} instance with an initial
* collection of delegates to use.
*/
public
CompositeDataSourceMetadataProvider
(
Collection
<?
extends
DataSourceMetadataProvider
>
providers
)
{
this
.
providers
=
new
ArrayList
<
DataSourceMetadataProvider
>(
providers
);
public
CompositeDataSource
Pool
MetadataProvider
(
Collection
<?
extends
DataSource
Pool
MetadataProvider
>
providers
)
{
this
.
providers
=
new
ArrayList
<
DataSource
Pool
MetadataProvider
>(
providers
);
}
@Override
public
DataSource
Metadata
getDataSource
Metadata
(
DataSource
dataSource
)
{
for
(
DataSourceMetadataProvider
provider
:
this
.
providers
)
{
DataSource
Metadata
metadata
=
provider
.
getDataSource
Metadata
(
dataSource
);
public
DataSource
PoolMetadata
getDataSourcePool
Metadata
(
DataSource
dataSource
)
{
for
(
DataSource
Pool
MetadataProvider
provider
:
this
.
providers
)
{
DataSource
PoolMetadata
metadata
=
provider
.
getDataSourcePool
Metadata
(
dataSource
);
if
(
metadata
!=
null
)
{
return
metadata
;
}
...
...
@@ -61,9 +61,9 @@ public class CompositeDataSourceMetadataProvider implements DataSourceMetadataPr
}
/**
* Add a {@link DataSourceMetadataProvider} delegate to the list.
* Add a {@link DataSource
Pool
MetadataProvider} delegate to the list.
*/
public
void
addDataSourceMetadataProvider
(
DataSourceMetadataProvider
provider
)
{
public
void
addDataSourceMetadataProvider
(
DataSource
Pool
MetadataProvider
provider
)
{
this
.
providers
.
add
(
provider
);
}
...
...
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceMetadata.java
→
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSource
Pool
Metadata.java
View file @
e56be6cf
...
...
@@ -19,13 +19,13 @@ package org.springframework.boot.autoconfigure.jdbc;
import
javax.sql.DataSource
;
/**
* Provides access meta-data that is commonly available from most
{@link DataSource}
* implementations.
* Provides access meta-data that is commonly available from most
polled
*
{@link DataSource}
implementations.
*
* @author Stephane Nicoll
* @since 1.2.0
*/
public
interface
DataSourceMetadata
{
public
interface
DataSource
Pool
Metadata
{
/**
* Return the usage of the pool as value between 0 and 1 (or -1 if the pool is not
...
...
@@ -38,26 +38,26 @@ public interface DataSourceMetadata {
* This may also return {@code null} if the data source does not provide the necessary
* information to compute the poll usage.
*/
Float
get
Pool
Usage
();
Float
getUsage
();
/**
* Return the current number of active connections that have been allocated from the
* data source or {@code null} if that information is not available.
*/
Integer
get
PoolSiz
e
();
Integer
get
Activ
e
();
/**
* Return the maximum number of active connections that can be allocated at the same
* time or {@code -1} if there is no limit. Can also return {@code null} if that
* information is not available.
*/
Integer
getMax
PoolSize
();
Integer
getMax
();
/**
* Return the minimum number of idle connections in the pool or {@code null} if that
* information is not available.
*/
Integer
getMin
PoolSize
();
Integer
getMin
();
/**
* Return the query to use to validate that a connection is valid or {@code null} if
...
...
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceMetadataProvider.java
→
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSource
Pool
MetadataProvider.java
View file @
e56be6cf
...
...
@@ -19,17 +19,17 @@ package org.springframework.boot.autoconfigure.jdbc;
import
javax.sql.DataSource
;
/**
* Provide a {@link DataSourceMetadata} based on a {@link DataSource}.
* Provide a {@link DataSource
Pool
Metadata} based on a {@link DataSource}.
*
* @author Stephane Nicoll
* @since 1.2.0
*/
public
interface
DataSourceMetadataProvider
{
public
interface
DataSource
Pool
MetadataProvider
{
/**
* Return the {@link DataSourceMetadata} instance able to manage the specified
* Return the {@link DataSource
Pool
Metadata} instance able to manage the specified
* {@link DataSource} or {@code null} if the given data source could not be handled.
*/
DataSource
Metadata
getDataSource
Metadata
(
DataSource
dataSource
);
DataSource
PoolMetadata
getDataSourcePool
Metadata
(
DataSource
dataSource
);
}
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceMetadataProvidersConfiguration.java
→
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSource
Pool
MetadataProvidersConfiguration.java
View file @
e56be6cf
...
...
@@ -26,26 +26,27 @@ import org.springframework.context.annotation.Configuration;
import
com.zaxxer.hikari.HikariDataSource
;
/**
* Register the {@link DataSourceMetadataProvider} instances for the supported data
* Register the {@link DataSource
Pool
MetadataProvider} instances for the supported data
* sources.
*
* @author Stephane Nicoll
* @since 1.2.0
*/
@Configuration
public
class
DataSourceMetadataProvidersConfiguration
{
public
class
DataSource
Pool
MetadataProvidersConfiguration
{
@Configuration
@ConditionalOnClass
(
org
.
apache
.
tomcat
.
jdbc
.
pool
.
DataSource
.
class
)
static
class
TomcatDataSourceProviderConfiguration
{
static
class
TomcatDataSourceP
oolMetadataP
roviderConfiguration
{
@Bean
public
DataSource
MetadataProvider
tomcatDataSource
Provider
()
{
return
new
DataSourceMetadataProvider
()
{
public
DataSource
PoolMetadataProvider
tomcatPoolDataSourceMetadata
Provider
()
{
return
new
DataSource
Pool
MetadataProvider
()
{
@Override
public
DataSourceMetadata
getDataSourceMetadata
(
DataSource
dataSource
)
{
public
DataSourcePoolMetadata
getDataSourcePoolMetadata
(
DataSource
dataSource
)
{
if
(
dataSource
instanceof
org
.
apache
.
tomcat
.
jdbc
.
pool
.
DataSource
)
{
return
new
TomcatDataSourceMetadata
(
return
new
TomcatDataSource
Pool
Metadata
(
(
org
.
apache
.
tomcat
.
jdbc
.
pool
.
DataSource
)
dataSource
);
}
return
null
;
...
...
@@ -57,15 +58,17 @@ public class DataSourceMetadataProvidersConfiguration {
@Configuration
@ConditionalOnClass
(
HikariDataSource
.
class
)
static
class
Hikari
DataSource
ProviderConfiguration
{
static
class
Hikari
PoolDataSourceMetadata
ProviderConfiguration
{
@Bean
public
DataSource
MetadataProvider
hikariDataSource
Provider
()
{
return
new
DataSourceMetadataProvider
()
{
public
DataSource
PoolMetadataProvider
hikariPoolDataSourceMetadata
Provider
()
{
return
new
DataSource
Pool
MetadataProvider
()
{
@Override
public
DataSourceMetadata
getDataSourceMetadata
(
DataSource
dataSource
)
{
public
DataSourcePoolMetadata
getDataSourcePoolMetadata
(
DataSource
dataSource
)
{
if
(
dataSource
instanceof
HikariDataSource
)
{
return
new
HikariDataSourceMetadata
((
HikariDataSource
)
dataSource
);
return
new
HikariDataSourcePoolMetadata
(
(
HikariDataSource
)
dataSource
);
}
return
null
;
}
...
...
@@ -76,15 +79,16 @@ public class DataSourceMetadataProvidersConfiguration {
@Configuration
@ConditionalOnClass
(
BasicDataSource
.
class
)
static
class
CommonsDbcp
DataSource
ProviderConfiguration
{
static
class
CommonsDbcp
PoolDataSourceMetadata
ProviderConfiguration
{
@Bean
public
DataSource
MetadataProvider
commonsDbcpDataSource
Provider
()
{
return
new
DataSourceMetadataProvider
()
{
public
DataSource
PoolMetadataProvider
commonsDbcpPoolDataSourceMetadata
Provider
()
{
return
new
DataSource
Pool
MetadataProvider
()
{
@Override
public
DataSourceMetadata
getDataSourceMetadata
(
DataSource
dataSource
)
{
public
DataSourcePoolMetadata
getDataSourcePoolMetadata
(
DataSource
dataSource
)
{
if
(
dataSource
instanceof
BasicDataSource
)
{
return
new
CommonsDbcpDataSourceMetadata
(
return
new
CommonsDbcpDataSource
Pool
Metadata
(
(
BasicDataSource
)
dataSource
);
}
return
null
;
...
...
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/HikariDataSourceMetadata.java
→
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/HikariDataSource
Pool
Metadata.java
View file @
e56be6cf
...
...
@@ -24,20 +24,20 @@ import com.zaxxer.hikari.HikariDataSource;
import
com.zaxxer.hikari.pool.HikariPool
;
/**
* {@link DataSourceMetadata} for a Hikari {@link DataSource}.
* {@link DataSource
Pool
Metadata} for a Hikari {@link DataSource}.
*
* @author Stephane Nicoll
* @since 1.2.0
*/
public
class
HikariDataSourceMetadata
extends
AbstractDataSourceMetadata
<
HikariDataSource
>
{
public
class
HikariDataSource
Pool
Metadata
extends
AbstractDataSource
Pool
Metadata
<
HikariDataSource
>
{
public
HikariDataSourceMetadata
(
HikariDataSource
dataSource
)
{
public
HikariDataSource
Pool
Metadata
(
HikariDataSource
dataSource
)
{
super
(
dataSource
);
}
@Override
public
Integer
get
PoolSiz
e
()
{
public
Integer
get
Activ
e
()
{
try
{
return
getHikariPool
().
getActiveConnections
();
}
...
...
@@ -52,12 +52,12 @@ public class HikariDataSourceMetadata extends
}
@Override
public
Integer
getMax
PoolSize
()
{
public
Integer
getMax
()
{
return
getDataSource
().
getMaximumPoolSize
();
}
@Override
public
Integer
getMin
PoolSize
()
{
public
Integer
getMin
()
{
return
getDataSource
().
getMinimumIdle
();
}
...
...
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/TomcatDataSourceMetadata.java
→
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/TomcatDataSource
Pool
Metadata.java
View file @
e56be6cf
...
...
@@ -20,29 +20,29 @@ import org.apache.tomcat.jdbc.pool.ConnectionPool;
import
org.apache.tomcat.jdbc.pool.DataSource
;
/**
* {@link DataSourceMetadata} for a Tomcat {@link DataSource}.
* {@link DataSource
Pool
Metadata} for a Tomcat {@link DataSource}.
*
* @author Stephane Nicoll
*/
public
class
TomcatDataSource
Metadata
extends
AbstractDataSource
Metadata
<
DataSource
>
{
public
class
TomcatDataSource
PoolMetadata
extends
AbstractDataSourcePool
Metadata
<
DataSource
>
{
public
TomcatDataSourceMetadata
(
DataSource
dataSource
)
{
public
TomcatDataSource
Pool
Metadata
(
DataSource
dataSource
)
{
super
(
dataSource
);
}
@Override
public
Integer
get
PoolSiz
e
()
{
public
Integer
get
Activ
e
()
{
ConnectionPool
pool
=
getDataSource
().
getPool
();
return
(
pool
==
null
?
0
:
pool
.
getActive
());
}
@Override
public
Integer
getMax
PoolSize
()
{
public
Integer
getMax
()
{
return
getDataSource
().
getMaxActive
();
}
@Override
public
Integer
getMin
PoolSize
()
{
public
Integer
getMin
()
{
return
getDataSource
().
getMinIdle
();
}
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jdbc/AbstractDataSourceMetadataTests.java
→
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jdbc/AbstractDataSource
Pool
MetadataTests.java
View file @
e56be6cf
...
...
@@ -27,11 +27,11 @@ import org.springframework.jdbc.core.JdbcTemplate;
import
static
org
.
junit
.
Assert
.
assertEquals
;
/**
* Abstract base class for {@link DataSourceMetadata} tests.
* Abstract base class for {@link DataSource
Pool
Metadata} tests.
*
* @author Stephane Nicoll
*/
public
abstract
class
AbstractDataSource
MetadataTests
<
D
extends
AbstractDataSource
Metadata
<?>>
{
public
abstract
class
AbstractDataSource
PoolMetadataTests
<
D
extends
AbstractDataSourcePool
Metadata
<?>>
{
/**
* Return a data source metadata instance with a min size of 0 and max size of 2.
...
...
@@ -40,12 +40,12 @@ public abstract class AbstractDataSourceMetadataTests<D extends AbstractDataSour
@Test
public
void
getMaxPoolSize
()
{
assertEquals
(
Integer
.
valueOf
(
2
),
getDataSourceMetadata
().
getMax
PoolSize
());
assertEquals
(
Integer
.
valueOf
(
2
),
getDataSourceMetadata
().
getMax
());
}
@Test
public
void
getMinPoolSize
()
{
assertEquals
(
Integer
.
valueOf
(
0
),
getDataSourceMetadata
().
getMin
PoolSize
());
assertEquals
(
Integer
.
valueOf
(
0
),
getDataSourceMetadata
().
getMin
());
}
@Test
...
...
@@ -60,8 +60,8 @@ public abstract class AbstractDataSourceMetadataTests<D extends AbstractDataSour
return
null
;
}
});
assertEquals
(
Integer
.
valueOf
(
0
),
getDataSourceMetadata
().
get
PoolSiz
e
());
assertEquals
(
Float
.
valueOf
(
0
),
getDataSourceMetadata
().
get
Pool
Usage
());
assertEquals
(
Integer
.
valueOf
(
0
),
getDataSourceMetadata
().
get
Activ
e
());
assertEquals
(
Float
.
valueOf
(
0
),
getDataSourceMetadata
().
getUsage
());
}
@Test
...
...
@@ -72,8 +72,8 @@ public abstract class AbstractDataSourceMetadataTests<D extends AbstractDataSour
@Override
public
Void
doInConnection
(
Connection
connection
)
throws
SQLException
,
DataAccessException
{
assertEquals
(
Integer
.
valueOf
(
1
),
getDataSourceMetadata
().
get
PoolSiz
e
());
assertEquals
(
Float
.
valueOf
(
0.5
F
),
getDataSourceMetadata
().
get
Pool
Usage
());
assertEquals
(
Integer
.
valueOf
(
1
),
getDataSourceMetadata
().
get
Activ
e
());
assertEquals
(
Float
.
valueOf
(
0.5
F
),
getDataSourceMetadata
().
getUsage
());
return
null
;
}
});
...
...
@@ -92,9 +92,9 @@ public abstract class AbstractDataSourceMetadataTests<D extends AbstractDataSour
public
Void
doInConnection
(
Connection
connection
)
throws
SQLException
,
DataAccessException
{
assertEquals
(
Integer
.
valueOf
(
2
),
getDataSourceMetadata
()
.
get
PoolSiz
e
());
.
get
Activ
e
());
assertEquals
(
Float
.
valueOf
(
1
F
),
getDataSourceMetadata
()
.
get
Pool
Usage
());
.
getUsage
());
return
null
;
}
});
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jdbc/CommonsDbcpDataSourceMetadataTests.java
→
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jdbc/CommonsDbcpDataSource
Pool
MetadataTests.java
View file @
e56be6cf
...
...
@@ -24,14 +24,14 @@ import static org.junit.Assert.assertEquals;
import
static
org
.
junit
.
Assert
.
assertNull
;
/**
* Tests for {@link CommonsDbcpDataSourceMetadata}.
* Tests for {@link CommonsDbcpDataSource
Pool
Metadata}.
*
* @author Stephane Nicoll
*/
public
class
CommonsDbcpDataSourceMetadataTests
extends
AbstractDataSource
MetadataTests
<
CommonsDbcpDataSource
Metadata
>
{
public
class
CommonsDbcpDataSource
Pool
MetadataTests
extends
AbstractDataSource
PoolMetadataTests
<
CommonsDbcpDataSourcePool
Metadata
>
{
private
CommonsDbcpDataSourceMetadata
dataSourceMetadata
;
private
CommonsDbcpDataSource
Pool
Metadata
dataSourceMetadata
;
@Before
public
void
setup
()
{
...
...
@@ -39,38 +39,38 @@ public class CommonsDbcpDataSourceMetadataTests extends
}
@Override
protected
CommonsDbcpDataSourceMetadata
getDataSourceMetadata
()
{
protected
CommonsDbcpDataSource
Pool
Metadata
getDataSourceMetadata
()
{
return
this
.
dataSourceMetadata
;
}
@Test
public
void
getPoolUsageWithNoCurrent
()
{
CommonsDbcpDataSource
Metadata
dsm
=
new
CommonsDbcpDataSource
Metadata
(
CommonsDbcpDataSource
PoolMetadata
dsm
=
new
CommonsDbcpDataSourcePool
Metadata
(
createDataSource
())
{
@Override
public
Integer
get
PoolSiz
e
()
{
public
Integer
get
Activ
e
()
{
return
null
;
}
};
assertNull
(
dsm
.
get
Pool
Usage
());
assertNull
(
dsm
.
getUsage
());
}
@Test
public
void
getPoolUsageWithNoMax
()
{
CommonsDbcpDataSource
Metadata
dsm
=
new
CommonsDbcpDataSource
Metadata
(
CommonsDbcpDataSource
PoolMetadata
dsm
=
new
CommonsDbcpDataSourcePool
Metadata
(
createDataSource
())
{
@Override
public
Integer
getMax
PoolSize
()
{
public
Integer
getMax
()
{
return
null
;
}
};
assertNull
(
dsm
.
get
Pool
Usage
());
assertNull
(
dsm
.
getUsage
());
}
@Test
public
void
getPoolUsageWithUnlimitedPool
()
{
DataSourceMetadata
unlimitedDataSource
=
createDataSourceMetadata
(
0
,
-
1
);
assertEquals
(
Float
.
valueOf
(-
1
F
),
unlimitedDataSource
.
get
Pool
Usage
());
DataSource
Pool
Metadata
unlimitedDataSource
=
createDataSourceMetadata
(
0
,
-
1
);
assertEquals
(
Float
.
valueOf
(-
1
F
),
unlimitedDataSource
.
getUsage
());
}
@Override
...
...
@@ -78,15 +78,15 @@ public class CommonsDbcpDataSourceMetadataTests extends
BasicDataSource
dataSource
=
createDataSource
();
dataSource
.
setValidationQuery
(
"SELECT FROM FOO"
);
assertEquals
(
"SELECT FROM FOO"
,
new
CommonsDbcpDataSourceMetadata
(
dataSource
).
getValidationQuery
());
new
CommonsDbcpDataSource
Pool
Metadata
(
dataSource
).
getValidationQuery
());
}
private
CommonsDbcpDataSourceMetadata
createDataSourceMetadata
(
int
minSize
,
private
CommonsDbcpDataSource
Pool
Metadata
createDataSourceMetadata
(
int
minSize
,
int
maxSize
)
{
BasicDataSource
dataSource
=
createDataSource
();
dataSource
.
setMinIdle
(
minSize
);
dataSource
.
setMaxActive
(
maxSize
);
return
new
CommonsDbcpDataSourceMetadata
(
dataSource
);
return
new
CommonsDbcpDataSource
Pool
Metadata
(
dataSource
);
}
private
BasicDataSource
createDataSource
()
{
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jdbc/CompositeDataSourceMetadataProviderTests.java
View file @
e56be6cf
...
...
@@ -30,26 +30,26 @@ import static org.junit.Assert.assertSame;
import
static
org
.
mockito
.
BDDMockito
.
given
;
/**
* Tests for {@link CompositeDataSourceMetadataProvider}.
* Tests for {@link CompositeDataSource
Pool
MetadataProvider}.
*
* @author Stephane Nicoll
*/
public
class
CompositeDataSourceMetadataProviderTests
{
@Mock
private
DataSourceMetadataProvider
firstProvider
;
private
DataSource
Pool
MetadataProvider
firstProvider
;
@Mock
private
DataSourceMetadata
first
;
private
DataSource
Pool
Metadata
first
;
@Mock
private
DataSource
firstDataSource
;
@Mock
private
DataSourceMetadataProvider
secondProvider
;
private
DataSource
Pool
MetadataProvider
secondProvider
;
@Mock
private
DataSourceMetadata
second
;
private
DataSource
Pool
Metadata
second
;
@Mock
private
DataSource
secondDataSource
;
...
...
@@ -60,27 +60,27 @@ public class CompositeDataSourceMetadataProviderTests {
@Before
public
void
setup
()
{
MockitoAnnotations
.
initMocks
(
this
);
given
(
this
.
firstProvider
.
getDataSourceMetadata
(
this
.
firstDataSource
)).
willReturn
(
given
(
this
.
firstProvider
.
getDataSource
Pool
Metadata
(
this
.
firstDataSource
)).
willReturn
(
this
.
first
);
given
(
this
.
firstProvider
.
getDataSourceMetadata
(
this
.
secondDataSource
))
given
(
this
.
firstProvider
.
getDataSource
Pool
Metadata
(
this
.
secondDataSource
))
.
willReturn
(
this
.
second
);
}
@Test
public
void
createWithProviders
()
{
CompositeDataSource
MetadataProvider
provider
=
new
CompositeDataSource
MetadataProvider
(
CompositeDataSource
PoolMetadataProvider
provider
=
new
CompositeDataSourcePool
MetadataProvider
(
Arrays
.
asList
(
this
.
firstProvider
,
this
.
secondProvider
));
assertSame
(
this
.
first
,
provider
.
getDataSourceMetadata
(
this
.
firstDataSource
));
assertSame
(
this
.
second
,
provider
.
getDataSourceMetadata
(
this
.
secondDataSource
));
assertNull
(
provider
.
getDataSourceMetadata
(
this
.
unknownDataSource
));
assertSame
(
this
.
first
,
provider
.
getDataSource
Pool
Metadata
(
this
.
firstDataSource
));
assertSame
(
this
.
second
,
provider
.
getDataSource
Pool
Metadata
(
this
.
secondDataSource
));
assertNull
(
provider
.
getDataSource
Pool
Metadata
(
this
.
unknownDataSource
));
}
@Test
public
void
addProvider
()
{
CompositeDataSource
MetadataProvider
provider
=
new
CompositeDataSource
MetadataProvider
();
assertNull
(
provider
.
getDataSourceMetadata
(
this
.
firstDataSource
));
CompositeDataSource
PoolMetadataProvider
provider
=
new
CompositeDataSourcePool
MetadataProvider
();
assertNull
(
provider
.
getDataSource
Pool
Metadata
(
this
.
firstDataSource
));
provider
.
addDataSourceMetadataProvider
(
this
.
firstProvider
);
assertSame
(
this
.
first
,
provider
.
getDataSourceMetadata
(
this
.
firstDataSource
));
assertSame
(
this
.
first
,
provider
.
getDataSource
Pool
Metadata
(
this
.
firstDataSource
));
}
}
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jdbc/HikariDataSourceMetadataTests.java
→
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jdbc/HikariDataSource
Pool
MetadataTests.java
View file @
e56be6cf
...
...
@@ -23,22 +23,22 @@ import com.zaxxer.hikari.HikariDataSource;
import
static
org
.
junit
.
Assert
.
assertEquals
;
/**
* Tests for {@link HikariDataSourceMetadata}.
* Tests for {@link HikariDataSource
Pool
Metadata}.
*
* @author Stephane Nicoll
*/
public
class
HikariDataSourceMetadataTests
extends
AbstractDataSource
MetadataTests
<
HikariDataSource
Metadata
>
{
public
class
HikariDataSource
Pool
MetadataTests
extends
AbstractDataSource
PoolMetadataTests
<
HikariDataSourcePool
Metadata
>
{
private
HikariDataSourceMetadata
dataSourceMetadata
;
private
HikariDataSource
Pool
Metadata
dataSourceMetadata
;
@Before
public
void
setup
()
{
this
.
dataSourceMetadata
=
new
HikariDataSourceMetadata
(
createDataSource
(
0
,
2
));
this
.
dataSourceMetadata
=
new
HikariDataSource
Pool
Metadata
(
createDataSource
(
0
,
2
));
}
@Override
protected
HikariDataSourceMetadata
getDataSourceMetadata
()
{
protected
HikariDataSource
Pool
Metadata
getDataSourceMetadata
()
{
return
this
.
dataSourceMetadata
;
}
...
...
@@ -47,7 +47,7 @@ public class HikariDataSourceMetadataTests extends
HikariDataSource
dataSource
=
createDataSource
(
0
,
4
);
dataSource
.
setConnectionTestQuery
(
"SELECT FROM FOO"
);
assertEquals
(
"SELECT FROM FOO"
,
new
HikariDataSourceMetadata
(
dataSource
).
getValidationQuery
());
new
HikariDataSource
Pool
Metadata
(
dataSource
).
getValidationQuery
());
}
private
HikariDataSource
createDataSource
(
int
minSize
,
int
maxSize
)
{
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jdbc/TomcatDataSourceMetadataTests.java
→
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jdbc/TomcatDataSource
Pool
MetadataTests.java
View file @
e56be6cf
...
...
@@ -22,22 +22,22 @@ import org.junit.Before;
import
static
org
.
junit
.
Assert
.
assertEquals
;
/**
* Tests for {@link TomcatDataSourceMetadata}.
* Tests for {@link TomcatDataSource
Pool
Metadata}.
*
* @author Stephane Nicoll
*/
public
class
TomcatDataSourceMetadataTests
extends
AbstractDataSource
MetadataTests
<
TomcatDataSource
Metadata
>
{
public
class
TomcatDataSource
Pool
MetadataTests
extends
AbstractDataSource
PoolMetadataTests
<
TomcatDataSourcePool
Metadata
>
{
private
TomcatDataSourceMetadata
dataSourceMetadata
;
private
TomcatDataSource
Pool
Metadata
dataSourceMetadata
;
@Before
public
void
setup
()
{
this
.
dataSourceMetadata
=
new
TomcatDataSourceMetadata
(
createDataSource
(
0
,
2
));
this
.
dataSourceMetadata
=
new
TomcatDataSource
Pool
Metadata
(
createDataSource
(
0
,
2
));
}
@Override
protected
TomcatDataSourceMetadata
getDataSourceMetadata
()
{
protected
TomcatDataSource
Pool
Metadata
getDataSourceMetadata
()
{
return
this
.
dataSourceMetadata
;
}
...
...
@@ -46,7 +46,7 @@ public class TomcatDataSourceMetadataTests extends
DataSource
dataSource
=
createDataSource
(
0
,
4
);
dataSource
.
setValidationQuery
(
"SELECT FROM FOO"
);
assertEquals
(
"SELECT FROM FOO"
,
new
TomcatDataSourceMetadata
(
dataSource
).
getValidationQuery
());
new
TomcatDataSource
Pool
Metadata
(
dataSource
).
getValidationQuery
());
}
private
DataSource
createDataSource
(
int
minSize
,
int
maxSize
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment