-
Notifications
You must be signed in to change notification settings - Fork 592
HDDS-7721. Make OM Ratis roles available in /prom endpoint #4140
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
Changes from all commits
492048a
12d620b
abf2de1
b731eea
732bd36
e836659
69ca1ac
4d608b0
5a4e484
579778a
34cf3f3
dd60ffc
ac49ca7
3100c35
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -51,6 +51,7 @@ | |
| import java.util.stream.Collectors; | ||
|
|
||
| import com.google.common.base.Optional; | ||
| import com.google.common.base.Strings; | ||
| import com.google.common.collect.ImmutableSortedSet; | ||
| import com.google.common.collect.Lists; | ||
| import org.apache.hadoop.conf.Configuration; | ||
|
|
@@ -82,6 +83,7 @@ | |
| import org.apache.hadoop.hdds.utils.db.Table.KeyValue; | ||
| import org.apache.hadoop.hdds.utils.db.TableIterator; | ||
| import org.apache.hadoop.ozone.OzoneManagerVersion; | ||
| import org.apache.hadoop.ozone.om.ha.OMHAMetrics; | ||
| import org.apache.hadoop.ozone.om.helpers.KeyInfoWithVolumeContext; | ||
| import org.apache.hadoop.ozone.om.helpers.SnapshotInfo; | ||
| import org.apache.hadoop.ozone.om.request.OMClientRequest; | ||
|
|
@@ -347,6 +349,7 @@ public final class OzoneManager extends ServiceRuntimeInfoImpl | |
| private final OzoneAdmins s3OzoneAdmins; | ||
|
|
||
| private final OMMetrics metrics; | ||
| private OMHAMetrics omhaMetrics; | ||
| private final ProtocolMessageMetrics<ProtocolMessageEnum> | ||
| omClientProtocolMetrics; | ||
| private OzoneManagerHttpServer httpServer; | ||
|
|
@@ -1894,6 +1897,26 @@ public void updatePeerList(List<String> newPeers) { | |
| } | ||
| } | ||
| } | ||
| RaftPeer leader = null; | ||
| try { | ||
| leader = omRatisServer.getLeader(); | ||
| } catch (IOException ex) { | ||
| LOG.error("IOException while getting the " + | ||
| "Ratis server leader.", ex); | ||
| } | ||
| if (Objects.nonNull(leader)) { | ||
| String leaderId = leader.getId().toString(); | ||
|
|
||
| // If leaderId is empty, then leader is undefined | ||
| // and current OM is neither leader nor follower. | ||
| // OMHAMetrics shouldn't be registered in that case. | ||
| if (!Strings.isNullOrEmpty(leaderId)) { | ||
|
Comment on lines
+1900
to
+1913
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. I had to update this part of the code after merging the PR due to a conflicting change that had been just merged (HDDS-6743, Upon closer inspection, I think these I think it should be: if (Objects.nonNull(leader)) {
// init
} else {
// unregister
}
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. @adoroszlai You are right. This was missed because the code was String leaderId = "";
try{
leader =
} catch() {
}
if (Objects.nonNull(leader)) {
}
// leaderId could be deliberately left empty down here due to failure to get the leader
// after refactoring `String leaderId = "";` was removed.
I didn't know that. How can we handle this now since the code has been merged?
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. Thanks @xBis7 for checking.
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. @adoroszlai Thanks! I'll create a patch shortly for HDDS-8009.
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. Thanks @adoroszlai for merging and uncovering this change. With |
||
| omHAMetricsInit(leaderId); | ||
| } else { | ||
| // unregister, to get rid of stale metrics | ||
| OMHAMetrics.unRegister(); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -2160,6 +2183,7 @@ public void stop() { | |
| if (omRatisServer != null) { | ||
| omRatisServer.stop(); | ||
| omRatisServer = null; | ||
| OMHAMetrics.unRegister(); | ||
| } | ||
| isOmRpcServerRunning = false; | ||
| if (isOmGrpcServerEnabled) { | ||
|
|
@@ -2911,6 +2935,22 @@ public String getRatisRoles() { | |
| } | ||
| } | ||
|
|
||
| /** | ||
| * Create OMHAMetrics instance. | ||
| */ | ||
| private void omHAMetricsInit(String leaderId) { | ||
| // unregister, in case metrics already exist | ||
| // so that the metric tags will get updated. | ||
| OMHAMetrics.unRegister(); | ||
| omhaMetrics = OMHAMetrics | ||
| .create(getOMNodeId(), leaderId); | ||
| } | ||
|
|
||
| @VisibleForTesting | ||
| public OMHAMetrics getOmhaMetrics() { | ||
| return omhaMetrics; | ||
| } | ||
|
|
||
| public String getRatisLogDirectory() { | ||
| return OzoneManagerRatisUtils.getOMRatisDirectory(configuration); | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.