فهرست منبع

Merge pull request #4096 from jakesmith/hpcc-8966

HPCC-8966 - Provide a context for GetGlobalUniqueIds

Reviewed-By: Gavin Halliday <gavin.halliday@lexisnexis.com>
Reviewed-By: Richard Chapman <rchapman@hpccsystems.com>
Richard Chapman 12 سال پیش
والد
کامیت
3a0cd25137

+ 29 - 0
common/thorhelper/enginecontext.hpp

@@ -0,0 +1,29 @@
+/*##############################################################################
+
+    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.
+############################################################################## */
+
+#ifndef ENGINECONTEXT_HPP
+#define ENGINECONTEXT_HPP
+
+#include "jsocket.hpp"
+#include "dacoven.hpp"
+
+interface IEngineContext
+{
+    virtual DALI_UID getGlobalUniqueIds(unsigned num, SocketEndpoint *_foreignNode) = 0;
+};
+
+#endif // ENGINECONTEXT_HPP

+ 4 - 0
common/thorhelper/thorcommon.hpp

@@ -415,6 +415,10 @@ public:
     {
         return ctx->fromXml(_rowAllocator, len, utf8, xmlTransformer, stripWhitespace);
     }
+    virtual IEngineContext *queryEngineContext()
+    {
+        return ctx->queryEngineContext();
+    }
 
 protected:
     ICodeContext * ctx;

+ 1 - 1
dali/base/dacoven.cpp

@@ -992,7 +992,7 @@ const CDaliVersion &queryDaliServerVersion()
 }
 
 
-DALI_UID    getGlobalUniqueIds(unsigned num,SocketEndpoint *_foreignnode)
+DALI_UID getGlobalUniqueIds(unsigned num,SocketEndpoint *_foreignnode)
 {
     if (num==0)
         return 0;

+ 1 - 0
ecl/eclagent/eclagent.ipp

@@ -513,6 +513,7 @@ public:
     virtual bool queryWriteResultsToStdout() { return writeResultsToStdout; }
     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; }
 
     unsigned __int64 queryStopAfter() { return stopAfter; }
 

+ 6 - 2
plugins/fileservices/fileservices.cpp

@@ -34,6 +34,7 @@
 #include "dfuplus.hpp"
 #include "daclient.hpp"
 #include "dasds.hpp"
+#include "enginecontext.hpp"
 
 #define USE_DALIDFS
 #define SDS_LOCK_TIMEOUT  10000
@@ -115,7 +116,7 @@ static const char * EclDefinition =
 "  dataset(FsLogicalSuperSubRecord) LogicalFileSuperSubList() : c,context,entrypoint='fsLogicalFileSuperSubList';\n"
 "  PromoteSuperFileList(const set of varstring lsuperfns,const varstring addhead='',boolean deltail=false,boolean createonlyonesuperfile=false,boolean reverse=false) : c,action,context,entrypoint='fsPromoteSuperFileList'; \n"
 "  varstring fPromoteSuperFileList(const set of varstring lsuperfns,const varstring addhead='', boolean deltail=false,boolean createonlyonesuperfile=false, boolean reverse=false) : c,action,context,entrypoint='fsfPromoteSuperFileList'; \n"
-"  unsigned8 getUniqueInteger(const varstring foreigndali='') : c,entrypoint='fsGetUniqueInteger'; \n"
+"  unsigned8 getUniqueInteger(const varstring foreigndali='') : c,context,entrypoint='fsGetUniqueInteger'; \n"
 "  AddFileRelationship(const varstring primary, const varstring secondary, const varstring primaryflds,  const varstring secondaryflds, const varstring kind='link', const varstring cardinality, boolean payload, const varstring description='') : c,action,context,entrypoint='fsAddFileRelationship'; \n"
 "  dataset(FsFileRelationshipRecord) FileRelationshipList(const varstring primary, const varstring secondary, const varstring primflds='', const varstring secondaryflds='',  const varstring kind='link') : c,action,context,entrypoint='fsFileRelationshipList'; \n"
 "  RemoveFileRelationship(const varstring primary,  const varstring secondary, const varstring primaryflds='', const varstring secondaryflds='',  const varstring kind='link') : c,action,context,entrypoint='fsRemoveFileRelationship'; \n"
@@ -1858,11 +1859,14 @@ FILESERVICES_API  char * FILESERVICES_CALL fsfPromoteSuperFileList(ICodeContext
     return addlist.detach();
 }
 
-FILESERVICES_API unsigned __int64 FILESERVICES_CALL fsGetUniqueInteger(const char *foreigndali)
+FILESERVICES_API unsigned __int64 FILESERVICES_CALL fsGetUniqueInteger(ICodeContext * ctx, const char *foreigndali)
 {
     SocketEndpoint ep;
     if (foreigndali&&*foreigndali)
         ep.set(foreigndali);
+    IEngineContext *engineContext = ctx->queryEngineContext();
+    if (engineContext)
+        return engineContext->getGlobalUniqueIds(1,&ep);
     return getGlobalUniqueIds(1,&ep);
 }
 

+ 1 - 1
plugins/fileservices/fileservices.hpp

@@ -108,7 +108,7 @@ FILESERVICES_API char * FILESERVICES_CALL fslWaitDfuWorkunit(ICodeContext *ctx,
 FILESERVICES_API void FILESERVICES_CALL fslAbortDfuWorkunit(ICodeContext *ctx, const char *wuid, const char * espServerIpPort);
 FILESERVICES_API void FILESERVICES_CALL fsPromoteSuperFileList(ICodeContext * ctx,bool isAllLsuperfns,size32_t  lenLsuperfns,const void * lsuperfns,const char * addhead,bool deltail,bool createonlyonesuperfile,bool reverse);
 FILESERVICES_API char * FILESERVICES_CALL fsfPromoteSuperFileList(ICodeContext * ctx,bool isAllLsuperfns,size32_t  lenLsuperfns,const void * lsuperfns,const char * addhead,bool deltail,bool createonlyonesuperfile,bool reverse);
-FILESERVICES_API unsigned __int64 FILESERVICES_CALL fsGetUniqueInteger(const char *foreigndali);
+FILESERVICES_API unsigned __int64 FILESERVICES_CALL fsGetUniqueInteger(ICodeContext * ctx,const char *foreigndali);
 FILESERVICES_API void FILESERVICES_CALL fsAddFileRelationship(ICodeContext * ctx,const char *primary, const char *secondary, const char *primflds, const char *secflds, const char *kind, const char *cardinality, bool payload, const char *description);
 FILESERVICES_API void FILESERVICES_CALL fsFileRelationshipList(ICodeContext * ctx,size32_t & __lenResult,void * & __result,const char *primary, const char *secondary, const char *primflds, const char *secflds, const char *kind);
 FILESERVICES_API void FILESERVICES_CALL fsRemoveFileRelationship(ICodeContext * ctx,const char *primary, const char *secondary, const char *primflds, const char *secflds, const char *kind);

+ 1 - 0
roxie/ccd/ccdactivities.cpp

@@ -606,6 +606,7 @@ public:
     {
         return createRowFromXml(rowAllocator, len, utf8, xmlTransformer, stripWhitespace);
     }
+    virtual IEngineContext *queryEngineContext() { return NULL; }
 };
 
 //================================================================================================

+ 1 - 0
roxie/ccd/ccdcontext.cpp

@@ -1163,6 +1163,7 @@ public:
     {
         return createRowFromXml(rowAllocator, len, utf8, xmlTransformer, stripWhitespace);
     }
+    virtual IEngineContext *queryEngineContext() { return NULL; }
 
     // 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(); }

+ 4 - 2
rtl/include/eclhelper.hpp

@@ -39,8 +39,8 @@ if the supplied pointer was not from the roxiemem heap. Usually an OwnedRoxieStr
 
 //Should be incremented whenever the virtuals in the context or a helper are changed, so
 //that a work unit can't be rerun.  Try as hard as possible to retain compatibility.
-#define ACTIVITY_INTERFACE_VERSION      146
-#define MIN_ACTIVITY_INTERFACE_VERSION  146             //minimum value that is compatible with current interface - without using selectInterface
+#define ACTIVITY_INTERFACE_VERSION      147
+#define MIN_ACTIVITY_INTERFACE_VERSION  147             //minimum value that is compatible with current interface - without using selectInterface
 
 typedef unsigned char byte;
 
@@ -496,6 +496,7 @@ interface IDistributedFileTransaction;
 interface IUserDescriptor;
 interface IHThorArg;
 interface IHThorHashLookupInfo;
+interface IEngineContext;
 
 interface ICodeContext : public IResourceContext
 {
@@ -591,6 +592,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;
 };
 
 

+ 5 - 1
thorlcr/graph/thgraph.hpp

@@ -517,7 +517,11 @@ class graph_decl CGraphBase : public CInterface, implements IEclGraphResults, im
         {
             return ctx->fromXml(_rowAllocator, len, utf8, xmlTransformer, stripWhitespace);
         }
-    } graphCodeContext;
+        virtual IEngineContext *queryEngineContext()
+        {
+            return ctx->queryEngineContext();
+        }
+   } graphCodeContext;
 
 protected:
     Owned<IThorGraphResults> localResults, graphLoopResults;

+ 15 - 1
thorlcr/graph/thgraphslave.cpp

@@ -27,6 +27,7 @@
 #include "slwatchdog.hpp"
 #include "thgraphslave.hpp"
 #include "thcompressutil.hpp"
+#include "enginecontext.hpp"
 
 //////////////////////////////////
 
@@ -900,7 +901,7 @@ IThorResult *CSlaveGraph::getGlobalResult(CActivityBase &activity, IRowInterface
 
 ///////////////////////////
 
-class CThorCodeContextSlave : public CThorCodeContextBase
+class CThorCodeContextSlave : public CThorCodeContextBase, implements IEngineContext
 {
     mptag_t mptag;
     Owned<IDistributedFileTransaction> superfiletransaction;
@@ -992,6 +993,19 @@ public:
         job.fireException(e);
     }
     virtual unsigned __int64 getDatasetHash(const char * name, unsigned __int64 hash)   { throwUnexpected(); }      // Should only call from master
+    virtual IEngineContext *queryEngineContext() { return this; }
+// IEngineContext impl.
+    virtual DALI_UID getGlobalUniqueIds(unsigned num, SocketEndpoint *_foreignNode)
+    {
+        if (num==0)
+            return 0;
+        SocketEndpoint foreignNode;
+        if (_foreignNode && !_foreignNode->isNull())
+            foreignNode.set(*_foreignNode);
+        else
+            foreignNode.set(globals->queryProp("@DALISERVERS"));
+        return ::getGlobalUniqueIds(num, &foreignNode);
+    }
 };
 
 class CSlaveGraphTempHandler : public CGraphTempHandler

+ 1 - 0
thorlcr/thorcodectx/thcodectx.hpp

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