當前位置: 首頁>>代碼示例>>Java>>正文


Java MetricsFactory類代碼示例

本文整理匯總了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);
    }
}
 
開發者ID:vladmihalcea,項目名稱:flexy-pool,代碼行數:20,代碼來源:DropwizardMetricsFactoryServiceTest.java

示例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);
    }
}
 
開發者ID:vladmihalcea,項目名稱:flexy-pool,代碼行數:20,代碼來源:CodahaleMetricsFactoryServiceTest.java

示例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());
}
 
開發者ID:vladmihalcea,項目名稱:flexy-pool,代碼行數:28,代碼來源:ConfigurationTest.java

示例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());
}
 
開發者ID:vladmihalcea,項目名稱:flexy-pool,代碼行數:37,代碼來源:ConfigurationTest.java

示例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());
}
 
開發者ID:vladmihalcea,項目名稱:flexy-pool,代碼行數:37,代碼來源:ConfigurationTest.java

示例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();
}
 
開發者ID:hammock-project,項目名稱:hammock,代碼行數:10,代碼來源:FlexyPoolWrapper.java

示例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();
}
 
開發者ID:vladmihalcea,項目名稱:flexy-pool,代碼行數:47,代碼來源:FlexyPoolDataSource.java

示例9: testLoadSuccess

import com.vladmihalcea.flexypool.metric.MetricsFactory; //導入依賴的package包/類
@Test
public void testLoadSuccess() {
    MetricsFactory metricsFactory = new DropwizardMetricsFactoryService().load();
    assertNotNull(metricsFactory);
    assertSame(DropwizardMetrics.FACTORY, metricsFactory);
}
 
開發者ID:vladmihalcea,項目名稱:flexy-pool,代碼行數:7,代碼來源:DropwizardMetricsFactoryServiceTest.java

示例10: testLoadSuccess

import com.vladmihalcea.flexypool.metric.MetricsFactory; //導入依賴的package包/類
@Test
public void testLoadSuccess() {
    MetricsFactory metricsFactory = new CodahaleMetricsFactoryService().load();
    assertNotNull(metricsFactory);
    assertSame(CodahaleMetrics.FACTORY, metricsFactory);
}
 
開發者ID:vladmihalcea,項目名稱:flexy-pool,代碼行數:7,代碼來源:CodahaleMetricsFactoryServiceTest.java

示例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);
}
 
開發者ID:vladmihalcea,項目名稱:flexy-pool,代碼行數:9,代碼來源:PropertyLoader.java

示例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;
}
 
開發者ID:vladmihalcea,項目名稱:flexy-pool,代碼行數:11,代碼來源:Configuration.java

示例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;
}
 
開發者ID:vladmihalcea,項目名稱:flexy-pool,代碼行數:10,代碼來源:DropwizardMetricsFactoryService.java

示例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;
}
 
開發者ID:vladmihalcea,項目名稱:flexy-pool,代碼行數:10,代碼來源:CodahaleMetricsFactoryService.java


注:本文中的com.vladmihalcea.flexypool.metric.MetricsFactory類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。