本文整理汇总了Java中backtype.storm.metric.api.IMetricsConsumer.DataPoint类的典型用法代码示例。如果您正苦于以下问题:Java DataPoint类的具体用法?Java DataPoint怎么用?Java DataPoint使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DataPoint类属于backtype.storm.metric.api.IMetricsConsumer包,在下文中一共展示了DataPoint类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: monitorStatus
import backtype.storm.metric.api.IMetricsConsumer.DataPoint; //导入依赖的package包/类
public void monitorStatus(String stormId, TaskInfo taskInfo, DataPoint p) {
SpoutCounter counter = spoutCounterMap.get(taskInfo.srcTaskId);
if(counter == null){
counter = new SpoutCounter();
spoutCounterMap.put(taskInfo.srcTaskId, counter);
}
counter.incrRepeatCounter();
String value = String.valueOf(p.value);
long increment = Long.parseLong(value);
counter.incrTupleCounter(increment);
//连续1分钟
if(counter.getRepeatCounter() >= 12){
//数据量少于某个记录
LOGGER.info("last minute tuple = " + counter.getTupleCounter());
if(counter.getTupleCounter() <= 10000){
LOGGER.error("spout has problem, restar topology....");
//restartTopology(stormId);
}
spoutCounterMap.clear();
}
}
示例2: testDataPointsToMetrics
import backtype.storm.metric.api.IMetricsConsumer.DataPoint; //导入依赖的package包/类
public void testDataPointsToMetrics() {
TaskInfo taskInfo = new TaskInfo("host1", 6701, "myBolt7", 12,
123456789000L, 60);
List<DataPoint> dataPoints = new LinkedList<>();
dataPoints.add(new DataPoint("my.int", 57));
dataPoints.add(new DataPoint("my.long", 57L));
dataPoints.add(new DataPoint("my/float", 222f));
dataPoints.add(new DataPoint("my_double", 56.0d));
dataPoints.add(new DataPoint("ignored", "not a num"));
dataPoints.add(new DataPoint("points", ImmutableMap
.<String, Object> of("count", 123, "time", 2342234, "ignored",
"not a num")));
undertest.topologyName = "testTop";
undertest.statsdPrefix = "testPrefix";
// topology and prefix are used when creating statsd, and statsd client
// handles adding them
// they should not show up here
List<Metric> expected = ImmutableList.<Metric> of(new Metric(
"host1.6701.myBolt7.my_int", 57), new Metric(
"host1.6701.myBolt7.my_long", 57), new Metric(
"host1.6701.myBolt7.my_float", 222), new Metric(
"host1.6701.myBolt7.my_double", 56), new Metric(
"host1.6701.myBolt7.points.count", 123), new Metric(
"host1.6701.myBolt7.points.time", 2342234));
assertEquals(expected,
undertest.dataPointsToMetrics(taskInfo, dataPoints));
}