本文整理汇总了Java中org.springframework.boot.actuate.endpoint.DataSourcePublicMetrics类的典型用法代码示例。如果您正苦于以下问题:Java DataSourcePublicMetrics类的具体用法?Java DataSourcePublicMetrics怎么用?Java DataSourcePublicMetrics使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DataSourcePublicMetrics类属于org.springframework.boot.actuate.endpoint包,在下文中一共展示了DataSourcePublicMetrics类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: multipleDataSources
import org.springframework.boot.actuate.endpoint.DataSourcePublicMetrics; //导入依赖的package包/类
@Test
public void multipleDataSources() {
load(MultipleDataSourcesConfig.class);
PublicMetrics bean = this.context.getBean(DataSourcePublicMetrics.class);
Collection<Metric<?>> metrics = bean.metrics();
assertMetrics(metrics, "datasource.tomcat.active", "datasource.tomcat.usage",
"datasource.commonsDbcp.active", "datasource.commonsDbcp.usage");
// Hikari won't work unless a first connection has been retrieved
JdbcTemplate jdbcTemplate = new JdbcTemplate(
this.context.getBean("hikariDS", DataSource.class));
jdbcTemplate.execute(new ConnectionCallback<Void>() {
@Override
public Void doInConnection(Connection connection)
throws SQLException, DataAccessException {
return null;
}
});
Collection<Metric<?>> anotherMetrics = bean.metrics();
assertMetrics(anotherMetrics, "datasource.tomcat.active",
"datasource.tomcat.usage", "datasource.hikariDS.active",
"datasource.hikariDS.usage", "datasource.commonsDbcp.active",
"datasource.commonsDbcp.usage");
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:26,代码来源:PublicMetricsAutoConfigurationTests.java
示例2: autoDataSource
import org.springframework.boot.actuate.endpoint.DataSourcePublicMetrics; //导入依赖的package包/类
@Test
public void autoDataSource() {
load(DataSourceAutoConfiguration.class);
PublicMetrics bean = this.context.getBean(DataSourcePublicMetrics.class);
Collection<Metric<?>> metrics = bean.metrics();
assertMetrics(metrics, "datasource.primary.active", "datasource.primary.usage");
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:8,代码来源:PublicMetricsAutoConfigurationTests.java
示例3: multipleDataSourcesWithPrimary
import org.springframework.boot.actuate.endpoint.DataSourcePublicMetrics; //导入依赖的package包/类
@Test
public void multipleDataSourcesWithPrimary() {
load(MultipleDataSourcesWithPrimaryConfig.class);
PublicMetrics bean = this.context.getBean(DataSourcePublicMetrics.class);
Collection<Metric<?>> metrics = bean.metrics();
assertMetrics(metrics, "datasource.primary.active", "datasource.primary.usage",
"datasource.commonsDbcp.active", "datasource.commonsDbcp.usage");
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:9,代码来源:PublicMetricsAutoConfigurationTests.java
示例4: multipleDataSourcesWithCustomPrimary
import org.springframework.boot.actuate.endpoint.DataSourcePublicMetrics; //导入依赖的package包/类
@Test
public void multipleDataSourcesWithCustomPrimary() {
load(MultipleDataSourcesWithCustomPrimaryConfig.class);
PublicMetrics bean = this.context.getBean(DataSourcePublicMetrics.class);
Collection<Metric<?>> metrics = bean.metrics();
assertMetrics(metrics, "datasource.primary.active", "datasource.primary.usage",
"datasource.dataSource.active", "datasource.dataSource.usage");
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:9,代码来源:PublicMetricsAutoConfigurationTests.java
示例5: customPrefix
import org.springframework.boot.actuate.endpoint.DataSourcePublicMetrics; //导入依赖的package包/类
@Test
public void customPrefix() {
load(MultipleDataSourcesWithPrimaryConfig.class,
CustomDataSourcePublicMetrics.class);
PublicMetrics bean = this.context.getBean(DataSourcePublicMetrics.class);
Collection<Metric<?>> metrics = bean.metrics();
assertMetrics(metrics, "ds.first.active", "ds.first.usage", "ds.second.active",
"ds.second.usage");
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:10,代码来源:PublicMetricsAutoConfigurationTests.java
示例6: myDataSourcePublicMetrics
import org.springframework.boot.actuate.endpoint.DataSourcePublicMetrics; //导入依赖的package包/类
@Bean
public DataSourcePublicMetrics myDataSourcePublicMetrics() {
return new DataSourcePublicMetrics() {
@Override
protected String createPrefix(String dataSourceName,
DataSource dataSource, boolean primary) {
return (primary ? "ds.first." : "ds.second");
}
};
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:11,代码来源:PublicMetricsAutoConfigurationTests.java
示例7: dataSourcePublicMetrics
import org.springframework.boot.actuate.endpoint.DataSourcePublicMetrics; //导入依赖的package包/类
@Bean
@ConditionalOnMissingBean
@ConditionalOnBean(DataSourcePoolMetadataProvider.class)
public DataSourcePublicMetrics dataSourcePublicMetrics() {
return new DataSourcePublicMetrics();
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:7,代码来源:PublicMetricsAutoConfiguration.java
示例8: noDataSource
import org.springframework.boot.actuate.endpoint.DataSourcePublicMetrics; //导入依赖的package包/类
@Test
public void noDataSource() {
load();
assertThat(this.context.getBeansOfType(DataSourcePublicMetrics.class)).isEmpty();
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:6,代码来源:PublicMetricsAutoConfigurationTests.java
示例9: noDataSource
import org.springframework.boot.actuate.endpoint.DataSourcePublicMetrics; //导入依赖的package包/类
@Test
public void noDataSource() {
load();
assertEquals(0,
this.context.getBeansOfType(DataSourcePublicMetrics.class).size());
}