• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java CachedGauge类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ColumnSlice类代码示例发布时间:2022-05-22
下一篇:
Java AttachOperationFailedException类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap