本文整理匯總了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));
}