本文整理汇总了Java中com.vladmihalcea.flexypool.metric.MetricsFactory类的典型用法代码示例。如果您正苦于以下问题:Java MetricsFactory类的具体用法?Java MetricsFactory怎么用?Java MetricsFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MetricsFactory类属于com.vladmihalcea.flexypool.metric包,在下文中一共展示了MetricsFactory类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testLoadFailure
import com.vladmihalcea.flexypool.metric.MetricsFactory; //导入依赖的package包/类
@Test
public void testLoadFailure() {
ClassLoader currentClassLoader = ClassLoaderUtils.getClassLoader();
try {
Thread.currentThread().setContextClassLoader(new ClassLoader() {
@Override
protected Class loadClass(String class_name, boolean resolve) throws ClassNotFoundException {
if(class_name.equals(METRICS_CLASS_NAME)) {
return null;
}
return super.loadClass(class_name, resolve);
}
});
MetricsFactory metricsFactory = new DropwizardMetricsFactoryService().load();
assertNull(metricsFactory);
} finally {
Thread.currentThread().setContextClassLoader(currentClassLoader);
}
}
示例2: testLoadFailure
import com.vladmihalcea.flexypool.metric.MetricsFactory; //导入依赖的package包/类
@Test
public void testLoadFailure() {
ClassLoader currentClassLoader = ClassLoaderUtils.getClassLoader();
try {
Thread.currentThread().setContextClassLoader(new ClassLoader() {
@Override
protected Class loadClass(String class_name, boolean resolve) throws ClassNotFoundException {
if(class_name.equals(METRICS_CLASS_NAME)) {
return null;
}
return super.loadClass(class_name, resolve);
}
});
MetricsFactory metricsFactory = new CodahaleMetricsFactoryService().load();
assertNull(metricsFactory);
} finally {
Thread.currentThread().setContextClassLoader(currentClassLoader);
}
}
示例3: testBuilder
import com.vladmihalcea.flexypool.metric.MetricsFactory; //导入依赖的package包/类
@Test
public void testBuilder() {
DataSource dataSource = Mockito.mock(DataSource.class);
PoolAdapterFactory<DataSource> poolAdapterFactory = Mockito.mock(PoolAdapterFactory.class);
ConnectionProxyFactory connectionProxyFactory = Mockito.mock(ConnectionProxyFactory.class);
MetricsFactory metricsFactory = Mockito.mock(MetricsFactory.class);
Metrics metrics = Mockito.mock(Metrics.class);
PoolAdapter poolAdapter = Mockito.mock(PoolAdapter.class);
when(metricsFactory.newInstance(any(ConfigurationProperties.class))).thenReturn(metrics);
when(poolAdapterFactory.newInstance(any(ConfigurationProperties.class))).thenReturn(poolAdapter);
Configuration<DataSource> configuration = new Configuration.Builder<DataSource>(
"unique", dataSource, poolAdapterFactory)
.setConnectionProxyFactory(connectionProxyFactory)
.setJmxAutoStart(true)
.setJmxEnabled(true)
.setMetricLogReporterMillis(120)
.setMetricsFactory(metricsFactory)
.build();
assertSame("unique", configuration.getUniqueName());
assertSame(connectionProxyFactory, configuration.getConnectionProxyFactory());
assertTrue(configuration.isJmxAutoStart());
assertTrue(configuration.isJmxEnabled());
assertEquals(120, configuration.getMetricLogReporterMillis());
assertSame(metrics, configuration.getMetrics());
assertSame(poolAdapter, configuration.getPoolAdapter());
assertSame(dataSource, configuration.getTargetDataSource());
}
示例4: testBuilder
import com.vladmihalcea.flexypool.metric.MetricsFactory; //导入依赖的package包/类
@Test
public void testBuilder() {
final MetricRegistry metricRegistry = Mockito.mock(MetricRegistry.class);
DataSource dataSource = Mockito.mock(DataSource.class);
PoolAdapterFactory<DataSource> poolAdapterFactory = Mockito.mock(PoolAdapterFactory.class);
ConnectionProxyFactory connectionProxyFactory = Mockito.mock(ConnectionProxyFactory.class);
Metrics metrics = Mockito.mock(Metrics.class);
PoolAdapter poolAdapter = Mockito.mock(PoolAdapter.class);
when(poolAdapterFactory.newInstance(any(ConfigurationProperties.class))).thenReturn(poolAdapter);
Configuration<DataSource> configuration = new Configuration.Builder<DataSource>(
"unique", dataSource, poolAdapterFactory)
.setConnectionProxyFactory(connectionProxyFactory)
.setJmxAutoStart(true)
.setJmxEnabled(true)
.setMetricLogReporterMillis(120)
.setMetricsFactory(new MetricsFactory() {
@Override
public Metrics newInstance(ConfigurationProperties configurationProperties) {
return new DropwizardMetrics(configurationProperties, metricRegistry, new ReservoirFactory() {
@Override
public Reservoir newInstance(Class<? extends Metric> metricClass, String metricName) {
return new ExponentiallyDecayingReservoir();
}
});
}
})
.build();
assertSame("unique", configuration.getUniqueName());
assertSame(connectionProxyFactory, configuration.getConnectionProxyFactory());
assertTrue(configuration.isJmxAutoStart());
assertTrue(configuration.isJmxEnabled());
assertEquals(120, configuration.getMetricLogReporterMillis());
assertSame(poolAdapter, configuration.getPoolAdapter());
assertSame(dataSource, configuration.getTargetDataSource());
}
示例5: testBuilder
import com.vladmihalcea.flexypool.metric.MetricsFactory; //导入依赖的package包/类
@Test
public void testBuilder() {
final MetricRegistry metricRegistry = Mockito.mock(MetricRegistry.class);
DataSource dataSource = Mockito.mock(DataSource.class);
PoolAdapterFactory<DataSource> poolAdapterFactory = Mockito.mock(PoolAdapterFactory.class);
ConnectionProxyFactory connectionProxyFactory = Mockito.mock(ConnectionProxyFactory.class);
Metrics metrics = Mockito.mock(Metrics.class);
PoolAdapter poolAdapter = Mockito.mock(PoolAdapter.class);
when(poolAdapterFactory.newInstance(any(ConfigurationProperties.class))).thenReturn(poolAdapter);
Configuration<DataSource> configuration = new Configuration.Builder<DataSource>(
"unique", dataSource, poolAdapterFactory)
.setConnectionProxyFactory(connectionProxyFactory)
.setJmxAutoStart(true)
.setJmxEnabled(true)
.setMetricLogReporterMillis(120)
.setMetricsFactory(new MetricsFactory() {
@Override
public Metrics newInstance(ConfigurationProperties configurationProperties) {
return new CodahaleMetrics(configurationProperties, metricRegistry, new ReservoirFactory() {
@Override
public Reservoir newInstance(Class<? extends Metric> metricClass, String metricName) {
return new ExponentiallyDecayingReservoir();
}
});
}
})
.build();
assertSame("unique", configuration.getUniqueName());
assertSame(connectionProxyFactory, configuration.getConnectionProxyFactory());
assertTrue(configuration.isJmxAutoStart());
assertTrue(configuration.isJmxEnabled());
assertEquals(120, configuration.getMetricLogReporterMillis());
assertSame(poolAdapter, configuration.getPoolAdapter());
assertSame(dataSource, configuration.getTargetDataSource());
}
示例6: createConfiguration
import com.vladmihalcea.flexypool.metric.MetricsFactory; //导入依赖的package包/类
private Configuration<HikariDataSource> createConfiguration(String name, Config config, HikariDataSource dataSource) {
String uniqueId = config.getOptionalValue(format(UNIQUE_ID_PROPERTY_FORMAT, name), String.class).orElse(name);
Configuration.Builder<HikariDataSource> builder = new Configuration.Builder<>(uniqueId, dataSource, HikariCPPoolAdapter.FACTORY);
if(metricsFactoryInstance.isResolvable()) {
MetricsFactory metricsFactory = metricsFactoryInstance.get();
builder.setMetricsFactory(metricsFactory);
}
return builder.build();
}
示例7: load
import com.vladmihalcea.flexypool.metric.MetricsFactory; //导入依赖的package包/类
@Override
public MetricsFactory load() {
return mock(MetricsFactory.class, RETURNS_MOCKS);
}
开发者ID:gavlyukovskiy,项目名称:spring-boot-data-source-decorator,代码行数:5,代码来源:DataSourceDecoratorAutoConfigurationTests.java
示例8: configuration
import com.vladmihalcea.flexypool.metric.MetricsFactory; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private Configuration<D> configuration(D dataSource) {
String uniqueName = propertyLoader.getUniqueName();
PoolAdapterFactory<D> poolAdapterFactory = propertyLoader.getPoolAdapterFactory();
MetricsFactory metricsFactory = propertyLoader.getMetricsFactory();
ConnectionProxyFactory connectionProxyFactory = propertyLoader.getConnectionProxyFactory();
Integer metricLogReporterMillis = propertyLoader.getMetricLogReporterMillis();
Boolean jmxEnabled = propertyLoader.isJmxEnabled();
Boolean jmxAutoStart = propertyLoader.isJmxAutoStart();
EventListenerResolver eventListenerResolver = propertyLoader.getEventListenerResolver();
Long connectionAcquireTimeThresholdMillis = propertyLoader.getConnectionAcquireTimeThresholdMillis();
Long connectionLeaseTimeThresholdMillis = propertyLoader.getConnectionLeaseTimeThresholdMillis();
if (poolAdapterFactory == null) {
poolAdapterFactory = (PoolAdapterFactory<D>) DataSourcePoolAdapter.FACTORY;
}
Configuration.Builder<D> configurationBuilder = new Configuration.Builder<D>(
uniqueName, dataSource, poolAdapterFactory
);
if (metricsFactory != null) {
configurationBuilder.setMetricsFactory(metricsFactory);
}
if (connectionProxyFactory != null) {
configurationBuilder.setConnectionProxyFactory(connectionProxyFactory);
}
if (metricLogReporterMillis != null) {
configurationBuilder.setMetricLogReporterMillis(metricLogReporterMillis);
}
if (jmxEnabled != null) {
configurationBuilder.setJmxEnabled(jmxEnabled);
}
if (jmxAutoStart != null) {
configurationBuilder.setJmxAutoStart(jmxAutoStart);
}
if (eventListenerResolver != null) {
configurationBuilder.setEventListenerResolver(eventListenerResolver);
}
if (connectionAcquireTimeThresholdMillis != null) {
configurationBuilder.setConnectionAcquireTimeThresholdMillis(connectionAcquireTimeThresholdMillis);
}
if (connectionLeaseTimeThresholdMillis != null) {
configurationBuilder.setConnectionLeaseTimeThresholdMillis(connectionLeaseTimeThresholdMillis);
}
return configurationBuilder.build();
}
示例9: testLoadSuccess
import com.vladmihalcea.flexypool.metric.MetricsFactory; //导入依赖的package包/类
@Test
public void testLoadSuccess() {
MetricsFactory metricsFactory = new DropwizardMetricsFactoryService().load();
assertNotNull(metricsFactory);
assertSame(DropwizardMetrics.FACTORY, metricsFactory);
}
示例10: testLoadSuccess
import com.vladmihalcea.flexypool.metric.MetricsFactory; //导入依赖的package包/类
@Test
public void testLoadSuccess() {
MetricsFactory metricsFactory = new CodahaleMetricsFactoryService().load();
assertNotNull(metricsFactory);
assertSame(CodahaleMetrics.FACTORY, metricsFactory);
}
示例11: getMetricsFactory
import com.vladmihalcea.flexypool.metric.MetricsFactory; //导入依赖的package包/类
/**
* Get the {@link MetricsFactory}
*
* @return {@link MetricsFactory}
*/
public MetricsFactory getMetricsFactory() {
return instantiateClass(PropertyKey.POOL_METRICS_FACTORY);
}
示例12: setMetricsFactory
import com.vladmihalcea.flexypool.metric.MetricsFactory; //导入依赖的package包/类
/**
* Set metrics factory
*
* @param metricsFactory metrics factory
* @return this {@link com.vladmihalcea.flexypool.config.Configuration.Builder}
*/
public Builder<T> setMetricsFactory(MetricsFactory metricsFactory) {
this.metricsFactory = metricsFactory;
return this;
}
示例13: load
import com.vladmihalcea.flexypool.metric.MetricsFactory; //导入依赖的package包/类
/**
* Load DropwizardMetrics Factory if the Dropwizard Metrics is available at runtime
*
* @return DropwizardMetrics Factory
*/
@Override
public MetricsFactory load() {
return ClassLoaderUtils.findClass(METRICS_CLASS_NAME) ? DropwizardMetrics.FACTORY : null;
}
示例14: load
import com.vladmihalcea.flexypool.metric.MetricsFactory; //导入依赖的package包/类
/**
* Load CodahaleMetrics Factory if the Codahale Metrics is available at runtime
*
* @return CodahaleMetrics Factory
*/
@Override
public MetricsFactory load() {
return ClassLoaderUtils.findClass(METRICS_CLASS_NAME) ? CodahaleMetrics.FACTORY : null;
}