-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Improved Connection Count server select strategy #15975
Improved Connection Count server select strategy #15975
Conversation
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.
The description could use some clarity. If creating connection to a node is slow, then that slowness wouldn't be accounted for if we count the open connections after sending the request. So we increment the counter and then send the request.
catch (RuntimeException e) { | ||
if (openConnections.get() > 0) { | ||
openConnections.getAndDecrement(); | ||
} | ||
throw 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.
This could be moved to after httpClient.go
call. Also, why not decrement the counter for any exception and why is there a check on get() > 0
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.
added just to be on safe side, But it will never happen. Will remove the condition.
EasyMock.expect( | ||
httpClient.go( | ||
EasyMock.capture(capturedRequest), | ||
EasyMock.<HttpResponseHandler>anyObject(), | ||
EasyMock.anyObject(Duration.class) | ||
) | ||
) | ||
httpClient.go( | ||
EasyMock.capture(capturedRequest), | ||
EasyMock.<HttpResponseHandler>anyObject(), | ||
EasyMock.anyObject(Duration.class) | ||
) | ||
) |
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.
This re-formatting shouldn't have happened. Are you using a different checkstyle?
@@ -427,4 +431,47 @@ public void testQueryTimeoutFromFuture() | |||
Assert.assertEquals(hostName, actualException.getHost()); | |||
EasyMock.verify(httpClient); | |||
} | |||
|
|||
@Test | |||
public void testRuntimeException() throws JsonProcessingException |
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.
This is too generic test name. I would suggest testConnectionCountAfterException
public void testRuntimeException() throws JsonProcessingException | ||
{ | ||
ObjectMapper mockObjectMapper = EasyMock.createMock(ObjectMapper.class); | ||
EasyMock.expect(mockObjectMapper.writeValueAsBytes(EasyMock.anyObject())) |
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.
lets intercept this call only when an object of type query is being serialized.
Fixes #XXXX.
Description
Updated the Direct Druid Client so as to make Connection Count Server Selector Strategy work more efficiently.
If creating connection to a node is slow, then that slowness wouldn't be accounted for if we count the open connections after sending the request. So we increment the counter and then send the request.
Fixed the bug ...
Currently if a connection of server is blocked in creating a future job to run the query, it is not being counted resulting in the selector strategy allotting a new connection to same server.
Fixed this behaviour by incrementing the connection count prior to the start of future.
Release note
Key changed/added classes in this PR
DirectDruidClient
DirectDruidClientTest
This PR has: