Skip to content

Give NodeInfo a more flexible serialization/deserialization style#54305

Closed
williamrandolph wants to merge 6 commits intoelastic:masterfrom
williamrandolph:nodes-info-response-transport-refactor
Closed

Give NodeInfo a more flexible serialization/deserialization style#54305
williamrandolph wants to merge 6 commits intoelastic:masterfrom
williamrandolph:nodes-info-response-transport-refactor

Conversation

@williamrandolph
Copy link
Copy Markdown
Contributor

In #53140, we changed the NodesInfoRequest class so that its serialization could handle requests for arbitrary lists of metrics rather than a hard-coded group. Now we need to do something similar for the response. NodesInfoResponse just rolls up a list of NodeInfo objects, so this work really needs to happen in NodeInfo.

There are two features of the NodeInfo class that have made this a little tricky

  1. The blocks of "info" are heterogeneous. All they really have in common is that they are Writeables.
  2. Other classes, in particular ClusterStatsNodes, access some of the info objects in order to aggregate information from different nodes.

At this stage of the refactoring, it doesn't seem possible to treat the blocks of info as maps of strings. It seems that we still need to be able to deserialize into objects.

For my first approach, I've tried to leverage the existing NamedWriteable code to read the info objects out of the stream. I've created a ReportingService interface and a ReportingService.Info interface in order to mark the classes that can be used as info blocks; perhaps this is overkill at this stage. I've also used a map keyed on classes in order to handle all casting within this class. Instead of calling OsInfo os = nodeInfo.getOs(), we can now call OsInfo os = nodeInfo.getInfo(OsInfo.class).

We have talked about, in the long run, serializing and deserializing these blocks of info as Map<String, Map<String, String>> types. If we do that, it seems like we might have to take a significantly different approach to calculating cluster stats. At the moment, cluster stats uses NodesInfo and NodesStats requests as a way to bundle the various info and stats objects it needs to aggregate. I am still thinking through how to get there from here.

I don't want to merge this PR unless we're sure it's the right way forward, but I would like to get some feedback on it.

This is a first cut at giving NodeInfo the ability to carry a flexible
list of heterogeneous info responses. The trick is to be able to
serialize and deserialize an arbitrary list of blocks of information. It
is convenient to be able to deserialize into usable Java objects so that
we can aggregate nodes stats for the cluster stats endpoint.

In order to provide a little bit of clarity about which objects can and
can't be used as info blocks, I've introduced a new interface called
"ReportingService."
@elasticmachine
Copy link
Copy Markdown
Collaborator

Pinging @elastic/es-core-infra (:Core/Infra/Plugins)

@williamrandolph
Copy link
Copy Markdown
Contributor Author

One option I have here is that I could use the map of "ReportingService.Info" objects and see how well it works as the refactoring proceeds, but hold off on changing the serialization for as long as possible, i.e., until we actually start plugging in other reporting services. The more I think about this, the more I like the idea.

@williamrandolph
Copy link
Copy Markdown
Contributor Author

Yeah, I'm going to punt on changing the response serialization until I'm more sure of what I want it to look like. I'll issue a new PR with the part of this work that doesn't affect serialization.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants