Skip to content
Open
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 @@ -49,8 +49,10 @@
import org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.ReplicationCommandPriority;
import org.apache.hadoop.metrics2.lib.MetricsRegistry;
import org.apache.hadoop.metrics2.lib.MutableRate;
import org.apache.hadoop.ozone.container.checksum.ReconcileContainerTask;
import org.apache.hadoop.ozone.container.common.statemachine.DatanodeConfiguration;
import org.apache.hadoop.ozone.container.common.statemachine.StateContext;
import org.apache.hadoop.ozone.container.ec.reconstruction.ECReconstructionCoordinatorTask;
import org.apache.hadoop.ozone.container.replication.AbstractReplicationTask.Status;
import org.apache.hadoop.ozone.container.replication.ReplicationServer.ReplicationConfig;
import org.apache.hadoop.util.Time;
Expand Down Expand Up @@ -224,6 +226,7 @@ private ReplicationSupervisor(StateContext context, ExecutorService executor,
}
}
registry = new MetricsRegistry(ReplicationSupervisor.class.getSimpleName());
initAllTaskCounters();
}

/**
Expand All @@ -247,19 +250,36 @@ private boolean queueHasRoomFor(AbstractReplicationTask task) {
return true;
}

private void initAllTaskCounters() {
initCounters(ReplicationTask.METRIC_NAME,
ReplicationTask.METRIC_DESCRIPTION_SEGMENT,
ReplicationTask.class.getSimpleName());
initCounters(ECReconstructionCoordinatorTask.METRIC_NAME,
ECReconstructionCoordinatorTask.METRIC_DESCRIPTION_SEGMENT,
ECReconstructionCoordinatorTask.class.getSimpleName());
initCounters(ReconcileContainerTask.METRIC_NAME,
ReconcileContainerTask.METRIC_DESCRIPTION_SEGMENT,
ReconcileContainerTask.class.getSimpleName());
}

public void initCounters(AbstractReplicationTask task) {
if (requestCounter.get(task.getMetricName()) == null) {
initCounters(task.getMetricName(), task.getMetricDescriptionSegment(),
task.getClass().getSimpleName());
}

public void initCounters(String metricName, String metricDescriptionSegment,
String taskSimpleName) {
Comment on lines +267 to +271
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it would be better to pass the class itself instead of its name. This would retain previous behavior of not having to call getSimpleName() for each task in the common case that metrics are already initialized.

if (requestCounter.get(metricName) == null) {
synchronized (this) {
if (requestCounter.get(task.getMetricName()) == null) {
requestCounter.put(task.getMetricName(), new AtomicLong(0));
successCounter.put(task.getMetricName(), new AtomicLong(0));
failureCounter.put(task.getMetricName(), new AtomicLong(0));
timeoutCounter.put(task.getMetricName(), new AtomicLong(0));
skippedCounter.put(task.getMetricName(), new AtomicLong(0));
queuedCounter.put(task.getMetricName(), new AtomicLong(0));
opsLatencyMs.put(task.getMetricName(), registry.newRate(
task.getClass().getSimpleName() + "Ms"));
METRICS_MAP.put(task.getMetricName(), task.getMetricDescriptionSegment());
if (requestCounter.get(metricName) == null) {
requestCounter.put(metricName, new AtomicLong(0));
successCounter.put(metricName, new AtomicLong(0));
failureCounter.put(metricName, new AtomicLong(0));
timeoutCounter.put(metricName, new AtomicLong(0));
skippedCounter.put(metricName, new AtomicLong(0));
queuedCounter.put(metricName, new AtomicLong(0));
opsLatencyMs.put(metricName, registry.newRate(taskSimpleName + "Ms"));
METRICS_MAP.put(metricName, metricDescriptionSegment);
}
}
}
Expand Down