Copilot commented on code in PR #7262:
URL: https://github.com/apache/ozone/pull/7262#discussion_r2252216405
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/ratis/OzoneManagerRatisServer.java:
##########
@@ -408,10 +422,44 @@ public void removeOMFromRatisRing(OMNodeDetails
removeOMNode)
/**
* Return a list of peer NodeIds.
*/
- public Set<String> getPeerIds() {
+ public Set<String> getAllPeerIds() {
return Collections.unmodifiableSet(raftPeerMap.keySet());
}
+ public List<String> getFollowerIds() {
+ return raftPeerMap.entrySet().stream()
+ .filter(entry -> entry.getValue().getStartupRole() ==
RaftPeerRole.FOLLOWER)
+ .map(Map.Entry::getKey)
+ .collect(Collectors.toList());
+ }
+
+ public List<String> getListenerIds() {
+ return raftPeerMap.entrySet().stream()
+ .filter(entry -> entry.getValue().getStartupRole() ==
RaftPeerRole.FOLLOWER)
Review Comment:
The filter condition is checking for FOLLOWER role but the method is named
`getListenerIds()`. This should filter for LISTENER role instead.
```suggestion
.filter(entry -> entry.getValue().getStartupRole() ==
RaftPeerRole.LISTENER)
```
##########
hadoop-ozone/mini-cluster/src/main/java/org/apache/hadoop/ozone/MiniOzoneHAClusterImpl.java:
##########
@@ -784,15 +789,19 @@ public void bootstrapOzoneManager(String omNodeId,
* Set the configs for new OMs.
*/
private OzoneConfiguration addNewOMToConfig(String omServiceId,
- String omNodeId) {
-
+ String omNodeId, boolean isListener) {
OzoneConfiguration newConf = new OzoneConfiguration(getConf());
configureOMPorts(newConf, omServiceId, omNodeId);
String omNodesKey = ConfUtils.addKeySuffixes(
OMConfigKeys.OZONE_OM_NODES_KEY, omServiceId);
newConf.set(omNodesKey, newConf.get(omNodesKey) + "," + omNodeId);
+ if (isListener) {
+ String listenerOmNodesKey = ConfUtils.addKeySuffixes(
+ OMConfigKeys.OZONE_OM_LISTENER_NODES_KEY, omServiceId);
+ newConf.set(listenerOmNodesKey, newConf.get(listenerOmNodesKey) + "," +
omNodeId);
Review Comment:
Potential null pointer exception if `newConf.get(listenerOmNodesKey)`
returns null. Should handle the case where the listener nodes key doesn't exist
yet.
```suggestion
String existingListenerNodes = newConf.get(listenerOmNodesKey);
if (existingListenerNodes == null || existingListenerNodes.isEmpty()) {
newConf.set(listenerOmNodesKey, omNodeId);
} else {
newConf.set(listenerOmNodesKey, existingListenerNodes + "," +
omNodeId);
}
```
--
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]