Bläddra i källkod

Merge pull request #13367 from richardkchapman/trace-config

HPCC-23527 Add option to trace configuration

Reviewed-by: Gavin Halliday <ghalliday@hpccsystems.com>
Gavin Halliday 5 år sedan
förälder
incheckning
362c6abdaa
4 ändrade filer med 22 tillägg och 6 borttagningar
  1. 0 1
      ecl/agentexec/agentexec.cpp
  2. 13 0
      roxie/ccd/ccdmain.cpp
  3. 8 5
      system/jlib/jptree.cpp
  4. 1 0
      system/jlib/jptree.hpp

+ 0 - 1
ecl/agentexec/agentexec.cpp

@@ -260,7 +260,6 @@ int main(int argc, const char *argv[])
     Owned<IPropertyTree> config;
     try
     {
-        DBGLOG("AgentExec: Loading config file 'agentexec.xml'");
         config.setown(loadConfiguration(eclagentDefaultJson, argv, "EclAgent", "ECLAGENT", "agentexec.xml", nullptr));
     }
     catch (IException *e) 

+ 13 - 0
roxie/ccd/ccdmain.cpp

@@ -578,6 +578,7 @@ int STARTQUERY_API start_query(int argc, const char *argv[])
     }
     init_signals();
 
+    bool dumpArgs = false;
     for (unsigned i=0; i<(unsigned)argc; i++)
     {
         if (stricmp(argv[i], "--help")==0 ||
@@ -592,6 +593,8 @@ int STARTQUERY_API start_query(int argc, const char *argv[])
             argv[i] = "--csv";
         else if (strsame(argv[i], "-raw"))
             argv[i] = "--raw";
+        else if (strsame(argv[i], "-v"))
+            dumpArgs = true;
     }
 
     #ifdef _USE_CPPUNIT
@@ -654,6 +657,16 @@ int STARTQUERY_API start_query(int argc, const char *argv[])
         topologyFile.append(codeDirectory).append(PATHSEPCHAR).append("RoxieTopology.xml");
         useOldTopology = checkFileExists(topologyFile.str());
         topology = loadConfiguration(useOldTopology ? nullptr : defaultJson, argv, "Roxie", "ROXIE", topologyFile, nullptr);
+        if (dumpArgs)
+        {
+            for (unsigned i=0; i<(unsigned)argc; i++)
+            {
+                DBGLOG("Arg: %s", argv[i]);
+            }
+            StringBuffer jsonText;
+            regenerateConfig(jsonText, topology, "Roxie");
+            DBGLOG("Configuration: %s", jsonText.str());
+        }
         saveTopology();
         const char *channels = topology->queryProp("@channels");
         if (channels)

+ 8 - 5
system/jlib/jptree.cpp

@@ -7860,16 +7860,15 @@ static void applyCommandLineOption(IPropertyTree * config, const char * option)
     }
 }
 
-static void displayConfig(IPropertyTree * config, const char * componentTag)
+jlib_decl StringBuffer & regenerateConfig(StringBuffer &jsonText, IPropertyTree * config, const char * componentTag)
 {
     Owned<IPropertyTree> recreated = createPTree();
     Owned<IPropertyTree> json = mapXmlConfigToJson(config);
     recreated->setProp("version", currentVersion);
     recreated->addPropTree(componentTag, json.getClear());
 
-    StringBuffer jsonText;
     toJSON(recreated, jsonText, 0, JSON_SortTags|JSON_Format);
-    printf("%s\n", jsonText.str());
+    return jsonText;
 }
 
 jlib_decl IPropertyTree * loadConfiguration(const char * defaultYaml, const char * * argv, const char * componentTag, const char * envPrefix, const char * legacyFilename, IPropertyTree * (mapper)(IPropertyTree *))
@@ -7902,7 +7901,9 @@ jlib_decl IPropertyTree * loadConfiguration(const char * defaultYaml, const char
         }
         else if (strsame(cur, "--init"))
         {
-            displayConfig(config, componentTag);
+            StringBuffer jsonText;
+            regenerateConfig(jsonText, config, componentTag);
+            printf("%s\n", jsonText.str());
             exit(0);
         }
         else if (strsame(cur, "--outputconfig"))
@@ -7955,7 +7956,9 @@ jlib_decl IPropertyTree * loadConfiguration(const char * defaultYaml, const char
 
     if (outputConfig)
     {
-        displayConfig(config, componentTag);
+        StringBuffer jsonText;
+        regenerateConfig(jsonText, config, componentTag);
+        printf("%s\n", jsonText.str());
         exit(0);
     }
 

+ 1 - 0
system/jlib/jptree.hpp

@@ -289,5 +289,6 @@ inline static bool isValidXPathChr(char c)
 }
 
 jlib_decl IPropertyTree * loadConfiguration(const char * defaultYaml, const char * * argv, const char * componentTag, const char * envPrefix, const char * legacyFilename, IPropertyTree * (mapper)(IPropertyTree *));
+jlib_decl StringBuffer & regenerateConfig(StringBuffer &jsonText, IPropertyTree * config, const char * componentTag);
 
 #endif