|
@@ -361,7 +361,7 @@ CGraphElementBase::CGraphElementBase(CGraphBase &_owner, IPropertyTree &_xgmml)
|
|
isGrouped = xgmml->getPropBool("att[@name=\"grouped\"]/@value", false);
|
|
isGrouped = xgmml->getPropBool("att[@name=\"grouped\"]/@value", false);
|
|
resultsGraph = NULL;
|
|
resultsGraph = NULL;
|
|
ownerId = xgmml->getPropInt("att[@name=\"_parentActivity\"]/@value", 0);
|
|
ownerId = xgmml->getPropInt("att[@name=\"_parentActivity\"]/@value", 0);
|
|
- onCreateCalled = onStartCalled = prepared = haveCreateCtx = haveStartCtx = nullAct = false;
|
|
|
|
|
|
+ onCreateCalled = prepared = haveCreateCtx = nullAct = false;
|
|
onlyUpdateIfChanged = xgmml->getPropBool("att[@name=\"_updateIfChanged\"]/@value", false);
|
|
onlyUpdateIfChanged = xgmml->getPropBool("att[@name=\"_updateIfChanged\"]/@value", false);
|
|
|
|
|
|
StringBuffer helperName("fAc");
|
|
StringBuffer helperName("fAc");
|
|
@@ -467,7 +467,6 @@ IThorGraphDependencyIterator *CGraphElementBase::getDependsIterator() const
|
|
void CGraphElementBase::reset()
|
|
void CGraphElementBase::reset()
|
|
{
|
|
{
|
|
alreadyUpdated = false;
|
|
alreadyUpdated = false;
|
|
- onStartCalled = false;
|
|
|
|
if (activity)
|
|
if (activity)
|
|
activity->reset();
|
|
activity->reset();
|
|
}
|
|
}
|
|
@@ -556,14 +555,6 @@ void CGraphElementBase::serializeCreateContext(MemoryBuffer &mb)
|
|
mb.append(alreadyUpdated);
|
|
mb.append(alreadyUpdated);
|
|
}
|
|
}
|
|
|
|
|
|
-void CGraphElementBase::serializeStartContext(MemoryBuffer &mb)
|
|
|
|
-{
|
|
|
|
- if (!onStartCalled) return;
|
|
|
|
- DelayedSizeMarker sizeMark(mb);
|
|
|
|
- queryHelper()->serializeStartContext(mb);
|
|
|
|
- sizeMark.write();
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
void CGraphElementBase::deserializeCreateContext(MemoryBuffer &mb)
|
|
void CGraphElementBase::deserializeCreateContext(MemoryBuffer &mb)
|
|
{
|
|
{
|
|
size32_t createCtxLen;
|
|
size32_t createCtxLen;
|
|
@@ -574,13 +565,11 @@ void CGraphElementBase::deserializeCreateContext(MemoryBuffer &mb)
|
|
mb.read(alreadyUpdated);
|
|
mb.read(alreadyUpdated);
|
|
}
|
|
}
|
|
|
|
|
|
-void CGraphElementBase::deserializeStartContext(MemoryBuffer &mb)
|
|
|
|
|
|
+void CGraphElementBase::serializeStartContext(MemoryBuffer &mb)
|
|
{
|
|
{
|
|
- size32_t startCtxLen;
|
|
|
|
- mb.read(startCtxLen);
|
|
|
|
- startCtxMb.clear().append(startCtxLen, mb.readDirect(startCtxLen));
|
|
|
|
- haveStartCtx = true;
|
|
|
|
- onStartCalled = false; // allow to be called again
|
|
|
|
|
|
+ DelayedSizeMarker sizeMark(mb);
|
|
|
|
+ queryHelper()->serializeStartContext(mb);
|
|
|
|
+ sizeMark.write();
|
|
}
|
|
}
|
|
|
|
|
|
void CGraphElementBase::onCreate()
|
|
void CGraphElementBase::onCreate()
|
|
@@ -609,22 +598,12 @@ void CGraphElementBase::onCreate()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-void CGraphElementBase::onStart(size32_t parentExtractSz, const byte *parentExtract)
|
|
|
|
|
|
+void CGraphElementBase::onStart(size32_t parentExtractSz, const byte *parentExtract, MemoryBuffer *startCtx)
|
|
{
|
|
{
|
|
- if (onStartCalled)
|
|
|
|
|
|
+ if (nullAct)
|
|
return;
|
|
return;
|
|
- onStartCalled = true;
|
|
|
|
- if (!nullAct)
|
|
|
|
- {
|
|
|
|
- if (haveStartCtx)
|
|
|
|
- {
|
|
|
|
- baseHelper->onStart(parentExtract, &startCtxMb);
|
|
|
|
- startCtxMb.reset();
|
|
|
|
- haveStartCtx = false;
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- baseHelper->onStart(parentExtract, NULL);
|
|
|
|
- }
|
|
|
|
|
|
+ CriticalBlock b(crit);
|
|
|
|
+ baseHelper->onStart(parentExtract, startCtx);
|
|
}
|
|
}
|
|
|
|
|
|
bool CGraphElementBase::executeDependencies(size32_t parentExtractSz, const byte *parentExtract, int controlId, bool async)
|
|
bool CGraphElementBase::executeDependencies(size32_t parentExtractSz, const byte *parentExtract, int controlId, bool async)
|
|
@@ -647,7 +626,7 @@ bool CGraphElementBase::prepareContext(size32_t parentExtractSz, const byte *par
|
|
bool create = true;
|
|
bool create = true;
|
|
if (connectOnly)
|
|
if (connectOnly)
|
|
{
|
|
{
|
|
- if (activity)
|
|
|
|
|
|
+ if (prepared)
|
|
return true;
|
|
return true;
|
|
ForEachItemIn(i, inputs)
|
|
ForEachItemIn(i, inputs)
|
|
{
|
|
{
|
|
@@ -799,10 +778,7 @@ bool CGraphElementBase::prepareContext(size32_t parentExtractSz, const byte *par
|
|
CIOConnection *inputIO = inputs.item(i2);
|
|
CIOConnection *inputIO = inputs.item(i2);
|
|
connectInput(i2, inputIO->activity, inputIO->index);
|
|
connectInput(i2, inputIO->activity, inputIO->index);
|
|
}
|
|
}
|
|
- if (isSink())
|
|
|
|
- owner->addActiveSink(*this);
|
|
|
|
- assertex(!activity);
|
|
|
|
- activity.setown(factory());
|
|
|
|
|
|
+ createActivity();
|
|
}
|
|
}
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
@@ -828,11 +804,14 @@ void CGraphElementBase::preStart(size32_t parentExtractSz, const byte *parentExt
|
|
activity->preStart(parentExtractSz, parentExtract);
|
|
activity->preStart(parentExtractSz, parentExtract);
|
|
}
|
|
}
|
|
|
|
|
|
-void CGraphElementBase::initActivity()
|
|
|
|
|
|
+void CGraphElementBase::createActivity()
|
|
{
|
|
{
|
|
|
|
+ CriticalBlock b(crit);
|
|
if (activity)
|
|
if (activity)
|
|
return;
|
|
return;
|
|
activity.setown(factory());
|
|
activity.setown(factory());
|
|
|
|
+ if (isSink())
|
|
|
|
+ owner->addActiveSink(*this);
|
|
}
|
|
}
|
|
|
|
|
|
ICodeContext *CGraphElementBase::queryCodeContext()
|
|
ICodeContext *CGraphElementBase::queryCodeContext()
|
|
@@ -1104,23 +1083,6 @@ void CGraphBase::serializeCreateContexts(MemoryBuffer &mb)
|
|
sizeMark.write();
|
|
sizeMark.write();
|
|
}
|
|
}
|
|
|
|
|
|
-void CGraphBase::serializeStartContexts(MemoryBuffer &mb)
|
|
|
|
-{
|
|
|
|
- DelayedSizeMarker sizeMark(mb);
|
|
|
|
- Owned<IThorActivityIterator> iter = getIterator();
|
|
|
|
- ForEach (*iter)
|
|
|
|
- {
|
|
|
|
- CGraphElementBase &element = iter->query();
|
|
|
|
- if (element.isOnStarted())
|
|
|
|
- {
|
|
|
|
- mb.append(element.queryId());
|
|
|
|
- element.serializeStartContext(mb);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- mb.append((activity_id)0);
|
|
|
|
- sizeMark.write();
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
void CGraphBase::deserializeCreateContexts(MemoryBuffer &mb)
|
|
void CGraphBase::deserializeCreateContexts(MemoryBuffer &mb)
|
|
{
|
|
{
|
|
activity_id id;
|
|
activity_id id;
|
|
@@ -1134,19 +1096,6 @@ void CGraphBase::deserializeCreateContexts(MemoryBuffer &mb)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-void CGraphBase::deserializeStartContexts(MemoryBuffer &mb)
|
|
|
|
-{
|
|
|
|
- activity_id id;
|
|
|
|
- loop
|
|
|
|
- {
|
|
|
|
- mb.read(id);
|
|
|
|
- if (0 == id) break;
|
|
|
|
- CGraphElementBase *element = queryElement(id);
|
|
|
|
- assertex(element);
|
|
|
|
- element->deserializeStartContext(mb);
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
void CGraphBase::reset()
|
|
void CGraphBase::reset()
|
|
{
|
|
{
|
|
setCompleteEx(false);
|
|
setCompleteEx(false);
|
|
@@ -1194,7 +1143,6 @@ bool CGraphBase::fireException(IException *e)
|
|
|
|
|
|
bool CGraphBase::preStart(size32_t parentExtractSz, const byte *parentExtract)
|
|
bool CGraphBase::preStart(size32_t parentExtractSz, const byte *parentExtract)
|
|
{
|
|
{
|
|
- started = true; // causes reset() to be called on all subsequent executions of this subgraph.
|
|
|
|
Owned<IThorActivityIterator> iter = getConnectedIterator();
|
|
Owned<IThorActivityIterator> iter = getConnectedIterator();
|
|
ForEach(*iter)
|
|
ForEach(*iter)
|
|
{
|
|
{
|
|
@@ -1274,11 +1222,14 @@ void CGraphBase::doExecute(size32_t parentExtractSz, const byte *parentExtract,
|
|
throw abortException.getLink();
|
|
throw abortException.getLink();
|
|
throw MakeGraphException(this, 0, "subgraph aborted");
|
|
throw MakeGraphException(this, 0, "subgraph aborted");
|
|
}
|
|
}
|
|
|
|
+ GraphPrintLog("Processing graph");
|
|
Owned<IException> exception;
|
|
Owned<IException> exception;
|
|
try
|
|
try
|
|
{
|
|
{
|
|
if (started)
|
|
if (started)
|
|
reset();
|
|
reset();
|
|
|
|
+ else
|
|
|
|
+ started = true;
|
|
Owned<IThorActivityIterator> iter = getConnectedIterator();
|
|
Owned<IThorActivityIterator> iter = getConnectedIterator();
|
|
ForEach(*iter)
|
|
ForEach(*iter)
|
|
{
|
|
{
|
|
@@ -1286,6 +1237,7 @@ void CGraphBase::doExecute(size32_t parentExtractSz, const byte *parentExtract,
|
|
element.onStart(parentExtractSz, parentExtract);
|
|
element.onStart(parentExtractSz, parentExtract);
|
|
element.initActivity();
|
|
element.initActivity();
|
|
}
|
|
}
|
|
|
|
+ initialized = true;
|
|
if (!preStart(parentExtractSz, parentExtract)) return;
|
|
if (!preStart(parentExtractSz, parentExtract)) return;
|
|
start();
|
|
start();
|
|
if (!wait(aborted?MEDIUMTIMEOUT:INFINITE)) // can't wait indefinitely, query may have aborted and stall, but prudent to wait a short time for underlying graphs to unwind.
|
|
if (!wait(aborted?MEDIUMTIMEOUT:INFINITE)) // can't wait indefinitely, query may have aborted and stall, but prudent to wait a short time for underlying graphs to unwind.
|