smiklosovic commented on a change in pull request #1438:
URL: https://github.com/apache/cassandra/pull/1438#discussion_r799371360
##########
File path:
src/java/org/apache/cassandra/net/StartupClusterConnectivityChecker.java
##########
@@ -171,7 +172,10 @@ public boolean execute(Set<InetAddressAndPort> peers,
Function<InetAddressAndPor
{
// dc -> missing peer host addresses
Map<String, List<String>> peersDown =
acks.getMissingPeers().stream()
-
.collect(groupingBy(peerToDatacenter::get,
+ .collect(groupingBy(peer
-> {
+
String dc = peerToDatacenter.get(peer);
+
return dc != null ? dc :
StringUtils.defaultString(getDatacenterSource.apply(peer), "unknown");
Review comment:
can be reworked like this:
```
.collect(groupingBy(peer -> peerToDatacenter.getOrDefault(peer,
StringUtils.defaultString(getDatacenterSource.apply(peer), "unknown")),
mapping(InetAddressAndPort::getHostAddressAndPort, toList())));
```
EDIT: However, after think about it a little bit, I have to admit that I am
computing it unnecessarilly if it does not return null which differs with your
approach.
--
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]