Skip to content

Commit

Permalink
HPCC-31196 Add "disconnect", "unlock", etc. to WsDali
Browse files Browse the repository at this point in the history
Add "disconnect", "unlock", "settracetransactions",
"settraceslowtransactions", "cleartracetransactions",
"save" (from dalidiag) to the WsDali service.

Signed-off-by: wangkx <[email protected]>
  • Loading branch information
wangkx committed Feb 26, 2024
1 parent 5a76ec3 commit 5853ecc
Show file tree
Hide file tree
Showing 3 changed files with 173 additions and 1 deletion.
36 changes: 35 additions & 1 deletion esp/scm/ws_dali.ecm
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,36 @@ ESPrequest [nil_remove] GetSDSSubscribersRequest
{
};

ESPrequest [nil_remove] DisconnectClientConnectionRequest
{
string URL;
};

ESPrequest [nil_remove] UnlockSDSLockRequest
{
string ConnectionID;
bool Close(false);
};

ESPrequest [nil_remove] SaveSDSStoreRequest
{
};

ESPrequest [nil_remove] SetTraceTransactionsRequest
{
};

ESPrequest [nil_remove] SetTraceSlowTransactionsRequest
{
unsigned SlowThresholdMS(1000); //default to 1000 ms
};

ESPrequest [nil_remove] ClearTraceTransactionsRequest
{
};

ESPservice [auth_feature("NONE"), //This declares that the method logic handles feature level authorization
version("1.05"), default_client_version("1.05"), exceptions_inline("./smc_xslt/exceptions.xslt")] WSDali
version("1.06"), default_client_version("1.06"), exceptions_inline("./smc_xslt/exceptions.xslt")] WSDali
{
ESPmethod [min_ver("1.01")] SetValue(SetValueRequest, ResultResponse);
ESPmethod [min_ver("1.01")] GetValue(GetValueRequest, ResultResponse);
Expand All @@ -176,6 +204,12 @@ ESPservice [auth_feature("NONE"), //This declares that the method logic handles
ESPmethod [min_ver("1.05")] GetClients(GetClientsRequest, ResultResponse);
ESPmethod [min_ver("1.05")] GetSDSStats(GetSDSStatsRequest, ResultResponse);
ESPmethod [min_ver("1.05")] GetSDSSubscribers(GetSDSSubscribersRequest, ResultResponse);
ESPmethod [min_ver("1.06")] DisconnectClientConnection(DisconnectClientConnectionRequest, ResultResponse);
ESPmethod [min_ver("1.06")] UnlockSDSLock(UnlockSDSLockRequest, ResultResponse);
ESPmethod [min_ver("1.06")] SaveSDSStore(SaveSDSStoreRequest, ResultResponse);
ESPmethod [min_ver("1.06")] SetTraceTransactions(SetTraceTransactionsRequest, ResultResponse);
ESPmethod [min_ver("1.06")] SetTraceSlowTransactions(SetTraceSlowTransactionsRequest, ResultResponse);
ESPmethod [min_ver("1.06")] ClearTraceTransactions(ClearTraceTransactionsRequest, ResultResponse);
};

SCMexportdef(WSDali);
Expand Down
132 changes: 132 additions & 0 deletions esp/services/ws_dali/ws_daliservice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -594,3 +594,135 @@ bool CWSDaliEx::onGetSDSSubscribers(IEspContext& context, IEspGetSDSSubscribersR
}
return true;
}

bool CWSDaliEx::onDisconnectClientConnection(IEspContext& context, IEspDisconnectClientConnectionRequest& req, IEspResultResponse& resp)
{
try
{
checkAccess(context);

const char* url = req.getURL();
if (isEmptyString(url))
throw makeStringException(ECLWATCH_INVALID_INPUT, "URL not specified.");

MemoryBuffer mb;
mb.append("disconnect").append(url);
getDaliDiagnosticValue(mb);

VStringBuffer result("DisconnectClientConnection called for %s.", url);
resp.setResult(result);
}
catch(IException* e)
{
FORWARDEXCEPTION(context, e, ECLWATCH_INTERNAL_ERROR);
}
return true;
}

bool CWSDaliEx::onUnlockSDSLock(IEspContext& context, IEspUnlockSDSLockRequest& req, IEspResultResponse& resp)
{
try
{
checkAccess(context);

const char* connectionIdHex = req.getConnectionID();
if (isEmptyString(connectionIdHex))
throw makeStringException(ECLWATCH_INVALID_INPUT, "ConnectionID not specified.");

MemoryBuffer mb;
mb.append("unlock").append(strtoll(connectionIdHex, nullptr, 16)).append(req.getClose());
getDaliDiagnosticValue(mb);

bool success = false;
mb.read(success);
if (!success)
resp.setResult("Lock not found");
else
{
StringBuffer result(("Lock successfully removed: "));
mb.read(result);
resp.setResult(result);
}
}
catch(IException* e)
{
FORWARDEXCEPTION(context, e, ECLWATCH_INTERNAL_ERROR);
}
return true;
}

bool CWSDaliEx::onSaveSDSStore(IEspContext& context, IEspSaveSDSStoreRequest& req, IEspResultResponse& resp)
{
try
{
checkAccess(context);

MemoryBuffer mb;
mb.append("save");
getDaliDiagnosticValue(mb);
resp.setResult("SaveSDSStore called.");
}
catch(IException* e)
{
FORWARDEXCEPTION(context, e, ECLWATCH_INTERNAL_ERROR);
}
return true;
}

bool CWSDaliEx::onSetTraceTransactions(IEspContext& context, IEspSetTraceTransactionsRequest& req, IEspResultResponse& resp)
{
try
{
checkAccess(context);

StringBuffer result;
const char* cmd = "settracetransactions";
getDaliDiagnosticValue(cmd, result);
resp.setResult(result.isEmpty() ? "SetTraceTransactions called." : result);
}
catch(IException* e)
{
FORWARDEXCEPTION(context, e, ECLWATCH_INTERNAL_ERROR);
}
return true;
}

bool CWSDaliEx::onSetTraceSlowTransactions(IEspContext& context, IEspSetTraceSlowTransactionsRequest& req, IEspResultResponse& resp)
{
try
{
checkAccess(context);

MemoryBuffer mb;
mb.append("settraceslowtransactions");
mb.append(req.getSlowThresholdMS());
getDaliDiagnosticValue(mb);

StringAttr result;
mb.read(result);
resp.setResult(result.isEmpty() ? "SetTraceSlowTransactions called." : result);
}
catch(IException* e)
{
FORWARDEXCEPTION(context, e, ECLWATCH_INTERNAL_ERROR);
}
return true;
}

bool CWSDaliEx::onClearTraceTransactions(IEspContext& context, IEspClearTraceTransactionsRequest& req, IEspResultResponse& resp)
{
try
{
checkAccess(context);

StringBuffer result;
const char* cmd = "cleartracetransactions";
getDaliDiagnosticValue(cmd, result);
resp.setResult(result.isEmpty() ? "ClearTraceTransactions called." : result);
}
catch(IException* e)
{
FORWARDEXCEPTION(context, e, ECLWATCH_INTERNAL_ERROR);
}
return true;
}
6 changes: 6 additions & 0 deletions esp/services/ws_dali/ws_daliservice.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ class CWSDaliEx : public CWSDali
virtual bool onGetClients(IEspContext& context, IEspGetClientsRequest& req, IEspResultResponse& resp) override;
virtual bool onGetSDSStats(IEspContext& context, IEspGetSDSStatsRequest& req, IEspResultResponse& resp) override;
virtual bool onGetSDSSubscribers(IEspContext& context, IEspGetSDSSubscribersRequest& req, IEspResultResponse& resp) override;
virtual bool onDisconnectClientConnection(IEspContext& context, IEspDisconnectClientConnectionRequest& req, IEspResultResponse& resp) override;
virtual bool onUnlockSDSLock(IEspContext& context, IEspUnlockSDSLockRequest& req, IEspResultResponse& resp) override;
virtual bool onSaveSDSStore(IEspContext& context, IEspSaveSDSStoreRequest& req, IEspResultResponse& resp) override;
virtual bool onSetTraceTransactions(IEspContext& context, IEspSetTraceTransactionsRequest& req, IEspResultResponse& resp) override;
virtual bool onSetTraceSlowTransactions(IEspContext& context, IEspSetTraceSlowTransactionsRequest& req, IEspResultResponse& resp) override;
virtual bool onClearTraceTransactions(IEspContext& context, IEspClearTraceTransactionsRequest& req, IEspResultResponse& resp) override;
};

class CWSDaliSoapBindingEx : public CWSDaliSoapBinding
Expand Down

0 comments on commit 5853ecc

Please sign in to comment.