-
Notifications
You must be signed in to change notification settings - Fork 24.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Transport client: Fix remove address to actually work #21743
Conversation
The removeTransportAddress method of TransportClient removes the address from the list of nodes that the client pings to sniff for nodes. However, it does not remove it from the list of existing connected nodes. This means removing a node is not possible, as long as that node is still up. This change removes the node from the connected nodes list before triggering sampling (ie sniffing). While the fix is simple, testing was not because there were no existing tests for sniffing. This change also modifies the mocks used by transport client unit tests in order to allow mocking sniffing.
Note I have marked this for 5.1 and 6.0. It should backport to 5.0.2 fine (I don't think there have been many changes, if any), but I would only do that if there is a strong need for it. |
@@ -547,6 +547,8 @@ protected void doRun() throws Exception { | |||
holderToNotify.handler().handleException(sendRequestException); | |||
} | |||
}); | |||
} else { | |||
logger.debug("Exception while sending request, handler likely already notified due to timeout", e); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note this debug statement is so that we do not completely swallow an exception where the holder has already been removed. This was causing an NPE I had while developing my mock code to be hidden. @jasontedor can explain more on why this is an "ok" case normally...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, just some nits, address at your discretion and fire at will.
} else { | ||
logger.debug("removing address [{}]", otherNode); | ||
logger.debug("removing address [{}] from list nodes", otherNode); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: list nodes
-> listed nodes
?
if (!otherNode.getAddress().equals(transportAddress)) { | ||
nodesBuilder.add(otherNode); | ||
} else { | ||
logger.debug("removing address [{}] from connected nodes", otherNode); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if this should say something more like disconnecting from node with address [{}]
?
ClusterState clusterState = getMockClusterState(node); | ||
transportResponseHandler.handleResponse(new ClusterStateResponse(clusterName, clusterState)); | ||
} else { | ||
throw new UnsupportedOperationException("Mock transport does not understand action " + action); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
checkRemoveAddress(false); | ||
} | ||
|
||
private void checkRemoveAddress(boolean sniff) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice tests.
Nice work @rjernst, thanks for adding the tests, I know that was where most of the work was and it's very much appreciated. |
retest this please |
* Transport client: Fix remove address to actually work The removeTransportAddress method of TransportClient removes the address from the list of nodes that the client pings to sniff for nodes. However, it does not remove it from the list of existing connected nodes. This means removing a node is not possible, as long as that node is still up. This change removes the node from the connected nodes list before triggering sampling (ie sniffing). While the fix is simple, testing was not because there were no existing tests for sniffing. This change also modifies the mocks used by transport client unit tests in order to allow mocking sniffing.
* Transport client: Fix remove address to actually work The removeTransportAddress method of TransportClient removes the address from the list of nodes that the client pings to sniff for nodes. However, it does not remove it from the list of existing connected nodes. This means removing a node is not possible, as long as that node is still up. This change removes the node from the connected nodes list before triggering sampling (ie sniffing). While the fix is simple, testing was not because there were no existing tests for sniffing. This change also modifies the mocks used by transport client unit tests in order to allow mocking sniffing.
* Transport client: Fix remove address to actually work The removeTransportAddress method of TransportClient removes the address from the list of nodes that the client pings to sniff for nodes. However, it does not remove it from the list of existing connected nodes. This means removing a node is not possible, as long as that node is still up. This change removes the node from the connected nodes list before triggering sampling (ie sniffing). While the fix is simple, testing was not because there were no existing tests for sniffing. This change also modifies the mocks used by transport client unit tests in order to allow mocking sniffing.
The removeTransportAddress method of TransportClient removes the address
from the list of nodes that the client pings to sniff for nodes.
However, it does not remove it from the list of existing connected
nodes. This means removing a node is not possible, as long as that node
is still up.
This change removes the node from the connected nodes list before
triggering sampling (ie sniffing). While the fix is simple, testing was
not because there were no existing tests for sniffing. This change also
modifies the mocks used by transport client unit tests in order to allow
mocking sniffing.