diff options
| author | Ed Tanous <ed.tanous@intel.com> | 2018-11-12 15:17:05 -0800 |
|---|---|---|
| committer | Ed Tanous <ed.tanous@intel.com> | 2018-11-26 09:08:11 -0800 |
| commit | 0f74e643ec246c333ef4724af1ecd5adeb1b6658 (patch) | |
| tree | 37547678cbfd59f8eb67658c87b350073d0e9139 /redfish-core/include | |
| parent | 244365165adba1bc6b96aebbd7d305b055f379b1 (diff) | |
| download | bmcweb-0f74e643ec246c333ef4724af1ecd5adeb1b6658.tar.gz bmcweb-0f74e643ec246c333ef4724af1ecd5adeb1b6658.zip | |
bmcweb: Redfish away from json cache
In the original incarnation of bmcweb, route registration was done
automatically. This has proved to be a terrible idea, wraught with
corner cases and issues.
The route registration is currently the only user of the
redfish::Node::json element. Unfortunately, as written, this structure
consumes a lot of memory that's duplicated and not very useful. From a
performance perspective, there is almost no difference between
rebuilding the structure for each GET request, and having the "cache"
that needs to be copied into the response and modified before it can be
useful.
In the programming tradeoffs for bmc, lower memory usage is more important
than latency, especially at these levels.
Change-Id: I785e8352123e5e886acf05cd59cb23648f93839d
Signed-off-by: Ed Tanous <ed.tanous@intel.com>
Diffstat (limited to 'redfish-core/include')
| -rw-r--r-- | redfish-core/include/node.hpp | 65 | ||||
| -rw-r--r-- | redfish-core/include/redfish.hpp | 5 |
2 files changed, 0 insertions, 70 deletions
diff --git a/redfish-core/include/node.hpp b/redfish-core/include/node.hpp index 41257e0..049393f 100644 --- a/redfish-core/include/node.hpp +++ b/redfish-core/include/node.hpp @@ -67,69 +67,6 @@ class Node virtual ~Node() = default; - const std::string* getUrl() const - { - auto odataId = json.find("@odata.id"); - if (odataId == json.end()) - { - return nullptr; - } - - return odataId->get_ptr<const std::string*>(); - } - - /** - * @brief Inserts subroute fields into for the node's json in the form: - * "subroute_name" : { "odata.id": "node_url/subroute_name/" } - * Excludes metadata urls starting with "$" and child urls having - * more than one level. - * - * @return None - */ - void getSubRoutes(const std::vector<std::unique_ptr<Node>>& allNodes) - { - const std::string* url = getUrl(); - if (url == nullptr) - { - // BMCWEB_LOG_CRITICAL << "Unable to get url for route"; - return; - } - - for (const auto& node : allNodes) - { - const std::string* route = node->getUrl(); - if (route == nullptr) - { - // BMCWEB_LOG_CRITICAL << "Unable to get url for route"; - continue; - } - if (boost::starts_with(*route, *url)) - { - std::string subRoute = route->substr(url->size()); - if (subRoute.empty()) - { - continue; - } - - if (boost::starts_with(subRoute, "/")) - { - subRoute.erase(0, 1); - } - - if (boost::ends_with(subRoute, "/")) - { - subRoute.pop_back(); - } - - if (!boost::starts_with(subRoute, "$") && - subRoute.find('/') == std::string::npos) - { - json[subRoute] = nlohmann::json{{"@odata.id", *route}}; - } - } - } - } - OperationMap entityPrivileges; protected: @@ -162,8 +99,6 @@ class Node res.end(); } - nlohmann::json json; - private: void dispatchRequest(CrowApp& app, const crow::Request& req, crow::Response& res, diff --git a/redfish-core/include/redfish.hpp b/redfish-core/include/redfish.hpp index c2d64c2..2a61c52 100644 --- a/redfish-core/include/redfish.hpp +++ b/redfish-core/include/redfish.hpp @@ -103,11 +103,6 @@ class RedfishService nodes.emplace_back(std::make_unique<SystemsCollection>(app)); nodes.emplace_back(std::make_unique<Systems>(app)); nodes.emplace_back(std::make_unique<SystemActionsReset>(app)); - - for (auto& node : nodes) - { - node->getSubRoutes(nodes); - } } private: |

