Skip to content

KAFKA-15556: Remove NetworkClientDelegate methods isUnavailable, maybeThrowAuthFailure, and tryConnect #15020

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

Open
wants to merge 3 commits into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,22 @@ public class FetchRequestManager extends AbstractFetch implements RequestManager
this.networkClientDelegate = networkClientDelegate;
}

/**
* Node's availability will be checked at a later stage, so we default to return false.
* @param node {@link Node} to check for availability
* @return
*/
@Override
protected boolean isUnavailable(Node node) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does seem a bit like half a refactor. Would it be possible to remove isUnavailable and maybeThrowAuthFailure entirely from AbstractFetch?

return networkClientDelegate.isUnavailable(node);
return false;
}

/**
* Authentication failure will be checked at a later stage, so we do nothing here.
* @param node {@link Node} to check for a previous {@link AuthenticationException}; if found it is thrown
*/
@Override
protected void maybeThrowAuthFailure(Node node) {
networkClientDelegate.maybeThrowAuthFailure(node);
}
protected void maybeThrowAuthFailure(Node node) {}

/**
* {@inheritDoc}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,27 +81,6 @@ Queue<UnsentRequest> unsentRequests() {
return unsentRequests;
}

/**
* Check if the node is disconnected and unavailable for immediate reconnection (i.e. if it is in
* reconnect backoff window following the disconnect).
*
* @param node {@link Node} to check for availability
* @see NetworkClientUtils#isUnavailable(KafkaClient, Node, Time)
*/
public boolean isUnavailable(Node node) {
return NetworkClientUtils.isUnavailable(client, node, time);
}

/**
* Checks for an authentication error on a given node and throws the exception if it exists.
*
* @param node {@link Node} to check for a previous {@link AuthenticationException}; if found it is thrown
* @see NetworkClientUtils#maybeThrowAuthFailure(KafkaClient, Node)
*/
public void maybeThrowAuthFailure(Node node) {
NetworkClientUtils.maybeThrowAuthFailure(client, node);
}

/**
* Initiate a connection if currently possible. This is only really useful for resetting
* the failed status of a socket.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -781,10 +781,10 @@ public void testFetchSkipsBlackedOutNodes() {
Node node = initialUpdateResponse.brokers().iterator().next();

client.backoff(node, 500);
assertEquals(0, sendFetches());
assertEquals(1, sendFetches());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are you changing the tests?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we're not checking the node availablity using the networkClientDelegate in FetchRequestManager, the request that was made would pass through the check and made it way to unsentRequest. After the backoff the request should be sent already.

Should I not change the test and make new one instead?


time.sleep(500);
assertEquals(1, sendFetches());
assertEquals(0, sendFetches());
}

@Test
Expand Down