workunit.hpp 64 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470
  1. /*##############################################################################
  2. HPCC SYSTEMS software Copyright (C) 2012 HPCC Systems.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. ############################################################################## */
  13. #ifndef WORKUNIT_INCL
  14. #define WORKUNIT_INCL
  15. #ifdef _WIN32
  16. #ifdef WORKUNIT_EXPORTS
  17. #define WORKUNIT_API __declspec(dllexport)
  18. #else
  19. #define WORKUNIT_API __declspec(dllimport)
  20. #endif
  21. #else
  22. #define WORKUNIT_API
  23. #endif
  24. #define MINIMUM_SCHEDULE_PRIORITY 0
  25. #define DEFAULT_SCHEDULE_PRIORITY 50
  26. #define MAXIMUM_SCHEDULE_PRIORITY 100
  27. #include "jiface.hpp"
  28. #include "errorlist.h"
  29. #include "jtime.hpp"
  30. #include "jsocket.hpp"
  31. #include "jstats.h"
  32. #include "jprop.hpp"
  33. #define GLOBAL_SCOPE "workunit"
  34. #define CHEAP_UCHAR_DEF
  35. #ifdef _WIN32
  36. typedef wchar_t UChar;
  37. #else //_WIN32
  38. typedef unsigned short UChar;
  39. #endif //_WIN32
  40. // error codes
  41. #define QUERRREG_ADD_NAMEDQUERY QUERYREGISTRY_ERROR_START
  42. #define QUERRREG_REMOVE_NAMEDQUERY QUERYREGISTRY_ERROR_START+1
  43. #define QUERRREG_WUID QUERYREGISTRY_ERROR_START+2
  44. #define QUERRREG_DLL QUERYREGISTRY_ERROR_START+3
  45. #define QUERRREG_SETALIAS QUERYREGISTRY_ERROR_START+4
  46. #define QUERRREG_RESOLVEALIAS QUERYREGISTRY_ERROR_START+5
  47. #define QUERRREG_REMOVEALIAS QUERYREGISTRY_ERROR_START+6
  48. #define QUERRREG_QUERY_REGISTRY QUERYREGISTRY_ERROR_START+7
  49. #define QUERRREG_SUSPEND QUERYREGISTRY_ERROR_START+8
  50. #define QUERRREG_UNSUSPEND QUERYREGISTRY_ERROR_START+9
  51. #define QUERRREG_COMMENT QUERYREGISTRY_ERROR_START+10
  52. class CDateTime;
  53. interface ISetToXmlTransformer;
  54. interface ISecManager;
  55. interface ISecUser;
  56. class StringArray;
  57. class StringBuffer;
  58. typedef unsigned __int64 __uint64;
  59. interface IScmIterator : extends IInterface
  60. {
  61. virtual bool first() = 0;
  62. virtual bool next() = 0;
  63. virtual bool isValid() = 0;
  64. };
  65. interface IQueueSwitcher : extends IInterface
  66. {
  67. virtual void * getQ(const char * qname, const char * wuid) = 0;
  68. virtual void putQ(const char * qname, const char * wuid, void * qitem) = 0;
  69. virtual bool isAuto() = 0;
  70. };
  71. //! PriorityClass
  72. //! Not sure what the real current class values are -- TBD
  73. enum WUPriorityClass
  74. {
  75. PriorityClassUnknown = 0,
  76. PriorityClassLow = 1,
  77. PriorityClassNormal = 2,
  78. PriorityClassHigh = 3,
  79. PriorityClassSize = 4
  80. };
  81. enum WUQueryType
  82. {
  83. QueryTypeUnknown = 0,
  84. QueryTypeEcl = 1,
  85. QueryTypeSql = 2,
  86. QueryTypeXml = 3,
  87. QueryTypeAttribute = 4,
  88. QueryTypeSize = 5
  89. };
  90. enum WUState
  91. {
  92. WUStateUnknown = 0,
  93. WUStateCompiled = 1,
  94. WUStateRunning = 2,
  95. WUStateCompleted = 3,
  96. WUStateFailed = 4,
  97. WUStateArchived = 5,
  98. WUStateAborting = 6,
  99. WUStateAborted = 7,
  100. WUStateBlocked = 8,
  101. WUStateSubmitted = 9,
  102. WUStateScheduled = 10,
  103. WUStateCompiling = 11,
  104. WUStateWait = 12,
  105. WUStateUploadingFiles = 13,
  106. WUStateDebugPaused = 14,
  107. WUStateDebugRunning = 15,
  108. WUStatePaused = 16,
  109. WUStateSize = 17
  110. };
  111. enum WUAction
  112. {
  113. WUActionUnknown = 0,
  114. WUActionCompile = 1,
  115. WUActionCheck = 2,
  116. WUActionRun = 3,
  117. WUActionExecuteExisting = 4,
  118. WUActionPause = 5,
  119. WUActionPauseNow = 6,
  120. WUActionResume = 7,
  121. WUActionSize = 8
  122. };
  123. enum WUResultStatus
  124. {
  125. ResultStatusUndefined = 0,
  126. ResultStatusCalculated = 1,
  127. ResultStatusSupplied = 2,
  128. ResultStatusFailed = 3,
  129. ResultStatusPartial = 4,
  130. ResultStatusSize = 5
  131. };
  132. //! IConstWUGraph
  133. enum WUGraphType
  134. {
  135. GraphTypeAny = 0,
  136. GraphTypeProgress = 1,
  137. GraphTypeEcl = 2,
  138. GraphTypeActivities = 3,
  139. GraphTypeSubProgress = 4,
  140. GraphTypeSize = 5
  141. };
  142. interface IConstWUGraphIterator;
  143. interface ICsvToRawTransformer;
  144. interface IXmlToRawTransformer;
  145. interface IPropertyTree;
  146. interface IPropertyTreeIterator;
  147. enum WUGraphState
  148. {
  149. WUGraphUnknown = 0,
  150. WUGraphComplete = 1,
  151. WUGraphRunning = 2,
  152. WUGraphFailed = 3,
  153. WUGraphPaused = 4
  154. };
  155. interface IConstWUGraphMeta : extends IInterface
  156. {
  157. virtual IStringVal & getName(IStringVal & ret) const = 0;
  158. virtual IStringVal & getLabel(IStringVal & ret) const = 0;
  159. virtual IStringVal & getTypeName(IStringVal & ret) const = 0;
  160. virtual WUGraphType getType() const = 0;
  161. virtual WUGraphState getState() const = 0;
  162. };
  163. interface IConstWUGraph : extends IConstWUGraphMeta
  164. {
  165. virtual IStringVal & getXGMML(IStringVal & ret, bool mergeProgress) const = 0;
  166. virtual IPropertyTree * getXGMMLTree(bool mergeProgress) const = 0;
  167. virtual IPropertyTree * getXGMMLTreeRaw() const = 0;
  168. };
  169. interface IWUGraph : extends IConstWUGraph
  170. {
  171. virtual void setXGMML(const char * text) = 0;
  172. virtual void setXGMMLTree(IPropertyTree * tree, bool compress=true) = 0;
  173. virtual void setName(const char * name) = 0;
  174. virtual void setLabel(const char * name) = 0;
  175. virtual void setType(WUGraphType type) = 0;
  176. };
  177. interface IConstWUGraphIterator : extends IScmIterator
  178. {
  179. virtual IConstWUGraph & query() = 0;
  180. };
  181. interface IConstWUTimer : extends IInterface
  182. {
  183. virtual IStringVal & getName(IStringVal & ret) const = 0;
  184. virtual unsigned getCount() const = 0;
  185. virtual unsigned getDuration() const = 0;
  186. };
  187. interface IWUTimer : extends IConstWUTimer
  188. {
  189. virtual void setName(const char * str) = 0;
  190. virtual void setCount(unsigned c) = 0;
  191. virtual void setDuration(unsigned d) = 0;
  192. };
  193. interface IConstWUTimerIterator : extends IScmIterator
  194. {
  195. virtual IConstWUTimer & query() = 0;
  196. };
  197. interface IConstWUGraphMetaIterator : extends IScmIterator
  198. {
  199. virtual IConstWUGraphMeta & query() = 0;
  200. };
  201. //! IWUResult
  202. enum
  203. {
  204. ResultSequenceStored = -1,
  205. ResultSequencePersist = -2,
  206. ResultSequenceInternal = -3,
  207. ResultSequenceOnce = -4,
  208. };
  209. extern WORKUNIT_API bool isSpecialResultSequence(unsigned sequence);
  210. enum WUResultFormat
  211. {
  212. ResultFormatRaw = 0,
  213. ResultFormatXml = 1,
  214. ResultFormatXmlSet = 2,
  215. ResultFormatCsv = 3,
  216. ResultFormatSize = 4
  217. };
  218. interface IConstWUResult : extends IInterface
  219. {
  220. virtual WUResultStatus getResultStatus() const = 0;
  221. virtual IStringVal & getResultName(IStringVal & str) const = 0;
  222. virtual int getResultSequence() const = 0;
  223. virtual bool isResultScalar() const = 0;
  224. virtual IStringVal & getResultXml(IStringVal & str) const = 0;
  225. virtual unsigned getResultFetchSize() const = 0;
  226. virtual __int64 getResultTotalRowCount() const = 0;
  227. virtual __int64 getResultRowCount() const = 0;
  228. virtual void getResultDataset(IStringVal & ecl, IStringVal & defs) const = 0;
  229. virtual IStringVal & getResultLogicalName(IStringVal & ecl) const = 0;
  230. virtual IStringVal & getResultKeyField(IStringVal & ecl) const = 0;
  231. virtual unsigned getResultRequestedRows() const = 0;
  232. virtual __int64 getResultInt() const = 0;
  233. virtual bool getResultBool() const = 0;
  234. virtual double getResultReal() const = 0;
  235. virtual IStringVal & getResultString(IStringVal & str) const = 0;
  236. virtual IDataVal & getResultRaw(IDataVal & data, IXmlToRawTransformer * xmlTransformer, ICsvToRawTransformer * csvTransformer) const = 0;
  237. virtual IDataVal & getResultUnicode(IDataVal & data) const = 0;
  238. virtual IStringVal & getResultEclSchema(IStringVal & str) const = 0;
  239. virtual __int64 getResultRawSize(IXmlToRawTransformer * xmlTransformer, ICsvToRawTransformer * csvTransformer) const = 0;
  240. virtual IDataVal & getResultRaw(IDataVal & data, __int64 from, __int64 length, IXmlToRawTransformer * xmlTransformer, ICsvToRawTransformer * csvTransformer) const = 0;
  241. virtual IStringVal & getResultRecordSizeEntry(IStringVal & str) const = 0;
  242. virtual IStringVal & getResultTransformerEntry(IStringVal & str) const = 0;
  243. virtual __int64 getResultRowLimit() const = 0;
  244. virtual IStringVal & getResultFilename(IStringVal & str) const = 0;
  245. virtual WUResultFormat getResultFormat() const = 0;
  246. virtual unsigned getResultHash() const = 0;
  247. virtual void getResultDecimal(void * val, unsigned length, unsigned precision, bool isSigned) const = 0;
  248. virtual bool getResultIsAll() const = 0;
  249. virtual const IProperties *queryResultXmlns() = 0;
  250. virtual IStringVal &getResultFieldOpt(const char *name, IStringVal &str) const = 0;
  251. };
  252. interface IWUResult : extends IConstWUResult
  253. {
  254. virtual void setResultStatus(WUResultStatus status) = 0;
  255. virtual void setResultName(const char * name) = 0;
  256. virtual void setResultSequence(unsigned seq) = 0;
  257. virtual void setResultSchemaRaw(unsigned len, const void * schema) = 0;
  258. virtual void setResultScalar(bool isScalar) = 0;
  259. virtual void setResultRaw(unsigned len, const void * data, WUResultFormat format) = 0;
  260. virtual void setResultFetchSize(unsigned rows) = 0;
  261. virtual void setResultTotalRowCount(__int64 rows) = 0;
  262. virtual void setResultRowCount(__int64 rows) = 0;
  263. virtual void setResultDataset(const char * ecl, const char * defs) = 0;
  264. virtual void setResultLogicalName(const char * logicalName) = 0;
  265. virtual void setResultKeyField(const char * name) = 0;
  266. virtual void setResultRequestedRows(unsigned rowcount) = 0;
  267. virtual void setResultInt(__int64 val) = 0;
  268. virtual void setResultBool(bool val) = 0;
  269. virtual void setResultReal(double val) = 0;
  270. virtual void setResultString(const char * val, unsigned length) = 0;
  271. virtual void setResultData(const void * val, unsigned length) = 0;
  272. virtual void setResultDecimal(const void * val, unsigned length) = 0;
  273. virtual void addResultRaw(unsigned len, const void * data, WUResultFormat format) = 0;
  274. virtual void setResultRecordSizeEntry(const char * val) = 0;
  275. virtual void setResultTransformerEntry(const char * val) = 0;
  276. virtual void setResultRowLimit(__int64 value) = 0;
  277. virtual void setResultFilename(const char * name) = 0;
  278. virtual void setResultUnicode(const void * val, unsigned length) = 0;
  279. virtual void setResultUInt(__uint64 val) = 0;
  280. virtual void setResultIsAll(bool value) = 0;
  281. virtual void setResultFormat(WUResultFormat format) = 0;
  282. virtual void setResultXML(const char * xml) = 0;
  283. virtual void setResultRow(unsigned len, const void * data) = 0;
  284. virtual void setResultXmlns(const char *prefix, const char *uri) = 0;
  285. virtual void setResultFieldOpt(const char *name, const char *value)=0;
  286. virtual IPropertyTree *queryPTree() = 0;
  287. };
  288. interface IConstWUResultIterator : extends IScmIterator
  289. {
  290. virtual IConstWUResult & query() = 0;
  291. };
  292. //! IWUQuery
  293. enum WUFileType
  294. {
  295. FileTypeCpp = 0,
  296. FileTypeDll = 1,
  297. FileTypeResText = 2,
  298. FileTypeHintXml = 3,
  299. FileTypeXml = 4,
  300. FileTypeSize = 5
  301. };
  302. interface IConstWUAssociatedFile : extends IInterface
  303. {
  304. virtual WUFileType getType() const = 0;
  305. virtual IStringVal & getDescription(IStringVal & ret) const = 0;
  306. virtual IStringVal & getIp(IStringVal & ret) const = 0;
  307. virtual IStringVal & getName(IStringVal & ret) const = 0;
  308. virtual IStringVal & getNameTail(IStringVal & ret) const = 0;
  309. virtual unsigned getCrc() const = 0;
  310. };
  311. interface IConstWUAssociatedFileIterator : extends IScmIterator
  312. {
  313. virtual IConstWUAssociatedFile & query() = 0;
  314. };
  315. interface IConstWUQuery : extends IInterface
  316. {
  317. virtual WUQueryType getQueryType() const = 0;
  318. virtual IStringVal & getQueryText(IStringVal & str) const = 0;
  319. virtual IStringVal & getQueryName(IStringVal & str) const = 0;
  320. virtual IStringVal & getQueryDllName(IStringVal & str) const = 0;
  321. virtual unsigned getQueryDllCrc() const = 0;
  322. virtual IStringVal & getQueryCppName(IStringVal & str) const = 0;
  323. virtual IStringVal & getQueryResTxtName(IStringVal & str) const = 0;
  324. virtual IConstWUAssociatedFile * getAssociatedFile(WUFileType type, unsigned index) const = 0;
  325. virtual IConstWUAssociatedFileIterator & getAssociatedFiles() const = 0;
  326. virtual IStringVal & getQueryShortText(IStringVal & str) const = 0;
  327. virtual IStringVal & getQueryMainDefinition(IStringVal & str) const = 0;
  328. };
  329. interface IWUQuery : extends IConstWUQuery
  330. {
  331. virtual void setQueryType(WUQueryType qt) = 0;
  332. virtual void setQueryText(const char * pstr) = 0;
  333. virtual void setQueryName(const char * pstr) = 0;
  334. virtual void addAssociatedFile(WUFileType type, const char * name, const char * ip, const char * desc, unsigned crc) = 0;
  335. virtual void removeAssociatedFiles() = 0;
  336. virtual void setQueryMainDefinition(const char * str) = 0;
  337. virtual void removeAssociatedFile(WUFileType type, const char * name, const char * desc) = 0;
  338. };
  339. interface IConstWUWebServicesInfo : extends IInterface
  340. {
  341. virtual IStringVal & getModuleName(IStringVal & str) const = 0;
  342. virtual IStringVal & getAttributeName(IStringVal & str) const = 0;
  343. virtual IStringVal & getDefaultName(IStringVal & str) const = 0;
  344. virtual IStringVal & getInfo(const char * name, IStringVal & str) const = 0;
  345. virtual unsigned getWebServicesCRC() const = 0;
  346. virtual IStringVal & getText(const char * name, IStringVal & str) const = 0;
  347. };
  348. interface IWUWebServicesInfo : extends IConstWUWebServicesInfo
  349. {
  350. virtual void setModuleName(const char * pstr) = 0;
  351. virtual void setAttributeName(const char * pstr) = 0;
  352. virtual void setDefaultName(const char * pstr) = 0;
  353. virtual void setInfo(const char * name, const char * info) = 0;
  354. virtual void setWebServicesCRC(unsigned crc) = 0;
  355. virtual void setText(const char * name, const char * text) = 0;
  356. };
  357. interface IConstWURoxieQueryInfo : extends IInterface
  358. {
  359. virtual IStringVal & getQueryInfo(IStringVal & str) const = 0;
  360. virtual IStringVal & getDefaultPackageInfo(IStringVal & str) const = 0;
  361. virtual IStringVal & getRoxieClusterName(IStringVal & str) const = 0;
  362. virtual IStringVal & getWuid(IStringVal & str) const = 0;
  363. };
  364. interface IWURoxieQueryInfo : extends IConstWURoxieQueryInfo
  365. {
  366. virtual void setQueryInfo(const char * info) = 0;
  367. virtual void setDefaultPackageInfo(const char * pstr, int len) = 0;
  368. virtual void setRoxieClusterName(const char * name) = 0;
  369. virtual void setWuid(const char * wuid) = 0;
  370. };
  371. //! IWUPlugin
  372. interface IConstWUPlugin : extends IInterface
  373. {
  374. virtual IStringVal & getPluginName(IStringVal & str) const = 0;
  375. virtual IStringVal & getPluginVersion(IStringVal & str) const = 0;
  376. };
  377. interface IWUPlugin : extends IConstWUPlugin
  378. {
  379. virtual void setPluginName(const char * str) = 0;
  380. virtual void setPluginVersion(const char * str) = 0;
  381. };
  382. interface IConstWUPluginIterator : extends IScmIterator
  383. {
  384. virtual IConstWUPlugin & query() = 0;
  385. };
  386. interface IConstWULibrary : extends IInterface
  387. {
  388. virtual IStringVal & getName(IStringVal & str) const = 0;
  389. };
  390. interface IWULibrary : extends IConstWULibrary
  391. {
  392. virtual void setName(const char * str) = 0;
  393. };
  394. interface IConstWULibraryIterator : extends IScmIterator
  395. {
  396. virtual IConstWULibrary & query() = 0;
  397. };
  398. //! IWUException
  399. interface IConstWUException : extends IInterface
  400. {
  401. virtual IStringVal & getExceptionSource(IStringVal & str) const = 0;
  402. virtual IStringVal & getExceptionMessage(IStringVal & str) const = 0;
  403. virtual unsigned getExceptionCode() const = 0;
  404. virtual ErrorSeverity getSeverity() const = 0;
  405. virtual IStringVal & getTimeStamp(IStringVal & dt) const = 0;
  406. virtual IStringVal & getExceptionFileName(IStringVal & str) const = 0;
  407. virtual unsigned getExceptionLineNo() const = 0;
  408. virtual unsigned getExceptionColumn() const = 0;
  409. };
  410. interface IWUException : extends IConstWUException
  411. {
  412. virtual void setExceptionSource(const char * str) = 0;
  413. virtual void setExceptionMessage(const char * str) = 0;
  414. virtual void setExceptionCode(unsigned code) = 0;
  415. virtual void setSeverity(ErrorSeverity level) = 0;
  416. virtual void setTimeStamp(const char * dt) = 0;
  417. virtual void setExceptionFileName(const char * str) = 0;
  418. virtual void setExceptionLineNo(unsigned r) = 0;
  419. virtual void setExceptionColumn(unsigned c) = 0;
  420. };
  421. interface IConstWUExceptionIterator : extends IScmIterator
  422. {
  423. virtual IConstWUException & query() = 0;
  424. };
  425. enum ClusterType { NoCluster, HThorCluster, RoxieCluster, ThorLCRCluster };
  426. extern WORKUNIT_API ClusterType getClusterType(const char * platform, ClusterType dft = NoCluster);
  427. extern WORKUNIT_API const char *clusterTypeString(ClusterType clusterType, bool lcrSensitive);
  428. inline bool isThorCluster(ClusterType type) { return (type == ThorLCRCluster); }
  429. //! IClusterInfo
  430. interface IConstWUClusterInfo : extends IInterface
  431. {
  432. virtual IStringVal & getName(IStringVal & str) const = 0;
  433. virtual IStringVal & getScope(IStringVal & str) const = 0;
  434. virtual IStringVal & getThorQueue(IStringVal & str) const = 0;
  435. virtual unsigned getSize() const = 0;
  436. virtual ClusterType getPlatform() const = 0;
  437. virtual IStringVal & getAgentQueue(IStringVal & str) const = 0;
  438. virtual IStringVal & getServerQueue(IStringVal & str) const = 0;
  439. virtual IStringVal & getRoxieProcess(IStringVal & str) const = 0;
  440. virtual const StringArray & getThorProcesses() const = 0;
  441. virtual const StringArray & getPrimaryThorProcesses() const = 0;
  442. virtual const SocketEndpointArray & getRoxieServers() const = 0;
  443. virtual const char *getLdapUser() const = 0;
  444. virtual const char *getLdapPassword() const = 0;
  445. };
  446. //! IWorkflowItem
  447. enum WFType
  448. {
  449. WFTypeNormal = 0,
  450. WFTypeSuccess = 1,
  451. WFTypeFailure = 2,
  452. WFTypeRecovery = 3,
  453. WFTypeWait = 4,
  454. WFTypeSize = 5
  455. };
  456. enum WFMode
  457. {
  458. WFModeNormal = 0,
  459. WFModeCondition = 1,
  460. WFModeSequential = 2,
  461. WFModeParallel = 3,
  462. WFModePersist = 4,
  463. WFModeBeginWait = 5,
  464. WFModeWait = 6,
  465. WFModeOnce = 7,
  466. WFModeSize = 8
  467. };
  468. enum WFState
  469. {
  470. WFStateNull = 0,
  471. WFStateReqd = 1,
  472. WFStateDone = 2,
  473. WFStateFail = 3,
  474. WFStateSkip = 4,
  475. WFStateWait = 5,
  476. WFStateBlocked = 6,
  477. WFStateSize = 7
  478. };
  479. interface IWorkflowDependencyIterator : extends IScmIterator
  480. {
  481. virtual unsigned query() const = 0;
  482. };
  483. interface IWorkflowEvent : extends IInterface
  484. {
  485. virtual const char * queryName() const = 0;
  486. virtual const char * queryText() const = 0;
  487. virtual bool matches(const char * name, const char * text) const = 0;
  488. };
  489. interface IConstWorkflowItem : extends IInterface
  490. {
  491. virtual unsigned queryWfid() const = 0;
  492. virtual bool isScheduled() const = 0;
  493. virtual bool isScheduledNow() const = 0;
  494. virtual IWorkflowEvent * getScheduleEvent() const = 0;
  495. virtual unsigned querySchedulePriority() const = 0;
  496. virtual bool hasScheduleCount() const = 0;
  497. virtual unsigned queryScheduleCount() const = 0;
  498. virtual IWorkflowDependencyIterator * getDependencies() const = 0;
  499. virtual WFType queryType() const = 0;
  500. virtual WFMode queryMode() const = 0;
  501. virtual unsigned querySuccess() const = 0;
  502. virtual unsigned queryFailure() const = 0;
  503. virtual unsigned queryRecovery() const = 0;
  504. virtual unsigned queryRetriesAllowed() const = 0;
  505. virtual unsigned queryContingencyFor() const = 0;
  506. virtual IStringVal & getPersistName(IStringVal & val) const = 0;
  507. virtual unsigned queryPersistWfid() const = 0;
  508. virtual int queryPersistCopies() const = 0; // 0 - unmangled name, < 0 - use default, > 0 - max number
  509. virtual unsigned queryScheduleCountRemaining() const = 0;
  510. virtual WFState queryState() const = 0;
  511. virtual unsigned queryRetriesRemaining() const = 0;
  512. virtual int queryFailCode() const = 0;
  513. virtual const char * queryFailMessage() const = 0;
  514. virtual const char * queryEventName() const = 0;
  515. virtual const char * queryEventExtra() const = 0;
  516. virtual unsigned queryScheduledWfid() const = 0;
  517. virtual IStringVal & queryCluster(IStringVal & val) const = 0;
  518. };
  519. inline bool isPersist(const IConstWorkflowItem & item) { return item.queryMode() == WFModePersist; }
  520. interface IRuntimeWorkflowItem : extends IConstWorkflowItem
  521. {
  522. virtual void setState(WFState state) = 0;
  523. virtual bool testAndDecRetries() = 0;
  524. virtual bool decAndTestScheduleCountRemaining() = 0;
  525. virtual void setFailInfo(int code, const char * message) = 0;
  526. virtual void reset() = 0;
  527. virtual void setEvent(const char * name, const char * extra) = 0;
  528. virtual void incScheduleCount() = 0;
  529. };
  530. interface IWorkflowItem : extends IRuntimeWorkflowItem
  531. {
  532. virtual void setScheduledNow() = 0;
  533. virtual void setScheduledOn(const char * name, const char * text) = 0;
  534. virtual void setSchedulePriority(unsigned priority) = 0;
  535. virtual void setScheduleCount(unsigned count) = 0;
  536. virtual void addDependency(unsigned wfid) = 0;
  537. virtual void setPersistInfo(const char * name, unsigned wfid, int maxCopies) = 0;
  538. virtual void syncRuntimeData(const IConstWorkflowItem & other) = 0;
  539. virtual void setScheduledWfid(unsigned wfid) = 0;
  540. virtual void setCluster(const char * cluster) = 0;
  541. };
  542. interface IConstWorkflowItemIterator : extends IScmIterator
  543. {
  544. virtual IConstWorkflowItem * query() const = 0;
  545. };
  546. interface IRuntimeWorkflowItemIterator : extends IConstWorkflowItemIterator
  547. {
  548. virtual IRuntimeWorkflowItem * get() const = 0;
  549. };
  550. interface IWorkflowItemIterator : extends IConstWorkflowItemIterator
  551. {
  552. virtual IWorkflowItem * get() const = 0;
  553. };
  554. interface IWorkflowItemArray : extends IInterface
  555. {
  556. virtual IRuntimeWorkflowItem & queryWfid(unsigned wfid) = 0;
  557. virtual unsigned count() const = 0;
  558. virtual IRuntimeWorkflowItemIterator * getSequenceIterator() = 0;
  559. virtual void addClone(const IConstWorkflowItem * other) = 0;
  560. virtual bool hasScheduling() const = 0;
  561. };
  562. enum LocalFileUploadType
  563. {
  564. UploadTypeFileSpray = 0,
  565. UploadTypeWUResult = 1,
  566. UploadTypeWUResultCsv = 2,
  567. UploadTypeWUResultXml = 3,
  568. UploadTypeSize = 4
  569. };
  570. interface IConstLocalFileUpload : extends IInterface
  571. {
  572. virtual unsigned queryID() const = 0;
  573. virtual LocalFileUploadType queryType() const = 0;
  574. virtual IStringVal & getSource(IStringVal & ret) const = 0;
  575. virtual IStringVal & getDestination(IStringVal & ret) const = 0;
  576. virtual IStringVal & getEventTag(IStringVal & ret) const = 0;
  577. };
  578. interface IConstLocalFileUploadIterator : extends IScmIterator
  579. {
  580. virtual IConstLocalFileUpload * get() = 0;
  581. };
  582. enum WUSubscribeOptions
  583. {
  584. SubscribeOptionAbort = 2,
  585. };
  586. interface IWUGraphProgress;
  587. interface IPropertyTree;
  588. enum WUFileKind
  589. {
  590. WUFileStandard = 0,
  591. WUFileTemporary = 1,
  592. WUFileOwned = 2,
  593. WUFileJobOwned = 3
  594. };
  595. typedef unsigned __int64 WUGraphIDType;
  596. typedef unsigned __int64 WUNodeIDType;
  597. interface IWUGraphProgress;
  598. interface IWUGraphStats;
  599. interface IPropertyTree;
  600. interface IConstWUGraphProgress : extends IInterface
  601. {
  602. virtual IPropertyTree * getProgressTree() = 0;
  603. virtual WUGraphState queryGraphState() = 0;
  604. virtual WUGraphState queryNodeState(WUGraphIDType nodeId) = 0;
  605. virtual IWUGraphProgress * update() = 0;
  606. virtual IWUGraphStats * update(StatisticCreatorType creatorType, const char * creator, unsigned subgraph) = 0;
  607. virtual unsigned queryFormatVersion() = 0;
  608. };
  609. interface IWUGraphStats : public IInterface
  610. {
  611. virtual IStatisticGatherer & queryStatsBuilder() = 0;
  612. };
  613. interface IWUGraphProgress : extends IConstWUGraphProgress
  614. {
  615. virtual void setGraphState(WUGraphState state) = 0;
  616. virtual void setNodeState(WUGraphIDType nodeId, WUGraphState state) = 0;
  617. };
  618. interface IConstWUTimeStamp : extends IInterface
  619. {
  620. virtual IStringVal & getApplication(IStringVal & str) const = 0;
  621. virtual IStringVal & getEvent(IStringVal & str) const = 0;
  622. virtual IStringVal & getDate(IStringVal & dt) const = 0;
  623. };
  624. interface IConstWUTimeStampIterator : extends IScmIterator
  625. {
  626. virtual IConstWUTimeStamp & query() = 0;
  627. };
  628. interface IConstWUAppValue : extends IInterface
  629. {
  630. virtual IStringVal & getApplication(IStringVal & str) const = 0;
  631. virtual IStringVal & getName(IStringVal & str) const = 0;
  632. virtual IStringVal & getValue(IStringVal & str) const = 0;
  633. };
  634. interface IConstWUAppValueIterator : extends IScmIterator
  635. {
  636. virtual IConstWUAppValue & query() = 0;
  637. };
  638. //More: Counts on files? optional target?
  639. /*
  640. * Statistics are used to store timestamps, time periods, counts memory usage and any other interesting statistic
  641. * which is collected as the query is built or executed.
  642. *
  643. * Each statistic has the following details:
  644. *
  645. * Creator - Which component created the statistic. This should be the name of the component instance i.e., "mythor_x_y" rather than the type ("thor").
  646. * - It can also be used to represent a subcomponent e.g., mythor:0 the master, mythor:10 means the 10th slave.
  647. * ?? Is the sub component always numeric ??
  648. *
  649. * Kind - The specific kind of the statistic - uses a global enumeration. (Engines can locally use different ranges of numbers and map them to the global enumeration).
  650. *
  651. * Measure - What kind of statistic is it? It can always be derived from the kind. The following values are supported:
  652. * time - elapsed time in nanoseconds
  653. * timestamp/when - a point in time (?to the nanosecond?)
  654. * count - a count of the number of occurrences
  655. * memory/size - a quantity of memory (or disk) measured in kb
  656. * load - measure of cpu activity (stored as 1/1000000 core)
  657. * skew - a measure of skew. 10000 = perfectly balanced, range [0..infinity]
  658. *
  659. *Optional:
  660. *
  661. * Description - Purely for display, calculated if not explicitly supplied.
  662. * Scope - Where in the execution of the task is statistic gathered? It can have multiple levels (separated by colons), and statistics for
  663. * a given level can be retrieved independently. The following scopes are supported:
  664. * "global" - the default if not specified. Globally/within a workunit.
  665. * "wfid<n>" - within workflow item <n> (is this at all useful?)
  666. * "graphn[:sg<n>[:ac<n>"]"
  667. * Possibly additional levels to allow multiple instances of an activity when used in a graph etc.
  668. *
  669. * Target - The target of the thing being monitored. E.g., a filename. ?? Is this needed? Should this be combined with scope??
  670. *
  671. * Examples:
  672. * creator(mythor),scope(),kind(TimeWall) total time spend processing in thor search ct(thor),scope(),kind(TimeWall)
  673. * creator(mythor),scope(graph1),kind(TimeWall) - total time spent processing a graph
  674. * creator(mythor),scope(graph1:sg<subid>),kind(TimeElapsed) - total time spent processing a subgraph
  675. * creator(mythor),scope(graph1:sg<n>:ac<id>),kind(TimeElapsed) - time for activity from start to stop
  676. * creator(mythor),scope(graph1:sg<n>:ac<id>),kind(TimeLocal) - time spent locally processing
  677. * creator(mythor),scope(graph1:sg<n>:ac<id>),kind(TimeWallRowRange) - time from first row to last row
  678. * creator(mythor),scope(graph1:sg<n>:ac<id>),kind(WhenFirstRow) - timestamp for first row
  679. * creator(myeclccserver@myip),scope(compile),kind(TimeWall)
  680. * creator(myeclccserver@myip),scope(compile:transform),kind(TimeWall)
  681. * creator(myeclccserver@myip),scope(compile:transform:fold),kind(TimeWall)
  682. *
  683. * Other possibilities
  684. * creator(myesp),scope(filefile::abc::def),kind(NumAccesses)
  685. *
  686. * Configuring statistic collection:
  687. * - Each engine allows the statistics being collected to be specified. You need to configure the area (time/memory/disk/), the level of detail by component and location.
  688. *
  689. * Some background notes:
  690. * - Start time and end time (time processing first and last record) is useful for detecting time skew/serial activities.
  691. * - Information is lost if you only show final skew, rather than skew over time, but storing time series data is
  692. * prohibitive so we may need to create some derived metrics.
  693. * - The engines need options to control what information is gathered.
  694. * - Need to ensure clocks are synchronized for the timestamps to be useful.
  695. *
  696. * Some typical analysis we want to perform:
  697. * - Activities that show significant skew between first (or last) record times between nodes.
  698. * - Activities where the majority of the time is being spent.
  699. *
  700. * Filtering statistics - with control over who is creating it, what is being recorded, and
  701. * [in order of importance]
  702. * - which level of creator you are interested in [summary or individual nodes, or both] (*;*:*)?
  703. * - which level of scope (interested in activities, or just by graph, or both)
  704. * - a particular kind of statistic
  705. * - A particular creator (including fixed/wildcarded sub-component)
  706. *
  707. * => Provide a class for representing a filter, which can be used to filter when recording and retrieving. Start simple and then extend.
  708. * Text representation creator(*,*:*),creatordepth(n),creatorkind(x),scopedepth(n),scopekind(xxx,yyy),scope(*:23),kind(x).
  709. *
  710. * Examples
  711. * kind(TimeElapsed),scopetype(subgraph) - subgraph timings
  712. * kind(Time*),scopedepth(1)&kind(TimeElapsed),scopedepth(2),scopetype(subgraph) - all legacy global timings.
  713. * creatortype(thor),kind(TimeElapsed),scope("") - how much time has been spent on thor? (Need to sum?)
  714. * creator(mythor),kind(TimeElapsed),scope("") - how much time has been spent on *this* thor.
  715. * kind(TimeElapsed),scope("compiled") - how much time has been spent on *this* thor.
  716. *
  717. * Need to efficiently
  718. * - Get all (simple) stats for a graph/activities (creator(*),kind(*),scope(x:*)) - display in graph, finding hotspots
  719. * - Get all stats for an activity (creator(*:*),measure(*:*),scope(x:y)) - providing details in a graph
  720. * - Merge stats from multiple components
  721. * - Merge stats from multiple runs?
  722. *
  723. * Bulk updates will tend to be for a given component and should only need minor processing (e.g. patch ids) or no processing to update/combine.
  724. * - You need to be able to filter only a certain level of statistic - e.g., times for transforms, but not details of those transforms.
  725. *
  726. * => suggest store as
  727. * stats[creatorDepth,scopeDepth][creator] { kind, scope, value, target }. sorted by (scope, target, kind)
  728. * - allows high level filtering by level
  729. * - allows combining with minor updates.
  730. * - possibly extra structure within each creator - maybe depending on the level of the scope
  731. * - need to be sub-sorted to allow efficient merging between creators (e.g. for calculating skew)
  732. * - possibly different structure when collecting [e.g., indexed by stat, or using a local stat mapping ] and storing.
  733. *
  734. * Use (local) tables to map scope->uid. Possibly implicitly defined on first occurrence, or zip the entire structure.
  735. *
  736. * The progress information should be stored compressed, with min,max child ids to avoid decompressing
  737. */
  738. // Should the statistics classes be able to be stored globally e.g., for esp and other non workunit contexts?
  739. /*
  740. * Work out how to represent all of the existing statistics
  741. *
  742. * Counts of number of skips on an index: kind(CountIndexSkips),measure(count),scope(workunit | filename | graph:activity#)
  743. * Activity start time kind(WhenStart),measure(timestamp),scope(graph:activity#),creator(mythor)
  744. * kind(WhenFirstRow),measure(timestamp),scope(graph:activity#),creator(mythor:slave#)
  745. * Number of times files accessed by esp: kind(CountFileAccess),measure(count),scope(),target(filename);
  746. * Elapsed/remaining time for sprays:
  747. */
  748. /*
  749. * Statistics and their kinds - prefixed indicates their type. Note generally the same type won't be reused for two different things.
  750. *
  751. * TimeStamps:
  752. * StWhenGraphStart - When a graph starts
  753. * StWhenFirstRow - When the first row is processed by slave activity
  754. *
  755. * Time
  756. * StTimeParseQuery
  757. * StTimeTransformQuery
  758. * StTimeTransformQuery_Fold - transformquery:fold? effectively an extra level of detail on the kind.
  759. * StTimeTransformQuery_Normalize
  760. * StTimeElapsedExecuting - Elapsed wall time between first row and last row.
  761. * StTimeExecuting - Cpu time spent executing
  762. *
  763. *
  764. * Memory
  765. * StSizeGeneratedCpp
  766. * StSizePeakMemory
  767. *
  768. * Count
  769. * StCountIndexSeeks
  770. * StCountIndexScans
  771. *
  772. * Load
  773. * StLoadWhileSorting - Average load while processing a sort?
  774. *
  775. * Skew
  776. * StSkewRecordDistribution - Skew on the records across the different nodes
  777. * StSkewExecutionTime - Skew in the execution time between activities.
  778. *
  779. */
  780. interface IConstWUStatistic : extends IInterface
  781. {
  782. virtual IStringVal & getDescription(IStringVal & str, bool createDefault) const = 0; // Description of the statistic suitable for displaying to the user
  783. virtual IStringVal & getCreator(IStringVal & str) const = 0; // what component gathered the statistic e.g., myroxie/eclserver_12/mythor:100
  784. virtual IStringVal & getScope(IStringVal & str) const = 0; // what scope is the statistic gathered over? e.g., workunit, wfid:n, graphn, graphn:m
  785. virtual IStringVal & getFormattedValue(IStringVal & str) const = 0; // The formatted value for display
  786. virtual StatisticMeasure getMeasure() const = 0;
  787. virtual StatisticKind getKind() const = 0;
  788. virtual StatisticCreatorType getCreatorType() const = 0;
  789. virtual StatisticScopeType getScopeType() const = 0;
  790. virtual unsigned __int64 getValue() const = 0;
  791. virtual unsigned __int64 getCount() const = 0;
  792. virtual unsigned __int64 getMax() const = 0;
  793. virtual unsigned __int64 getTimestamp() const = 0; // time the statistic was created
  794. virtual bool matches(const IStatisticsFilter * filter) const = 0;
  795. };
  796. interface IConstWUStatisticIterator : extends IScmIterator
  797. {
  798. virtual IConstWUStatistic & query() = 0;
  799. };
  800. //! IWorkUnit
  801. //! Provides high level access to WorkUnit "header" data.
  802. interface IWorkUnit;
  803. interface IUserDescriptor;
  804. interface IStringIterator : extends IScmIterator
  805. {
  806. virtual IStringVal & str(IStringVal & str) = 0;
  807. };
  808. interface IConstWorkUnitInfo : extends IInterface
  809. {
  810. virtual const char *queryWuid() const = 0;
  811. virtual const char *queryUser() const = 0;
  812. virtual const char *queryJobName() const = 0;
  813. virtual const char *queryClusterName() const = 0;
  814. virtual WUState getState() const = 0;
  815. virtual const char *queryStateDesc() const = 0;
  816. virtual bool isProtected() const = 0;
  817. virtual IJlibDateTime & getTimeScheduled(IJlibDateTime & val) const = 0;
  818. };
  819. interface IConstWorkUnit : extends IConstWorkUnitInfo
  820. {
  821. virtual bool aborting() const = 0;
  822. virtual void forceReload() = 0;
  823. virtual WUAction getAction() const = 0;
  824. virtual IStringVal& getActionEx(IStringVal & str) const = 0;
  825. virtual IStringVal & getApplicationValue(const char * application, const char * propname, IStringVal & str) const = 0;
  826. virtual int getApplicationValueInt(const char * application, const char * propname, int defVal) const = 0;
  827. virtual IConstWUAppValueIterator & getApplicationValues() const = 0;
  828. virtual bool hasWorkflow() const = 0;
  829. virtual unsigned queryEventScheduledCount() const = 0;
  830. virtual IPropertyTree * queryWorkflowTree() const = 0;
  831. virtual IConstWorkflowItemIterator * getWorkflowItems() const = 0;
  832. virtual IWorkflowItemArray * getWorkflowClone() const = 0;
  833. virtual IConstLocalFileUploadIterator * getLocalFileUploads() const = 0;
  834. virtual bool requiresLocalFileUpload() const = 0;
  835. virtual bool getIsQueryService() const = 0;
  836. virtual bool hasDebugValue(const char * propname) const = 0;
  837. virtual IStringVal & getDebugValue(const char * propname, IStringVal & str) const = 0;
  838. virtual int getDebugValueInt(const char * propname, int defVal) const = 0;
  839. virtual __int64 getDebugValueInt64(const char * propname, __int64 defVal) const = 0;
  840. virtual bool getDebugValueBool(const char * propname, bool defVal) const = 0;
  841. virtual IStringIterator & getDebugValues() const = 0;
  842. virtual IStringIterator & getDebugValues(const char * prop) const = 0;
  843. virtual unsigned getExceptionCount() const = 0;
  844. virtual IConstWUExceptionIterator & getExceptions() const = 0;
  845. virtual IConstWUResult * getGlobalByName(const char * name) const = 0;
  846. virtual IConstWUGraphMetaIterator & getGraphsMeta(WUGraphType type) const = 0;
  847. virtual IConstWUGraphIterator & getGraphs(WUGraphType type) const = 0;
  848. virtual IConstWUGraph * getGraph(const char * name) const = 0;
  849. virtual IConstWUGraphProgress * getGraphProgress(const char * name) const = 0;
  850. virtual IConstWUPlugin * getPluginByName(const char * name) const = 0;
  851. virtual IConstWUPluginIterator & getPlugins() const = 0;
  852. virtual IConstWULibraryIterator & getLibraries() const = 0;
  853. virtual WUPriorityClass getPriority() const = 0;
  854. virtual int getPriorityLevel() const = 0;
  855. virtual IConstWUQuery * getQuery() const = 0;
  856. virtual bool getRescheduleFlag() const = 0;
  857. virtual IConstWUResult * getResultByName(const char * name) const = 0;
  858. virtual IConstWUResult * getResultBySequence(unsigned seq) const = 0;
  859. virtual unsigned getResultLimit() const = 0;
  860. virtual IConstWUResultIterator & getResults() const = 0;
  861. virtual IStringVal & getScope(IStringVal & str) const = 0;
  862. virtual IStringVal & getSecurityToken(IStringVal & str) const = 0;
  863. virtual IStringVal & getStateEx(IStringVal & str) const = 0;
  864. virtual __int64 getAgentSession() const = 0;
  865. virtual unsigned getAgentPID() const = 0;
  866. virtual IConstWUResult * getTemporaryByName(const char * name) const = 0;
  867. virtual IConstWUResultIterator & getTemporaries() const = 0;
  868. virtual bool getRunningGraph(IStringVal & graphName, WUGraphIDType & subId) const = 0;
  869. virtual IConstWUWebServicesInfo * getWebServicesInfo() const = 0;
  870. virtual IConstWURoxieQueryInfo * getRoxieQueryInfo() const = 0;
  871. virtual IConstWUStatisticIterator & getStatistics(const IStatisticsFilter * filter) const = 0; // filter must currently stay alive while the iterator does.
  872. virtual IConstWUStatistic * getStatistic(const char * creator, const char * scope, StatisticKind kind) const = 0;
  873. virtual IStringVal & getWuScope(IStringVal & str) const = 0;
  874. virtual IConstWUResult * getVariableByName(const char * name) const = 0;
  875. virtual IConstWUResultIterator & getVariables() const = 0;
  876. virtual bool isPausing() const = 0;
  877. virtual IWorkUnit & lock() = 0;
  878. virtual void requestAbort() = 0;
  879. virtual void subscribe(WUSubscribeOptions options) = 0;
  880. virtual unsigned queryFileUsage(const char * filename) const = 0;
  881. virtual unsigned getCodeVersion() const = 0;
  882. virtual unsigned getWuidVersion() const = 0;
  883. virtual void getBuildVersion(IStringVal & buildVersion, IStringVal & eclVersion) const = 0;
  884. virtual IPropertyTree * getDiskUsageStats() = 0;
  885. virtual IPropertyTreeIterator & getFileIterator() const = 0;
  886. virtual bool getCloneable() const = 0;
  887. virtual IUserDescriptor * queryUserDescriptor() const = 0;
  888. virtual IStringVal & getSnapshot(IStringVal & str) const = 0;
  889. virtual ErrorSeverity getWarningSeverity(unsigned code, ErrorSeverity defaultSeverity) const = 0;
  890. virtual IPropertyTreeIterator & getFilesReadIterator() const = 0;
  891. virtual void protect(bool protectMode) = 0;
  892. virtual IStringVal & getAllowedClusters(IStringVal & str) const = 0;
  893. virtual int getPriorityValue() const = 0;
  894. virtual void remoteCheckAccess(IUserDescriptor * user, bool writeaccess) const = 0;
  895. virtual bool getAllowAutoQueueSwitch() const = 0;
  896. virtual IConstWULibrary * getLibraryByName(const char * name) const = 0;
  897. virtual unsigned getGraphCount() const = 0;
  898. virtual unsigned getSourceFileCount() const = 0;
  899. virtual unsigned getResultCount() const = 0;
  900. virtual unsigned getVariableCount() const = 0;
  901. virtual unsigned getApplicationValueCount() const = 0;
  902. virtual unsigned getDebugAgentListenerPort() const = 0;
  903. virtual IStringVal & getDebugAgentListenerIP(IStringVal & ip) const = 0;
  904. virtual IStringVal & getXmlParams(IStringVal & params) const = 0;
  905. virtual const IPropertyTree * getXmlParams() const = 0;
  906. virtual unsigned __int64 getHash() const = 0;
  907. virtual IStringIterator *getLogs(const char *type, const char *instance=NULL) const = 0;
  908. virtual IStringIterator *getProcesses(const char *type) const = 0;
  909. virtual IPropertyTreeIterator* getProcesses(const char *type, const char *instance) const = 0;
  910. };
  911. interface IDistributedFile;
  912. interface IWorkUnit : extends IConstWorkUnit
  913. {
  914. virtual void clearExceptions() = 0;
  915. virtual void commit() = 0;
  916. virtual IWUException * createException() = 0;
  917. virtual void addProcess(const char *type, const char *instance, unsigned pid, const char *log=NULL) = 0;
  918. virtual void setAction(WUAction action) = 0;
  919. virtual void setApplicationValue(const char * application, const char * propname, const char * value, bool overwrite) = 0;
  920. virtual void setApplicationValueInt(const char * application, const char * propname, int value, bool overwrite) = 0;
  921. virtual void incEventScheduledCount() = 0;
  922. virtual void setIsQueryService(bool cached) = 0;
  923. virtual void setClusterName(const char * value) = 0;
  924. virtual void setDebugValue(const char * propname, const char * value, bool overwrite) = 0;
  925. virtual void setDebugValueInt(const char * propname, int value, bool overwrite) = 0;
  926. virtual void setJobName(const char * value) = 0;
  927. virtual void setPriority(WUPriorityClass cls) = 0;
  928. virtual void setPriorityLevel(int level) = 0;
  929. virtual void setRescheduleFlag(bool value) = 0;
  930. virtual void setResultLimit(unsigned value) = 0;
  931. virtual void setSecurityToken(const char * value) = 0;
  932. virtual void setState(WUState state) = 0;
  933. virtual void setStateEx(const char * text) = 0;
  934. virtual void setAgentSession(__int64 sessionId) = 0;
  935. virtual void setStatistic(StatisticCreatorType creatorType, const char * creator, StatisticScopeType scopeType, const char * scope, StatisticKind kind, const char * optDescription, unsigned __int64 value, unsigned __int64 count, unsigned __int64 maxValue, StatsMergeAction mergeAction) = 0;
  936. virtual void setTracingValue(const char * propname, const char * value) = 0;
  937. virtual void setTracingValueInt(const char * propname, int value) = 0;
  938. virtual void setUser(const char * value) = 0;
  939. virtual void setWuScope(const char * value) = 0;
  940. virtual void setSnapshot(const char * value) = 0;
  941. virtual void setWarningSeverity(unsigned code, ErrorSeverity severity) = 0;
  942. virtual IWorkflowItemIterator * updateWorkflowItems() = 0;
  943. virtual void syncRuntimeWorkflow(IWorkflowItemArray * array) = 0;
  944. virtual IWorkflowItem * addWorkflowItem(unsigned wfid, WFType type, WFMode mode, unsigned success, unsigned failure, unsigned recovery, unsigned retriesAllowed, unsigned contingencyFor) = 0;
  945. virtual void resetWorkflow() = 0;
  946. virtual void schedule() = 0;
  947. virtual void deschedule() = 0;
  948. virtual unsigned addLocalFileUpload(LocalFileUploadType type, const char * source, const char * destination, const char * eventTag) = 0;
  949. virtual IWUResult * updateGlobalByName(const char * name) = 0;
  950. virtual IWUGraph * createGraph(const char * name, WUGraphType type, IPropertyTree *xgmml) = 0;
  951. virtual IWUGraph * updateGraph(const char * name) = 0;
  952. virtual IWUQuery * updateQuery() = 0;
  953. virtual IWUWebServicesInfo * updateWebServicesInfo(bool create) = 0;
  954. virtual IWURoxieQueryInfo * updateRoxieQueryInfo(const char * wuid, const char * roxieClusterName) = 0;
  955. virtual IWUPlugin * updatePluginByName(const char * name) = 0;
  956. virtual IWULibrary * updateLibraryByName(const char * name) = 0;
  957. virtual IWUResult * updateResultByName(const char * name) = 0;
  958. virtual IWUResult * updateResultBySequence(unsigned seq) = 0;
  959. virtual IWUResult * updateTemporaryByName(const char * name) = 0;
  960. virtual IWUResult * updateVariableByName(const char * name) = 0;
  961. virtual void addFile(const char * fileName, StringArray * clusters, unsigned usageCount, WUFileKind fileKind, const char * graphOwner) = 0;
  962. virtual void releaseFile(const char * fileName) = 0;
  963. virtual void setCodeVersion(unsigned version, const char * buildVersion, const char * eclVersion) = 0;
  964. virtual void deleteTempFiles(const char * graph, bool deleteOwned, bool deleteJobOwned) = 0;
  965. virtual void deleteTemporaries() = 0;
  966. virtual void addDiskUsageStats(__int64 avgNodeUsage, unsigned minNode, __int64 minNodeUsage, unsigned maxNode, __int64 maxNodeUsage, __int64 graphId) = 0;
  967. virtual void setCloneable(bool value) = 0;
  968. virtual void setIsClone(bool value) = 0;
  969. virtual void setTimeScheduled(const IJlibDateTime & val) = 0;
  970. virtual void noteFileRead(IDistributedFile * file) = 0;
  971. virtual void clearGraphProgress() = 0;
  972. virtual void resetBeforeGeneration() = 0;
  973. virtual bool switchThorQueue(const char * newcluster, IQueueSwitcher * qs) = 0;
  974. virtual void setAllowedClusters(const char * value) = 0;
  975. virtual void setAllowAutoQueueSwitch(bool val) = 0;
  976. virtual void setLibraryInformation(const char * name, unsigned interfaceHash, unsigned definitionHash) = 0;
  977. virtual void setDebugAgentListenerPort(unsigned port) = 0;
  978. virtual void setDebugAgentListenerIP(const char * ip) = 0;
  979. virtual void setXmlParams(const char *xml) = 0;
  980. virtual void setXmlParams(IPropertyTree *tree) = 0;
  981. virtual void setHash(unsigned __int64 hash) = 0;
  982. virtual void setResultInt(const char * name, unsigned sequence, __int64 val) = 0;
  983. virtual void setResultUInt(const char * name, unsigned sequence, unsigned __int64 val) = 0;
  984. virtual void setResultReal(const char *name, unsigned sequence, double val) = 0;
  985. virtual void setResultVarString(const char * stepname, unsigned sequence, const char *val) = 0;
  986. virtual void setResultVarUnicode(const char * stepname, unsigned sequence, UChar const *val) = 0;
  987. virtual void setResultString(const char * stepname, unsigned sequence, int len, const char *val) = 0;
  988. virtual void setResultData(const char * stepname, unsigned sequence, int len, const void *val) = 0;
  989. // virtual void doSetResultString(type_t type, const char *name, unsigned sequence, int len, const char *val) = 0;
  990. virtual void setResultRaw(const char * name, unsigned sequence, int len, const void *val) = 0;
  991. virtual void setResultSet(const char * name, unsigned sequence, bool isAll, size32_t len, const void *val, ISetToXmlTransformer *) = 0;
  992. virtual void setResultUnicode(const char * name, unsigned sequence, int len, UChar const * val) = 0;
  993. virtual void setResultBool(const char *name, unsigned sequence, bool val) = 0;
  994. virtual void setResultDecimal(const char *name, unsigned sequence, int len, int precision, bool isSigned, const void *val) = 0;
  995. virtual void setResultDataset(const char * name, unsigned sequence, size32_t len, const void *val, unsigned numRows, bool extend) = 0;
  996. };
  997. interface IConstWorkUnitIterator : extends IScmIterator
  998. {
  999. virtual IConstWorkUnitInfo & query() = 0;
  1000. };
  1001. //! IWUTimers
  1002. interface IWUTimers : extends IInterface
  1003. {
  1004. virtual void setTrigger(const IJlibDateTime & dt) = 0;
  1005. virtual IJlibDateTime & getTrigger(IJlibDateTime & dt) const = 0;
  1006. virtual void setExpiration(const IJlibDateTime & dt) = 0;
  1007. virtual IJlibDateTime & getExpiration(IJlibDateTime & dt) const = 0;
  1008. virtual void setSubmission(const IJlibDateTime & dt) = 0;
  1009. virtual IJlibDateTime & getSubmission(IJlibDateTime & dt) const = 0;
  1010. };
  1011. //! IWUFactory
  1012. //! Used to instantiate WorkUnit components.
  1013. class MemoryBuffer;
  1014. interface ILocalWorkUnit : extends IWorkUnit
  1015. {
  1016. virtual void serialize(MemoryBuffer & tgt) = 0;
  1017. virtual void deserialize(MemoryBuffer & src) = 0;
  1018. virtual IConstWorkUnit * unlock() = 0;
  1019. };
  1020. enum WUSortField
  1021. {
  1022. WUSFuser = 1,
  1023. WUSFcluster = 2,
  1024. WUSFjob = 3,
  1025. WUSFstate = 4,
  1026. WUSFpriority = 5,
  1027. WUSFwuid = 6,
  1028. WUSFwuidhigh = 7,
  1029. WUSFfileread = 8,
  1030. WUSFroxiecluster = 9,
  1031. WUSFprotected = 10,
  1032. WUSFtotalthortime = 11,
  1033. WUSFwildwuid = 12,
  1034. WUSFecl = 13,
  1035. WUSFcustom = 14,
  1036. WUSFterm = 0,
  1037. WUSFreverse = 256,
  1038. WUSFnocase = 512,
  1039. WUSFnumeric = 1024,
  1040. WUSFwild = 2048
  1041. };
  1042. enum WUQueryFilterBoolean
  1043. {
  1044. WUQFSNo = 0,
  1045. WUQFSYes = 1,
  1046. WUQFSAll = 2
  1047. };
  1048. enum WUQuerySortField
  1049. {
  1050. WUQSFId = 1,
  1051. WUQSFname = 2,
  1052. WUQSFwuid = 3,
  1053. WUQSFdll = 4,
  1054. WUQSFmemoryLimit = 5,
  1055. WUQSFmemoryLimitHi = 6,
  1056. WUQSFtimeLimit = 7,
  1057. WUQSFtimeLimitHi = 8,
  1058. WUQSFwarnTimeLimit = 9,
  1059. WUQSFwarnTimeLimitHi = 10,
  1060. WUQSFpriority = 11,
  1061. WUQSFpriorityHi = 12,
  1062. WUQSFQuerySet = 13,
  1063. WUQSFActivited = 14,
  1064. WUQSFSuspendedByUser = 15,
  1065. WUQSFLibrary = 16,
  1066. WUQSFterm = 0,
  1067. WUQSFreverse = 256,
  1068. WUQSFnocase = 512,
  1069. WUQSFnumeric = 1024,
  1070. WUQSFwild = 2048
  1071. };
  1072. typedef IIteratorOf<IPropertyTree> IConstQuerySetQueryIterator;
  1073. interface IWorkUnitFactory : extends IInterface
  1074. {
  1075. virtual IWorkUnit *createWorkUnit(const char *app, const char *user, ISecManager *secmgr = NULL, ISecUser *secuser = NULL) = 0;
  1076. virtual bool deleteWorkUnit(const char *wuid, ISecManager *secmgr = NULL, ISecUser *secuser = NULL) = 0;
  1077. virtual IConstWorkUnit * openWorkUnit(const char *wuid, bool lock, ISecManager *secmgr = NULL, ISecUser *secuser = NULL) = 0;
  1078. virtual IConstWorkUnitIterator * getWorkUnitsByOwner(const char * owner, ISecManager *secmgr = NULL, ISecUser *secuser = NULL) = 0;
  1079. virtual IWorkUnit * updateWorkUnit(const char * wuid, ISecManager *secmgr = NULL, ISecUser *secuser = NULL) = 0;
  1080. virtual int setTracingLevel(int newlevel) = 0;
  1081. virtual IWorkUnit * createNamedWorkUnit(const char * wuid, const char * app, const char * user, ISecManager *secmgr = NULL, ISecUser *secuser = NULL) = 0;
  1082. virtual IWorkUnit * getGlobalWorkUnit(ISecManager *secmgr = NULL, ISecUser *secuser = NULL) = 0;
  1083. virtual IConstWorkUnitIterator * getWorkUnitsByState(WUState state, ISecManager *secmgr = NULL, ISecUser *secuser = NULL) = 0;
  1084. virtual IConstWorkUnitIterator * getWorkUnitsByECL(const char * ecl, ISecManager *secmgr = NULL, ISecUser *secuser = NULL) = 0;
  1085. virtual IConstWorkUnitIterator * getWorkUnitsByCluster(const char * cluster, ISecManager *secmgr = NULL, ISecUser *secuser = NULL) = 0;
  1086. virtual IConstWorkUnitIterator * getWorkUnitsByXPath(const char * xpath, ISecManager *secmgr = NULL, ISecUser *secuser = NULL) = 0;
  1087. virtual IConstWorkUnitIterator * getWorkUnitsSorted(WUSortField * sortorder, WUSortField * filters, const void * filterbuf,
  1088. unsigned startoffset, unsigned maxnum, const char * queryowner, __int64 * cachehint, unsigned *total,
  1089. ISecManager *secmgr = NULL, ISecUser *secuser = NULL) = 0;
  1090. virtual unsigned numWorkUnits() = 0;
  1091. virtual unsigned numWorkUnitsFiltered(WUSortField * filters, const void * filterbuf, ISecManager *secmgr = NULL, ISecUser *secuser = NULL) = 0;
  1092. virtual void descheduleAllWorkUnits(ISecManager *secmgr = NULL, ISecUser *secuser = NULL) = 0;
  1093. virtual IConstQuerySetQueryIterator * getQuerySetQueriesSorted(WUQuerySortField *sortorder, WUQuerySortField *filters, const void *filterbuf, unsigned startoffset, unsigned maxnum, __int64 *cachehint, unsigned *total, const MapStringTo<bool> *subset) = 0;
  1094. virtual bool isAborting(const char *wuid) const = 0;
  1095. virtual void clearAborting(const char *wuid) = 0;
  1096. virtual WUState waitForWorkUnit(const char * wuid, unsigned timeout, bool compiled, bool returnOnWaitState) = 0;
  1097. };
  1098. interface IWorkflowScheduleConnection : extends IInterface
  1099. {
  1100. virtual void lock() = 0;
  1101. virtual void unlock() = 0;
  1102. virtual void setActive() = 0;
  1103. virtual void resetActive() = 0;
  1104. virtual bool queryActive() = 0;
  1105. virtual bool pull(IWorkflowItemArray * workflow) = 0;
  1106. virtual void push(const char * name, const char * text) = 0;
  1107. virtual void remove() = 0;
  1108. };
  1109. interface IExtendedWUInterface
  1110. {
  1111. virtual unsigned calculateHash(unsigned prevHash) = 0;
  1112. virtual void copyWorkUnit(IConstWorkUnit *cached, bool all) = 0;
  1113. virtual bool archiveWorkUnit(const char *base,bool del,bool ignoredllerrors,bool deleteOwned) = 0;
  1114. virtual void packWorkUnit(bool pack=true) = 0;
  1115. };
  1116. struct WorkunitUpdate : public Owned<IWorkUnit>
  1117. {
  1118. public:
  1119. WorkunitUpdate(IWorkUnit *wu) : Owned<IWorkUnit>(wu) { }
  1120. ~WorkunitUpdate() { if (get()) get()->commit(); }
  1121. };
  1122. class WuStatisticTarget : implements IStatisticTarget
  1123. {
  1124. public:
  1125. WuStatisticTarget(IWorkUnit * _wu, const char * _defaultWho) : wu(_wu), defaultWho(_defaultWho) {}
  1126. virtual void addStatistic(StatisticScopeType scopeType, const char * scope, StatisticKind kind, char * description, unsigned __int64 value, unsigned __int64 count, unsigned __int64 maxValue, StatsMergeAction mergeAction)
  1127. {
  1128. wu->setStatistic(queryStatisticsComponentType(), queryStatisticsComponentName(), scopeType, scope, kind, description, value, count, maxValue, mergeAction);
  1129. }
  1130. protected:
  1131. Linked<IWorkUnit> wu;
  1132. const char * defaultWho;
  1133. };
  1134. typedef IWorkUnitFactory * (* WorkUnitFactoryFactory)(const IPropertyTree *);
  1135. extern WORKUNIT_API IStringVal &getEclCCServerQueueNames(IStringVal &ret, const char *process);
  1136. extern WORKUNIT_API IStringVal &getEclServerQueueNames(IStringVal &ret, const char *process);
  1137. extern WORKUNIT_API IStringVal &getEclSchedulerQueueNames(IStringVal &ret, const char *process);
  1138. extern WORKUNIT_API IStringVal &getAgentQueueNames(IStringVal &ret, const char *process);
  1139. extern WORKUNIT_API IStringVal &getRoxieQueueNames(IStringVal &ret, const char *process);
  1140. extern WORKUNIT_API IStringVal &getThorQueueNames(IStringVal &ret, const char *process);
  1141. extern WORKUNIT_API StringBuffer &getClusterThorQueueName(StringBuffer &ret, const char *cluster);
  1142. extern WORKUNIT_API StringBuffer &getClusterThorGroupName(StringBuffer &ret, const char *cluster);
  1143. extern WORKUNIT_API StringBuffer &getClusterRoxieQueueName(StringBuffer &ret, const char *cluster);
  1144. extern WORKUNIT_API StringBuffer &getClusterEclCCServerQueueName(StringBuffer &ret, const char *cluster);
  1145. extern WORKUNIT_API StringBuffer &getClusterEclServerQueueName(StringBuffer &ret, const char *cluster);
  1146. extern WORKUNIT_API StringBuffer &getClusterEclAgentQueueName(StringBuffer &ret, const char *cluster);
  1147. extern WORKUNIT_API IStringIterator *getTargetClusters(const char *processType, const char *processName);
  1148. extern WORKUNIT_API bool validateTargetClusterName(const char *clustname);
  1149. extern WORKUNIT_API IConstWUClusterInfo* getTargetClusterInfo(const char *clustname);
  1150. typedef IArrayOf<IConstWUClusterInfo> CConstWUClusterInfoArray;
  1151. extern WORKUNIT_API unsigned getEnvironmentClusterInfo(CConstWUClusterInfoArray &clusters);
  1152. extern WORKUNIT_API unsigned getEnvironmentClusterInfo(IPropertyTree* environmentRoot, CConstWUClusterInfoArray &clusters);
  1153. extern WORKUNIT_API void getRoxieProcessServers(const char *process, SocketEndpointArray &servers);
  1154. extern WORKUNIT_API bool isProcessCluster(const char *remoteDali, const char *process);
  1155. extern WORKUNIT_API bool isProcessCluster(const char *process);
  1156. extern WORKUNIT_API IStatisticGatherer * createGlobalStatisticGatherer(IWorkUnit * wu);
  1157. extern WORKUNIT_API bool getWorkUnitCreateTime(const char *wuid,CDateTime &time); // based on WUID
  1158. extern WORKUNIT_API bool restoreWorkUnit(const char *base,const char *wuid);
  1159. extern WORKUNIT_API void clientShutdownWorkUnit();
  1160. extern WORKUNIT_API IExtendedWUInterface * queryExtendedWU(IWorkUnit * wu);
  1161. extern WORKUNIT_API unsigned getEnvironmentThorClusterNames(StringArray &thorNames, StringArray &groupNames, StringArray &targetNames, StringArray &queueNames);
  1162. extern WORKUNIT_API unsigned getEnvironmentHThorClusterNames(StringArray &eclAgentNames, StringArray &groupNames, StringArray &targetNames);
  1163. extern WORKUNIT_API StringBuffer &formatGraphTimerLabel(StringBuffer &str, const char *graphName, unsigned subGraphNum=0, unsigned __int64 subId=0);
  1164. extern WORKUNIT_API StringBuffer &formatGraphTimerScope(StringBuffer &str, const char *graphName, unsigned subGraphNum, unsigned __int64 subId);
  1165. extern WORKUNIT_API bool parseGraphTimerLabel(const char *label, StringAttr &graphName, unsigned & graphNum, unsigned &subGraphNum, unsigned &subId);
  1166. extern WORKUNIT_API bool parseGraphScope(const char *scope, StringAttr &graphName, unsigned & graphNum, unsigned &subGraphId);
  1167. extern WORKUNIT_API void addExceptionToWorkunit(IWorkUnit * wu, ErrorSeverity severity, const char * source, unsigned code, const char * text, const char * filename, unsigned lineno, unsigned column);
  1168. extern WORKUNIT_API void setWorkUnitFactory(IWorkUnitFactory *_factory);
  1169. extern WORKUNIT_API IWorkUnitFactory * getWorkUnitFactory();
  1170. extern WORKUNIT_API IWorkUnitFactory * getWorkUnitFactory(ISecManager *secmgr, ISecUser *secuser);
  1171. extern WORKUNIT_API ILocalWorkUnit* createLocalWorkUnit(const char *XML);
  1172. extern WORKUNIT_API IStringVal& exportWorkUnitToXML(const IConstWorkUnit *wu, IStringVal &str, bool unpack, bool includeProgress);
  1173. extern WORKUNIT_API StringBuffer &exportWorkUnitToXML(const IConstWorkUnit *wu, StringBuffer &str, bool unpack, bool includeProgress);
  1174. extern WORKUNIT_API void exportWorkUnitToXMLFile(const IConstWorkUnit *wu, const char * filename, unsigned extraXmlFlags, bool unpack, bool includeProgress);
  1175. extern WORKUNIT_API void submitWorkUnit(const char *wuid, const char *username, const char *password);
  1176. extern WORKUNIT_API void abortWorkUnit(const char *wuid);
  1177. extern WORKUNIT_API void submitWorkUnit(const char *wuid, ISecManager *secmgr, ISecUser *secuser);
  1178. extern WORKUNIT_API void abortWorkUnit(const char *wuid, ISecManager *secmgr, ISecUser *secuser);
  1179. extern WORKUNIT_API void secSubmitWorkUnit(const char *wuid, ISecManager &secmgr, ISecUser &secuser);
  1180. extern WORKUNIT_API void secAbortWorkUnit(const char *wuid, ISecManager &secmgr, ISecUser &secuser);
  1181. extern WORKUNIT_API IWUResult * updateWorkUnitResult(IWorkUnit * w, const char *name, unsigned sequence);
  1182. extern WORKUNIT_API IConstWUResult * getWorkUnitResult(IConstWorkUnit * w, const char *name, unsigned sequence);
  1183. extern WORKUNIT_API void updateSuppliedXmlParams(IWorkUnit * w);
  1184. //returns a state code. WUStateUnknown == timeout
  1185. extern WORKUNIT_API WUState waitForWorkUnitToComplete(const char * wuid, int timeout = -1, bool returnOnWaitState = false);
  1186. extern WORKUNIT_API bool waitForWorkUnitToCompile(const char * wuid, int timeout = -1);
  1187. extern WORKUNIT_API WUState secWaitForWorkUnitToComplete(const char * wuid, ISecManager &secmgr, ISecUser &secuser, int timeout = -1, bool returnOnWaitState = false);
  1188. extern WORKUNIT_API bool secWaitForWorkUnitToCompile(const char * wuid, ISecManager &secmgr, ISecUser &secuser, int timeout = -1);
  1189. extern WORKUNIT_API bool secDebugWorkunit(const char * wuid, ISecManager &secmgr, ISecUser &secuser, const char *command, StringBuffer &response);
  1190. extern WORKUNIT_API IStringVal& createToken(const char *wuid, const char *user, const char *password, IStringVal &str);
  1191. // This latter is temporary - tokens will be replaced by something more secure
  1192. extern WORKUNIT_API void extractToken(const char *token, const char *wuid, IStringVal &user, IStringVal &password);
  1193. extern WORKUNIT_API WUState getWorkUnitState(const char* state);
  1194. extern WORKUNIT_API IWorkflowScheduleConnection * getWorkflowScheduleConnection(char const * wuid);
  1195. extern WORKUNIT_API const char *skipLeadingXml(const char *text);
  1196. extern WORKUNIT_API bool isArchiveQuery(const char * text);
  1197. extern WORKUNIT_API bool isQueryManifest(const char * text);
  1198. extern WORKUNIT_API IPropertyTree * resolveDefinitionInArchive(IPropertyTree * archive, const char * path);
  1199. inline bool isLibrary(IConstWorkUnit * wu) { return wu->getApplicationValueInt("LibraryModule", "interfaceHash", 0) != 0; }
  1200. extern WORKUNIT_API bool looksLikeAWuid(const char * wuid, const char firstChar);
  1201. enum WUQueryActivationOptions
  1202. {
  1203. DO_NOT_ACTIVATE = 0,
  1204. MAKE_ACTIVATE= 1,
  1205. ACTIVATE_SUSPEND_PREVIOUS = 2,
  1206. ACTIVATE_DELETE_PREVIOUS = 3,
  1207. DO_NOT_ACTIVATE_LOAD_DATA_ONLY = 4,
  1208. MAKE_ACTIVATE_LOAD_DATA_ONLY = 5
  1209. };
  1210. extern WORKUNIT_API int calcPriorityValue(const IPropertyTree * p); // Calls to this should really go through the workunit interface.
  1211. extern WORKUNIT_API IPropertyTree * addNamedQuery(IPropertyTree * queryRegistry, const char * name, const char * wuid, const char * dll, bool library, const char *userid, const char *snapshot); // result not linked
  1212. extern WORKUNIT_API void removeNamedQuery(IPropertyTree * queryRegistry, const char * id);
  1213. extern WORKUNIT_API void removeWuidFromNamedQueries(IPropertyTree * queryRegistry, const char * wuid);
  1214. extern WORKUNIT_API void removeDllFromNamedQueries(IPropertyTree * queryRegistry, const char * dll);
  1215. extern WORKUNIT_API void removeAliasesFromNamedQuery(IPropertyTree * queryRegistry, const char * id);
  1216. extern WORKUNIT_API void setQueryAlias(IPropertyTree * queryRegistry, const char * name, const char * value);
  1217. extern WORKUNIT_API IPropertyTree * getQueryById(IPropertyTree * queryRegistry, const char *queryid);
  1218. extern WORKUNIT_API IPropertyTree * getQueryById(const char *queryset, const char *queryid, bool readonly);
  1219. extern WORKUNIT_API IPropertyTree * resolveQueryAlias(IPropertyTree * queryRegistry, const char * alias);
  1220. extern WORKUNIT_API IPropertyTree * resolveQueryAlias(const char *queryset, const char *alias, bool readonly);
  1221. extern WORKUNIT_API IPropertyTree * getQueryRegistry(const char * wsEclId, bool readonly);
  1222. extern WORKUNIT_API IPropertyTree * getQueryRegistryRoot();
  1223. extern WORKUNIT_API void checkAddLibrariesToQueryEntry(IPropertyTree *queryTree, IConstWULibraryIterator *libraries);
  1224. extern WORKUNIT_API void checkAddLibrariesToQueryEntry(IPropertyTree *queryTree, IConstWorkUnit *cw);
  1225. extern WORKUNIT_API void setQueryCommentForNamedQuery(IPropertyTree * queryRegistry, const char *id, const char *queryComment);
  1226. extern WORKUNIT_API void setQuerySuspendedState(IPropertyTree * queryRegistry, const char * name, bool suspend, const char *userid);
  1227. extern WORKUNIT_API IPropertyTree * addNamedPackageSet(IPropertyTree * packageRegistry, const char * name, IPropertyTree *packageInfo, bool overWrite); // result not linked
  1228. extern WORKUNIT_API void removeNamedPackage(IPropertyTree * packageRegistry, const char * id);
  1229. extern WORKUNIT_API IPropertyTree * getPackageSetRegistry(const char * wsEclId, bool readonly);
  1230. extern WORKUNIT_API void addQueryToQuerySet(IWorkUnit *workunit, IPropertyTree *queryRegistry, const char *queryName, WUQueryActivationOptions activateOption, StringBuffer &newQueryId, const char *userid);
  1231. extern WORKUNIT_API void addQueryToQuerySet(IWorkUnit *workunit, const char *querySetName, const char *queryName, WUQueryActivationOptions activateOption, StringBuffer &newQueryId, const char *userid);
  1232. extern WORKUNIT_API void activateQuery(IPropertyTree *queryRegistry, WUQueryActivationOptions activateOption, const char *queryName, const char *queryId, const char *userid);
  1233. extern WORKUNIT_API bool removeQuerySetAlias(const char *querySetName, const char *alias);
  1234. extern WORKUNIT_API void addQuerySetAlias(const char *querySetName, const char *alias, const char *id);
  1235. extern WORKUNIT_API void setSuspendQuerySetQuery(const char *querySetName, const char *id, bool suspend, const char *userid);
  1236. extern WORKUNIT_API void deleteQuerySetQuery(const char *querySetName, const char *id);
  1237. extern WORKUNIT_API const char *queryIdFromQuerySetWuid(IPropertyTree *queryRegistry, const char *wuid, const char *queryName, IStringVal &id);
  1238. extern WORKUNIT_API const char *queryIdFromQuerySetWuid(const char *querySetName, const char *wuid, const char *queryName, IStringVal &id);
  1239. extern WORKUNIT_API void removeQuerySetAliasesFromNamedQuery(const char *querySetName, const char * id);
  1240. extern WORKUNIT_API void setQueryCommentForNamedQuery(const char *querySetName, const char *id, const char *comment);
  1241. extern WORKUNIT_API void gatherLibraryNames(StringArray &names, StringArray &unresolved, IWorkUnitFactory &workunitFactory, IConstWorkUnit &cw, IPropertyTree *queryset);
  1242. extern WORKUNIT_API void associateLocalFile(IWUQuery * query, WUFileType type, const char * name, const char * description, unsigned crc);
  1243. interface ITimeReporter;
  1244. extern WORKUNIT_API void updateWorkunitTimeStat(IWorkUnit * wu, StatisticScopeType scopeType, const char * scope, StatisticKind kind, const char * description, unsigned __int64 value);
  1245. extern WORKUNIT_API void updateWorkunitTimings(IWorkUnit * wu, ITimeReporter *timer);
  1246. extern WORKUNIT_API void getWorkunitTotalTime(IConstWorkUnit* workunit, const char* creator, unsigned __int64 & totalTimeNs, unsigned __int64 & totalThisTimeNs);
  1247. extern WORKUNIT_API IConstWUStatistic * getStatistic(IConstWorkUnit * wu, const IStatisticsFilter & filter);
  1248. extern WORKUNIT_API const char *getTargetClusterComponentName(const char *clustname, const char *processType, StringBuffer &name);
  1249. extern WORKUNIT_API void descheduleWorkunit(char const * wuid);
  1250. #if 0
  1251. void WORKUNIT_API testWorkflow();
  1252. #endif
  1253. extern WORKUNIT_API const char * getWorkunitStateStr(WUState state);
  1254. extern WORKUNIT_API void addTimeStamp(IWorkUnit * wu, StatisticScopeType scopeType, const char * scope, StatisticKind kind);
  1255. #endif