Skip to content

Commit

Permalink
HPCC-30032 Refector ESDL request processing
Browse files Browse the repository at this point in the history
- Define workflows for each request type, clarifying the logic associated
  with each type.
- Improve plugin method integration with the scripting environment.
- Enable per-method control of transaction ID generation.
- Enable per-method control of logging.

Signed-off-by: Tim Klemm <[email protected]>
  • Loading branch information
Tim Klemm committed Oct 1, 2023
1 parent e057926 commit d112a38
Show file tree
Hide file tree
Showing 8 changed files with 857 additions and 648 deletions.
1 change: 1 addition & 0 deletions esp/esdllib/esdl_transformer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ typedef void REQUEST_HOOK (IEspContext& ctx, IEspStruct& req, StringBuffer& quer
#define ESDL_TRANS_OUTPUT_ROOT 0x0400

#define ESDL_TRANS_START_AT_ROOT 0x1000
#define ESDL_TRANS_JSON_OUT 0x2000

interface IXmlWriterExt;
interface IEsdlTransformer : extends IInterface
Expand Down
5 changes: 4 additions & 1 deletion esp/esdllib/esdl_transformer2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1588,6 +1588,7 @@ static void updateTransformFlags(EsdlProcessMode mode, IEsdlDefMethod *mthdef, I
int Esdl2Transformer::process(IEspContext &ctx, EsdlProcessMode mode, const char* service, const char *method, StringBuffer &out, const char *in, unsigned int flags, const char *ns, const char *schema_location)
{
int rc = 0;
XMLWriterType wtype = WTStandard;
IEsdlMethodInfo *mi = queryMethodInfo(service,method);
if (!mi)
throw MakeStringException(-1, "Error processing ESDL - method '%s'not found", method);
Expand All @@ -1604,6 +1605,8 @@ int Esdl2Transformer::process(IEspContext &ctx, EsdlProcessMode mode, const char
else if (mode==EsdlResponseMode)
{
root_type = mi->queryResponseType();
if (flags & ESDL_TRANS_JSON_OUT)
wtype = WTJSONRootless;
}

if (!root_type)
Expand All @@ -1620,7 +1623,7 @@ int Esdl2Transformer::process(IEspContext &ctx, EsdlProcessMode mode, const char
XmlPullParser xppx(in, strlen(in)+1);
if (gotoStartTag(xppx, root->queryName(), "Results"))
{
Owned<IXmlWriterExt> respWriter = createIXmlWriterExt(0, 0, NULL, WTStandard);
Owned<IXmlWriterExt> respWriter = createIXmlWriterExt(0, 0, NULL, wtype);
Esdl2TransformerContext tctx(*this, respWriter, xppx, ctx.getClientVersion(), param_groups, mode, 0, ns,schema_location);

tctx.flags = flags;
Expand Down
5 changes: 5 additions & 0 deletions esp/logging/logginglib/logthread.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ interface IUpdateLogThread : extends IInterface
virtual IEspLogAgent* getLogAgent() = 0;

virtual bool hasService(LOGServiceType service) = 0;
virtual bool usesSafeLogging() = 0;
virtual bool queueLog(IEspUpdateLogRequest* logRequest) = 0;
virtual bool queueLog(IEspUpdateLogRequestWrap* logRequest) = 0;
virtual void sendLog() = 0;
Expand Down Expand Up @@ -159,6 +160,10 @@ class CLogThread : public Thread , implements IUpdateLogThread
{
return logAgent->hasService(service);
}
virtual bool usesSafeLogging() override
{
return (ensureFailSafe && hasService(LGSTUpdateLOG));
}

int run();
void start();
Expand Down
7 changes: 7 additions & 0 deletions esp/logging/loggingmanager/loggingmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ bool CLoggingManager::init(IPropertyTree* cfg, const char* service)
IUpdateLogThread* logThread = createUpdateLogThread(&loggingAgentTree, service, agentName, failSafeLogsDir.get(), loggingAgent);
if(!logThread)
throw MakeStringException(-1, "Failed to create update log thread for %s", agentName);
if (!safeAgents && logThread->usesSafeLogging())
safeAgents = true;
loggingAgentThreads.push_back(logThread);
}

Expand Down Expand Up @@ -124,6 +126,11 @@ bool CLoggingManager::hasService(LOGServiceType service) const
return ((serviceMask & (1 << service)) != 0);
}

bool CLoggingManager::usesSafeLogging() const
{
return (initialized && (oneTankFile || decoupledLogging || safeAgents));
}

bool CLoggingManager::updateLog(IEspLogEntry* entry, StringBuffer& status)
{
if (entry->getLogContent())
Expand Down
1 change: 1 addition & 0 deletions esp/logging/loggingmanager/loggingmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ interface ILoggingManager : implements IInterface
virtual bool init(IPropertyTree* loggingConfig, const char* service) = 0;
virtual IEspLogEntry* createLogEntry() = 0;
virtual bool hasService(LOGServiceType service) const = 0;
virtual bool usesSafeLogging() const = 0;
virtual bool updateLog(IEspLogEntry* entry, StringBuffer& status) = 0;
virtual bool updateLog(IEspContext* espContext, IEspUpdateLogRequestWrap& req, IEspUpdateLogResponse& resp) = 0;
virtual bool getTransactionSeed(StringBuffer& transactionSeed, StringBuffer& status) = 0;
Expand Down
3 changes: 2 additions & 1 deletion esp/logging/loggingmanager/loggingmanager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class CLoggingManager : implements ILoggingManager, public CInterface
{
typedef std::vector<IUpdateLogThread*> LOGGING_AGENTTHREADS;
LOGGING_AGENTTHREADS loggingAgentThreads;
bool oneTankFile = false, decoupledLogging = false, initialized = false;
bool oneTankFile = false, decoupledLogging = false, initialized = false, safeAgents = false;
Owned<ILogFailSafe> logFailSafe;
CLogContentFilter logContentFilter;
unsigned serviceMask = 0;
Expand Down Expand Up @@ -108,6 +108,7 @@ class CLoggingManager : implements ILoggingManager, public CInterface

virtual IEspLogEntry* createLogEntry() override;
virtual bool hasService(LOGServiceType service) const override;
virtual bool usesSafeLogging() const override;
virtual bool updateLog(IEspContext* espContext, IEspUpdateLogRequestWrap& req, IEspUpdateLogResponse& resp) override;;
virtual bool updateLog(IEspLogEntry* entry, StringBuffer& status) override;
virtual bool getTransactionSeed(StringBuffer& transactionSeed, StringBuffer& status) override { return getFilteredTransactionSeed(transactionSeed, status, defaultIdFilter); }
Expand Down
Loading

0 comments on commit d112a38

Please sign in to comment.