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

HPCC-17851 New config manager core library #10773

Merged
merged 1 commit into from Feb 2, 2018

Conversation

kenrowland
Copy link
Contributor

@kenrowland kenrowland commented Jan 9, 2018

Adds the core library for the new configuration manager.

Signed-off-by: Ken Rowland kenneth.rowland@lexisnexisrisk.com

Type of change:

  • This change is a bug fix (non-breaking change which fixes an issue).
  • This change is a new feature (non-breaking change which adds functionality).
  • This change improves the code (refactor or other change that does not change the functionality)
  • This change fixes warnings (the fix does not alter the functionality or the generated code)
  • This change is a breaking change (fix or feature that will cause existing behavior to change).
  • This change alters the query API (existing queries will have to be recompiled)

Checklist:

  • My code follows the code style of this project.
    • My code does not create any new warnings from compiler, build system, or lint.
  • The commit message is properly formatted and free of typos.
    • The commit message title makes sense in a changelog, by itself.
    • The commit is signed.
  • My change requires a change to the documentation.
    • I have updated the documentation accordingly, or...
    • I have created a JIRA ticket to update the documentation.
    • Any new interfaces or exported functions are appropriately commented.
  • I have read the CONTRIBUTORS document.
  • The change has been fully tested:
    • I have added tests to cover my changes.
    • All new and existing tests passed.
    • I have checked that this change does not introduce memory leaks.
    • I have used Valgrind or similar tools to check for potential issues.
  • I have given due consideration to all of the following potential concerns:
    • Scalability
    • Performance
    • Security
    • Thread-safety
    • Premature optimization
    • Existing deployed queries will not be broken
    • This change fixes the problem, not just the symptom
    • The target branch of this pull request is appropriate for such a change.
  • There are no similar instances of the same problem that should be addressed
    • I have addressed them here
    • I have raised JIRA issues to address them separately
  • This is a user interface / front-end modification
    • I have tested my changes in multiple modern browsers
    • The component(s) render as expected

Testing:

@hpcc-jirabot
Copy link

https://track.hpccsystems.com/browse/HPCC-17851
Jira not updated (pull request already registered)

@kenrowland
Copy link
Contributor Author

@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.

Copy link
Member

@rpastrana rpastrana left a 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;
Copy link
Member

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")
Copy link
Member

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

Copy link
Contributor Author

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.

Copy link
Member

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)
Copy link
Member

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?

Copy link
Member

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
Copy link
Member

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.

Copy link
Contributor Author

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
Copy link
Member

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;
Copy link
Member

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;
Copy link
Member

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)?

Copy link
Contributor Author

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

#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)
Copy link
Member

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.

Copy link
Contributor Author

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;
Copy link
Member

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.

Copy link
Contributor Author

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®.
Copy link
Member

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?

Copy link
Contributor Author

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

Copy link
Contributor Author

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.

Copy link
Member

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?

Copy link
Member

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.

Copy link
Contributor Author

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/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this do?

Copy link
Contributor Author

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>
Copy link
Member

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"?>
Copy link
Member

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?

Copy link
Contributor Author

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>
Copy link
Member

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");
Copy link
Member

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?

Copy link
Contributor Author

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
Copy link
Member

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.

Copy link
Contributor Author

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

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)
Copy link
Member

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?

Copy link
Contributor Author

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;
Copy link
Member

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"?

Copy link
Contributor Author

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 {
Copy link
Member

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed it to NameValue

@kenrowland
Copy link
Contributor Author

@rpastrana @afishbeck Review comments incorporated or addressed with comments. Please let me know if there are any additional comments.

Copy link
Member

@rpastrana rpastrana left a 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

Copy link
Member

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

@kenrowland
Copy link
Contributor Author

@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.

@richardkchapman
Copy link
Member

@kenrowland Please do squash via whatever means are necessary.

Adds the core library for the new configuration manager.

Signed-off-by: Ken Rowland <kenneth.rowland@lexisnexisrisk.com>
@HPCCSmoketest
Copy link
Contributor

Automated Smoketest: ✅
Sha: 0550ad5
Build: success
Install hpccsystems-platform-community_6.5.0-trunk0.el7.x86_64.rpm
HPCC Start: OK

Unit tests result:

Test total passed failed errors timeout
unittest 81 81 0 0 0
wutoolTest(Dali) 19 19 0 0 0
wutoolTest(Cassandra) 19 19 0 0 0

Regression test result:

phase total pass fail
setup (hthor) 11 11 0
setup (thor) 11 11 0
setup (roxie) 11 11 0
test (hthor) 741 741 0
test (thor) 650 650 0
test (roxie) 768 768 0

HPCC Stop: OK
HPCC Uninstall: OK
Time stats:

Prep time Build time Package time Install time Start time Test time Stop time Summary
15 sec (00:00:15) 182 sec (00:03:02) 55 sec (00:00:55) 6 sec (00:00:06) 37 sec (00:00:37) 1106 sec (00:18:26) 33 sec (00:00:33) 1434 sec (00:23:54)

@richardkchapman richardkchapman merged commit 7e9390d into hpcc-systems:master Feb 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
6 participants