Browse Source

Merge remote-tracking branch 'origin/candidate-4.0.2' into closedown-4.0.x

Signed-off-by: Richard Chapman <rchapman@hpccsystems.com>
Richard Chapman 12 years ago
parent
commit
09f21b09fb

+ 1 - 1
cmake_modules/commonSetup.cmake

@@ -182,7 +182,7 @@ IF ("${COMMONSETUP_DONE}" STREQUAL "")
 
 
     if (CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANGXX)
     if (CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANGXX)
       message ("${CMAKE_CXX_COMPILER_ID}")
       message ("${CMAKE_CXX_COMPILER_ID}")
-      SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -frtti -fPIC -fmessage-length=0 -Wformat -Wformat-security -Wformat-nonliteral -pthread")
+      SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -frtti -fPIC -fmessage-length=0 -Wformat -Wformat-security -Wformat-nonliteral -pthread -Wuninitialized")
       SET (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -rdynamic")
       SET (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -rdynamic")
       SET (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -g -fno-inline-functions")
       SET (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -g -fno-inline-functions")
       if (CMAKE_COMPILER_IS_GNUCXX)
       if (CMAKE_COMPILER_IS_GNUCXX)

+ 4 - 1
common/thorhelper/thorcommon.hpp

@@ -420,7 +420,10 @@ public:
     {
     {
         return ctx->queryEngineContext();
         return ctx->queryEngineContext();
     }
     }
-
+    virtual char *getDaliServers()
+    {
+        return ctx->getDaliServers();
+    }
 protected:
 protected:
     ICodeContext * ctx;
     ICodeContext * ctx;
 };
 };

+ 18 - 0
ecl/eclagent/eclagent.cpp

@@ -2868,6 +2868,24 @@ IDistributedFileTransaction *EclAgent::querySuperFileTransaction()
 }
 }
 
 
 
 
+char * EclAgent::getDaliServers()
+{
+    if (!isCovenActive())
+        return strdup("");
+    StringBuffer dali;
+    IGroup &group = queryCoven().queryComm().queryGroup();
+    Owned<INodeIterator> coven = group.getIterator();
+    bool first = true;
+    ForEach(*coven)
+    {
+        if (first)
+            first = false;
+        else
+            dali.append(',');
+        coven->query().endpoint().getUrlStr(dali);
+    }
+    return dali.detach();
+}
 
 
 void EclAgent::addTimings()
 void EclAgent::addTimings()
 {
 {

+ 1 - 0
ecl/eclagent/eclagent.ipp

@@ -514,6 +514,7 @@ public:
     virtual IOrderedOutputSerializer * queryOutputSerializer() { return outputSerializer; }
     virtual IOrderedOutputSerializer * queryOutputSerializer() { return outputSerializer; }
     virtual const void * fromXml(IEngineRowAllocator * _rowAllocator, size32_t len, const char * utf8, IXmlToRowTransformer * xmlTransformer, bool stripWhitespace);
     virtual const void * fromXml(IEngineRowAllocator * _rowAllocator, size32_t len, const char * utf8, IXmlToRowTransformer * xmlTransformer, bool stripWhitespace);
     virtual IEngineContext *queryEngineContext() { return NULL; }
     virtual IEngineContext *queryEngineContext() { return NULL; }
+    virtual char *getDaliServers();
 
 
     unsigned __int64 queryStopAfter() { return stopAfter; }
     unsigned __int64 queryStopAfter() { return stopAfter; }
 
 

+ 6 - 1
ecl/eclcmd/eclcmd_common.cpp

@@ -380,7 +380,12 @@ public:
             if (cmd.optManifest.length())
             if (cmd.optManifest.length())
                 cmdLine.append(" -manifest ").append(cmd.optManifest.get());
                 cmdLine.append(" -manifest ").append(cmd.optManifest.get());
             if (cmd.optObj.value.get())
             if (cmd.optObj.value.get())
-                cmdLine.append(" ").append(streq(cmd.optObj.value.get(), "stdin") ? "- " : cmd.optObj.value.get());
+            {
+                if (streq(cmd.optObj.value.get(), "stdin"))
+                    cmdLine.append(" - ");
+                else
+                    cmdLine.append(" \"").append(cmd.optObj.value.get()).append('"');;
+            }
         }
         }
         if (cmd.debugValues.length())
         if (cmd.debugValues.length())
         {
         {

+ 0 - 113
ecl/eclcmd/eclcmd_core.cpp

@@ -26,119 +26,6 @@
 #include "eclcmd_common.hpp"
 #include "eclcmd_common.hpp"
 #include "eclcmd_core.hpp"
 #include "eclcmd_core.hpp"
 
 
-class ConvertEclParameterToArchive
-{
-public:
-    ConvertEclParameterToArchive(EclCmdWithEclTarget &_cmd) : cmd(_cmd)
-    {
-    }
-
-    void appendOptPath(StringBuffer &cmdLine, const char opt, const char *path)
-    {
-        if (!path || !*path)
-            return;
-        if (*path==';')
-            path++;
-        cmdLine.append(" -").append(opt).append(path);
-    }
-
-    void buildCmd(StringBuffer &cmdLine)
-    {
-        cmdLine.set("eclcc -E");
-        appendOptPath(cmdLine, 'I', cmd.optImpPath.str());
-        appendOptPath(cmdLine, 'L', cmd.optLibPath.str());
-        if (cmd.optManifest.length())
-            cmdLine.append(" -manifest ").append(cmd.optManifest.get());
-        if (streq(cmd.optObj.value.sget(), "stdin"))
-            cmdLine.append(" - ");
-        else
-            cmdLine.append(" ").append(cmd.optObj.value.get());
-    }
-
-    bool eclcc(StringBuffer &out)
-    {
-        StringBuffer cmdLine;
-        buildCmd(cmdLine);
-
-        Owned<IPipeProcess> pipe = createPipeProcess();
-        bool hasInput = streq(cmd.optObj.value.sget(), "stdin");
-        pipe->run(cmd.optVerbose ? "EXEC" : NULL, cmdLine.str(), NULL, hasInput, true, true);
-
-        StringBuffer errors;
-        Owned<EclCmdErrorReader> errorReader = new EclCmdErrorReader(pipe, errors);
-        errorReader->start();
-
-        if (pipe->hasInput())
-        {
-            pipe->write(cmd.optObj.mb.length(), cmd.optObj.mb.toByteArray());
-            pipe->closeInput();
-        }
-        if (pipe->hasOutput())
-        {
-           byte buf[4096];
-           loop
-           {
-                size32_t read = pipe->read(sizeof(buf),buf);
-                if (!read)
-                    break;
-                out.append(read, (const char *) buf);
-            }
-        }
-        int retcode = pipe->wait();
-        errorReader->join();
-
-        if (errors.length())
-            fprintf(stderr, "%s\n", errors.str());
-
-        return (retcode == 0);
-    }
-
-    bool process()
-    {
-        if (cmd.optObj.type!=eclObjSource || cmd.optObj.value.isEmpty())
-            return false;
-
-        StringBuffer output;
-        if (eclcc(output) && output.length() && isArchiveQuery(output.str()))
-        {
-            cmd.optObj.type = eclObjArchive;
-            cmd.optObj.mb.clear().append(output.str());
-            return true;
-        }
-        fprintf(stderr,"\nError creating archive\n");
-        return false;
-    }
-
-private:
-    EclCmdWithEclTarget &cmd;
-
-    class EclCmdErrorReader : public Thread
-    {
-    public:
-        EclCmdErrorReader(IPipeProcess *_pipe, StringBuffer &_errs)
-            : Thread("EclToArchive::ErrorReader"), pipe(_pipe), errs(_errs)
-        {
-        }
-
-        virtual int run()
-        {
-           byte buf[4096];
-           loop
-           {
-                size32_t read = pipe->readError(sizeof(buf), buf);
-                if (!read)
-                    break;
-                errs.append(read, (const char *) buf);
-            }
-            return 0;
-        }
-    private:
-        IPipeProcess *pipe;
-        StringBuffer &errs;
-    };
-};
-
-
 
 
 bool doDeploy(EclCmdWithEclTarget &cmd, IClientWsWorkunits *client, const char *cluster, const char *name, StringBuffer *wuid, bool noarchive, bool displayWuid=true)
 bool doDeploy(EclCmdWithEclTarget &cmd, IClientWsWorkunits *client, const char *cluster, const char *name, StringBuffer *wuid, bool noarchive, bool displayWuid=true)
 {
 {

+ 1 - 1
ecl/hql/hqlparse.cpp

@@ -31,7 +31,7 @@
 
 
 //#define TIMING_DEBUG
 //#define TIMING_DEBUG
 
 
-#define  MAX_LOOP_TIMES 10000
+#define  MAX_LOOP_TIMES 250000
 
 
 // =========================== local helper functions ===================================
 // =========================== local helper functions ===================================
 
 

+ 194 - 51
esp/services/ws_ecl/ws_ecl_service.cpp

@@ -197,6 +197,72 @@ static void appendServerAddress(StringBuffer &s, IPropertyTree &env, IPropertyTr
     s.append(netAddress).append(':').append(port ? port : "9876");
     s.append(netAddress).append(':').append(port ? port : "9876");
 }
 }
 
 
+
+const char *nextParameterTag(StringAttr &tag, const char *path)
+{
+    while (*path=='.')
+        path++;
+    const char *finger = strchr(path, '.');
+    if (finger)
+    {
+        tag.set(path, finger - path);
+        finger++;
+    }
+    else
+        tag.set(path);
+    return finger;
+}
+
+void ensureParameter(IPropertyTree *pt, const char *tag, const char *path, const char *value, const char *fullpath)
+{
+    unsigned idx = 1;
+    if (path && isdigit(*path))
+    {
+        StringAttr pos;
+        path = nextParameterTag(pos, path);
+        idx = (unsigned) atoi(pos.sget())+1;
+        if (idx>25) //adf
+            throw MakeStringException(-1, "Array items above 25 not supported in WsECL HTTP parameters: %s", fullpath);
+    }
+    unsigned count = pt->getCount(tag);
+    while (count++ < idx)
+        pt->addPropTree(tag, createPTree(tag));
+    StringBuffer xpath(tag);
+    xpath.append('[').append(idx).append(']');
+    pt = pt->queryPropTree(xpath);
+
+    if (!path || !*path)
+    {
+        pt->setProp(NULL, value);
+        return;
+    }
+
+    StringAttr nextTag;
+    path = nextParameterTag(nextTag, path);
+    ensureParameter(pt, nextTag, path, value, fullpath);
+}
+
+void ensureParameter(IPropertyTree *pt, const char *path, const char *value)
+{
+    const char *fullpath = path;
+    StringAttr tag;
+    path = nextParameterTag(tag, path);
+    ensureParameter(pt, tag, path, value, fullpath);
+}
+
+IPropertyTree *createPTreeFromHttpParameters(const char *name, IProperties *parameters)
+{
+    Owned<IPropertyTree> pt = createPTree(name);
+    Owned<IPropertyIterator> props = parameters->getIterator();
+    ForEach(*props)
+    {
+        const char *key = props->getPropKey();
+        const char *value = parameters->queryProp(key);
+        ensureParameter(pt, key, value);
+    }
+    return pt.getClear();
+}
+
 bool CWsEclService::init(const char * name, const char * type, IPropertyTree * cfg, const char * process)
 bool CWsEclService::init(const char * name, const char * type, IPropertyTree * cfg, const char * process)
 {
 {
     StringBuffer xpath;
     StringBuffer xpath;
@@ -223,17 +289,25 @@ bool CWsEclService::init(const char * name, const char * type, IPropertyTree * c
     xpath.clear().appendf("EspService[@name='%s']/VIPS", name);
     xpath.clear().appendf("EspService[@name='%s']/VIPS", name);
     IPropertyTree *vips = prc->queryPropTree(xpath.str());
     IPropertyTree *vips = prc->queryPropTree(xpath.str());
 
 
-    Owned<IPropertyTreeIterator> it = pRoot->getElements("Software/RoxieCluster");
-    ForEach(*it)
+    Owned<IStringIterator> roxieTargets = getTargetClusters("RoxieCluster", NULL);
+    ForEach(*roxieTargets)
     {
     {
-        const char *name = it->query().queryProp("@name");
-        if (connMap.getValue(name)) //bad config?
+        SCMStringBuffer target;
+        roxieTargets->str(target);
+        if (!target.length() || connMap.getValue(target.str())) //bad config?
+            continue;
+        Owned<IConstWUClusterInfo> clusterInfo = getTargetClusterInfo(target.str());
+        if (!clusterInfo)
+            continue;
+        SCMStringBuffer process;
+        clusterInfo->getRoxieProcess(process);
+        if (!process.length())
             continue;
             continue;
-        bool loadBalanced = false;
-        StringBuffer list;
         const char *vip = NULL;
         const char *vip = NULL;
         if (vips)
         if (vips)
-            vip = vips->queryProp(xpath.clear().appendf("ProcessCluster[@name='%s']/@vip", name).str());
+            vip = vips->queryProp(xpath.clear().appendf("ProcessCluster[@name='%s']/@vip", process.str()).str());
+        StringBuffer list;
+        bool loadBalanced = false;
         if (vip && *vip)
         if (vip && *vip)
         {
         {
             list.append(vip);
             list.append(vip);
@@ -241,14 +315,19 @@ bool CWsEclService::init(const char * name, const char * type, IPropertyTree * c
         }
         }
         else
         else
         {
         {
-            Owned<IPropertyTreeIterator> servers = it->query().getElements("RoxieServerProcess");
-            ForEach(*servers)
-                appendServerAddress(list, *pRoot, servers->query(), daliAddress.str());
+            VStringBuffer xpath("Software/RoxieCluster[@name='%s']", process.str());
+            Owned<IPropertyTreeIterator> it = pRoot->getElements(xpath.str());
+            ForEach(*it)
+            {
+                Owned<IPropertyTreeIterator> servers = it->query().getElements("RoxieServerProcess");
+                ForEach(*servers)
+                    appendServerAddress(list, *pRoot, servers->query(), daliAddress.str());
+            }
         }
         }
         if (list.length())
         if (list.length())
         {
         {
             Owned<ISmartSocketFactory> sf = createSmartSocketFactory(list.str(), !loadBalanced);
             Owned<ISmartSocketFactory> sf = createSmartSocketFactory(list.str(), !loadBalanced);
-            connMap.setValue(name, sf.get());
+            connMap.setValue(target.str(), sf.get());
         }
         }
     }
     }
 
 
@@ -1688,9 +1767,12 @@ void buildParametersXml(IPropertyTree *parmtree, IProperties *parms)
             parmtree->setProp(xpath.str(), val);
             parmtree->setProp(xpath.str(), val);
         }
         }
     }
     }
-    StringBuffer xml;
-    toXML(parmtree, xml);
-    DBGLOG("parmtree: %s", xml.str());
+    if (getEspLogLevel()>LogNormal)
+    {
+        StringBuffer xml;
+        toXML(parmtree, xml);
+        DBGLOG("parmtree: %s", xml.str());
+    }
 }
 }
 
 
 void appendValidInputBoxContent(StringBuffer &xml, const char *in)
 void appendValidInputBoxContent(StringBuffer &xml, const char *in)
@@ -1720,7 +1802,8 @@ void CWsEclBinding::getWsEcl2XmlRequest(StringBuffer& soapmsg, IEspContext &cont
 
 
     StringBuffer schemaXml;
     StringBuffer schemaXml;
     getSchema(schemaXml, context, request, wsinfo);
     getSchema(schemaXml, context, request, wsinfo);
-    DBGLOG("request schema: %s", schemaXml.str());
+    if (getEspLogLevel()>LogNormal)
+        DBGLOG("request schema: %s", schemaXml.str());
     Owned<IXmlSchema> schema = createXmlSchemaFromString(schemaXml);
     Owned<IXmlSchema> schema = createXmlSchemaFromString(schemaXml);
     if (schema.get())
     if (schema.get())
     {
     {
@@ -1792,7 +1875,8 @@ void CWsEclBinding::getWsEclJsonRequest(StringBuffer& jsonmsg, IEspContext &cont
 
 
         StringBuffer schemaXml;
         StringBuffer schemaXml;
         getSchema(schemaXml, context, request, wsinfo);
         getSchema(schemaXml, context, request, wsinfo);
-        DBGLOG("request schema: %s", schemaXml.str());
+        if (getEspLogLevel()>LogNormal)
+            DBGLOG("request schema: %s", schemaXml.str());
         Owned<IXmlSchema> schema = createXmlSchemaFromString(schemaXml);
         Owned<IXmlSchema> schema = createXmlSchemaFromString(schemaXml);
         if (schema.get())
         if (schema.get())
         {
         {
@@ -2252,16 +2336,9 @@ void CWsEclBinding::sendRoxieRequest(const char *target, StringBuffer &req, Stri
     SocketEndpoint ep;
     SocketEndpoint ep;
     try
     try
     {
     {
-        Owned<IConstWUClusterInfo> clusterInfo = getTargetClusterInfo(target);
-        if (!clusterInfo)
-            throw MakeStringException(-1, "target cluster not found");
-
-        SCMStringBuffer process;
-        clusterInfo->getRoxieProcess(process);
-        ISmartSocketFactory *conn = wsecl->connMap.getValue(process.str());
+        ISmartSocketFactory *conn = wsecl->connMap.getValue(target);
         if (!conn)
         if (!conn)
-            throw MakeStringException(-1, "process cluster not found: %s", process.str());
-
+            throw MakeStringException(-1, "roxie target cluster not mapped: %s", target);
         ep = conn->nextEndpoint();
         ep = conn->nextEndpoint();
 
 
         Owned<IHttpClientContext> httpctx = getHttpClientContext();
         Owned<IHttpClientContext> httpctx = getHttpClientContext();
@@ -2270,7 +2347,7 @@ void CWsEclBinding::sendRoxieRequest(const char *target, StringBuffer &req, Stri
 
 
         Owned<IHttpClient> httpclient = httpctx->createHttpClient(NULL, url);
         Owned<IHttpClient> httpclient = httpctx->createHttpClient(NULL, url);
         if (0 > httpclient->sendRequest("POST", contentType, req, resp, status))
         if (0 > httpclient->sendRequest("POST", contentType, req, resp, status))
-            throw MakeStringException(-1, "Process cluster communication error: %s", process.str());
+            throw MakeStringException(-1, "Roxie cluster communication error: %s", target);
     }
     }
     catch (IException *e)
     catch (IException *e)
     {
     {
@@ -2307,7 +2384,8 @@ int CWsEclBinding::onSubmitQueryOutput(IEspContext &context, CHttpRequest* reque
     StringBuffer soapmsg;
     StringBuffer soapmsg;
 
 
     getSoapMessage(soapmsg, context, request, wsinfo, REQXML_TRIM|REQXML_ROOT);
     getSoapMessage(soapmsg, context, request, wsinfo, REQXML_TRIM|REQXML_ROOT);
-    DBGLOG("submitQuery soap: %s", soapmsg.str());
+    if (getEspLogLevel()>LogNormal)
+        DBGLOG("submitQuery soap: %s", soapmsg.str());
 
 
     const char *thepath = request->queryPath();
     const char *thepath = request->queryPath();
 
 
@@ -2360,7 +2438,8 @@ int CWsEclBinding::onSubmitQueryOutputView(IEspContext &context, CHttpRequest* r
     StringBuffer soapmsg;
     StringBuffer soapmsg;
 
 
     getSoapMessage(soapmsg, context, request, wsinfo, REQXML_TRIM|REQXML_ROOT);
     getSoapMessage(soapmsg, context, request, wsinfo, REQXML_TRIM|REQXML_ROOT);
-    DBGLOG("submitQuery soap: %s", soapmsg.str());
+    if (getEspLogLevel()>LogNormal)
+        DBGLOG("submitQuery soap: %s", soapmsg.str());
 
 
     const char *thepath = request->queryPath();
     const char *thepath = request->queryPath();
 
 
@@ -2644,8 +2723,60 @@ int CWsEclBinding::onGet(CHttpRequest* request, CHttpResponse* response)
         {
         {
             return getWsEcl2Form(request, response, thepath);
             return getWsEcl2Form(request, response, thepath);
         }
         }
+        else if (!stricmp(methodName.str(), "proxy"))
+        {
+            context->addTraceSummaryValue("wseclMode", "proxy");
+
+            StringBuffer wuid;
+            StringBuffer target;
+            StringBuffer qid;
+
+            splitLookupInfo(parms, thepath, wuid, target, qid);
+
+            StringBuffer format;
+            nextPathNode(thepath, format);
+
+            if (!wsecl->connMap.getValue(target.str()))
+                throw MakeStringException(-1, "Target cluster not mapped to roxie process!");
+            Owned<IPropertyTree> pt = createPTreeFromHttpParameters(qid.str(), parms);
+            StringBuffer soapreq(
+                "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+                "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\""
+                  " xmlns:SOAP-ENC=\"http://schemas.xmlsoap.org/soap/encoding/\">"
+                    " <soap:Body>"
+                );
+            toXML(pt, soapreq);
+            soapreq.append("</soap:Body></soap:Envelope>");
+            StringBuffer output;
+            StringBuffer status;
+            if (getEspLogLevel()>LogNormal)
+                DBGLOG("roxie req: %s", soapreq.str());
+            sendRoxieRequest(target, soapreq, output, status, qid);
+            if (getEspLogLevel()>LogNormal)
+                DBGLOG("roxie resp: %s", output.str());
+
+            if (context->queryRequestParameters()->hasProp("display"))
+            {
+                unsigned pos = 0;
+                const char *start = output.str();
+                if (!strnicmp(start, "<?xml ", 6))
+                {
+                    const char *enddecl = strstr(start, "?>");
+                    if (enddecl)
+                        pos = enddecl - start + 2;
+                }
+                output.insert(pos, "<?xml-stylesheet type='text/xsl' href='/esp/xslt/xmlformatter.xsl' ?>");
+            }
+
+            response->setContent(output.str());
+            response->setContentType("application/xml");
+            response->setStatus("200 OK");
+            response->send();
+        }
         else if (!stricmp(methodName.str(), "submit"))
         else if (!stricmp(methodName.str(), "submit"))
         {
         {
+            context->addTraceSummaryValue("wseclMode", "submit");
+
             StringBuffer wuid;
             StringBuffer wuid;
             StringBuffer qs;
             StringBuffer qs;
             StringBuffer qid;
             StringBuffer qid;
@@ -2660,6 +2791,8 @@ int CWsEclBinding::onGet(CHttpRequest* request, CHttpResponse* response)
         }
         }
         else if (!stricmp(methodName.str(), "xslt"))
         else if (!stricmp(methodName.str(), "xslt"))
         {
         {
+            context->addTraceSummaryValue("wseclMode", "xslt");
+
             StringBuffer wuid;
             StringBuffer wuid;
             StringBuffer qs;
             StringBuffer qs;
             StringBuffer qid;
             StringBuffer qid;
@@ -2750,6 +2883,7 @@ void createPTreeFromJsonString(const char *json, bool caseInsensitive, StringBuf
 void CWsEclBinding::handleJSONPost(CHttpRequest *request, CHttpResponse *response)
 void CWsEclBinding::handleJSONPost(CHttpRequest *request, CHttpResponse *response)
 {
 {
     IEspContext *ctx = request->queryContext();
     IEspContext *ctx = request->queryContext();
+    ctx->addTraceSummaryValue("wseclMode", "JSONPost");
     IProperties *parms = request->queryParameters();
     IProperties *parms = request->queryParameters();
     StringBuffer jsonresp;
     StringBuffer jsonresp;
 
 
@@ -2788,21 +2922,22 @@ void CWsEclBinding::handleJSONPost(CHttpRequest *request, CHttpResponse *respons
             nextPathNode(thepath, queryname);
             nextPathNode(thepath, queryname);
         }
         }
 
 
-        WsEclWuInfo wsinfo(wuid.str(), queryset.str(), queryname.str(), ctx->queryUserId(), ctx->queryPassword());
-        SCMStringBuffer clustertype;
-        wsinfo.wu->getDebugValue("targetclustertype", clustertype);
 
 
         StringBuffer content(request->queryContent());
         StringBuffer content(request->queryContent());
         StringBuffer status;
         StringBuffer status;
-        if (strieq(clustertype.str(), "roxie"))
+        if (wsecl->connMap.getValue(queryset.str()))
         {
         {
             StringBuffer output;
             StringBuffer output;
-            DBGLOG("json req: %s", content.str());
-            sendRoxieRequest(wsinfo.qsetname.get(), content, jsonresp, status, wsinfo.queryname, "application/json");
-            DBGLOG("json resp: %s", jsonresp.str());
+            if (getEspLogLevel()>LogNormal)
+                DBGLOG("roxie json req: %s", content.str());
+            sendRoxieRequest(queryset.str(), content, jsonresp, status, queryname.str(), "application/json");
+            if (getEspLogLevel()>LogNormal)
+                DBGLOG("roxie json resp: %s", jsonresp.str());
         }
         }
         else
         else
         {
         {
+            WsEclWuInfo wsinfo(wuid.str(), queryset.str(), queryname.str(), ctx->queryUserId(), ctx->queryPassword());
+
             StringBuffer soapfromjson;
             StringBuffer soapfromjson;
             soapfromjson.append(
             soapfromjson.append(
                 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
                 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
@@ -2812,7 +2947,8 @@ void CWsEclBinding::handleJSONPost(CHttpRequest *request, CHttpResponse *respons
                 );
                 );
             createPTreeFromJsonString(content.str(), false, soapfromjson, "Request");
             createPTreeFromJsonString(content.str(), false, soapfromjson, "Request");
             soapfromjson.append("</soap:Body></soap:Envelope>");
             soapfromjson.append("</soap:Body></soap:Envelope>");
-            DBGLOG("soap from json req: %s", soapfromjson.str());
+            if (getEspLogLevel()>LogNormal)
+                DBGLOG("soap from json req: %s", soapfromjson.str());
 
 
             StringBuffer soapresp;
             StringBuffer soapresp;
             unsigned xmlflags = WWV_ADD_SOAP | WWV_ADD_RESULTS_TAG | WWV_ADD_RESPONSE_TAG | WWV_INCL_NAMESPACES | WWV_INCL_GENERATED_NAMESPACES;
             unsigned xmlflags = WWV_ADD_SOAP | WWV_ADD_RESULTS_TAG | WWV_ADD_RESPONSE_TAG | WWV_INCL_NAMESPACES | WWV_INCL_GENERATED_NAMESPACES;
@@ -2824,7 +2960,8 @@ void CWsEclBinding::handleJSONPost(CHttpRequest *request, CHttpResponse *respons
                 xmlflags |= WWV_OMIT_SCHEMAS;
                 xmlflags |= WWV_OMIT_SCHEMAS;
 
 
             submitWsEclWorkunit(*ctx, wsinfo, soapfromjson.str(), soapresp, xmlflags);
             submitWsEclWorkunit(*ctx, wsinfo, soapfromjson.str(), soapresp, xmlflags);
-            DBGLOG("HandleSoapRequest response: %s", soapresp.str());
+            if (getEspLogLevel()>LogNormal)
+                DBGLOG("HandleSoapRequest response: %s", soapresp.str());
             getWsEclJsonResponse(jsonresp, *ctx, request, soapresp.str(), wsinfo);
             getWsEclJsonResponse(jsonresp, *ctx, request, soapresp.str(), wsinfo);
         }
         }
 
 
@@ -2858,6 +2995,7 @@ void CWsEclBinding::handleHttpPost(CHttpRequest *request, CHttpResponse *respons
 int CWsEclBinding::HandleSoapRequest(CHttpRequest* request, CHttpResponse* response)
 int CWsEclBinding::HandleSoapRequest(CHttpRequest* request, CHttpResponse* response)
 {
 {
     IEspContext *ctx = request->queryContext();
     IEspContext *ctx = request->queryContext();
+    ctx->addTraceSummaryValue("wseclMode", "SOAPPost");
     IProperties *parms = request->queryParameters();
     IProperties *parms = request->queryParameters();
 
 
     const char *thepath = request->queryPath();
     const char *thepath = request->queryPath();
@@ -2884,30 +3022,25 @@ int CWsEclBinding::HandleSoapRequest(CHttpRequest* request, CHttpResponse* respo
     nextPathNode(thepath, lookup);
     nextPathNode(thepath, lookup);
 
 
     StringBuffer wuid;
     StringBuffer wuid;
-    StringBuffer queryset;
+    StringBuffer target;
     StringBuffer queryname;
     StringBuffer queryname;
 
 
     if (strieq(lookup.str(), "wuid"))
     if (strieq(lookup.str(), "wuid"))
     {
     {
         nextPathNode(thepath, wuid);
         nextPathNode(thepath, wuid);
-        queryset.append(parms->queryProp("qset"));
+        target.append(parms->queryProp("qset"));
         queryname.append(parms->queryProp("qname"));
         queryname.append(parms->queryProp("qname"));
     }
     }
     else if (strieq(lookup.str(), "query"))
     else if (strieq(lookup.str(), "query"))
     {
     {
-        nextPathNode(thepath, queryset);
+        nextPathNode(thepath, target);
         nextPathNode(thepath, queryname);
         nextPathNode(thepath, queryname);
     }
     }
 
 
-    WsEclWuInfo wsinfo(wuid.str(), queryset.str(), queryname.str(), ctx->queryUserId(), ctx->queryPassword());
-
     StringBuffer content(request->queryContent());
     StringBuffer content(request->queryContent());
     StringBuffer soapresp;
     StringBuffer soapresp;
     StringBuffer status;
     StringBuffer status;
 
 
-    SCMStringBuffer clustertype;
-    wsinfo.wu->getDebugValue("targetclustertype", clustertype);
-
     unsigned xmlflags = WWV_ADD_SOAP | WWV_ADD_RESULTS_TAG | WWV_ADD_RESPONSE_TAG | WWV_INCL_NAMESPACES | WWV_INCL_GENERATED_NAMESPACES;
     unsigned xmlflags = WWV_ADD_SOAP | WWV_ADD_RESULTS_TAG | WWV_ADD_RESPONSE_TAG | WWV_INCL_NAMESPACES | WWV_INCL_GENERATED_NAMESPACES;
     if (ctx->queryRequestParameters()->hasProp("display"))
     if (ctx->queryRequestParameters()->hasProp("display"))
         xmlflags |= WWV_USE_DISPLAY_XSLT;
         xmlflags |= WWV_USE_DISPLAY_XSLT;
@@ -2916,19 +3049,29 @@ int CWsEclBinding::HandleSoapRequest(CHttpRequest* request, CHttpResponse* respo
     else
     else
         xmlflags |= WWV_OMIT_SCHEMAS;
         xmlflags |= WWV_OMIT_SCHEMAS;
 
 
-    if (strieq(clustertype.str(), "roxie"))
+    if (wsecl->connMap.getValue(target))
     {
     {
         StringBuffer content(request->queryContent());
         StringBuffer content(request->queryContent());
         StringBuffer output;
         StringBuffer output;
-        sendRoxieRequest(wsinfo.qsetname.get(), content, output, status, wsinfo.queryname);
-        Owned<IWuWebView> web = createWuWebView(*wsinfo.wu, wsinfo.queryname.get(), getCFD(), true);
-        if (web.get())
-            web->expandResults(output.str(), soapresp, xmlflags);
+        sendRoxieRequest(target, content, output, status, queryname);
+        if (!(xmlflags  & WWV_CDATA_SCHEMAS))
+            soapresp.swapWith(output);
+        else
+        {
+            WsEclWuInfo wsinfo(wuid.str(), target.str(), queryname.str(), ctx->queryUserId(), ctx->queryPassword());
+            Owned<IWuWebView> web = createWuWebView(*wsinfo.wu, wsinfo.queryname.get(), getCFD(), true);
+            if (web.get())
+                web->expandResults(output.str(), soapresp, xmlflags);
+        }
     }
     }
     else
     else
+    {
+        WsEclWuInfo wsinfo(wuid.str(), target.str(), queryname.str(), ctx->queryUserId(), ctx->queryPassword());
         submitWsEclWorkunit(*ctx, wsinfo, content.str(), soapresp, xmlflags);
         submitWsEclWorkunit(*ctx, wsinfo, content.str(), soapresp, xmlflags);
+    }
 
 
-    DBGLOG("HandleSoapRequest response: %s", soapresp.str());
+    if (getEspLogLevel()>LogNormal)
+        DBGLOG("HandleSoapRequest response: %s", soapresp.str());
 
 
     response->setContent(soapresp.str());
     response->setContent(soapresp.str());
     response->setContentType("text/xml");
     response->setContentType("text/xml");

+ 1 - 0
roxie/ccd/ccdactivities.cpp

@@ -564,6 +564,7 @@ public:
     virtual char *getClusterName() { throwUnexpected(); } // caller frees return str.
     virtual char *getClusterName() { throwUnexpected(); } // caller frees return str.
     virtual char *getGroupName() { throwUnexpected(); } // caller frees return string.
     virtual char *getGroupName() { throwUnexpected(); } // caller frees return string.
     virtual char * queryIndexMetaData(char const * lfn, char const * xpath) { throwUnexpected(); }
     virtual char * queryIndexMetaData(char const * lfn, char const * xpath) { throwUnexpected(); }
+    virtual char *getDaliServers() { return queryContext->queryCodeContext()->getDaliServers(); }
 
 
     // The below are called on Roxie server and passed in context
     // The below are called on Roxie server and passed in context
     virtual unsigned getPriority() const { throwUnexpected(); }
     virtual unsigned getPriority() const { throwUnexpected(); }

+ 7 - 0
roxie/ccd/ccdcontext.cpp

@@ -1164,6 +1164,7 @@ public:
         return createRowFromXml(rowAllocator, len, utf8, xmlTransformer, stripWhitespace);
         return createRowFromXml(rowAllocator, len, utf8, xmlTransformer, stripWhitespace);
     }
     }
     virtual IEngineContext *queryEngineContext() { return NULL; }
     virtual IEngineContext *queryEngineContext() { return NULL; }
+    virtual char *getDaliServers() { throwUnexpected(); }
 
 
     // The following from ICodeContext should never be executed in slave activity. If we are on Roxie server (or in child query on slave), they will be implemented by more derived CRoxieServerContext class
     // The following from ICodeContext should never be executed in slave activity. If we are on Roxie server (or in child query on slave), they will be implemented by more derived CRoxieServerContext class
     virtual void setResultBool(const char *name, unsigned sequence, bool value) { throwUnexpected(); }
     virtual void setResultBool(const char *name, unsigned sequence, bool value) { throwUnexpected(); }
@@ -2171,6 +2172,12 @@ public:
         return result;
         return result;
     }
     }
 
 
+    virtual char *getDaliServers()
+    {
+        //MORE: Should this now be implemented using IRoxieDaliHelper?
+        throwUnexpected();
+    }
+
     virtual void setResultBool(const char *name, unsigned sequence, bool value)
     virtual void setResultBool(const char *name, unsigned sequence, bool value)
     {
     {
         if (isSpecialResultSequence(sequence))
         if (isSpecialResultSequence(sequence))

+ 1 - 0
rtl/include/eclhelper.hpp

@@ -595,6 +595,7 @@ interface ICodeContext : public IResourceContext
     virtual void getExternalResultRaw(unsigned & tlen, void * & tgt, const char * wuid, const char * stepname, unsigned sequence, IXmlToRowTransformer * xmlTransformer, ICsvToRowTransformer * csvTransformer) = 0;    // shouldn't really be here, but it broke thor.
     virtual void getExternalResultRaw(unsigned & tlen, void * & tgt, const char * wuid, const char * stepname, unsigned sequence, IXmlToRowTransformer * xmlTransformer, ICsvToRowTransformer * csvTransformer) = 0;    // shouldn't really be here, but it broke thor.
     virtual char * queryIndexMetaData(char const * lfn, char const * xpath) = 0;
     virtual char * queryIndexMetaData(char const * lfn, char const * xpath) = 0;
     virtual IEngineContext *queryEngineContext() = 0;
     virtual IEngineContext *queryEngineContext() = 0;
+    virtual char *getDaliServers() = 0;
 };
 };
 
 
 
 

+ 6 - 0
testing/ecl/key/thorlib1.xml

@@ -0,0 +1,6 @@
+<Dataset name='Result 1'>
+ <Row><Result_1>true</Result_1></Row>
+</Dataset>
+<Dataset name='Result 2'>
+ <Row><Result_2>true</Result_2></Row>
+</Dataset>

+ 25 - 0
testing/ecl/thorlib1.ecl

@@ -0,0 +1,25 @@
+/*##############################################################################
+
+    HPCC SYSTEMS software Copyright (C) 2012 HPCC Systems.
+
+    Licensed under the Apache License, Version 2.0 (the "License");
+    you may not use this file except in compliance with the License.
+    You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+############################################################################## */
+
+//noroxie
+
+import lib_thorlib;
+
+dali := lib_thorlib.thorlib.daliServers();
+
+dali != '';
+dali[LENGTH(dali)-4..] = ':7070';

+ 4 - 0
thorlcr/graph/thgraph.hpp

@@ -522,6 +522,10 @@ class graph_decl CGraphBase : public CInterface, implements IEclGraphResults, im
         {
         {
             return ctx->queryEngineContext();
             return ctx->queryEngineContext();
         }
         }
+        virtual char *getDaliServers()
+        {
+            return ctx->getDaliServers();
+        }
    } graphCodeContext;
    } graphCodeContext;
 
 
 protected:
 protected:

+ 16 - 0
thorlcr/thorcodectx/thcodectx.cpp

@@ -71,6 +71,22 @@ const char *CThorCodeContextBase::loadResource(unsigned id)
     return (const char *) querySo.getResource(id);
     return (const char *) querySo.getResource(id);
 }
 }
 
 
+char *CThorCodeContextBase::getDaliServers()
+{
+    StringBuffer dali;
+    IGroup &group = queryCoven().queryComm().queryGroup();
+    Owned<INodeIterator> coven = group.getIterator();
+    bool first = true;
+    ForEach(*coven)
+    {
+        if (first)
+            first = false;
+        else
+            dali.append(',');
+        coven->query().endpoint().getUrlStr(dali);
+    }
+    return dali.detach();
+}
 
 
 void CThorCodeContextBase::expandLogicalName(StringBuffer & fullname, const char * logicalName)
 void CThorCodeContextBase::expandLogicalName(StringBuffer & fullname, const char * logicalName)
 {
 {

+ 1 - 0
thorlcr/thorcodectx/thcodectx.hpp

@@ -117,6 +117,7 @@ public:
     virtual IConstWUResult *getResultForGet(const char *name, unsigned sequence) { throwUnexpected(); }
     virtual IConstWUResult *getResultForGet(const char *name, unsigned sequence) { throwUnexpected(); }
     virtual const void * fromXml(IEngineRowAllocator * rowAllocator, size32_t len, const char * utf8, IXmlToRowTransformer * xmlTransformer, bool stripWhitespace);
     virtual const void * fromXml(IEngineRowAllocator * rowAllocator, size32_t len, const char * utf8, IXmlToRowTransformer * xmlTransformer, bool stripWhitespace);
     virtual IEngineContext *queryEngineContext() { return NULL; }
     virtual IEngineContext *queryEngineContext() { return NULL; }
+    virtual char *getDaliServers();
 };
 };
 
 
 #endif
 #endif