private static void clearMetricIfNotNull(MutableGaugeLong metric) { if (metric != null) { metric.set(0L); } }
@Override public void snapshot(MetricsRecordBuilder builder, boolean all) { if (all || changed()) { builder.addGauge(info(), value()); clearChanged(); } }
@Override public void incrementAuthFailedCount() { authFailedFailedOpCount.incr(); }
@Override public int getSizeOfLogQueue() { return (int)sizeOfLogQueueGauge.value(); }
@Override public void decrSizeOfHFileRefsQueue(long size) { sizeOfHFileRefsQueueGauge.decr(size); }
private void updateThreadMetrics(MetricsRecordBuilder rb) { if (threadMXBean.isThreadCpuTimeSupported() && threadMXBean.isThreadCpuTimeEnabled()) { final long[] ids = threadMXBean.getAllThreadIds(); final ThreadInfo[] infos = threadMXBean.getThreadInfo(ids); for (int i = 0; i < ids.length; i++) { ThreadInfo threadInfo = infos[i]; if (threadInfo == null) { continue; } String threadName = threadInfo.getThreadName(); long threadId = ids[i]; Integer id = executorNames.get(threadName); if (id != null) { executorThreadCpuTime[id].set(threadMXBean.getThreadCpuTime(threadId)); executorThreadUserTime[id].set(threadMXBean.getThreadUserTime(threadId)); } } for (int i=0; i<numExecutors; i++) { rb.addGauge(cpuMetricsInfoMap.get(i), executorThreadCpuTime[i].value()); rb.addGauge(userMetricsInfoMap.get(i), executorThreadUserTime[i].value()); } } }
/** * Create a mutable long integer gauge * @param info metadata of the metric * @param iVal initial value * @return a new gauge object */ public MutableGaugeLong newGauge(MetricsInfo info, long iVal) { MutableGaugeLong ret = new MutableGaugeLong(info, iVal); return addNewMetricIfAbsent(info.name(), ret, MutableGaugeLong.class); }
/** * Increment by delta * @param delta of the increment */ public void incr(long delta) { value.addAndGet(delta); setChanged(); }
@Override public int getSizeOfLogQueue() { return (int)sizeOfLogQueueGauge.value(); }
@Override public void decrSizeOfLogQueue(int size) { sizeOfLogQueueGauge.decr(size); }
/** * Create a mutable long integer gauge * @param info metadata of the metric * @param iVal initial value * @return a new gauge object */ public synchronized MutableGaugeLong newGauge(MetricsInfo info, long iVal) { checkMetricName(info.name()); MutableGaugeLong ret = new MutableGaugeLong(info, iVal); metricsMap.put(info.name(), ret); return ret; }
/** * decrement by delta * @param delta of the decrement */ public void decr(long delta) { value.addAndGet(-delta); setChanged(); }
public void snapshot(MetricsRecordBuilder builder, boolean all) { if (all || changed()) { builder.addGauge(info(), value()); clearChanged(); } }
@Override public void setRIT(final int ritCount) { ritGauge.set(ritCount); }
@Override public void incrementInvalidACLCount() { invalidACLFailedOpCount.incr(); }
private void getIoStats(MetricsRecordBuilder rb) { rb.addGauge(MaxDecodingTime, maxDecodingTime.value()); rateOfDecoding.snapshot(rb, true); for (MutableQuantiles q : decodingTimes) { q.snapshot(rb, true); } }
@Override public void decActiveWorkerCount() { activeWorkerCountGauge.decr(); }
/** * Get a MetricMutableGaugeLong from the storage. If it is not there atomically put it. * * @param gaugeName name of the gauge to create or get. * @param potentialStartingValue value of the new gauge if we have to create it. */ public MutableGaugeLong getGauge(String gaugeName, long potentialStartingValue) { //Try and get the guage. MutableMetric metric = metricsMap.get(gaugeName); //If it's not there then try and put a new one in the storage. if (metric == null) { //Create the potential new gauge. MutableGaugeLong newGauge = new MutableGaugeLong(new MetricsInfoImpl(gaugeName, ""), potentialStartingValue); // Try and put the gauge in. This is atomic. metric = metricsMap.putIfAbsent(gaugeName, newGauge); //If the value we get back is null then the put was successful and we will return that. //otherwise gaugeLong should contain the thing that was in before the put could be completed. if (metric == null) { return newGauge; } } if (!(metric instanceof MutableGaugeLong)) { throw new MetricsException("Metric already exists in registry for metric name: " + gaugeName + " and not of type MetricMutableGaugeLong"); } return (MutableGaugeLong) metric; }
/** * Set the value of the metric * @param value to set */ public void set(long value) { this.value.set(value); setChanged(); }