use of com.alibaba.jstorm.common.metric.AsmGauge 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.AsmGauge in project jstorm by alibaba.
the class Worker method startDispatchThread.
private AsyncLoopThread startDispatchThread() {
// send tuple directly from netty server
// send control tuple to dispatch thread
// startDispatchDisruptor();
IContext context = workerData.getContext();
String topologyId = workerData.getTopologyId();
// create recv connection
Map stormConf = workerData.getStormConf();
long timeout = JStormUtils.parseLong(stormConf.get(Config.TOPOLOGY_DISRUPTOR_WAIT_TIMEOUT), 10);
WaitStrategy waitStrategy = new TimeoutBlockingWaitStrategy(timeout, TimeUnit.MILLISECONDS);
int queueSize = JStormUtils.parseInt(stormConf.get(Config.TOPOLOGY_CTRL_BUFFER_SIZE), 256);
DisruptorQueue recvControlQueue = DisruptorQueue.mkInstance("Dispatch-control", ProducerType.MULTI, queueSize, waitStrategy, false, 0, 0);
// metric for recvControlQueue
QueueGauge revCtrlGauge = new QueueGauge(recvControlQueue, MetricDef.RECV_CTRL_QUEUE);
JStormMetrics.registerWorkerMetric(JStormMetrics.workerMetricName(MetricDef.RECV_CTRL_QUEUE, MetricType.GAUGE), new AsmGauge(revCtrlGauge));
IConnection recvConnection = context.bind(topologyId, workerData.getPort(), workerData.getDeserializeQueues(), recvControlQueue, false, workerData.getTaskIds());
workerData.setRecvConnection(recvConnection);
// create recvice control messages's thread
RunnableCallback recvControlDispather = new VirtualPortCtrlDispatch(workerData, recvConnection, recvControlQueue, MetricDef.RECV_THREAD);
return new AsyncLoopThread(recvControlDispather, false, Thread.MAX_PRIORITY, true);
}
use of com.alibaba.jstorm.common.metric.AsmGauge in project jstorm by alibaba.
the class SupervisorManger method registerSupervisorMetrics.
private void registerSupervisorMetrics() {
JStormMetrics.registerWorkerMetric(JStormMetrics.workerMetricName(MetricDef.CPU_USED_RATIO, MetricType.GAUGE), new AsmGauge(new Gauge<Double>() {
@Override
public Double getValue() {
return JStormUtils.getTotalCpuUsage();
}
}));
String duHome = ConfigExtension.getDuHome(conf);
if (duHome != null) {
LinuxResource.setDuHome(duHome);
}
JStormMetrics.registerWorkerMetric(JStormMetrics.workerMetricName(MetricDef.DISK_USAGE, MetricType.GAUGE), new AsmGauge(new Gauge<Double>() {
@Override
public Double getValue() {
return JStormUtils.getDiskUsage();
}
}));
JStormMetrics.registerWorkerMetric(JStormMetrics.workerMetricName(MetricDef.MEMORY_USAGE, MetricType.GAUGE), new AsmGauge(new Gauge<Double>() {
@Override
public Double getValue() {
return JStormUtils.getTotalMemUsage();
}
}));
JStormMetrics.registerWorkerMetric(JStormMetrics.workerMetricName(MetricDef.NETRECVSPEED, MetricType.GAUGE), new AsmGauge(new Gauge<Double>() {
Long lastRecvCount = LinuxResource.getNetRevSendCount().getFirst();
Long lastCalTime = System.currentTimeMillis();
@Override
public Double getValue() {
Long nowRecvCount = LinuxResource.getNetRevSendCount().getFirst();
Long nowCalTime = System.currentTimeMillis();
long deltaValue = nowRecvCount - lastRecvCount;
long deltaTime = nowCalTime - lastCalTime;
lastRecvCount = nowRecvCount;
lastCalTime = nowCalTime;
double ret = 0.0;
if (deltaTime > 0) {
ret = deltaValue / (double) deltaTime * 1000d;
}
return ret;
}
}));
JStormMetrics.registerWorkerMetric(JStormMetrics.workerMetricName(MetricDef.NETSENDSPEED, MetricType.GAUGE), new AsmGauge(new Gauge<Double>() {
Long lastSendCount = LinuxResource.getNetRevSendCount().getSecond();
Long lastCalTime = System.currentTimeMillis();
@Override
public Double getValue() {
Long nowSendCount = LinuxResource.getNetRevSendCount().getSecond();
Long nowCalTime = System.currentTimeMillis();
long deltaValue = nowSendCount - lastSendCount;
long deltaTime = nowCalTime - lastCalTime;
lastSendCount = nowSendCount;
lastCalTime = nowCalTime;
double ret = 0.0;
if (deltaTime > 0) {
ret = deltaValue / (double) deltaTime * 1000d;
}
return ret;
}
}));
}
Aggregations