Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add balancer meter fixes #4470 #4471

Open
wants to merge 8 commits into
base: 2.1
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,10 @@ 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";

// balancer
String METRICS_MANAGER_BALANCER_MIGRATING = "manager.balancer.balancing.total";
String METRICS_MANAGER_BALANCER_NEED_MIGRATION = "manager.balancer.need.balancing.total";
EdColeman marked this conversation as resolved.
Show resolved Hide resolved

/**
* Build Micrometer Meter objects and register them with the registry
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@
import org.apache.accumulo.core.util.Retry;
import org.apache.accumulo.core.util.threads.ThreadPools;
import org.apache.accumulo.core.util.threads.Threads;
import org.apache.accumulo.manager.metrics.BalancerMetrics;
import org.apache.accumulo.manager.metrics.ManagerMetrics;
import org.apache.accumulo.manager.recovery.RecoveryManager;
import org.apache.accumulo.manager.state.TableCounts;
Expand Down Expand Up @@ -208,6 +209,7 @@ public class Manager extends AbstractServer
private TServer clientService = null;
private volatile TabletBalancer tabletBalancer;
private final BalancerEnvironment balancerEnvironment;
private final BalancerMetrics balancerMetrics = new BalancerMetrics();

private ManagerState state = ManagerState.INITIAL;

Expand Down Expand Up @@ -561,6 +563,10 @@ public void clearMigrations(TableId tableId) {
}
}

public MetricsProducer getBalancerMetrics() {
return balancerMetrics;
}

enum TabletGoalState {
HOSTED(TUnloadTabletGoal.UNKNOWN),
UNASSIGNED(TUnloadTabletGoal.UNASSIGNED),
Expand Down Expand Up @@ -934,7 +940,11 @@ private long balanceTablets() {
synchronized (balancedNotifier) {
balancedNotifier.notifyAll();
}
balancerMetrics.setMigratingCount(0);
balancerMetrics.setNeedMigrationCount(0);
} else {
balancerMetrics.setMigratingCount(params.migrationsOut().size());
balancerMetrics.setNeedMigrationCount(migrations.size());
Comment on lines +989 to +990
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe that the migrations variable in the Manager contains all of the in-flight migrations. The params.migrationsOut contains the tablets that need to be migrated from this call to the balancer. I think based on what I'm seeing here, it's double counting. I wonder if we just want the size of the migrations list as that will encompass newly added, newly removed, and migrations waiting to happen.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want to capture the newly added migrations, then it might make sense to capture the migration completions (which are in the TabletGroupWatcher) and cancellations (which happen in a couple places in the Manager).

nextEvent.event("Migrating %d more tablets, %d total", params.migrationsOut().size(),
migrations.size());
}
Expand Down Expand Up @@ -1104,6 +1114,7 @@ public void run() {
metricsInfo.addServiceTags(getApplicationName(), sa.getAddress());

var producers = ManagerMetrics.getProducers(getConfiguration(), this);
producers.add(balancerMetrics);
metricsInfo.addMetricsProducers(producers.toArray(new MetricsProducer[0]));
metricsInfo.init();

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* 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.manager.metrics;

import java.util.concurrent.atomic.AtomicLong;

import org.apache.accumulo.core.metrics.MetricsProducer;

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

public class BalancerMetrics implements MetricsProducer {

AtomicLong migratingCount = new AtomicLong();
AtomicLong needMigrationCount = new AtomicLong();

public long getMigratingCount() {
return migratingCount.get();
}

public void setMigratingCount(final long migratingCount) {
this.migratingCount.set(migratingCount);
}

public long getNeedMigrationCount() {
return needMigrationCount.get();
}

public void setNeedMigrationCount(final long needMigrationCount) {
this.needMigrationCount.set(needMigrationCount);
}

@Override
public void registerMetrics(MeterRegistry registry) {
Gauge.builder(METRICS_MANAGER_BALANCER_MIGRATING, this, BalancerMetrics::getMigratingCount)
.description("Snapshot count of tablets currently being migrated").register(registry);
Gauge
.builder(METRICS_MANAGER_BALANCER_NEED_MIGRATION, this,
BalancerMetrics::getNeedMigrationCount)
.description("Snapshot count of tablets that need to be migrated").register(registry);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,9 @@
import org.apache.accumulo.core.metrics.MetricsProducer;
import org.apache.accumulo.manager.Manager;
import org.apache.accumulo.manager.metrics.fate.FateMetrics;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class ManagerMetrics {

private final static Logger log = LoggerFactory.getLogger(ManagerMetrics.class);

public static List<MetricsProducer> getProducers(AccumuloConfiguration conf, Manager m) {
ArrayList<MetricsProducer> producers = new ArrayList<>();
@SuppressWarnings("deprecation")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ public void confirmMetricsPublished() throws Exception {

Set<String> unexpectedMetrics = Set.of(METRICS_SCAN_YIELDS, METRICS_UPDATE_ERRORS,
METRICS_REPLICATION_QUEUE, METRICS_COMPACTOR_MAJC_STUCK, METRICS_SCAN_BUSY_TIMEOUT);
Set<String> flakyMetrics = Set.of(METRICS_GC_WAL_ERRORS, METRICS_FATE_TYPE_IN_PROGRESS);
Set<String> flakyMetrics = Set.of(METRICS_GC_WAL_ERRORS, METRICS_FATE_TYPE_IN_PROGRESS,
METRICS_MANAGER_BALANCER_NEED_MIGRATION, METRICS_MANAGER_BALANCER_MIGRATING);

Map<String,String> expectedMetricNames = this.getMetricFields();
flakyMetrics.forEach(expectedMetricNames::remove); // might not see these
Expand Down