Skip to content

Commit

Permalink
HPCC-32780 Changes following review
Browse files Browse the repository at this point in the history
Signed-off-by: Shamser Ahmed <[email protected]>
  • Loading branch information
shamser committed Dec 6, 2024
1 parent fa8850d commit 74185f7
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 7 deletions.
4 changes: 3 additions & 1 deletion ecllibrary/std/system/Workunit.ecl
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ EXPORT TimeStampRecord := lib_workunitservices.WsTimeStamp;

EXPORT MessageRecord := lib_workunitservices.WsMessage;

EXPORT MessageRecord_v2 := lib_workunitservices.WsMessage_v2;

EXPORT FileReadRecord := lib_workunitservices.WsFileRead;

EXPORT FileWrittenRecord := lib_workunitservices.WsFileWritten;
Expand Down Expand Up @@ -126,7 +128,7 @@ EXPORT dataset(TimeStampRecord) WorkunitTimeStamps(varstring wuid) :=
* @param wuid the name of the workunit
*/

EXPORT dataset(MessageRecord) WorkunitMessages(varstring wuid) :=
EXPORT dataset(MessageRecord_v2) WorkunitMessages(varstring wuid) :=
lib_workunitservices.WorkUnitServices.WorkunitMessages(wuid);

/*
Expand Down
34 changes: 29 additions & 5 deletions plugins/workunitservices/workunitservices.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,16 @@ static const char * EclDefinition =
" string16 instance;"
" end;\n"
"export WsMessage := record "
" unsigned4 severity;"
" integer4 code;"
" string32 location;"
" unsigned4 row;"
" unsigned4 col;"
" string16 source;"
" string20 time;"
" string message{maxlength(1024)};"
" end;\n"
"export WsMessage_v2 := record "
" unsigned4 severity;"
" integer4 code;"
" string32 location;"
Expand All @@ -92,7 +102,7 @@ static const char * EclDefinition =
" string20 time;"
" unsigned4 priority;"
" real8 cost;"
" string message{maxlength(1024)};"
" string message{maxlength(1024)};"
" end;\n"
"export WsFileRead := record "
" string name{maxlength(256)};"
Expand Down Expand Up @@ -145,7 +155,7 @@ static const char * EclDefinition =
" varstring WUIDonDate(unsigned4 year,unsigned4 month,unsigned4 day,unsigned4 hour, unsigned4 minute) : entrypoint='wsWUIDonDate'; \n"
" varstring WUIDdaysAgo(unsigned4 daysago) : entrypoint='wsWUIDdaysAgo'; \n"
" dataset(WsTimeStamp) WorkunitTimeStamps(const varstring wuid) : context,entrypoint='wsWorkunitTimeStamps'; \n"
" dataset(WsMessage) WorkunitMessages(const varstring wuid) : context,entrypoint='wsWorkunitMessages'; \n"
" dataset(WsMessage_v2) WorkunitMessages(const varstring wuid) : context,entrypoint='wsWorkunitMessages_v2'; \n"
" dataset(WsFileRead) WorkunitFilesRead(const varstring wuid) : context,entrypoint='wsWorkunitFilesRead'; \n"
" dataset(WsFileWritten) WorkunitFilesWritten(const varstring wuid) : context,entrypoint='wsWorkunitFilesWritten'; \n"
" dataset(WsTiming) WorkunitTimings(const varstring wuid) : context,entrypoint='wsWorkunitTimings'; \n"
Expand Down Expand Up @@ -580,7 +590,7 @@ WORKUNITSERVICES_API void wsWorkunitTimeStamps(ICodeContext *ctx, size32_t & __l
__result = mb.detach();
}

WORKUNITSERVICES_API void wsWorkunitMessages( ICodeContext *ctx, size32_t & __lenResult, void * & __result, const char *wuid )
void wsWorkunitMessagesImpl( ICodeContext *ctx, size32_t & __lenResult, void * & __result, const char *wuid, bool returnCosts)
{
Owned<IConstWorkUnit> wu = getWorkunit(ctx, wuid);
MemoryBuffer mb;
Expand All @@ -601,8 +611,11 @@ WORKUNITSERVICES_API void wsWorkunitMessages( ICodeContext *ctx, size32_t & __le
fixedAppend(mb, 16, s.str(), s.length());
e.getTimeStamp(s);
fixedAppend(mb, 20, s.str(), s.length());
mb.append((unsigned) e.getPriority());
mb.append((double) e.getCost());
if (returnCosts)
{
mb.append((unsigned) e.getPriority());
mb.append((double) e.getCost());
}
e.getExceptionMessage(s);
varAppendMax(mb, 1024, s.str(), s.length());
}
Expand All @@ -611,6 +624,17 @@ WORKUNITSERVICES_API void wsWorkunitMessages( ICodeContext *ctx, size32_t & __le
__result = mb.detach();
}


WORKUNITSERVICES_API void wsWorkunitMessages( ICodeContext *ctx, size32_t & __lenResult, void * & __result, const char *wuid)
{
wsWorkunitMessagesImpl(ctx, __lenResult, __result, wuid, false);
}

WORKUNITSERVICES_API void wsWorkunitMessages_v2( ICodeContext *ctx, size32_t & __lenResult, void * & __result, const char *wuid)
{
wsWorkunitMessagesImpl(ctx, __lenResult, __result, wuid, true);
}

WORKUNITSERVICES_API void wsWorkunitFilesRead( ICodeContext *ctx, size32_t & __lenResult, void * & __result, const char *wuid )
{
MemoryBuffer mb;
Expand Down
3 changes: 2 additions & 1 deletion plugins/workunitservices/workunitservices.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ WORKUNITSERVICES_API void WORKUNITSERVICES_CALL wsWorkunitList( ICodeContext *ct
WORKUNITSERVICES_API char * wsWUIDonDate(unsigned year,unsigned month,unsigned day,unsigned hour,unsigned minute);
WORKUNITSERVICES_API char * wsWUIDdaysAgo(unsigned daysago);
WORKUNITSERVICES_API void WORKUNITSERVICES_CALL wsWorkunitTimeStamps( ICodeContext *ctx, size32_t & __lenResult, void * & __result, const char *wuid );
WORKUNITSERVICES_API void WORKUNITSERVICES_CALL wsWorkunitMessages( ICodeContext *ctx, size32_t & __lenResult, void * & __result, const char *wuid );
WORKUNITSERVICES_API void WORKUNITSERVICES_CALL wsWorkunitMessages( ICodeContext *ctx, size32_t & __lenResult, void * & __result, const char *wuid);
WORKUNITSERVICES_API void WORKUNITSERVICES_CALL wsWorkunitMessages_v2( ICodeContext *ctx, size32_t & __lenResult, void * & __result, const char *wuid);
WORKUNITSERVICES_API void WORKUNITSERVICES_CALL wsWorkunitFilesRead( ICodeContext *ctx, size32_t & __lenResult, void * & __result, const char *wuid );
WORKUNITSERVICES_API void WORKUNITSERVICES_CALL wsWorkunitFilesWritten( ICodeContext *ctx, size32_t & __lenResult, void * & __result, const char *wuid );
WORKUNITSERVICES_API void WORKUNITSERVICES_CALL wsWorkunitTimings( ICodeContext *ctx, size32_t & __lenResult, void * & __result, const char *wuid );
Expand Down

0 comments on commit 74185f7

Please sign in to comment.