-
Notifications
You must be signed in to change notification settings - Fork 587
HDDS-11711. Add SCM metrics for delete commands sent and response received per datanode #7522
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 6 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
f5f4098
HDDS-11711. Add metrics in SCM to print number of delete command sent…
2092fbd
Remove unnecessary annotations
af41d82
Add assert for new metrics in tests
48646ac
Remove env change in docker file
bc68a5f
rearrange code in metrics class
941c4f6
checkstyle fix
12a971a
Use concurrentHashMap and remove unnecessary test annotations
ef499e1
final variable
72518d1
synchronized initialization of static instance
76a5829
Change local variable names
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
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
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 |
|---|---|---|
|
|
@@ -19,23 +19,37 @@ | |
|
|
||
| package org.apache.hadoop.hdds.scm.block; | ||
|
|
||
| import com.google.common.annotations.VisibleForTesting; | ||
| import org.apache.hadoop.metrics2.MetricsInfo; | ||
| import org.apache.hadoop.metrics2.MetricsCollector; | ||
| import org.apache.hadoop.metrics2.MetricsRecordBuilder; | ||
| import org.apache.hadoop.metrics2.MetricsSource; | ||
| import org.apache.hadoop.metrics2.MetricsSystem; | ||
| import org.apache.hadoop.metrics2.MetricsTag; | ||
| 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.metrics2.lib.MetricsRegistry; | ||
| import org.apache.hadoop.metrics2.lib.Interns; | ||
|
|
||
| import java.util.Map; | ||
| import java.util.UUID; | ||
| import java.util.HashMap; | ||
|
|
||
| /** | ||
| * Metrics related to Block Deleting Service running in SCM. | ||
| */ | ||
| @Metrics(name = "ScmBlockDeletingService Metrics", about = "Metrics related to " | ||
| + "background block deleting service in SCM", context = "SCM") | ||
| public final class ScmBlockDeletingServiceMetrics { | ||
| public final class ScmBlockDeletingServiceMetrics implements MetricsSource { | ||
|
|
||
| private static ScmBlockDeletingServiceMetrics instance; | ||
| public static final String SOURCE_NAME = | ||
| SCMBlockDeletingService.class.getSimpleName(); | ||
| private final MetricsRegistry registry; | ||
|
|
||
| /** | ||
| * Given all commands are finished and no new coming deletes from OM. | ||
|
|
@@ -86,7 +100,11 @@ public final class ScmBlockDeletingServiceMetrics { | |
| @Metric(about = "The number of dataNodes of delete transactions.") | ||
| private MutableGaugeLong numBlockDeletionTransactionDataNodes; | ||
|
|
||
| private Map<UUID, DatanodeCommandCounts> numCommandsDatanode; | ||
|
|
||
| private ScmBlockDeletingServiceMetrics() { | ||
| this.registry = new MetricsRegistry(SOURCE_NAME); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. verify if registry can be removed ... seems no usages here.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we remove it we get this error: So we require it. |
||
| numCommandsDatanode = new HashMap<>(); | ||
Tejaskriya marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| public static ScmBlockDeletingServiceMetrics create() { | ||
|
|
@@ -152,6 +170,19 @@ public void setNumBlockDeletionTransactionDataNodes(long dataNodes) { | |
| this.numBlockDeletionTransactionDataNodes.set(dataNodes); | ||
| } | ||
|
|
||
| public void incrDNCommandsSent(UUID id, long delta) { | ||
| numCommandsDatanode.computeIfAbsent(id, k -> new DatanodeCommandCounts()) | ||
| .incrCommandsSent(delta); | ||
| } | ||
| public void incrDNCommandsSuccess(UUID id, long delta) { | ||
| numCommandsDatanode.computeIfAbsent(id, k -> new DatanodeCommandCounts()) | ||
| .incrCommandsSuccess(delta); | ||
| } | ||
| public void incrDNCommandsFailure(UUID id, long delta) { | ||
| numCommandsDatanode.computeIfAbsent(id, k -> new DatanodeCommandCounts()) | ||
| .incrCommandsFailure(delta); | ||
| } | ||
|
|
||
| public long getNumBlockDeletionCommandSent() { | ||
| return numBlockDeletionCommandSent.value(); | ||
| } | ||
|
|
@@ -196,6 +227,119 @@ public long getNumBlockDeletionTransactionDataNodes() { | |
| return numBlockDeletionTransactionDataNodes.value(); | ||
| } | ||
|
|
||
| public Map<UUID, DatanodeCommandCounts> getNumCommandsDatanode() { | ||
| return numCommandsDatanode; | ||
| } | ||
|
|
||
| @Override | ||
| public void getMetrics(MetricsCollector metricsCollector, boolean all) { | ||
| MetricsRecordBuilder builder = metricsCollector.addRecord(SOURCE_NAME); | ||
| numBlockDeletionCommandSent.snapshot(builder, all); | ||
| numBlockDeletionCommandSuccess.snapshot(builder, all); | ||
| numBlockDeletionCommandFailure.snapshot(builder, all); | ||
| numBlockDeletionTransactionSent.snapshot(builder, all); | ||
| numBlockDeletionTransactionSuccess.snapshot(builder, all); | ||
| numBlockDeletionTransactionFailure.snapshot(builder, all); | ||
| numBlockDeletionTransactionCompleted.snapshot(builder, all); | ||
| numBlockDeletionTransactionCreated.snapshot(builder, all); | ||
| numSkippedTransactions.snapshot(builder, all); | ||
| numProcessedTransactions.snapshot(builder, all); | ||
| numBlockDeletionTransactionDataNodes.snapshot(builder, all); | ||
|
|
||
| MetricsRecordBuilder recordBuilder = builder; | ||
| for (Map.Entry<UUID, DatanodeCommandCounts> e : numCommandsDatanode.entrySet()) { | ||
| recordBuilder = recordBuilder.endRecord().addRecord(SOURCE_NAME) | ||
| .add(new MetricsTag(Interns.info("datanode", | ||
| "Datanode host for deletion commands"), e.getKey().toString())) | ||
| .addGauge(DatanodeCommandCounts.COMMANDS_SENT_TO_DN, | ||
| e.getValue().getCommandsSent()) | ||
| .addGauge(DatanodeCommandCounts.COMMANDS_SUCCESSFUL_EXECUTION_BY_DN, | ||
| e.getValue().getCommandsSuccess()) | ||
| .addGauge(DatanodeCommandCounts.COMMANDS_FAILED_EXECUTION_BY_DN, | ||
| e.getValue().getCommandsFailure()); | ||
| } | ||
| recordBuilder.endRecord(); | ||
| } | ||
|
|
||
| /** | ||
| * Class contains metrics related to the ScmBlockDeletingService for each datanode. | ||
| */ | ||
| public static final class DatanodeCommandCounts { | ||
| private long commandsSent; | ||
| private long commandsSuccess; | ||
| private long commandsFailure; | ||
|
|
||
| private static final MetricsInfo COMMANDS_SENT_TO_DN = Interns.info( | ||
| "CommandsSent", | ||
| "Number of commands sent from SCM to the datanode for deletion"); | ||
| private static final MetricsInfo COMMANDS_SUCCESSFUL_EXECUTION_BY_DN = Interns.info( | ||
| "CommandsSuccess", | ||
| "Number of commands sent from SCM to the datanode for deletion for which execution succeeded."); | ||
| private static final MetricsInfo COMMANDS_FAILED_EXECUTION_BY_DN = Interns.info( | ||
| "CommandsFailed", | ||
| "Number of commands sent from SCM to the datanode for deletion for which execution failed."); | ||
|
|
||
| public DatanodeCommandCounts() { | ||
| this.commandsSent = 0; | ||
| this.commandsSuccess = 0; | ||
| this.commandsFailure = 0; | ||
| } | ||
|
|
||
| public void incrCommandsSent(long delta) { | ||
| this.commandsSent += delta; | ||
| } | ||
|
|
||
| public void incrCommandsSuccess(long delta) { | ||
| this.commandsSuccess += delta; | ||
| } | ||
|
|
||
| public void incrCommandsFailure(long delta) { | ||
| this.commandsFailure += delta; | ||
| } | ||
|
|
||
| public long getCommandsSent() { | ||
| return commandsSent; | ||
| } | ||
|
|
||
| public long getCommandsSuccess() { | ||
| return commandsSuccess; | ||
| } | ||
|
|
||
| public long getCommandsFailure() { | ||
| return commandsFailure; | ||
| } | ||
|
|
||
| @Override | ||
| public String toString() { | ||
| return "Sent=" + commandsSent + ", Success=" + commandsSuccess + ", Failed=" + commandsFailure; | ||
| } | ||
| } | ||
|
|
||
| @VisibleForTesting | ||
Tejaskriya marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| public int getNumCommandsDatanodeSent() { | ||
| int sent = 0; | ||
Tejaskriya marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| for (Map.Entry<UUID, DatanodeCommandCounts> e : numCommandsDatanode.entrySet()) { | ||
| sent += e.getValue().commandsSent; | ||
Tejaskriya marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
| return sent; | ||
| } | ||
| @VisibleForTesting | ||
| public int getNumCommandsDatanodeSuccess() { | ||
| int sent = 0; | ||
| for (Map.Entry<UUID, DatanodeCommandCounts> e : numCommandsDatanode.entrySet()) { | ||
| sent += e.getValue().commandsSuccess; | ||
| } | ||
| return sent; | ||
| } | ||
| @VisibleForTesting | ||
| public int getNumCommandsDatanodeFailed() { | ||
| int sent = 0; | ||
| for (Map.Entry<UUID, DatanodeCommandCounts> e : numCommandsDatanode.entrySet()) { | ||
| sent += e.getValue().commandsFailure; | ||
| } | ||
| return sent; | ||
| } | ||
|
|
||
| @Override | ||
| public String toString() { | ||
| StringBuffer buffer = new StringBuffer(); | ||
|
|
@@ -214,7 +358,9 @@ public String toString() { | |
| .append("numBlockDeletionTransactionSuccess = " | ||
| + numBlockDeletionTransactionSuccess.value()).append("\t") | ||
| .append("numBlockDeletionTransactionFailure = " | ||
| + numBlockDeletionTransactionFailure.value()); | ||
| + numBlockDeletionTransactionFailure.value()).append("\t") | ||
| .append("numDeletionCommandsPerDatanode = " | ||
| + numCommandsDatanode); | ||
| return buffer.toString(); | ||
| } | ||
| } | ||
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
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.
Uh oh!
There was an error while loading. Please reload this page.