Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HPCC-31196 Add "disconnect", "unlock", etc. to WsDali #18342

Merged
merged 2 commits into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a url is misleading. It's a host:port. Endpoint would be better.

};

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.");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see prev. comment re. "endpoint"


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());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to check this, because it's not clear from the dalidiag usage (not a new issue) that it expects a hex number.
I think worth updating the daliadmin usage text at the same time to note it expect the connectionID to be hex.

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
Loading