-
Notifications
You must be signed in to change notification settings - Fork 616
HDDS-5401. Add more metrics to ReplicationManager to help monitor replication progress. #2382
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
Merged
Merged
Changes from 3 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
82a9da2
HDDS-5401. Add more metrics to ReplicationManager to help monitor rep…
7fda29d
Use inflightReplication/Deletion.size() for the 2 metrics.
72fa012
Add more tests to cover all metrics
7557ee6
Merge remote-tracking branch 'origin/master' into HDDS-5401
5b743ce
retrigger ci
a265938
retrigger ci
00adc5d
Merge remote-tracking branch 'origin/master' into HDDS-5401
7eaf2e9
retrigger ci
07aecdb
retrigger ci
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
154 changes: 154 additions & 0 deletions
154
...main/java/org/apache/hadoop/hdds/scm/container/replication/ReplicationManagerMetrics.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,154 @@ | ||
| /** | ||
| * 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 | ||
| * <p/> | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * <p/> | ||
| * 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.hadoop.hdds.scm.container.replication; | ||
|
|
||
| import org.apache.hadoop.hdds.scm.container.ReplicationManager; | ||
| import org.apache.hadoop.metrics2.annotation.Metric; | ||
| import org.apache.hadoop.metrics2.annotation.Metrics; | ||
| import org.apache.hadoop.metrics2.lib.DefaultMetricsSystem; | ||
| import org.apache.hadoop.metrics2.lib.MutableCounterLong; | ||
| import org.apache.hadoop.metrics2.lib.MutableGaugeLong; | ||
| import org.apache.hadoop.ozone.OzoneConsts; | ||
|
|
||
| /** | ||
| * Class contains metrics related to ReplicationManager. | ||
| */ | ||
| @Metrics(about = "Replication Manager Metrics", context = OzoneConsts.OZONE) | ||
| public final class ReplicationManagerMetrics { | ||
|
|
||
| public static final String METRICS_SOURCE_NAME = | ||
| ReplicationManagerMetrics.class.getSimpleName(); | ||
|
|
||
| @Metric("Tracked inflight container replication requests.") | ||
| private MutableGaugeLong inflightReplication; | ||
|
|
||
| @Metric("Tracked inflight container deletion requests.") | ||
| private MutableGaugeLong inflightDeletion; | ||
|
|
||
| @Metric("Number of replication commands sent.") | ||
| private MutableCounterLong numReplicationCmdsSent; | ||
|
|
||
| @Metric("Number of replication commands completed.") | ||
| private MutableCounterLong numReplicationCmdsCompleted; | ||
|
|
||
| @Metric("Number of replication commands timeout.") | ||
| private MutableCounterLong numReplicationCmdsTimeout; | ||
|
|
||
| @Metric("Number of deletion commands sent.") | ||
| private MutableCounterLong numDeletionCmdsSent; | ||
|
|
||
| @Metric("Number of deletion commands completed.") | ||
| private MutableCounterLong numDeletionCmdsCompleted; | ||
|
|
||
| @Metric("Number of deletion commands timeout.") | ||
| private MutableCounterLong numDeletionCmdsTimeout; | ||
|
|
||
| @Metric("Number of replication bytes total.") | ||
| private MutableCounterLong numReplicationBytesTotal; | ||
|
|
||
| @Metric("Number of replication bytes completed.") | ||
| private MutableCounterLong numReplicationBytesCompleted; | ||
|
|
||
| private ReplicationManager replicationManager; | ||
|
|
||
| public ReplicationManagerMetrics(ReplicationManager manager) { | ||
| this.replicationManager = manager; | ||
| } | ||
|
|
||
| public static ReplicationManagerMetrics create(ReplicationManager manager) { | ||
| return DefaultMetricsSystem.instance().register(METRICS_SOURCE_NAME, | ||
| "SCM Replication manager (closed container replication) related " | ||
| + "metrics", | ||
| new ReplicationManagerMetrics(manager)); | ||
| } | ||
|
|
||
| public void unRegister() { | ||
| DefaultMetricsSystem.instance().unregisterSource(METRICS_SOURCE_NAME); | ||
| } | ||
|
|
||
| public void incrNumReplicationCmdsSent() { | ||
| this.numReplicationCmdsSent.incr(); | ||
| } | ||
|
|
||
| public void incrNumReplicationCmdsCompleted() { | ||
| this.numReplicationCmdsCompleted.incr(); | ||
| } | ||
|
|
||
| public void incrNumReplicationCmdsTimeout() { | ||
| this.numReplicationCmdsTimeout.incr(); | ||
| } | ||
|
|
||
| public void incrNumDeletionCmdsSent() { | ||
| this.numDeletionCmdsSent.incr(); | ||
| } | ||
|
|
||
| public void incrNumDeletionCmdsCompleted() { | ||
| this.numDeletionCmdsCompleted.incr(); | ||
| } | ||
|
|
||
| public void incrNumDeletionCmdsTimeout() { | ||
| this.numDeletionCmdsTimeout.incr(); | ||
| } | ||
|
|
||
| public void incrNumReplicationBytesTotal(long bytes) { | ||
| this.numReplicationBytesTotal.incr(bytes); | ||
| } | ||
|
|
||
| public void incrNumReplicationBytesCompleted(long bytes) { | ||
| this.numReplicationBytesCompleted.incr(bytes); | ||
| } | ||
|
|
||
| public long getInflightReplication() { | ||
| return replicationManager.getInflightReplication().size(); | ||
| } | ||
|
|
||
| public long getInflightDeletion() { | ||
| return replicationManager.getInflightDeletion().size(); | ||
| } | ||
|
|
||
| public long getNumReplicationCmdsSent() { | ||
| return this.numReplicationCmdsSent.value(); | ||
| } | ||
|
|
||
| public long getNumReplicationCmdsCompleted() { | ||
| return this.numReplicationCmdsCompleted.value(); | ||
| } | ||
|
|
||
| public long getNumReplicationCmdsTimeout() { | ||
| return this.numReplicationCmdsTimeout.value(); | ||
| } | ||
|
|
||
| public long getNumDeletionCmdsSent() { | ||
| return this.numDeletionCmdsSent.value(); | ||
| } | ||
|
|
||
| public long getNumDeletionCmdsCompleted() { | ||
| return this.numDeletionCmdsCompleted.value(); | ||
| } | ||
|
|
||
| public long getNumDeletionCmdsTimeout() { | ||
| return this.numDeletionCmdsTimeout.value(); | ||
| } | ||
|
|
||
| public long getNumReplicationBytesTotal() { | ||
| return this.numReplicationBytesTotal.value(); | ||
| } | ||
|
|
||
| public long getNumReplicationBytesCompleted() { | ||
| return this.numReplicationBytesCompleted.value(); | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for the work! NIT: if RM start->stop->start,
ReplicationManagerMetrics#createwill be call twice ,and thusnew ReplicationManagerMetrics(manager)will be called twice, it seems a little confuse to create theReplicationManagerMetricstwice. i think it is better off usingregisterinstead ofcreateforReplicationManagerMetrics, and making ReplicationManagerMetrics singletonUh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, thanks for the comments, it seems to be reasonable to adopt singleton pattern at first glance.
But actually there are things to be made clear:
So what is the desired behavior?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general I prefer to avoid singletons, as they can make testing difficult, especially around Mini-Cluster tests.
I think its reasonable for a RM restart to reset the counts to zero, as it is a new instance. A RM restart should only happen in tests, as to restart it in a real cluster, you must restart all of SCM.