Search in sources :

Example 1 with AsmMeter

use of com.alibaba.jstorm.common.metric.AsmMeter 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 AsmMeter

use of com.alibaba.jstorm.common.metric.AsmMeter 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)

Aggregations

AsmHistogram (com.alibaba.jstorm.common.metric.AsmHistogram)2 AsmMeter (com.alibaba.jstorm.common.metric.AsmMeter)2 AsmGauge (com.alibaba.jstorm.common.metric.AsmGauge)1 QueueGauge (com.alibaba.jstorm.common.metric.QueueGauge)1 JStormHealthCheck (com.alibaba.jstorm.metric.JStormHealthCheck)1 HealthCheck (com.codahale.metrics.health.HealthCheck)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1