本文整理汇总了Java中com.codahale.metrics.CachedGauge类的典型用法代码示例。如果您正苦于以下问题:Java CachedGauge类的具体用法?Java CachedGauge怎么用?Java CachedGauge使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CachedGauge类属于com.codahale.metrics包,在下文中一共展示了CachedGauge类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: gauge
import com.codahale.metrics.CachedGauge; //导入依赖的package包/类
/**
* Acquires the named cached gauge
* @param name The name of the gauge
* @param provider The value provider for the gauge
* @param refreshPeriod The refresh period of the cached gauge in seconds
* @return the cached gauge
*/
public <T> CachedGauge<T> gauge(final String name, final Callable<T> provider, final int refreshPeriod) {
final String fullName = name + serviceTag;
final CachedGauge<T> g = new CachedGauge<T>(refreshPeriod, TimeUnit.SECONDS) {
@Override
protected T loadValue() {
try {
return provider.call();
} catch (Exception ex) {
throw new RuntimeException("Failed to get cached value for [" + name + "]", ex);
}
}
};
metricRegistry.register("gauge." + fullName, g);
gauges.put(name, g);
return g;
}
开发者ID:nickman,项目名称:HeliosStreams,代码行数:24,代码来源:PluginMetricManager.java
示例2: registerAggregateMetrics
import com.codahale.metrics.CachedGauge; //导入依赖的package包/类
private void registerAggregateMetrics(final MetricRegistry registry) {
//
// JVM used percentage
//
Map<String, Gauge> gauges = registry.getGauges();
final Gauge<Long> gaugeJvmMemMax = gauges.get("jvm.memory.total.max");
final Gauge<Long> gaugeJvmMemUsed = gauges.get("jvm.memory.total.used");
registry.register(JVM_MEM_PERC.key(), new CachedGauge<Double>(5L, TimeUnit.SECONDS) {
@Override
protected Double loadValue() {
double memMax = gaugeJvmMemMax.getValue();
double memUsed = gaugeJvmMemUsed.getValue();
return (memUsed / memMax) * 100.0d;
}
});
}
开发者ID:clidev,项目名称:spike.x,代码行数:19,代码来源:Activator.java
示例3: afterPropertiesSet
import com.codahale.metrics.CachedGauge; //导入依赖的package包/类
/**
* {@inheritDoc}
* @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet()
*/
@Override
public void afterPropertiesSet() throws Exception {
configDir = new File(configDirName).getAbsoluteFile();
appDir = new File(appDirName).getAbsoluteFile();
if(!configDir.isDirectory()) throw new IllegalArgumentException("The configuration directory [" + configDirName + "] is invalid");
if(!appDir.exists()) {
appDir.mkdirs();
}
if(!appDir.isDirectory()) throw new IllegalArgumentException("The app directory [" + appDirName + "] is invalid");
log.info("Configuration Directory: [{}]", configDir);
if(!cacheSpec.contains("recordStats")) cacheSpec = cacheSpec + ",recordStats";
configCache = CacheBuilder.from(cacheSpec).build(configCacheLoader);
configCacheStats = new CachedGauge<CacheStats>(5, TimeUnit.SECONDS) {
@Override
protected CacheStats loadValue() {
return configCache.stats();
}
};
appJarCache = CacheBuilder.from(cacheSpec).build(appJarCacheLoader);
appJarCacheStats = new CachedGauge<CacheStats>(5, TimeUnit.SECONDS) {
@Override
protected CacheStats loadValue() {
return appJarCache.stats();
}
};
reloadConfigCache();
log.info("Loaded [{}] App Configurations", configCache.size());
reloadAppJarCache();
log.info("Loaded [{}] App Jar Sets", appJarCache.size());
}
开发者ID:nickman,项目名称:HeliosStreams,代码行数:37,代码来源:NodeConfigurationServer.java
示例4: TSDBEndpoint
import com.codahale.metrics.CachedGauge; //导入依赖的package包/类
/**
* Creates a new TSDBEndpoint
* @param sqlWorker The SQLWorker that will drive the lookups
*/
private TSDBEndpoint(final SQLWorker sqlWorker) {
this.sqlWorker = sqlWorker;
knownServers = new CachedGauge<String[]>(60, TimeUnit.SECONDS) {
@Override
protected String[] loadValue() {
final String order = (asc.getAndSet(asc.get()) ? "ASC" : "DESC");
return sqlWorker.sqlForFormat(null, null, "SELECT HOST, PORT, URI FROM TSD_KNOWNSERVERS WHERE UP = 'Y' ORDER BY HOST " + order + ", PORT " + order, "http://##0##:##1##/##2##");
}
};
}
开发者ID:nickman,项目名称:HeliosStreams,代码行数:15,代码来源:TSDBEndpoint.java
示例5: CachedGaugeImpl
import com.codahale.metrics.CachedGauge; //导入依赖的package包/类
public CachedGaugeImpl(String name, Level level, long timeout, TimeUnit timeoutUnit, final Gauge<T> gauge) {
super(name, level);
this.gauge = new CachedGauge<T>(timeout, timeoutUnit) {
@Override
protected T loadValue() {
return gauge.getValue();
}
};
}
开发者ID:wso2,项目名称:carbon-metrics,代码行数:10,代码来源:CachedGaugeImpl.java
示例6: measureCachedGauge
import com.codahale.metrics.CachedGauge; //导入依赖的package包/类
public static <T> void measureCachedGauge( String metric, long timeout, TimeUnit timeUnit, Supplier<T> get ) {
registry.register( metric, new CachedGauge<T>( timeout, timeUnit ) {
@Override
protected T loadValue() {
return get.get();
}
} );
}
开发者ID:oaplatform,项目名称:oap,代码行数:9,代码来源:Metrics.java
注:本文中的com.codahale.metrics.CachedGauge类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论