use of com.alibaba.jstorm.common.metric.AsmHistogram in project jstorm by alibaba.
the class NettyClient method registerMetrics.
public void registerMetrics() {
if (this.enableNettyMetrics) {
sendTimer = (AsmHistogram) JStormMetrics.registerNettyMetric(MetricUtils.nettyMetricName(AsmMetric.mkName(MetricDef.NETTY_CLI_SEND_TIME, nettyConnection), MetricType.HISTOGRAM), new AsmHistogram());
sendSpeed = (AsmMeter) JStormMetrics.registerNettyMetric(MetricUtils.nettyMetricName(AsmMetric.mkName(MetricDef.NETTY_CLI_SEND_SPEED, nettyConnection), MetricType.METER), new AsmMeter());
CacheGaugeHealthCheck cacheGauge = new CacheGaugeHealthCheck(messageBuffer, MetricDef.NETTY_CLI_CACHE_SIZE + ":" + nettyConnection.toString());
JStormMetrics.registerNettyMetric(MetricUtils.nettyMetricName(AsmMetric.mkName(MetricDef.NETTY_CLI_CACHE_SIZE, nettyConnection), MetricType.GAUGE), new AsmGauge(cacheGauge));
JStormMetrics.registerNettyMetric(MetricUtils.nettyMetricName(AsmMetric.mkName(MetricDef.NETTY_CLI_SEND_PENDING, nettyConnection), MetricType.GAUGE), new AsmGauge(new com.codahale.metrics.Gauge<Double>() {
@Override
public Double getValue() {
return ((Long) pendings.get()).doubleValue();
}
}));
JStormHealthCheck.registerWorkerHealthCheck(MetricDef.NETTY_CLI_CACHE_SIZE + ":" + nettyConnection.toString(), cacheGauge);
}
JStormHealthCheck.registerWorkerHealthCheck(MetricDef.NETTY_CLI_CONNECTION + ":" + nettyConnection.toString(), new HealthCheck() {
HealthCheck.Result healthy = HealthCheck.Result.healthy();
HealthCheck.Result unhealthy = HealthCheck.Result.unhealthy("NettyConnection " + nettyConnection.toString() + " is broken.");
@Override
protected Result check() throws Exception {
if (isChannelReady() == null) {
return unhealthy;
} else {
return healthy;
}
}
});
}
use of com.alibaba.jstorm.common.metric.AsmHistogram in project jstorm by alibaba.
the class NettyMetricInstance method register.
public static synchronized void register() {
if (alreadyRegister.compareAndSet(false, true)) {
nettyServerRecvSpeed = (AsmMeter) JStormMetrics.registerWorkerTopologyMetric(JStormMetrics.workerMetricName(MetricDef.NETTY_SRV_RECV_SPEED, MetricType.METER), new AsmMeter());
networkWorkerTransmitTime = (AsmHistogram) JStormMetrics.registerWorkerMetric(MetricUtils.workerMetricName(MetricDef.NETTY_SRV_MSG_TRANS_TIME, MetricType.HISTOGRAM), new AsmHistogram());
totalSendSpeed = (AsmMeter) JStormMetrics.registerWorkerTopologyMetric(JStormMetrics.workerMetricName(MetricDef.NETTY_CLI_SEND_SPEED, MetricType.METER), new AsmMeter());
batchSizeWorkerHistogram = (AsmHistogram) JStormMetrics.registerWorkerMetric(MetricUtils.workerMetricName(MetricDef.NETTY_CLI_BATCH_SIZE, MetricType.HISTOGRAM), new AsmHistogram());
LOG.info("Successfully register netty metrics {}, {}, {}, {}", nettyServerRecvSpeed.getMetricName(), networkWorkerTransmitTime.getMetricName(), totalSendSpeed.getMetricName(), batchSizeWorkerHistogram.getMetricName());
}
}
use of com.alibaba.jstorm.common.metric.AsmHistogram in project jstorm by alibaba.
the class MessageDecoder method removeTransmitHistogram.
public static void removeTransmitHistogram(Channel channel) {
AsmHistogram netTransTime = networkTransmitTimeMap.remove(channel);
if (netTransTime != null) {
String nettyConnection = transmitNameMap.remove(channel);
JStormMetrics.unregisterNettyMetric(MetricUtils.nettyMetricName(AsmMetric.mkName(MetricDef.NETTY_SRV_MSG_TRANS_TIME, nettyConnection), MetricType.HISTOGRAM));
LOG.info("Remove transmit histogram of {}, channel {}", nettyConnection, channel);
}
}
use of com.alibaba.jstorm.common.metric.AsmHistogram in project jstorm by alibaba.
the class TaskBaseMetric method updateTime.
/**
* almost the same implementation of above update, but improves performance for histograms
*/
public void updateTime(String streamId, String name, long start, long end, int count, boolean mergeTopology) {
if (start > 0 && count > 0) {
AsmMetric existingMetric = findMetric(streamId, name, MetricType.HISTOGRAM, mergeTopology);
if (existingMetric instanceof AsmHistogram) {
AsmHistogram histogram = (AsmHistogram) existingMetric;
if (histogram.okToUpdate(end)) {
long elapsed = ((end - start) * TimeUtils.US_PER_MS) / count;
if (elapsed >= 0) {
histogram.update(elapsed);
histogram.setLastUpdateTime(end);
}
}
}
}
}
use of com.alibaba.jstorm.common.metric.AsmHistogram in project jstorm by alibaba.
the class MessageDecoder method getTransmitHistogram.
public AsmHistogram getTransmitHistogram(Channel channel, int clientPort) {
AsmHistogram netTransTime = networkTransmitTimeMap.get(channel);
if (netTransTime == null) {
InetSocketAddress sockAddr = (InetSocketAddress) (channel.getRemoteAddress());
String nettyConnection = NettyConnection.mkString(sockAddr.getAddress().getHostAddress(), clientPort, localIp, localPort);
netTransTime = (AsmHistogram) JStormMetrics.registerNettyMetric(MetricUtils.nettyMetricName(AsmMetric.mkName(MetricDef.NETTY_SRV_MSG_TRANS_TIME, nettyConnection), MetricType.HISTOGRAM), new AsmHistogram());
networkTransmitTimeMap.put(channel, netTransTime);
transmitNameMap.put(channel, nettyConnection);
LOG.info("Register transmit histogram of {}, channel {}", nettyConnection, channel);
}
return netTransTime;
}
Aggregations