-
Notifications
You must be signed in to change notification settings - Fork 24.9k
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
Extract HttpClientStatsTracker #76279
Extract HttpClientStatsTracker #76279
Conversation
Extracts the functionality in `AbstractHttpServerTransport` that keeps track of the HTTP client stats so that it can be more easily tested in isolation.
Pinging @elastic/es-distributed (Team:Distributed) |
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 just a mechanical move of the code, except as noted in comments below. I'll follow up with some tests and actual changes but it'll be easier to follow them if we do this first.
// when disabling, immediately clear client stats | ||
httpChannelStats.clear(); | ||
} | ||
return new HttpStats(httpClientStatsTracker.getClientStats(), httpChannels.size(), totalChannelsAccepted.get()); |
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.
getClientStats
also does the prune.
} | ||
|
||
protected void bindServer() { | ||
// Bind and start to accept incoming connections. | ||
InetAddress hostAddresses[]; | ||
final InetAddress[] hostAddresses; |
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.
Unrelated, but fixes the only warning left in this file.
} | ||
} catch (Exception e) { | ||
assert false : e; // the listener code above should never throw | ||
logger.warn("error removing HTTP channel listener", 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.
Promoted to WARN
, as the comment says this should never happen but if it does then it'd be good to hear about it.
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 :)
*/ | ||
private static int getChannelKey(HttpChannel channel) { | ||
// always use an identity-based hash code rather than one based on object state | ||
return System.identityHashCode(channel); |
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.
Unrelated comment but isn't this broken? I guess it's approximately ok and that might be good enough for the stats, but shouldn't we have a collision safer key here for the stats map?
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. Thanks for improving this, @DaveCTurner.
Extracts the functionality in `AbstractHttpServerTransport` that keeps track of the HTTP client stats so that it can be more easily tested in isolation.
Extracts the functionality in
AbstractHttpServerTransport
that keepstrack of the HTTP client stats so that it can be more easily tested in
isolation.