wuchong commented on code in PR #2098:
URL: https://github.com/apache/fluss/pull/2098#discussion_r2587250704
##########
fluss-common/src/main/java/org/apache/fluss/cluster/Cluster.java:
##########
@@ -155,7 +155,7 @@ public Map<Integer, ServerNode> getAliveTabletServers() {
}
public List<ServerNode> getAliveTabletServerList() {
- return aliveTabletServers;
+ return new ArrayList<>(aliveTabletServers);
Review Comment:
Do not copy at here, all the methods in Cluster, doesn't do a copy. Leave
the copy out of the method.
##########
fluss-client/src/main/java/org/apache/fluss/client/utils/MetadataUtils.java:
##########
@@ -253,10 +256,14 @@ public NewTableMetadata(
}
}
- public static ServerNode getOneAvailableTabletServerNode(Cluster cluster) {
+ public static @Nullable ServerNode getOneAvailableTabletServerNode(
+ Cluster cluster, Set<Integer> unavailableTabletServerIds) {
List<ServerNode> aliveTabletServers =
cluster.getAliveTabletServerList();
+ aliveTabletServers.removeIf(
+ serverNode ->
unavailableTabletServerIds.contains(serverNode.id()));
Review Comment:
1. copy the `cluster.getAliveTabletServerList()` into a new list
2. call `removeIf` only when `unavailableTabletServerIds` is not empty.
--
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]