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
HPCC-17851 New config manager core library #10773
Conversation
https://track.hpccsystems.com/browse/HPCC-17851 |
@rpastrana @RussWhitehead @afishbeck This pull request replaces the previous request. It incorporates the comments from previous reviews. It also includes a refactoring for better naming and class structure. Please review. Thanks. |
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.
@kenrowland several comments. some of them need to be applied in multiple files. there were several files where the diff was too big and github did not provide the diff.
Also, I did not review the new XSDs
|
||
EnvironmentMgr *getEnvironmentMgrInstance(const std::string &envType) | ||
{ | ||
EnvironmentMgr *pEnvMgr = NULL; |
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.
nullptr instead of NULL
EnvironmentMgr *getEnvironmentMgrInstance(const std::string &envType) | ||
{ | ||
EnvironmentMgr *pEnvMgr = NULL; | ||
if (envType == "XML") |
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.
If we're really going to support multiple enttypes we should provide an enumeration
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.
I prefer a string, then if we add a new type, client code does not need to be rebuilt to take advantage of 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.
There are many advantages to make this an enumeration. For one, the enumeration itself documents the supported types, no guessing by the developer. An enumerated value leaves no room for casing issues. A test of the enumerated value removes the need for more inefficient string compares. Unless I'm missing something, if we add a new type, the client would need to be rebuilt to request the envType anyway.
#include "XMLEnvironmentMgr.hpp" | ||
|
||
|
||
EnvironmentMgr *getEnvironmentMgrInstance(const std::string &envType) |
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.
@richardkchapman what's our current policy on using std constructs rather than those provided by jlib?
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.
@rpastrana any chance you discussed this with @richardkchapman offline?
} | ||
|
||
|
||
bool EnvironmentMgr::loadSchema(const std::string &configPath, const std::string &masterConfigFile, const std::vector<std::string> &cfgParms) // todo: add a status object here for return |
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.
We frown on letting todo comments reach the upstream branches, let's make a decision to either implement, or abandon the todo.
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.
Todo has been removed.
rc = m_pSchemaParser->parse(configPath, masterConfigFile, cfgParms); | ||
if (rc) | ||
{ | ||
m_pSchema->processUniqueAttributeValueSets(); // This must be done first |
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.
thumbs up on the comment
|
||
if (!found) | ||
{ | ||
isValid = false; |
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.
we could prob just go ahead and return false here
unsigned m_deprecated: 1; | ||
unsigned m_isUnique : 1; | ||
unsigned m_isDefined : 1; | ||
} bitMask; |
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.
I didn't notice this struct being used in any special way, is there any reason these couldn't be just a series SchemaValue member vars of type bool? and if we wanted to create an actual bit mask, why not use a single unsigned to represent the bitmask (where each of the bits represent a different meaning)?
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 a standard way of defining a bitfield where the members of the struct, bitMask, are single bits (or multiple bits if needed). The reason is to reduce memory usage. Multiple bools each take more memory that compacting all of the bool values into a single bitmask
configuration/config2/Status.cpp
Outdated
#include "Status.hpp" | ||
|
||
|
||
void Status::addStatusMsg(enum statusMsg::msgLevel level, const std::string &nodeId, const std::string &name, const std::string &referNodeId, const std::string &msg) |
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 status class has a generic name, but it seems to be specific to validate() actions (at least this method makes it seem specific to actions involving nodeIds).
If that's the case let's label it as such "ValidateStatus"
otherwise, let's provide a truly generic addStatusMsg (enum statusMsg::msgLevel level, const std::string &msg) as well.
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.
I changed the method per our conversation and provided overloads that eliminate the unneeded parameters.
{ | ||
m_message = "Unable to open environment file '" + filename + "'"; | ||
} | ||
return rc; |
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.
Ensure the stream is closed if it needs to be closed.
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.
Destructor for ifstream will close it on exit from method.
<?xml version="1.0" encoding="utf-8"?> | ||
<!-- | ||
################################################################################ | ||
# HPCC SYSTEMS software Copyright (C) 2012 HPCC Systems®. |
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.
the 2012 copyright date indicates this file has been around since then, but it appears to be new (at least in this location). Are we moving the original buildset, or is this a placeholder, or are we going to have multiple buildset.xmls?
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 still the original. I haven't made any changes
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.
We will have at least two buildsets for the time being. I am still looking at the long term need to keep buildset. for now I changed the date.
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.
ok, I'm actually not sure if the date should remain at 2012 since it's a pre-existing file or not. We're prob better off keeping the established date. of more concern is the fact that we have duplicate files now. Why can't we just use the original buildset only?
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.
based on offline conversation with @kenrowland this file is an exact copy of original buildset.xml and is here as placeholder. I'm not crazy about this approach, but for the sake of progress @kenrowland will open a jira to address this in a separate jira.
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.
Jira https://track.hpccsystems.com/browse/HPCC-19032 created to ensure this is removed.
@@ -6,3 +6,4 @@ ln/ | |||
node_modules | |||
esp/src/lib | |||
esp/src/build | |||
.vscode/ |
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.
What does this do?
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.
VS code creates a .vscode directory where you open a project. In three is stores settings for the component such as debug process information. I felt it best to simply add it to the ignore list to ensure any of these files were never committed accidentally.
</BuildSet> | ||
</Build> | ||
</Programs> | ||
</Environment> |
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.
add newline?
@@ -0,0 +1,1143 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> |
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.
How is this instance file used?
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 a test file for now and will be removed in a forthcoming PR
<xs:attribute name="build" type="xs:string" use="required" hpcc:hidden="true" hpcc:tooltip="The build name to be deployed"/> | ||
<xs:attribute name="buildSet" type="xs:string" use="required" hpcc:hidden="true" hpcc:autoGenerateType="configProperty" hpcc:autoGenerateValue="componentName"/> | ||
</xs:attributeGroup> | ||
</xs:schema> |
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.
Github wants returns at the end of these files.
// 158 | ||
//auto pNode = envMgr.getNodeFromPath("158"); | ||
// auto pNode = pEnvMgr->getEnvironmentNode("74"); // 29 is Hardware/Computer | ||
auto pNode = pEnvMgr->getEnvironmentNode("35"); |
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.
How are these Ids generated? Hardware/Computer will always be 29?
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.
IDs are generated during parsing of the environment. Each EnvironmentNode is given an ID value when added to the internal environment tree. IDs are immutable until a new environment is loaded. IDs are also be be treated as opaque values and not interpreted, only used to address a node. If a node is deleted, that ID is no longer valid and will not be recycled during a session with an environment file. Newly added nodes are assigned new IDs.
IDs in test.cpp were previously determined and hardcoded for testing purposes only.
} | ||
|
||
|
||
std::vector<std::shared_ptr<SchemaItem>> EnvironmentNode::getInsertableItems() const |
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.
Don't quite understand what "insertable" means.
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.
Insertable items is a collection of components or other environment items that can be added to the current node. For example, an Instance for an additional node for an ESP service. It could also be an ESP service as well. The method takes into account the number of allowed instances specified in the XSD file.
std::string getLastSchemaMessage() const; | ||
std::string getLastEnvironmentMessage() const { return m_message; } | ||
bool loadEnvironment(const std::string &qualifiedFilename); | ||
std::shared_ptr<EnvironmentNode> getEnvironmentNode(const std::string &nodeId); |
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.
Maybe you should walk me through how these IDs work.
std::shared_ptr<SchemaItem> m_pSchemaItem; | ||
std::weak_ptr<EnvironmentNode> m_pParent; | ||
std::multimap<std::string, std::shared_ptr<EnvironmentNode>> m_children; | ||
std::shared_ptr<EnvironmentValue> m_pNodeValue; // the node's value (not normal) |
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.
Should this inherit an EnvironementValue, rather than contain one?
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.
The EnvironmentValue is set during parsing if one is found in the environment. Since this is not common, it may not have one.
bool wasForced() const { return m_forcedSet; } | ||
bool isValueValid(const std::string &value) const; | ||
void validate(Status &status, const std::string &myId) const; | ||
std::vector<std::string> getAllValues() const; |
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 a little strange. "Get the value of me and all my siblings"?
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.
I know it's a little strange, but it's used for key and keyref processing. the method is a bit of a convenience method since it uses it's name (attribute name) and calls it's parent which actually does the search of all siblings. Without this convenience method, the caller would have to do several calls. Perhaps getAllValuesLikeMe or getAllSiblingValues?
#include <string> | ||
#include "platform.h" | ||
|
||
struct ValueDef { |
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.
Would "AttributeDef" or "NameValueDef" sometimes be more clear?
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.
Changed it to NameValue
@rpastrana @afishbeck Review comments incorporated or addressed with comments. Please let me know if there are any additional comments. |
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.
@kenrowland approved. please create the jira for removing the second buildset.xml
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.
@kenrowland looks fine. Further review will come when the web service is ready.
@richardkchapman Please merge. I tried to squash, but had some merge problems. If you need me to, I will abandon this PR and create a new one with a new single commit branch. |
@kenrowland Please do squash via whatever means are necessary. |
165947c
to
117c793
Compare
Adds the core library for the new configuration manager. Signed-off-by: Ken Rowland <kenneth.rowland@lexisnexisrisk.com>
117c793
to
0550ad5
Compare
Automated Smoketest: ✅ Unit tests result:
Regression test result:
HPCC Stop: OK
|
Adds the core library for the new configuration manager.
Signed-off-by: Ken Rowland kenneth.rowland@lexisnexisrisk.com
Type of change:
Checklist:
Testing: