Skip to content

Commit

Permalink
Merge pull request #18342 from wangkx/h31196
Browse files Browse the repository at this point in the history
HPCC-31196 Add "disconnect", "unlock", etc. to WsDali

Reviewed-by: Jake Smith <[email protected]>
Merged-by: Gavin Halliday <[email protected]>
  • Loading branch information
ghalliday authored Mar 6, 2024
2 parents 508af59 + 61b9603 commit 650582d
Show file tree
Hide file tree
Showing 4 changed files with 174 additions and 2 deletions.
2 changes: 1 addition & 1 deletion dali/dalidiag/dalidiag.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ void usage(const char *exe)
printf("-disconnect <ip>:<port> -- forcably disconnect a clients connection\n");
printf("-permissions <logicalname> <user> <password> -- get file permissions\n");
printf("-unlock <connection_id> [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 <millisecond-threshold> -- trace slow dali transactions\n");
printf("-cleartracetransactions -- stop tracing dali transactions\n");
Expand Down
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 Endpoint;
};

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* ep = req.getEndpoint();
if (isEmptyString(ep))
throw makeStringException(ECLWATCH_INVALID_INPUT, "Endpoint not specified.");

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

VStringBuffer result("DisconnectClientConnection called for %s.", ep);
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 650582d

Please sign in to comment.