Browse Source

Merge pull request #4678 from ghalliday/issue9745

HPCC-9745 Add getDaliServers() back into the ICodeContext
Richard Chapman 12 years ago
parent
commit
4f80ace6b7

+ 4 - 1
common/thorhelper/thorcommon.hpp

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

+ 18 - 0
ecl/eclagent/eclagent.cpp

@@ -2869,6 +2869,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()
 {

+ 1 - 0
ecl/eclagent/eclagent.ipp

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

+ 1 - 0
roxie/ccd/ccdactivities.cpp

@@ -564,6 +564,7 @@ public:
     virtual char *getClusterName() { throwUnexpected(); } // caller frees return str.
     virtual char *getGroupName() { throwUnexpected(); } // caller frees return string.
     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
     virtual unsigned getPriority() const { throwUnexpected(); }

+ 7 - 0
roxie/ccd/ccdcontext.cpp

@@ -1164,6 +1164,7 @@ public:
         return createRowFromXml(rowAllocator, len, utf8, xmlTransformer, stripWhitespace);
     }
     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
     virtual void setResultBool(const char *name, unsigned sequence, bool value) { throwUnexpected(); }
@@ -2171,6 +2172,12 @@ public:
         return result;
     }
 
+    virtual char *getDaliServers()
+    {
+        //MORE: Should this now be implemented using IRoxieDaliHelper?
+        throwUnexpected();
+    }
+
     virtual void setResultBool(const char *name, unsigned sequence, bool value)
     {
         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 char * queryIndexMetaData(char const * lfn, char const * xpath) = 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();
         }
+        virtual char *getDaliServers()
+        {
+            return ctx->getDaliServers();
+        }
    } graphCodeContext;
 
 protected:

+ 16 - 0
thorlcr/thorcodectx/thcodectx.cpp

@@ -71,6 +71,22 @@ const char *CThorCodeContextBase::loadResource(unsigned 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)
 {

+ 1 - 0
thorlcr/thorcodectx/thcodectx.hpp

@@ -117,6 +117,7 @@ public:
     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 IEngineContext *queryEngineContext() { return NULL; }
+    virtual char *getDaliServers();
 };
 
 #endif