Skip to content
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

Conversation

DaveCTurner
Copy link
Contributor

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 keeps
track of the HTTP client stats so that it can be more easily tested in
isolation.
@DaveCTurner DaveCTurner added :Distributed Coordination/Network Http and internode communication implementations >refactoring v8.0.0 v7.15.0 labels Aug 10, 2021
@elasticmachine elasticmachine added the Team:Distributed (Obsolete) Meta label for distributed team (obsolete). Replaced by Distributed Indexing/Coordination. label Aug 10, 2021
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-distributed (Team:Distributed)

Copy link
Contributor Author

@DaveCTurner DaveCTurner left a 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());
Copy link
Contributor Author

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;
Copy link
Contributor Author

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);
Copy link
Contributor Author

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.

Copy link
Member

@original-brownbear original-brownbear left a 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);
Copy link
Member

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?

Copy link
Contributor

@danhermann danhermann left a 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.

@DaveCTurner DaveCTurner merged commit 8cc8043 into elastic:master Aug 10, 2021
@DaveCTurner DaveCTurner deleted the 2021-08-10-extract-HttpClientStatsTracker branch August 10, 2021 17:33
DaveCTurner added a commit that referenced this pull request Aug 10, 2021
Extracts the functionality in `AbstractHttpServerTransport` that keeps
track of the HTTP client stats so that it can be more easily tested in
isolation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Distributed Coordination/Network Http and internode communication implementations >refactoring Team:Distributed (Obsolete) Meta label for distributed team (obsolete). Replaced by Distributed Indexing/Coordination. v7.15.0 v8.0.0-alpha2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants