Xushaohong commented on code in PR #4265:
URL: https://github.com/apache/ozone/pull/4265#discussion_r1104013443
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OzoneManager.java:
##########
@@ -3023,6 +3025,51 @@ public ServiceInfoEx getServiceInfo() throws IOException
{
return new ServiceInfoEx(getServiceList(), caCertPem, caCertPemList);
}
+ @Override
+ public void transferLeadership(String nodeId)
+ throws IOException {
+ final UserGroupInformation ugi = getRemoteUser();
+ if (!isAdmin(ugi)) {
+ throw new OMException(
+ "Only Ozone admins are allowed to transfer raft leadership.",
+ PERMISSION_DENIED);
+ }
+ if (!isRatisEnabled) {
+ throw new IOException("OM HA not enabled..");
+ }
+ boolean auditSuccess = true;
+ Map<String, String> auditMap = new LinkedHashMap<>();
+ auditMap.put("nodeId", nodeId);
+ try {
+ RaftGroupId groupID = omRatisServer.getRaftGroup().getGroupId();
+ RaftServer.Division division = omRatisServer.getServer()
+ .getDivision(groupID);
+ RaftPeerId targetPeerId;
+ if (nodeId.isEmpty()) {
+ RaftPeer curLeader = omRatisServer.getLeader();
+ targetPeerId = division.getGroup()
+ .getPeers().stream().filter(a -> !a.equals(curLeader)).findFirst()
+ .map(RaftPeer::getId).orElse(null);
Review Comment:
done
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]