FewJuho commented on code in PR #11855:
URL: https://github.com/apache/ignite/pull/11855#discussion_r1967644448
##########
modules/core/src/main/java/org/apache/ignite/internal/client/thin/ReliableChannel.java:
##########
@@ -631,22 +631,23 @@ synchronized void initChannelHolders() {
return;
}
+ Map<InetSocketAddress, ClientChannelHolder> curAddrs = new HashMap<>();
+
+ Set<InetSocketAddress> newAddrsSet =
newAddrs.stream().flatMap(Collection::stream).collect(Collectors.toSet());
Review Comment:
Since an addr needs to be added, explicit reuse is not possible, but it can
be reused using streams
##########
modules/core/src/main/java/org/apache/ignite/internal/client/thin/ReliableChannel.java:
##########
@@ -678,29 +681,25 @@ synchronized void initChannelHolders() {
int idx = curChIdx;
- if (idx != -1)
+ if (idx != -1 && holders != null)
currDfltHolder = holders.get(idx);
- for (List<InetSocketAddress> addrs : newAddrs) {
- ClientChannelHolder hld = null;
+ for (InetSocketAddress addr : newAddrsSet) {
+ ClientChannelHolder hld = curAddrs.get(addr);
- // Try to find already created channel holder.
- for (InetSocketAddress addr : addrs) {
- hld = curAddrs.get(addr);
+ if (hld == null) {
+ List<InetSocketAddress> addrList = new ArrayList<>();
- if (hld != null) {
- if (!hld.getAddresses().equals(addrs)) // Enrich holder
addresses.
- hld.setConfiguration(new
ClientChannelConfiguration(clientCfg, addrs));
+ addrList.add(addr);
- break;
- }
+ hld = new ClientChannelHolder(new
ClientChannelConfiguration(clientCfg, addrList));
}
+ else if (!hld.getAddresses().contains(addr)) {
+ List<InetSocketAddress> newAddrList = new
ArrayList<>(hld.getAddresses());
Review Comment:
Since an addr needs to be added, explicit reuse is not possible, but it can
be reused using streams
--
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]