理解Storm Metrics
Storm exposes a metrics interface to report summary statistics across the full topology. It's used internally to track the numbers you see in the Nimbus UI console: counts of executes and acks; average process latency per bolt; worker heap usage; and so forth.
public interface IMetric {
public Object getValueAndReset();
}

public class ReducedMetric implements IMetric {
private final IReducer _reducer;
private Object _accumulator;
public ReducedMetric(IReducer reducer) {
_reducer = reducer;
_accumulator = _reducer.init();
}
public void update(Object value) {
_accumulator = _reducer.reduce(_accumulator, value);
}
public Object getValueAndReset() {
Object ret = _reducer.extractResult(_accumulator);
_accumulator = _reducer.init();
return ret;
}
}
class MeanReducerState {
public int count = 0;
public double sum = 0.0;
}
public class MeanReducer implements IReducer<MeanReducerState> {
public MeanReducerState init() {
return new MeanReducerState();
}
public MeanReducerState reduce(MeanReducerState acc, Object input) {
acc.count++;
if(input instanceof Double) {
acc.sum += (Double)input;
} else if(input instanceof Long) {
acc.sum += ((Long)input).doubleValue();
} else if(input instanceof Integer) {
acc.sum += ((Integer)input).doubleValue();
} else {
throw new RuntimeException(
"MeanReducer::reduce called with unsupported input type `" + input.getClass()
+ "`. Supported types are Double, Long, Integer.");
}
return acc;
}
public Object extractResult(MeanReducerState acc) {
if(acc.count > 0) {
return acc.sum / (double) acc.count;
} else {
return null;
}
}
}
context.registerMetric("execute_count", countMetric, 5);
context.registerMetric("word_count", wordCountMetric, 60);
context.registerMetric("word_length", wordLengthMeanMetric, 60);
IMetricsConsumer
Listens for all metrics, dumps them to log To use, add this to your topology's configuration: ```java conf.registerMetricsConsumer(org.apache.storm.metrics.LoggingMetricsConsumer.class, 1); ``` Or edit the storm.yaml config file: ```yaml topology.metrics.consumer.register: - class: "org.apache.storm.metrics.LoggingMetricsConsumer" parallelism.hint: 1
config.registerMetricsConsumer(LoggingMetricsConsumer.class, 2);


/usr/local/apache-storm-1.0.1/logs/workers-artifacts/FirstTopo-46-1468485056/6703 -rw-rw-r-- 1 java java 55K 7月 14 18:47 gc.log.0
-rw-rw-r-- 1 java java 28K 7月 14 18:47 worker.log
-rw-rw-r-- 1 java java 0 7月 14 16:31 worker.log.err
-rw-rw-r-- 1 java java 1.2M 7月 14 18:47 worker.log.metrics
-rw-rw-r-- 1 java java 0 7月 14 16:31 worker.log.out
-rw-rw-r-- 1 java java 5 7月 14 16:31 worker.pid
-rw-rw-r-- 1 java java 120 7月 14 16:31 worker.yaml
2016-07-14 16:31:40,700 31721 1468485098 192.168.1.127:6702 6:bolt execute_count 5
2016-07-14 16:31:45,702 36723 1468485103 192.168.1.127:6702 6:bolt execute_count 5
2016-07-14 16:31:50,702 41723 1468485108 192.168.1.127:6702 6:bolt execute_count 5
2016-07-14 16:32:10,705 61726 1468485128 192.168.1.127:6702 6:bolt execute_count 5
2016-07-14 16:32:15,708 66729 1468485133 192.168.1.127:6702 6:bolt execute_count 5
2016-07-14 16:32:25,699 76720 1468485143 192.168.1.127:6702 6:bolt __ack-count {spout:default=60}
2016-07-14 16:32:25,701 76722 1468485143 192.168.1.127:6702 6:bolt __sendqueue {sojourn_time_ms=0.0, write_pos=10, read_pos=10, arrival_rate_secs=0.10267994660642776, overflow=0, capacity=1024, population=0}
2016-07-14 16:32:25,701 76722 1468485143 192.168.1.127:6702 6:bolt word_count {happy=18, angry=19, excited=14}
2016-07-14 16:32:25,702 76723 1468485143 192.168.1.127:6702 6:bolt __receive {sojourn_time_ms=817.6666666666666, write_pos=62, read_pos=61, arrival_rate_secs=1.222992254382389, overflow=0, capacity=1024, population=1}
理解Storm Metrics的更多相关文章
- 用实例的方式去理解storm的并发度
什么是storm的并发度 一个topology(拓扑)在storm集群上最总是以executor和task的形式运行在suppervisor管理的worker节点上.而worker进程都是运行在jvm ...
- 理解Storm并发
作者:Jack47 PS:如果喜欢我写的文章,欢迎关注我的微信公众账号程序员杰克,两边的文章会同步,也可以添加我的RSS订阅源. 注:本文主要内容翻译自understanding-the-parall ...
- storm源码之理解Storm中Worker、Executor、Task关系 + 并发度详解
本文导读: 1 Worker.Executor.task详解 2 配置拓扑的并发度 3 拓扑示例 4 动态配置拓扑并发度 Worker.Executor.Task详解: Storm在集群上运行一个To ...
- 【原】理解Storm拓扑的并行
Storm入门教程 1. Storm基础 Storm Storm主要特点 Storm基本概念 Storm调度器 Storm配置 Guaranteeing Message Processing(消息处理 ...
- 理解storm的ACKER机制原理
一.简介: storm中有一个很重要的特性: 保证发出的每个tuple都会被完整处理.一个tuple被完全处理的意思是: 这个tuple以及由这个tuple所产生的所有的子tuple都被成 ...
- 【原】【译文】理解storm拓扑并行度
原文地址: http://storm.apache.org/releases/1.2.1/Understanding-the-parallelism-of-a-Storm-topology.html ...
- 理解Storm可靠性消息
看过一些别人写的, 感觉有些东西没太说清楚,个人主要以源代码跟踪,参考个人理解讲述,有错误请指正. 1基本名词 1.1 Tuple: 消息传递的基本单位.很多文章中介绍都是这么说的, 个人觉得应该更详 ...
- 【原】storm源码之理解Storm中Worker、Executor、Task关系
Storm在集群上运行一个Topology时,主要通过以下3个实体来完成Topology的执行工作:1. Worker(进程)2. Executor(线程)3. Task 下图简要描述了这3者之间的关 ...
- 理解 Storm 拓扑的并行度(parallelism)概念
组成:一个运行中的拓扑是由什么构成的:工作进程(worker processes),执行器(executors)和任务(tasks)! 在一个 Storm 集群中,Storm 主要通过以下三个部件来运 ...
随机推荐
- redis 五大数据类型之string篇
一: 1:string(字符串) string是redis最基本的类型,你可以理解成与Memcached一模一样的类型,一个key对应一个value. string类型是二进制安全的.意思是redis ...
- 写在连载之前——DIY微型操作系统篇
这个博客开了这么久都没写过什么东西.可能是因为我想写的东西在网上都能找得到,所以自己也懒得去写了. 但是这次当我在看<30天自制操作系统>这本书的时候发现,如果不用作者原版的光盘软件,要自 ...
- uri 定义
function path(){ $path=explode("/",$_SERVER['REQUEST_URI']); unset($path[(count($path)-1)] ...
- TX2平台CAN总线收发功能的测试
前言 项目实现过程中需要将获取的数据信息通过CAN总线传输到控制规划模块,本文主要介绍如何在TX2平台测试CAN总线的收发功能. TX2是英伟达旗下为嵌入式平台人工智能应用开发出的一个硬件平台,TX1 ...
- 斐波那契数列的5种python实现写法
斐波那契数列的5种python写法 斐波那契数列(Fibonacci sequence),又称黄金分割数列.因数学家列昂纳多·斐波那契(Leonardoda Fibonacci)以兔子繁殖 ...
- Linux Shell查看物理CPU个数、核数、逻辑CPU个数
Linux Shell常用命令: ====================================== # 总核数 = 物理CPU个数 X 每颗物理CPU的核数 # 总逻辑CPU数 = 物理C ...
- USB gadget 驱动 printer.c 分析
1. modprobe g_printer idVendor=0x0525 idProduct=0xa4a8 modprobe后面也可以加模块参数 2. prn_example从stdout获取数据然 ...
- 使用blessed 开发丰富的cli 应用
blessed 是一个不错的npm 包,可以帮助我们开发出带有丰富ui界面的cli 应用,类似的有subzero 测试环境准备 项目结构 ├── README.md ├── app.js ├── my ...
- 7zip命令行中文说明
7z.exe 是 7-Zip 的命令行版本.7z.exe 使用 7-Zip 的其它模块,7za.exe 是7-Zip 的独立版本,7za.exe 仅支持 7z.zip.gzip.bzip2 和 tar ...
- 自适应巡航控制系统——ACC
ACC(Adaptive Cruise Control)自适应巡航控制系统(以下简称ACC)是一种基于传感器识别技术而诞生的智能巡航控制,相比只能根据驾驶者设置的速度进行恒定速度巡航的传统巡航控制系统 ...