void ProcessSlaveActivity::main() { #ifdef TIME_ACTIVITIES if (timeActivities) lastCycles = get_cycles_now(); #endif try { process(); } catch (IException *_e) { IThorException *e = QUERYINTERFACE(_e, IThorException); if (e) { if (!e->queryActivityId()) { e->setGraphId(container.queryOwner().queryGraphId()); e->setActivityKind(container.getKind()); e->setActivityId(container.queryId()); } } else { e = MakeActivityException(this, _e); if (QUERYINTERFACE(_e, ISEH_Exception)) { IThorException *e2 = MakeThorFatal(e, TE_SEH, "FATAL: (SEH)"); e->Release(); e = e2; } _e->Release(); } ActPrintLog(e, NULL); exception.setown(e); } catch (std::exception & es) { StringBuffer m("FATAL std::exception "); if(dynamic_cast<std::bad_alloc *>(&es)) m.append("out of memory (std::bad_alloc)"); else m.append("standard library exception (std::exception ").append(es.what()).append(")"); m.appendf(" in %"ACTPF"d",container.queryId()); ActPrintLogEx(&queryContainer(), thorlog_null, MCerror, "%s", m.str()); exception.setown(MakeThorFatal(NULL, TE_UnknownException, "%s", m.str())); } catch (CATCHALL) { ActPrintLogEx(&queryContainer(), thorlog_null, MCerror, "Unknown exception thrown in process()"); exception.setown(MakeThorFatal(NULL, TE_UnknownException, "FATAL: Unknown exception thrown by ProcessThread")); } try { endProcess(); } catch (IException *_e) { ActPrintLog(_e, "Exception calling activity endProcess"); fireException(_e); exception.set(_e); _e->Release(); } }
void CDiskWriteSlaveActivityBase::removeFiles() { if (!fName.length()) return; Owned<IFile> primary = createIFile(fName); try { primary->remove(); } catch (IException *e) { ActPrintLogEx(&queryContainer(), e, thorlog_null, MCwarning, "Failed to remove file: %s", fName.get()); } catch (CATCHALL) { ActPrintLogEx(&queryContainer(), thorlog_null, MCwarning, "Failed to remove: %s", fName.get()); } }
bool executeDependencies(int controlId) { if (global) { if (!barrier->wait(false)) return false; } else { ActPrintLog("Executing dependencies"); queryContainer().executeDependencies(savedParentExtractSz, savedParentExtract, controlId, true); } return true; }
void CDiskWriteSlaveActivityBase::close() { try { if (out) { uncompressedBytesWritten = out->getPosition(); if (calcFileCrc) { if (diskHelperBase->getFlags() & TDWextend) { assertex(!"TBD need to merge CRC"); } else out->flush(&fileCRC); } else if (!abortSoon) out->flush(); out.clear(); } else if (outraw) { outraw->flush(); uncompressedBytesWritten = outraw->tell(); outraw.clear(); } { CriticalBlock block(statsCs); mergeStats(fileStats, outputIO); outputIO.clear(); } if (!rfsQueryParallel && dlfn.isExternal() && !lastNode()) { rowcount_t rows = processed & THORDATALINK_COUNT_MASK; ActPrintLog("External write done, signalling next (row count = %" RCPF "d)", rows); CMessageBuffer msg; msg.append(rows); msg.append(tempExternalName); queryJobChannel().queryJobComm().send(msg, queryJobChannel().queryMyRank()+1, mpTag); } } catch (IException *e) { ActPrintLogEx(&queryContainer(), e, thorlog_null, MCwarning, "Error closing file: %s", fName.get()); abortSoon = true; removeFiles(); throw e; } if (abortSoon) removeFiles(); }
void start() { ActivityTimer s(totalCycles, timeActivities, NULL); dataLinkStart(activityKindStr(queryContainer().getKind()), container.queryId()); input = inputs.item(0); unsigned spillPriority = container.queryGrouped() ? SPILL_PRIORITY_GROUPSORT : SPILL_PRIORITY_LARGESORT; iLoader.setown(createThorRowLoader(*this, queryRowInterfaces(input), iCompare, !unstable, rc_mixed, spillPriority)); startInput(input); eoi = false; if (container.queryGrouped()) out.setown(iLoader->loadGroup(input, abortSoon)); else out.setown(iLoader->load(input, abortSoon)); if (0 == iLoader->numRows()) eoi = true; }
void init(MemoryBuffer &data, MemoryBuffer &slaveData) { if (!container.queryLocalOrGrouped()) mpTag = container.queryJobChannel().deserializeMPTag(data); global = !queryContainer().queryLoopGraph()->queryGraph()->isLocalOnly(); }
void processDone(MemoryBuffer &mb) { CSlaveActivity::processDone(mb); ((CSlaveGraph *)queryContainer().queryLoopGraph()->queryGraph())->serializeDone(mb); }
void start() { ActivityTimer s(totalCycles, timeActivities); input = inputs.item(0); try { try { startInput(input); } catch (IException *e) { fireException(e); barrier->cancel(); throw; } catch (CATCHALL) { Owned<IException> e = MakeActivityException(this, 0, "Unknown exception starting sort input"); fireException(e); barrier->cancel(); throw; } dataLinkStart(); Linked<IRowInterfaces> rowif = queryRowInterfaces(input); Owned<IRowInterfaces> auxrowif = createRowInterfaces(helper->querySortedRecordSize(),queryActivityId(),queryCodeContext()); sorter->Gather( rowif, input, helper->queryCompare(), helper->queryCompareLeftRight(), NULL,helper->querySerialize(), NULL, false, isUnstable(), abortSoon, auxrowif); stopInput(input); input = NULL; if (abortSoon) { ActPrintLogEx(&queryContainer(), thorlog_null, MCwarning, "MSortSlaveActivity::start aborting"); barrier->cancel(); return; } } catch (IException *e) { fireException(e); barrier->cancel(); throw; } catch (CATCHALL) { Owned<IException> e = MakeActivityException(this, 0, "Unknown exception gathering sort input"); fireException(e); barrier->cancel(); throw; } ActPrintLog("SORT waiting barrier.1"); if (!barrier->wait(false)) { Sleep(1000); // let original error through throw MakeThorException(TE_BarrierAborted,"SORT: Barrier Aborted"); } ActPrintLog("SORT barrier.1 raised"); output.setown(sorter->startMerge(totalrows)); }
CDependencyExecutorSlaveActivity(CGraphElementBase *_container) : CSlaveActivity(_container) { global = !queryContainer().queryOwner().queryOwner() || queryContainer().queryOwner().isGlobal(); if (!global) setRequireInitData(false); }