-
Notifications
You must be signed in to change notification settings - Fork 310
Expand file tree
/
Copy pathworkunit.hpp
More file actions
1882 lines (1613 loc) · 81.8 KB
/
workunit.hpp
File metadata and controls
1882 lines (1613 loc) · 81.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*##############################################################################
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 WORKUNIT_INCL
#define WORKUNIT_INCL
#ifdef WORKUNIT_EXPORTS
#define WORKUNIT_API DECL_EXPORT
#else
#define WORKUNIT_API DECL_IMPORT
#endif
#define MINIMUM_SCHEDULE_PRIORITY 0
#define DEFAULT_SCHEDULE_PRIORITY 50
#define MAXIMUM_SCHEDULE_PRIORITY 100
#include "jiface.hpp"
#include "errorlist.h"
#include "jtime.hpp"
#include "jsocket.hpp"
#include "jstats.h"
#include "jutil.hpp"
#include "jprop.hpp"
#include "jmisc.hpp"
#include "jtrace.hpp"
#include "wuattr.hpp"
#include <vector>
#include <list>
#include <utility>
#include <map>
#include <string>
#define LEGACY_GLOBAL_SCOPE "workunit"
#define GLOBAL_SCOPE ""
#define CHEAP_UCHAR_DEF
#ifdef _WIN32
typedef char16_t UChar;
#else //_WIN32
typedef unsigned short UChar;
#endif //_WIN32
enum : unsigned
{
WUERR_ModifyFilterAfterFinalize = WORKUNIT_ERROR_START,
WUERR_FinalizeAfterFinalize,
WUERR_InvalidDebugValueName,
};
// error codes
#define QUERRREG_ADD_NAMEDQUERY QUERYREGISTRY_ERROR_START
#define QUERRREG_REMOVE_NAMEDQUERY QUERYREGISTRY_ERROR_START+1
#define QUERRREG_WUID QUERYREGISTRY_ERROR_START+2
#define QUERRREG_DLL QUERYREGISTRY_ERROR_START+3
#define QUERRREG_SETALIAS QUERYREGISTRY_ERROR_START+4
#define QUERRREG_RESOLVEALIAS QUERYREGISTRY_ERROR_START+5
#define QUERRREG_REMOVEALIAS QUERYREGISTRY_ERROR_START+6
#define QUERRREG_QUERY_REGISTRY QUERYREGISTRY_ERROR_START+7
#define QUERRREG_SUSPEND QUERYREGISTRY_ERROR_START+8
#define QUERRREG_UNSUSPEND QUERYREGISTRY_ERROR_START+9
#define QUERRREG_COMMENT QUERYREGISTRY_ERROR_START+10
class CDateTime;
interface ISetToXmlTransformer;
interface ISecManager;
interface ISecUser;
class StringArray;
class StringBuffer;
typedef unsigned __int64 __uint64;
interface IQueueSwitcher : extends IInterface
{
virtual void * getQ(const char * qname, const char * wuid) = 0;
virtual void putQ(const char * qname, void * qitem) = 0;
virtual bool isAuto() = 0;
};
//! PriorityClass
//! Not sure what the real current class values are -- TBD
enum WUPriorityClass
{
PriorityClassUnknown = 0,
PriorityClassLow = 1,
PriorityClassNormal = 2,
PriorityClassHigh = 3,
PriorityClassSize = 4
};
enum WUQueryType
{
QueryTypeUnknown = 0,
QueryTypeEcl = 1,
QueryTypeSql = 2,
QueryTypeXml = 3,
QueryTypeAttribute = 4,
QueryTypeSize = 5
};
enum WUState
{
WUStateUnknown = 0,
WUStateCompiled = 1,
WUStateRunning = 2,
WUStateCompleted = 3,
WUStateFailed = 4,
WUStateArchived = 5,
WUStateAborting = 6,
WUStateAborted = 7,
WUStateBlocked = 8,
WUStateSubmitted = 9,
WUStateScheduled = 10,
WUStateCompiling = 11,
WUStateWait = 12,
WUStateUploadingFiles = 13,
WUStateDebugPaused = 14,
WUStateDebugRunning = 15,
WUStatePaused = 16,
WUStateSize = 17
};
enum WUAction
{
WUActionUnknown = 0,
WUActionCompile = 1,
WUActionCheck = 2,
WUActionRun = 3,
WUActionExecuteExisting = 4,
WUActionPause = 5,
WUActionPauseNow = 6,
WUActionResume = 7,
WUActionGenerateDebugInfo = 8,
WUActionSize = 9, // NB: must be last
};
enum WUResultStatus
{
ResultStatusUndefined = 0,
ResultStatusCalculated = 1,
ResultStatusSupplied = 2,
ResultStatusFailed = 3,
ResultStatusPartial = 4,
ResultStatusSize = 5
};
//! IConstWUGraph
enum WUGraphType
{
GraphTypeAny = 0,
GraphTypeProgress = 1,
GraphTypeEcl = 2,
GraphTypeActivities = 3,
GraphTypeSubProgress = 4,
GraphTypeSize = 5
};
interface IConstWUGraphIterator;
interface ICsvToRawTransformer;
interface IXmlToRawTransformer;
interface IPropertyTree;
interface IPropertyTreeIterator;
enum WUGraphState
{
WUGraphUnknown = 0,
WUGraphComplete = 1,
WUGraphRunning = 2,
WUGraphFailed = 3,
WUGraphPaused = 4
};
interface IConstWUGraphMeta : extends IInterface
{
virtual IStringVal & getName(IStringVal & ret) const = 0;
virtual IStringVal & getLabel(IStringVal & ret) const = 0;
virtual IStringVal & getTypeName(IStringVal & ret) const = 0;
virtual WUGraphType getType() const = 0;
virtual WUGraphState getState() const = 0;
virtual unsigned getWfid() const = 0;
};
interface IConstWUGraph : extends IConstWUGraphMeta
{
virtual IStringVal & getXGMML(IStringVal & ret, bool mergeProgress, bool doFormatStats) const = 0;
virtual IPropertyTree * getXGMMLTree(bool mergeProgress, bool doFormatStats) const = 0;
virtual IPropertyTree * getXGMMLTreeRaw() const = 0;
};
interface IConstWUGraphIterator : extends IScmIterator
{
virtual IConstWUGraph & query() = 0;
};
interface IConstWUTimer : extends IInterface
{
virtual IStringVal & getName(IStringVal & ret) const = 0;
virtual unsigned getCount() const = 0;
virtual unsigned getDuration() const = 0;
};
interface IWUTimer : extends IConstWUTimer
{
virtual void setName(const char * str) = 0;
virtual void setCount(unsigned c) = 0;
virtual void setDuration(unsigned d) = 0;
};
interface IConstWUTimerIterator : extends IScmIterator
{
virtual IConstWUTimer & query() = 0;
};
interface IConstWUGraphMetaIterator : extends IScmIterator
{
virtual IConstWUGraphMeta & query() = 0;
};
constexpr int LibraryBaseSequence = 1000000000;
//! IWUResult
enum
{
ResultSequenceStored = -1,
ResultSequencePersist = -2,
ResultSequenceInternal = -3,
ResultSequenceOnce = -4,
};
extern WORKUNIT_API bool isSpecialResultSequence(unsigned sequence);
enum WUResultFormat
{
ResultFormatRaw = 0,
ResultFormatXml = 1,
ResultFormatXmlSet = 2,
ResultFormatCsv = 3,
ResultFormatSize = 4
};
interface ITypeInfo;
interface IConstWUResult : extends IInterface
{
virtual WUResultStatus getResultStatus() const = 0;
virtual IStringVal & getResultName(IStringVal & str) const = 0;
virtual int getResultSequence() const = 0;
virtual bool isResultScalar() const = 0;
virtual IStringVal & getResultXml(IStringVal & str, bool hidePasswords) const = 0;
virtual unsigned getResultFetchSize() const = 0;
virtual __int64 getResultTotalRowCount() const = 0;
virtual bool hasTotalRowCount() const = 0;
virtual __int64 getResultRowCount() const = 0;
virtual void getResultDataset(IStringVal & ecl, IStringVal & defs) const = 0;
virtual IStringVal & getResultLogicalName(IStringVal & ecl) const = 0;
virtual IStringVal & getResultKeyField(IStringVal & ecl) const = 0;
virtual unsigned getResultRequestedRows() const = 0;
virtual __int64 getResultInt() const = 0;
virtual bool getResultBool() const = 0;
virtual double getResultReal() const = 0;
virtual IStringVal & getResultString(IStringVal & str, bool hidePasswords) const = 0;
virtual IDataVal & getResultRaw(IDataVal & data, IXmlToRawTransformer * xmlTransformer, ICsvToRawTransformer * csvTransformer) const = 0;
virtual IDataVal & getResultUnicode(IDataVal & data) const = 0;
virtual IStringVal & getResultEclSchema(IStringVal & str) const = 0;
virtual __int64 getResultRawSize(IXmlToRawTransformer * xmlTransformer, ICsvToRawTransformer * csvTransformer) const = 0;
virtual IDataVal & getResultRaw(IDataVal & data, __int64 from, __int64 length, IXmlToRawTransformer * xmlTransformer, ICsvToRawTransformer * csvTransformer) const = 0;
virtual IStringVal & getResultRecordSizeEntry(IStringVal & str) const = 0;
virtual IStringVal & getResultTransformerEntry(IStringVal & str) const = 0;
virtual __int64 getResultRowLimit() const = 0;
virtual IStringVal & getResultFilename(IStringVal & str) const = 0;
virtual WUResultFormat getResultFormat() const = 0;
virtual unsigned getResultHash() const = 0;
virtual void getResultDecimal(void * val, unsigned length, unsigned precision, bool isSigned) const = 0;
virtual bool getResultIsAll() const = 0;
virtual const IProperties *queryResultXmlns() = 0;
virtual IStringVal &getResultFieldOpt(const char *name, IStringVal &str) const = 0;
virtual void getSchema(IArrayOf<ITypeInfo> &types, StringAttrArray &names, IStringVal * eclText) const = 0;
virtual void getResultWriteLocation(IStringVal & _graph, unsigned & _activityId) const = 0;
};
interface IWUResult : extends IConstWUResult
{
virtual void setResultStatus(WUResultStatus status) = 0;
virtual void setResultName(const char * name) = 0;
virtual void setResultSequence(unsigned seq) = 0;
virtual void setResultSchemaRaw(unsigned len, const void * schema) = 0;
virtual void setResultScalar(bool isScalar) = 0;
virtual void setResultRaw(unsigned len, const void * data, WUResultFormat format) = 0;
virtual void setResultFetchSize(unsigned rows) = 0;
virtual void setResultTotalRowCount(__int64 rows) = 0;
virtual void setResultRowCount(__int64 rows) = 0;
virtual void setResultDataset(const char * ecl, const char * defs) = 0;
virtual void setResultLogicalName(const char * logicalName) = 0;
virtual void setResultKeyField(const char * name) = 0;
virtual void setResultRequestedRows(unsigned rowcount) = 0;
virtual void setResultInt(__int64 val) = 0;
virtual void setResultBool(bool val) = 0;
virtual void setResultReal(double val) = 0;
virtual void setResultString(const char * val, unsigned length) = 0;
virtual void setResultData(const void * val, unsigned length) = 0;
virtual void setResultDecimal(const void * val, unsigned length) = 0;
virtual void addResultRaw(unsigned len, const void * data, WUResultFormat format) = 0;
virtual void setResultRecordSizeEntry(const char * val) = 0;
virtual void setResultTransformerEntry(const char * val) = 0;
virtual void setResultRowLimit(__int64 value) = 0;
virtual void setResultFilename(const char * name) = 0;
virtual void setResultUnicode(const void * val, unsigned length) = 0;
virtual void setResultUInt(__uint64 val) = 0;
virtual void setResultIsAll(bool value) = 0;
virtual void setResultFormat(WUResultFormat format) = 0;
virtual void setResultXML(const char * xml) = 0;
virtual void setResultRow(unsigned len, const void * data) = 0;
virtual void setResultXmlns(const char *prefix, const char *uri) = 0;
virtual void setResultFieldOpt(const char *name, const char *value)=0;
virtual void setResultWriteLocation(const char * _graph, unsigned _activityId) = 0;
virtual IPropertyTree *queryPTree() = 0;
};
interface IConstWUResultIterator : extends IScmIterator
{
virtual IConstWUResult & query() = 0;
};
//! IWUQuery
enum WUFileType
{
FileTypeCpp = 0,
FileTypeDll = 1,
FileTypeResText = 2,
FileTypeHintXml = 3,
FileTypeXml = 4,
FileTypeLog = 5,
FileTypePostMortem = 6,
FileTypeSize = 7
};
extern WORKUNIT_API EnumMapping queryFileTypes[];
interface IConstWUAssociatedFile : extends IInterface
{
virtual WUFileType getType() const = 0;
virtual IStringVal & getDescription(IStringVal & ret) const = 0;
virtual IStringVal & getIp(IStringVal & ret) const = 0;
virtual IStringVal & getName(IStringVal & ret) const = 0;
virtual IStringVal & getNameTail(IStringVal & ret) const = 0;
virtual unsigned getCrc() const = 0;
virtual unsigned getMinActivityId() const = 0;
virtual unsigned getMaxActivityId() const = 0;
};
interface IConstWUAssociatedFileIterator : extends IScmIterator
{
virtual IConstWUAssociatedFile & query() = 0;
};
interface IConstWUFieldUsage : extends IInterface // Defines a file (dataset or index) that contains used fields from queries
{
virtual const char * queryName() const = 0;
};
interface IConstWUFieldUsageIterator : extends IScmIterator // Iterates over files that contains used fields
{
virtual IConstWUFieldUsage * get() const = 0;
};
interface IConstWUFileUsage : extends IInterface // Defines a file (dataset or index) that contains used fields from queries
{
virtual const char * queryName() const = 0;
virtual const char * queryType() const = 0; // used file type: "dataset" or "index"
virtual unsigned getNumFields() const = 0;
virtual unsigned getNumFieldsUsed() const = 0;
virtual IConstWUFieldUsageIterator * getFields() const = 0;
};
interface IConstWUFileUsageIterator : extends IScmIterator // Iterates over files that contains used fields
{
virtual IConstWUFileUsage * get() const = 0;
};
interface IConstWUQuery : extends IInterface
{
virtual WUQueryType getQueryType() const = 0;
virtual IStringVal & getQueryText(IStringVal & str) const = 0;
virtual IStringVal & getQueryName(IStringVal & str) const = 0;
virtual IStringVal & getQueryDllName(IStringVal & str) const = 0;
virtual unsigned getQueryDllCrc() const = 0;
virtual IStringVal & getQueryCppName(IStringVal & str) const = 0;
virtual IStringVal & getQueryResTxtName(IStringVal & str) const = 0;
virtual IConstWUAssociatedFile * getAssociatedFile(WUFileType type, unsigned index) const = 0;
virtual IConstWUAssociatedFileIterator & getAssociatedFiles() const = 0;
virtual IStringVal & getQueryShortText(IStringVal & str) const = 0;
virtual IStringVal & getQueryMainDefinition(IStringVal & str) const = 0;
virtual bool isArchive() const = 0;
virtual bool hasArchive() const = 0;
};
interface IWUQuery : extends IConstWUQuery
{
virtual void setQueryType(WUQueryType qt) = 0;
virtual void setQueryText(const char * pstr) = 0;
virtual void setQueryName(const char * pstr) = 0;
virtual void addAssociatedFile(WUFileType type, const char * name, const char * ip, const char * desc, unsigned crc, unsigned minActivity, unsigned maxActivity) = 0;
virtual void removeAssociatedFiles() = 0;
virtual void setQueryMainDefinition(const char * str) = 0;
virtual void removeAssociatedFile(WUFileType type, const char * name, const char * desc) = 0;
};
interface IConstWUWebServicesInfo : extends IInterface
{
virtual IStringVal & getModuleName(IStringVal & str) const = 0;
virtual IStringVal & getAttributeName(IStringVal & str) const = 0;
virtual IStringVal & getDefaultName(IStringVal & str) const = 0;
virtual IStringVal & getInfo(const char * name, IStringVal & str) const = 0;
virtual unsigned getWebServicesCRC() const = 0;
virtual IStringVal & getText(const char * name, IStringVal & str) const = 0;
};
interface IWUWebServicesInfo : extends IConstWUWebServicesInfo
{
virtual void setModuleName(const char * pstr) = 0;
virtual void setAttributeName(const char * pstr) = 0;
virtual void setDefaultName(const char * pstr) = 0;
virtual void setInfo(const char * name, const char * info) = 0;
virtual void setWebServicesCRC(unsigned crc) = 0;
virtual void setText(const char * name, const char * text) = 0;
};
//! IWUPlugin
interface IConstWUPlugin : extends IInterface
{
virtual IStringVal & getPluginName(IStringVal & str) const = 0;
virtual IStringVal & getPluginVersion(IStringVal & str) const = 0;
};
interface IWUPlugin : extends IConstWUPlugin
{
virtual void setPluginName(const char * str) = 0;
virtual void setPluginVersion(const char * str) = 0;
};
interface IConstWUPluginIterator : extends IScmIterator
{
virtual IConstWUPlugin & query() = 0;
};
interface IConstWULibrary : extends IInterface
{
virtual IStringVal & getName(IStringVal & str) const = 0;
};
interface IWULibrary : extends IConstWULibrary
{
virtual void setName(const char * str) = 0;
};
interface IConstWULibraryIterator : extends IScmIterator
{
virtual IConstWULibrary & query() = 0;
};
//! IWUException
interface IConstWUException : extends IInterface
{
virtual IStringVal & getExceptionSource(IStringVal & str) const = 0;
virtual IStringVal & getExceptionMessage(IStringVal & str) const = 0;
virtual unsigned getExceptionCode() const = 0;
virtual ErrorSeverity getSeverity() const = 0;
virtual IStringVal & getTimeStamp(IStringVal & dt) const = 0;
virtual IStringVal & getExceptionFileName(IStringVal & str) const = 0;
virtual unsigned getExceptionLineNo() const = 0;
virtual unsigned getExceptionColumn() const = 0;
virtual unsigned getSequence() const = 0;
virtual unsigned getActivityId() const = 0;
virtual const char * queryScope() const = 0;
virtual unsigned getPriority() const = 0; // For ordering within a severity - e.g. warnings about inefficiency
virtual double getCost() const = 0; // cost optimizer cost saving estimate.
};
interface IWUException : extends IConstWUException
{
virtual void setExceptionSource(const char * str) = 0;
virtual void setExceptionMessage(const char * str) = 0;
virtual void setExceptionCode(unsigned code) = 0;
virtual void setSeverity(ErrorSeverity level) = 0;
virtual void setTimeStamp(const char * dt) = 0;
virtual void setExceptionFileName(const char * str) = 0;
virtual void setExceptionLineNo(unsigned r) = 0;
virtual void setExceptionColumn(unsigned c) = 0;
virtual void setActivityId(unsigned _id) = 0;
virtual void setScope(const char * _scope) = 0;
virtual void setPriority(unsigned _priority) = 0;
virtual void setCost(double cost) = 0; // cost optimizer cost saving estimate.
};
interface IConstWUExceptionIterator : extends IScmIterator
{
virtual IConstWUException & query() = 0;
};
// This enumeration is currently duplicated in workunit.hpp and environment.hpp. They must stay in sync.
#ifndef ENGINE_CLUSTER_TYPE
#define ENGINE_CLUSTER_TYPE
enum ClusterType { NoCluster, HThorCluster, RoxieCluster, ThorLCRCluster };
#endif
extern WORKUNIT_API ClusterType getClusterType(const char * platform, ClusterType dft = NoCluster);
extern WORKUNIT_API const char *clusterTypeString(ClusterType clusterType, bool lcrSensitive);
inline bool isThorCluster(ClusterType type) { return (type == ThorLCRCluster); }
//! IWorkflowItem
enum WFType
{
WFTypeNormal = 0,
WFTypeSuccess = 1,
WFTypeFailure = 2,
WFTypeRecovery = 3,
WFTypeWait = 4,
WFTypeSize = 5
};
enum WFMode
{
WFModeNormal = 0,
WFModeCondition = 1,
WFModeSequential = 2,
WFModeParallel = 3,
WFModePersist = 4,
WFModeBeginWait = 5,
WFModeWait = 6,
WFModeOnce = 7,
WFModeUnused = 8,
WFModeCritical = 9,
WFModeOrdered = 10,
//for parallel workflow at runtime
WFModeConditionExpression = 11,
WFModePersistActivator = 12,
//Size needs to be the last mode
WFModeSize = 13
};
enum WFState
{
WFStateNull = 0,
WFStateReqd = 1,
WFStateDone = 2,
WFStateFail = 3,
WFStateSkip = 4,
WFStateWait = 5,
WFStateBlocked = 6,
WFStateSize = 7
};
interface IWorkflowDependencyIterator : extends IScmIterator
{
virtual unsigned query() const = 0;
};
interface IWorkflowEvent : extends IInterface
{
virtual const char * queryName() const = 0;
virtual const char * queryText() const = 0;
virtual bool matches(const char * name, const char * text) const = 0;
};
interface IConstWorkflowItem : extends IInterface
{
virtual unsigned queryWfid() const = 0;
virtual bool isScheduled() const = 0;
virtual bool isScheduledNow() const = 0;
virtual IWorkflowEvent * getScheduleEvent() const = 0;
virtual unsigned querySchedulePriority() const = 0;
virtual bool hasScheduleCount() const = 0;
virtual unsigned queryScheduleCount() const = 0;
virtual IWorkflowDependencyIterator * getDependencies() const = 0;
virtual WFType queryType() const = 0;
virtual WFMode queryMode() const = 0;
virtual unsigned querySuccess() const = 0;
virtual unsigned queryFailure() const = 0;
virtual unsigned queryRecovery() const = 0;
virtual unsigned queryRetriesAllowed() const = 0;
virtual unsigned queryContingencyFor() const = 0;
virtual IStringVal & getPersistName(IStringVal & val) const = 0;
virtual unsigned queryPersistWfid() const = 0;
virtual int queryPersistCopies() const = 0; // 0 - unmangled name, < 0 - use default, > 0 - max number
virtual bool queryPersistRefresh() const = 0;
virtual IStringVal &getCriticalName(IStringVal & val) const = 0;
virtual unsigned queryScheduleCountRemaining() const = 0;
virtual WFState queryState() const = 0;
virtual unsigned queryRetriesRemaining() const = 0;
virtual int queryFailCode() const = 0;
virtual const char * queryFailMessage() const = 0;
virtual const char * queryEventName() const = 0;
virtual const char * queryEventExtra() const = 0;
virtual unsigned queryScheduledWfid() const = 0;
virtual IStringVal & queryCluster(IStringVal & val) const = 0;
virtual IStringVal & getLabel(IStringVal & val) const = 0;
};
inline bool isPersist(const IConstWorkflowItem & item) { return item.queryMode() == WFModePersist; }
inline bool isCritical(const IConstWorkflowItem & item) { return item.queryMode() == WFModeCritical; }
interface IRuntimeWorkflowItem : extends IConstWorkflowItem
{
virtual void setState(WFState state) = 0;
virtual bool testAndDecRetries() = 0;
virtual bool decAndTestScheduleCountRemaining() = 0;
virtual void setFailInfo(int code, const char * message) = 0;
virtual void reset() = 0;
virtual void setEvent(const char * name, const char * extra) = 0;
virtual void incScheduleCount() = 0;
};
interface IWorkflowItem : extends IRuntimeWorkflowItem
{
virtual void setScheduledNow() = 0;
virtual void setScheduledOn(const char * name, const char * text) = 0;
virtual void setSchedulePriority(unsigned priority) = 0;
virtual void setScheduleCount(unsigned count) = 0;
virtual void addDependency(unsigned wfid) = 0;
virtual void setPersistInfo(const char * name, unsigned wfid, int maxCopies, bool refresh) = 0;
virtual void setCriticalInfo(char const * name) = 0;
virtual void syncRuntimeData(const IConstWorkflowItem & other) = 0;
virtual void setScheduledWfid(unsigned wfid) = 0;
virtual void setCluster(const char * cluster) = 0;
virtual void setLabel(const char * label) = 0;
};
interface IConstWorkflowItemIterator : extends IScmIterator
{
virtual IConstWorkflowItem * query() const = 0;
};
interface IRuntimeWorkflowItemIterator : extends IConstWorkflowItemIterator
{
virtual IRuntimeWorkflowItem * get() const = 0;
};
interface IWorkflowItemIterator : extends IConstWorkflowItemIterator
{
virtual IWorkflowItem * get() const = 0;
};
interface IWorkflowItemArray : extends IInterface
{
virtual IRuntimeWorkflowItem & queryWfid(unsigned wfid) = 0;
virtual unsigned count() const = 0;
virtual IRuntimeWorkflowItemIterator * getSequenceIterator() = 0;
virtual void addClone(const IConstWorkflowItem * other) = 0;
virtual bool hasScheduling() const = 0;
};
enum LocalFileUploadType
{
UploadTypeFileSpray = 0,
UploadTypeWUResult = 1,
UploadTypeWUResultCsv = 2,
UploadTypeWUResultXml = 3,
UploadTypeSize = 4
};
interface IConstLocalFileUpload : extends IInterface
{
virtual unsigned queryID() const = 0;
virtual LocalFileUploadType queryType() const = 0;
virtual IStringVal & getSource(IStringVal & ret) const = 0;
virtual IStringVal & getDestination(IStringVal & ret) const = 0;
virtual IStringVal & getEventTag(IStringVal & ret) const = 0;
};
interface IConstLocalFileUploadIterator : extends IScmIterator
{
virtual IConstLocalFileUpload * get() = 0;
};
enum WUSubscribeOptions
{
SubscribeOptionState = 1,
SubscribeOptionAbort = 2,
SubscribeOptionAction = 4
};
interface IWorkUnitSubscriber
{
virtual void notify(WUSubscribeOptions flags, unsigned valueLen, const void *valueData) = 0;
};
interface IWorkUnitWatcher : extends IInterface
{
virtual void unsubscribe() = 0;
};
interface IWUGraphProgress;
interface IPropertyTree;
enum WUFileKind
{
WUFileStandard = 0,
WUFileTemporary = 1,
WUFileOwned = 2,
WUFileJobOwned = 3
};
typedef unsigned __int64 WUGraphIDType;
typedef unsigned __int64 WUNodeIDType;
interface IWUGraphProgress;
interface IWUGraphStats;
interface IPropertyTree;
interface IConstWUGraphProgress : extends IInterface
{
virtual IPropertyTree * getProgressTree(bool doFormat) = 0;
virtual unsigned queryFormatVersion() = 0;
};
interface IWUGraphStats : public IInterface
{
virtual IStatisticGatherer & queryStatsBuilder() = 0;
};
interface IConstWUTimeStamp : extends IInterface
{
virtual IStringVal & getApplication(IStringVal & str) const = 0;
virtual IStringVal & getEvent(IStringVal & str) const = 0;
virtual IStringVal & getDate(IStringVal & dt) const = 0;
};
interface IConstWUTimeStampIterator : extends IScmIterator
{
virtual IConstWUTimeStamp & query() = 0;
};
interface IConstWUAppValue : extends IInterface
{
virtual const char *queryApplication() const = 0;
virtual const char *queryName() const = 0;
virtual const char *queryValue() const = 0;
};
interface IConstWUAppValueIterator : extends IScmIterator
{
virtual IConstWUAppValue & query() = 0;
};
//More: Counts on files? optional target?
/*
* Statistics are used to store timestamps, time periods, counts memory usage and any other interesting statistic
* which is collected as the query is built or executed.
*
* Each statistic has the following details:
*
* 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").
* - It can also be used to represent a subcomponent e.g., mythor:0 the master, mythor:10 means the 10th slave.
* ?? Is the sub component always numeric ??
*
* 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).
*
* Measure - What kind of statistic is it? It can always be derived from the kind. The following values are supported:
* time - elapsed time in nanoseconds
* timestamp/when - a point in time (?to the nanosecond?)
* count - a count of the number of occurrences
* memory/size - a quantity of memory (or disk) measured in kb
* load - measure of cpu activity (stored as 1/1000000 core)
* skew - a measure of skew. 10000 = perfectly balanced, range [0..infinity]
*
*Optional:
*
* Description - Purely for display, calculated if not explicitly supplied.
* Scope - Where in the execution of the task is statistic gathered? It can have multiple levels (separated by colons), and statistics for
* a given level can be retrieved independently. The following scopes are supported:
* "global" - the default if not specified. Globally/within a workunit.
* "wfid<n>" - within workflow item <n> (is this at all useful?)
* "graphn[:sg<n>[:ac<n>"]"
* Possibly additional levels to allow multiple instances of an activity when used in a graph etc.
*
* Target - The target of the thing being monitored. E.g., a filename. ?? Is this needed? Should this be combined with scope??
*
* Examples:
* creator(mythor),scope(),kind(TimeWall) total time spend processing in thor search ct(thor),scope(),kind(TimeWall)
* creator(mythor),scope(graph1),kind(TimeWall) - total time spent processing a graph
* creator(mythor),scope(graph1:sg<subid>),kind(TimeElapsed) - total time spent processing a subgraph
* creator(mythor),scope(graph1:sg<n>:ac<id>),kind(TimeElapsed) - time for activity from start to stop
* creator(mythor),scope(graph1:sg<n>:ac<id>),kind(TimeLocal) - time spent locally processing
* creator(mythor),scope(graph1:sg<n>:ac<id>),kind(TimeWallRowRange) - time from first row to last row
* creator(mythor),scope(graph1:sg<n>:ac<id>),kind(WhenFirstRow) - timestamp for first row
* creator(myeclccserver@myip),scope(compile),kind(TimeWall)
* creator(myeclccserver@myip),scope(compile:transform),kind(TimeWall)
* creator(myeclccserver@myip),scope(compile:transform:fold),kind(TimeWall)
*
* Other possibilities
* creator(myesp),scope(filefile::abc::def),kind(NumAccesses)
*
* Configuring statistic collection:
* - 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.
*
* Some background notes:
* - Start time and end time (time processing first and last record) is useful for detecting time skew/serial activities.
* - Information is lost if you only show final skew, rather than skew over time, but storing time series data is
* prohibitive so we may need to create some derived metrics.
* - The engines need options to control what information is gathered.
* - Need to ensure clocks are synchronized for the timestamps to be useful.
*
* Some typical analysis we want to perform:
* - Activities that show significant skew between first (or last) record times between nodes.
* - Activities where the majority of the time is being spent.
*
* Filtering statistics - with control over who is creating it, what is being recorded, and
* [in order of importance]
* - which level of creator you are interested in [summary or individual nodes, or both] (*;*:*)?
* - which level of scope (interested in activities, or just by graph, or both)
* - a particular kind of statistic
* - A particular creator (including fixed/wildcarded sub-component)
*
* => Provide a class for representing a filter, which can be used to filter when recording and retrieving. Start simple and then extend.
* Text representation creator(*,*:*),creatordepth(n),creatorkind(x),scopedepth(n),scopekind(xxx,yyy),scope(*:23),kind(x).
*
* Examples
* kind(TimeElapsed),scopetype(subgraph) - subgraph timings
* kind(Time*),scopedepth(1)&kind(TimeElapsed),scopedepth(2),scopetype(subgraph) - all legacy global timings.
* creatortype(thor),kind(TimeElapsed),scope("") - how much time has been spent on thor? (Need to sum?)
* creator(mythor),kind(TimeElapsed),scope("") - how much time has been spent on *this* thor.
* kind(TimeElapsed),scope("compiled") - how much time has been spent on *this* thor.
*
* Need to efficiently
* - Get all (simple) stats for a graph/activities (creator(*),kind(*),scope(x:*)) - display in graph, finding hotspots
* - Get all stats for an activity (creator(*:*),measure(*:*),scope(x:y)) - providing details in a graph
* - Merge stats from multiple components
* - Merge stats from multiple runs?
*
* 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.
* - You need to be able to filter only a certain level of statistic - e.g., times for transforms, but not details of those transforms.
*
* => suggest store as
* stats[creatorDepth,scopeDepth][creator] { kind, scope, value, target }. sorted by (scope, target, kind)
* - allows high level filtering by level
* - allows combining with minor updates.
* - possibly extra structure within each creator - maybe depending on the level of the scope
* - need to be sub-sorted to allow efficient merging between creators (e.g. for calculating skew)
* - possibly different structure when collecting [e.g., indexed by stat, or using a local stat mapping ] and storing.
*
* Use (local) tables to map scope->uid. Possibly implicitly defined on first occurrence, or zip the entire structure.
*
* The progress information should be stored compressed, with min,max child ids to avoid decompressing
*/
// Should the statistics classes be able to be stored globally e.g., for esp and other non workunit contexts?
/*
* Work out how to represent all of the existing statistics
*
* Counts of number of skips on an index: kind(CountIndexSkips),measure(count),scope(workunit | filename | graph:activity#)
* Activity start time kind(WhenStart),measure(timestamp),scope(graph:activity#),creator(mythor)
* kind(WhenFirstRow),measure(timestamp),scope(graph:activity#),creator(mythor:slave#)
* Number of times files accessed by esp: kind(CountFileAccess),measure(count),scope(),target(filename);
* Elapsed/remaining time for sprays:
*/
/*
* Statistics and their kinds - prefixed indicates their type. Note generally the same type won't be reused for two different things.
*
* TimeStamps:
* StWhenGraphStart - When a graph starts
* StWhenFirstRow - When the first row is processed by slave activity
*
* Time
* StTimeParseQuery
* StTimeTransformQuery
* StTimeTransformQuery_Fold - transformquery:fold? effectively an extra level of detail on the kind.
* StTimeTransformQuery_Normalize
* StTimeElapsedExecuting - Elapsed wall time between first row and last row.
* StTimeExecuting - Cpu time spent executing
*
*
* Memory
* StSizeGeneratedCpp
* StSizePeakMemory
*
* Count
* StCountIndexSeeks
* StCountIndexScans
*
* Load
* StLoadWhileSorting - Average load while processing a sort?
*
* Skew
* StSkewRecordDistribution - Skew on the records across the different nodes
* StSkewExecutionTime - Skew in the execution time between activities.
*
*/
interface IConstWUScope : extends IInterface
{
virtual IStringVal & getScope(IStringVal & str) const = 0; // what scope is the statistic gathered over? e.g., workunit, wfid:n, graphn, graphn:m
virtual StatisticScopeType getScopeType() const = 0;
};
interface IConstStatistic : extends IInterface
{
virtual IStringVal & getDescription(IStringVal & str, bool createDefault) const = 0; // Description of the statistic suitable for displaying to the user
virtual IStringVal & getCreator(IStringVal & str) const = 0; // what component gathered the statistic e.g., myroxie/eclserver_12/mythor:100
virtual IStringVal & getFormattedValue(IStringVal & str) const = 0; // The formatted value for display
virtual StatisticMeasure getMeasure() const = 0;
virtual StatisticKind getKind() const = 0;
virtual StatisticCreatorType getCreatorType() const = 0;
virtual unsigned __int64 getValue() const = 0;
virtual unsigned __int64 getCount() const = 0;
virtual unsigned __int64 getMax() const = 0;
};
interface IConstWUStatistic : extends IConstStatistic
{
virtual const char * queryScope() const = 0; // what scope is the statistic gathered over? e.g., workunit, wfid:n, graphn, graphn:m
virtual StatisticScopeType getScopeType() const = 0;
virtual unsigned __int64 getTimestamp() const = 0; // time the statistic was created
};
//---------------------------------------------------------------------------------------------------------------------
/*
* An interface that is provided as a callback to a scope iterator to report properties when iterating scopes
*/
interface IWuScopeVisitor
{
virtual void noteStatistic(StatisticKind kind, unsigned __int64 value, IConstWUStatistic & extra) = 0;
virtual void noteAttribute(WuAttr attr, const char * value) = 0;
virtual void noteHint(const char * kind, const char * value) = 0;
virtual void noteException(IConstWUException & exception) = 0;