From 5853ecc36d9fe4f9ddae57623f6427720485a65c Mon Sep 17 00:00:00 2001 From: wangkx Date: Tue, 13 Feb 2024 14:16:36 -0500 Subject: [PATCH 1/2] HPCC-31196 Add "disconnect", "unlock", etc. to WsDali Add "disconnect", "unlock", "settracetransactions", "settraceslowtransactions", "cleartracetransactions", "save" (from dalidiag) to the WsDali service. Signed-off-by: wangkx --- esp/scm/ws_dali.ecm | 36 ++++++- esp/services/ws_dali/ws_daliservice.cpp | 132 ++++++++++++++++++++++++ esp/services/ws_dali/ws_daliservice.hpp | 6 ++ 3 files changed, 173 insertions(+), 1 deletion(-) diff --git a/esp/scm/ws_dali.ecm b/esp/scm/ws_dali.ecm index ac0240dc27d..ee294da7d89 100644 --- a/esp/scm/ws_dali.ecm +++ b/esp/scm/ws_dali.ecm @@ -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); @@ -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); diff --git a/esp/services/ws_dali/ws_daliservice.cpp b/esp/services/ws_dali/ws_daliservice.cpp index 05cd3c3d16f..47bb00f5e0e 100644 --- a/esp/services/ws_dali/ws_daliservice.cpp +++ b/esp/services/ws_dali/ws_daliservice.cpp @@ -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; +} diff --git a/esp/services/ws_dali/ws_daliservice.hpp b/esp/services/ws_dali/ws_daliservice.hpp index 272ea0d06fe..3dc43d3d881 100644 --- a/esp/services/ws_dali/ws_daliservice.hpp +++ b/esp/services/ws_dali/ws_daliservice.hpp @@ -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 From 61b9603476403ac4357b970121b3496311f12f85 Mon Sep 17 00:00:00 2001 From: wangkx Date: Mon, 4 Mar 2024 09:56:11 -0500 Subject: [PATCH 2/2] HPCC-31196 Revise based on review 1. Inside the DisconnectClientConnectionRequest, rename the URL to Endpoint. 2. Update the usage text for dalidiag -unlock. Signed-off-by: wangkx --- dali/dalidiag/dalidiag.cpp | 2 +- esp/scm/ws_dali.ecm | 2 +- esp/services/ws_dali/ws_daliservice.cpp | 10 +++++----- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/dali/dalidiag/dalidiag.cpp b/dali/dalidiag/dalidiag.cpp index 6ffb07ec0c1..dfc9dabcbad 100644 --- a/dali/dalidiag/dalidiag.cpp +++ b/dali/dalidiag/dalidiag.cpp @@ -65,7 +65,7 @@ void usage(const char *exe) printf("-disconnect : -- forcably disconnect a clients connection\n"); printf("-permissions -- get file permissions\n"); printf("-unlock [close] -- forcibly disconnect an sds lock\n"); - printf(" (use id's given by '-locks'\n"); + printf(" (use the ConnectionId in hex given by '-locks'\n"); printf("-settracetransactions -- trace dali transactions\n"); printf("-settraceslowtransactions -- trace slow dali transactions\n"); printf("-cleartracetransactions -- stop tracing dali transactions\n"); diff --git a/esp/scm/ws_dali.ecm b/esp/scm/ws_dali.ecm index ee294da7d89..0404b14dadf 100644 --- a/esp/scm/ws_dali.ecm +++ b/esp/scm/ws_dali.ecm @@ -153,7 +153,7 @@ ESPrequest [nil_remove] GetSDSSubscribersRequest ESPrequest [nil_remove] DisconnectClientConnectionRequest { - string URL; + string Endpoint; }; ESPrequest [nil_remove] UnlockSDSLockRequest diff --git a/esp/services/ws_dali/ws_daliservice.cpp b/esp/services/ws_dali/ws_daliservice.cpp index 47bb00f5e0e..9f602878120 100644 --- a/esp/services/ws_dali/ws_daliservice.cpp +++ b/esp/services/ws_dali/ws_daliservice.cpp @@ -601,15 +601,15 @@ bool CWSDaliEx::onDisconnectClientConnection(IEspContext& context, IEspDisconnec { checkAccess(context); - const char* url = req.getURL(); - if (isEmptyString(url)) - throw makeStringException(ECLWATCH_INVALID_INPUT, "URL not specified."); + const char* ep = req.getEndpoint(); + if (isEmptyString(ep)) + throw makeStringException(ECLWATCH_INVALID_INPUT, "Endpoint not specified."); MemoryBuffer mb; - mb.append("disconnect").append(url); + mb.append("disconnect").append(ep); getDaliDiagnosticValue(mb); - VStringBuffer result("DisconnectClientConnection called for %s.", url); + VStringBuffer result("DisconnectClientConnection called for %s.", ep); resp.setResult(result); } catch(IException* e)