Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,15 @@ public interface MetricsProducer {
String METRICS_UPDATE_WALOG_WRITE = METRICS_UPDATE_PREFIX + "walog.write";
String METRICS_UPDATE_MUTATION_ARRAY_SIZE = METRICS_UPDATE_PREFIX + "mutation.arrays.size";

String METRICS_BLOCKCACHE_PREFIX = "accumulo.blockcache.";
String METRICS_BLOCKCACHE_INDEX_HITCOUNT = METRICS_BLOCKCACHE_PREFIX + "index.hitcount";
String METRICS_BLOCKCACHE_INDEX_REQUESTCOUNT = METRICS_BLOCKCACHE_PREFIX + "index.requestcount";
String METRICS_BLOCKCACHE_DATA_HITCOUNT = METRICS_BLOCKCACHE_PREFIX + "data.hitcount";
String METRICS_BLOCKCACHE_DATA_REQUESTCOUNT = METRICS_BLOCKCACHE_PREFIX + "data.requestcount";
String METRICS_BLOCKCACHE_SUMMARY_HITCOUNT = METRICS_BLOCKCACHE_PREFIX + "summary.hitcount";
String METRICS_BLOCKCACHE_SUMMARY_REQUESTCOUNT =
METRICS_BLOCKCACHE_PREFIX + "summary.requestcount";

/**
* Build Micrometer Meter objects and register them with the registry
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.accumulo.tserver;

import java.util.function.ToDoubleFunction;

import org.apache.accumulo.core.metrics.MetricsProducer;
import org.apache.accumulo.core.spi.cache.BlockCache;

import io.micrometer.core.instrument.FunctionCounter;
import io.micrometer.core.instrument.MeterRegistry;

public class BlockCacheMetrics implements MetricsProducer {

BlockCache indexCache;
BlockCache dataCache;
BlockCache summaryCache;

public BlockCacheMetrics(BlockCache indexCache, BlockCache dataCache, BlockCache summaryCache) {
this.indexCache = indexCache;
this.dataCache = dataCache;
this.summaryCache = summaryCache;
}

@Override
public void registerMetrics(MeterRegistry registry) {
ToDoubleFunction<BlockCache> getHitCount = cache -> cache.getStats().hitCount();
ToDoubleFunction<BlockCache> getRequestCount = cache -> cache.getStats().requestCount();

FunctionCounter.builder(METRICS_BLOCKCACHE_INDEX_HITCOUNT, indexCache, getHitCount)
.description("Index block cache hit count").register(registry);
FunctionCounter.builder(METRICS_BLOCKCACHE_INDEX_REQUESTCOUNT, indexCache, getRequestCount)
.description("Index block cache request count").register(registry);

FunctionCounter.builder(METRICS_BLOCKCACHE_DATA_HITCOUNT, dataCache, getHitCount)
.description("Data block cache hit count").register(registry);
FunctionCounter.builder(METRICS_BLOCKCACHE_DATA_REQUESTCOUNT, dataCache, getRequestCount)
.description("Data block cache request count").register(registry);

FunctionCounter.builder(METRICS_BLOCKCACHE_SUMMARY_HITCOUNT, summaryCache, getHitCount)
.description("Summary block cache hit count").register(registry);
FunctionCounter.builder(METRICS_BLOCKCACHE_SUMMARY_REQUESTCOUNT, summaryCache, getRequestCount)
.description("Summary block cache request count").register(registry);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ private TabletMetadataLoader(Ample ample) {
private ServiceLock scanServerLock;
protected TabletServerScanMetrics scanMetrics;
private ScanServerMetrics scanServerMetrics;
private BlockCacheMetrics blockCacheMetrics;

private ZooCache managerLockCache;

Expand Down Expand Up @@ -380,8 +381,10 @@ public void run() {

scanMetrics = new TabletServerScanMetrics();
scanServerMetrics = new ScanServerMetrics(tabletMetadataCache);
blockCacheMetrics = new BlockCacheMetrics(resourceManager.getIndexCache(),
resourceManager.getDataCache(), resourceManager.getSummaryCache());

metricsInfo.addMetricsProducers(scanMetrics, scanServerMetrics);
metricsInfo.addMetricsProducers(scanMetrics, scanServerMetrics, blockCacheMetrics);
metricsInfo.init();
// We need to set the compaction manager so that we don't get an NPE in CompactableImpl.close

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ public class TabletServer extends AbstractServer implements TabletHostingServer
TabletServerScanMetrics scanMetrics;
TabletServerMinCMetrics mincMetrics;
CompactionExecutorsMetrics ceMetrics;
BlockCacheMetrics blockCacheMetrics;

@Override
public TabletServerScanMetrics getScanMetrics() {
Expand Down Expand Up @@ -759,16 +760,19 @@ public void run() {
throw new RuntimeException("Failed to start the tablet client service", e1);
}

MetricsInfo metricsInfo = getContext().getMetricsInfo();
MetricsInfo metricsInfo = context.getMetricsInfo();
metricsInfo.addServiceTags(getApplicationName(), clientAddress);

metrics = new TabletServerMetrics(this);
updateMetrics = new TabletServerUpdateMetrics();
scanMetrics = new TabletServerScanMetrics();
mincMetrics = new TabletServerMinCMetrics();
ceMetrics = new CompactionExecutorsMetrics();
blockCacheMetrics = new BlockCacheMetrics(this.resourceManager.getIndexCache(),
this.resourceManager.getDataCache(), this.resourceManager.getSummaryCache());

metricsInfo.addMetricsProducers(metrics, updateMetrics, scanMetrics, mincMetrics, ceMetrics);
metricsInfo.addMetricsProducers(metrics, updateMetrics, scanMetrics, mincMetrics, ceMetrics,
blockCacheMetrics);
metricsInfo.init();

this.compactionManager = new CompactionManager(() -> Iterators
Expand Down