Search in sources :

Example 1 with AsmHistogram

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;
            }
        }
    });
}
Also used : AsmGauge(com.alibaba.jstorm.common.metric.AsmGauge) AtomicLong(java.util.concurrent.atomic.AtomicLong) JStormHealthCheck(com.alibaba.jstorm.metric.JStormHealthCheck) HealthCheck(com.codahale.metrics.health.HealthCheck) AsmHistogram(com.alibaba.jstorm.common.metric.AsmHistogram) AsmMeter(com.alibaba.jstorm.common.metric.AsmMeter) QueueGauge(com.alibaba.jstorm.common.metric.QueueGauge) AsmGauge(com.alibaba.jstorm.common.metric.AsmGauge)

Example 2 with AsmHistogram

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());
    }
}
Also used : AsmMeter(com.alibaba.jstorm.common.metric.AsmMeter) AsmHistogram(com.alibaba.jstorm.common.metric.AsmHistogram)

Example 3 with AsmHistogram

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);
    }
}
Also used : AsmHistogram(com.alibaba.jstorm.common.metric.AsmHistogram)

Example 4 with AsmHistogram

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);
                }
            }
        }
    }
}
Also used : AsmMetric(com.alibaba.jstorm.common.metric.AsmMetric) AsmHistogram(com.alibaba.jstorm.common.metric.AsmHistogram)

Example 5 with AsmHistogram

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;
}
Also used : InetSocketAddress(java.net.InetSocketAddress) AsmHistogram(com.alibaba.jstorm.common.metric.AsmHistogram)

Aggregations

AsmHistogram (com.alibaba.jstorm.common.metric.AsmHistogram)6 AsmMeter (com.alibaba.jstorm.common.metric.AsmMeter)2 ControlMessage (backtype.storm.messaging.ControlMessage)1 TaskMessage (backtype.storm.messaging.TaskMessage)1 AsmGauge (com.alibaba.jstorm.common.metric.AsmGauge)1 AsmMetric (com.alibaba.jstorm.common.metric.AsmMetric)1 QueueGauge (com.alibaba.jstorm.common.metric.QueueGauge)1 JStormHealthCheck (com.alibaba.jstorm.metric.JStormHealthCheck)1 HealthCheck (com.codahale.metrics.health.HealthCheck)1 InetSocketAddress (java.net.InetSocketAddress)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1 ChannelBuffer (org.jboss.netty.buffer.ChannelBuffer)1