浏览代码

HPCC-17491 Updated for review

Signed-off-by: Anthony Fishbeck <anthony.fishbeck@lexisnexis.com>
Anthony Fishbeck 7 年之前
父节点
当前提交
c360f7471b
共有 3 个文件被更改,包括 35 次插入27 次删除
  1. 12 7
      ecl/eclcmd/queries/ecl-queries.cpp
  2. 3 3
      esp/scm/ws_workunits.ecm
  3. 20 17
      esp/services/ws_workunits/ws_workunitsQuerySets.cpp

+ 12 - 7
ecl/eclcmd/queries/ecl-queries.cpp

@@ -1224,28 +1224,33 @@ public:
         }
         if (optFilename.isEmpty())
         {
-            StringBuffer name("./backup_queryset_");
+            StringBuffer name("./queryset_backup_");
             name.append(optTarget);
             if (optActiveOnly)
                 name.append("_activeonly_");
             CDateTime dt;
             dt.setNow();
             dt.getString(name, true);
+            name.replace(':', '_').append(".xml");
+            optFilename.set(name);
         }
         if (!EclCmdCommon::finalizeOptions(globals))
             return false;
         return true;
     }
 
-    void saveAsFile(const MemoryBuffer &mb, const char *filepath)
+    void saveAsFile(const char *s, const char *filepath)
     {
+        if (!s || !*s)
+            return;
+
         Owned<IFile> file = createIFile(filepath);
         Owned<IFileIO> io = file->open(IFOcreaterw);
 
         fprintf(stdout, "\nWriting to file %s\n", file->queryFilename());
 
         if (io.get())
-            io->write(0, mb.length(), mb.toByteArray());
+            io->write(0, strlen(s), s);
         else
             fprintf(stderr, "\nFailed to create file %s\n", file->queryFilename());
     }
@@ -1275,13 +1280,13 @@ public:
                 fprintf(stderr, "\nError decompressing response\n");
                 return 1;
             }
-            decompressed.append('\0');
             if (optFilename.length())
-                saveAsFile(decompressed, optFilename);
+                saveAsFile(decompressed.toByteArray(), optFilename);
             else
             {
+                decompressed.append('\0');
                 fputs(decompressed.toByteArray(), stdout); //for piping
-                fputs("\n", stdout); //for piping
+                fputs("\n", stdout);
             }
         }
         return ret;
@@ -1329,7 +1334,7 @@ public:
                 if (optDestQuerySet.isEmpty())
                     optDestQuerySet.set(arg);
                 else if (optFilename.isEmpty())
-                        optFilename.set(arg);
+                    optFilename.set(arg);
                 else
                 {
                     fprintf(stderr, "\nunrecognized argument %s\n", arg);

+ 3 - 3
esp/scm/ws_workunits.ecm

@@ -1989,7 +1989,7 @@ ESPresponse [exceptions_inline, nil_remove] WUGetNumFileToCopyResponse
 
 ESPservice [
     auth_feature("DEFERRED"), //This declares that the method logic handles feature level authorization
-    version("1.70"), default_client_version("1.70"),
+    version("1.71"), default_client_version("1.71"),
     noforms,exceptions_inline("./smc_xslt/exceptions.xslt"),use_method_name] WsWorkunits
 {
     ESPmethod [cache_seconds(60), resp_xsl_default("/esp/xslt/workunits.xslt")]     WUQuery(WUQueryRequest, WUQueryResponse);
@@ -2053,8 +2053,8 @@ ESPservice [
     ESPmethod [cache_seconds(60), resp_xsl_default("/esp/xslt/WUQuerysetQueries.xslt")] WUQuerysetDetails(WUQuerySetDetailsRequest, WUQuerySetDetailsResponse);
     ESPmethod [cache_seconds(60), resp_xsl_default("/esp/xslt/WUQueryDetails.xslt")] WUQueryDetails(WUQueryDetailsRequest, WUQueryDetailsResponse);
     ESPmethod [cache_seconds(60)] WUMultiQuerysetDetails(WUMultiQuerySetDetailsRequest, WUMultiQuerySetDetailsResponse);
-    ESPmethod WUQuerysetImport(WUQuerysetImportRequest, WUQuerysetImportResponse);
-    ESPmethod WUQuerysetExport(WUQuerysetExportRequest, WUQuerysetExportResponse);
+    ESPmethod [min_ver("1.71")] WUQuerysetImport(WUQuerysetImportRequest, WUQuerysetImportResponse);
+    ESPmethod [min_ver("1.71")] WUQuerysetExport(WUQuerysetExportRequest, WUQuerysetExportResponse);
     ESPmethod WUQuerysetQueryAction(WUQuerySetQueryActionRequest, WUQuerySetQueryActionResponse);
     ESPmethod WUQuerysetAliasAction(WUQuerySetAliasActionRequest, WUQuerySetAliasActionResponse);
     ESPmethod WUQuerysetCopyQuery(WUQuerySetCopyQueryRequest, WUQuerySetCopyQueryResponse);

+ 20 - 17
esp/services/ws_workunits/ws_workunitsQuerySets.cpp

@@ -2895,6 +2895,13 @@ bool CWsWorkunitsEx::onWUQuerysetImport(IEspContext &context, IEspWUQuerysetImpo
         if (!target || !*target)
             throw MakeStringException(ECLWATCH_QUERYSET_NOT_FOUND, "Target not specified");
 
+        Owned <IConstWUClusterInfo> clusterInfo = getTargetClusterInfo(target);
+        if (!clusterInfo)
+            throw MakeStringException(ECLWATCH_CANNOT_RESOLVE_CLUSTER_NAME, "Target not found");
+
+        if (req.getCopyFiles() && clusterInfo->getPlatform()!=RoxieCluster)
+            throw MakeStringException(ECLWATCH_INVALID_ACTION, "Copy files option only supported for Roxie");
+
         MemoryBuffer &mb = const_cast<MemoryBuffer &>(req.getData()); //for efficiency, content of request shouldn't matter after
         if (req.getCompressed())
         {
@@ -2927,24 +2934,20 @@ bool CWsWorkunitsEx::onWUQuerysetImport(IEspContext &context, IEspWUQuerysetImpo
         SCMStringBuffer process;
         if (req.getCopyFiles())
         {
-            Owned <IConstWUClusterInfo> clusterInfo = getTargetClusterInfo(target);
-            if (clusterInfo && clusterInfo->getPlatform()==RoxieCluster)
-            {
-                clusterInfo->getRoxieProcess(process);
-                if (!process.length())
-                    throw MakeStringException(ECLWATCH_INVALID_CLUSTER_INFO, "DFS process cluster not found for destination target %s", target);
-                unsigned updateFlags = 0;
-                if (req.getOverwriteDfs())
-                    updateFlags |= (DALI_UPDATEF_REPLACE_FILE | DALI_UPDATEF_CLONE_FROM | DALI_UPDATEF_SUPERFILES);
-                if (req.getUpdateCloneFrom())
-                    updateFlags |= DALI_UPDATEF_CLONE_FROM;
-                if (req.getUpdateSuperFiles())
-                    updateFlags |= DALI_UPDATEF_SUPERFILES;
-                if (req.getAppendCluster())
-                    updateFlags |= DALI_UPDATEF_APPEND_CLUSTER;
+            clusterInfo->getRoxieProcess(process); //checked if roxie when copying files above
+            if (!process.length())
+                throw MakeStringException(ECLWATCH_INVALID_CLUSTER_INFO, "DFS process cluster not found for destination target %s", target);
+            unsigned updateFlags = 0;
+            if (req.getOverwriteDfs())
+                updateFlags |= (DALI_UPDATEF_REPLACE_FILE | DALI_UPDATEF_CLONE_FROM | DALI_UPDATEF_SUPERFILES);
+            if (req.getUpdateCloneFrom())
+                updateFlags |= DALI_UPDATEF_CLONE_FROM;
+            if (req.getUpdateSuperFiles())
+                updateFlags |= DALI_UPDATEF_SUPERFILES;
+            if (req.getAppendCluster())
+                updateFlags |= DALI_UPDATEF_APPEND_CLUSTER;
 
-                cloner.enableFileCloning(updateFlags, req.getDfsServer(), process.str(), req.getSourceProcess(), req.getAllowForeignFiles());
-            }
+            cloner.enableFileCloning(updateFlags, req.getDfsServer(), process.str(), req.getSourceProcess(), req.getAllowForeignFiles());
         }
 
         if (req.getActiveOnly())