Currently, both the master and allocator track known roles in maps (note however that the master does not currently have complete tracking of known roles).
These Role structs track some information about roles, but currently do not track information hierarchically. As a result, when per-role resource quantities were exposed in the API, we had to add code outside of the master's Role struct to perform the hierarchical aggregation.
It would be nice if the master (and allocator) had a complete Role tree stored and updated in an event driven manner to obtain information cheaply at any point in time. Ideally this role tree abstraction can be shared (e.g. with the allocator) which may not be trivial since the information tracked might differ.