Skip to content

Commit

Permalink
fix targetsbynode logic
Browse files Browse the repository at this point in the history
Signed-off-by: Rahul Karajgikar <[email protected]>
  • Loading branch information
Rahul Karajgikar committed Sep 6, 2024
1 parent b0a7ae3 commit 0d3db12
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,9 @@ public void disconnectFromNodesExcept(DiscoveryNodes discoveryNodes) {
// to avoid permanently blocking node joins
// This situation should ideally not happen, this is just for extra safety
transportService.removePendingDisconnections(
targetsByNode.keySet()
transportService.getPendingDisconnections()
.stream()
.filter(discoveryNode -> !discoveryNodes.nodeExists(discoveryNode))
.filter(discoveryNode -> !discoveryNodes.nodeExists(discoveryNode) && !targetsByNode.containsKey(discoveryNode))
.collect(Collectors.toSet())
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,11 @@ public void disconnectFromNode(DiscoveryNode node) {
logger.debug("Removed node [{}] from pending disconnections list", node);
}

@Override
public Set<DiscoveryNode> getPendingDisconnections() {
return pendingDisconnections;
}

@Override
public void setPendingDisconnection(DiscoveryNode node) {
logger.debug("marking disconnection as pending for node: [{}]", node);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ void connectToNode(

void disconnectFromNode(DiscoveryNode node);

Set<DiscoveryNode> getPendingDisconnections();

void setPendingDisconnection(DiscoveryNode node);

void removePendingDisconnection(DiscoveryNode node);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,11 @@ public void disconnectFromNode(DiscoveryNode node) {
delegate.disconnectFromNode(node);
}

@Override
public Set<DiscoveryNode> getPendingDisconnections() {
return delegate.getPendingDisconnections();
}

@Override
public void setPendingDisconnection(DiscoveryNode node) {
delegate.setPendingDisconnection(node);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -773,6 +773,10 @@ public void disconnectFromNode(DiscoveryNode node) {
connectionManager.disconnectFromNode(node);
}

public Set<DiscoveryNode> getPendingDisconnections() {
return connectionManager.getPendingDisconnections();
}

public void setPendingDisconnections(Set<DiscoveryNode> nodes) {
nodes.forEach(connectionManager::setPendingDisconnection);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,11 @@ public void disconnectFromNode(DiscoveryNode node) {
delegate.disconnectFromNode(node);
}

@Override
public Set<DiscoveryNode> getPendingDisconnections() {
return delegate.getPendingDisconnections();
}

@Override
public void setPendingDisconnection(DiscoveryNode node) {
delegate.setPendingDisconnection(node);
Expand Down

0 comments on commit 0d3db12

Please sign in to comment.