Skip to content

Commit

Permalink
HPCC-30809 Change getLastServerMessage, etc.
Browse files Browse the repository at this point in the history
1. Change the getLastServerMessage() to match with the pattern of
the getVersion().
2. Remove extra ().
3. Divide the setResults() to setSuccess and setFailure.

Signed-off-by: wangkx <kevin.wang@lexisnexis.com>
  • Loading branch information
wangkx committed Dec 14, 2023
1 parent 0814710 commit a90e2a2
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 14 deletions.
5 changes: 3 additions & 2 deletions dali/sasha/saruncmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,10 @@ class CSashaCmdExecutor : public CInterfaceOf<ISashaCmdExecutor>
throw makeStringExceptionV(-1, "Sasha server[%s]: Protocol error", nodeText.str());
return version;
}
virtual StringBuffer &getLastServerMessage() const override
virtual StringBuffer &getLastServerMessage(StringBuffer &message) const override
{
return lastServerMessage;
message.append(lastServerMessage);
return message;
}
virtual bool restoreECLWorkUnit(const char *wuid) const override
{
Expand Down
2 changes: 1 addition & 1 deletion dali/sasha/saruncmd.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
interface ISashaCmdExecutor : extends IInterface
{
virtual StringBuffer &getVersion(StringBuffer &version) const = 0;
virtual StringBuffer &getLastServerMessage() const = 0;
virtual StringBuffer &getLastServerMessage(StringBuffer &lastServeressage) const = 0;
virtual bool restoreECLWorkUnit(const char *wuid) const = 0;
virtual bool restoreDFUWorkUnit(const char *wuid) const = 0;
virtual bool archiveECLWorkUnit(const char *wuid) const = 0;
Expand Down
27 changes: 17 additions & 10 deletions esp/services/ws_sasha/ws_sashaservice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,15 @@ bool CWSSashaEx::onGetVersion(IEspContext& context, IEspGetVersionRequest& req,
return true;
}

void CWSSashaEx::setResults(const char* lastServerMessage, const char* wuid, const char* action, IEspResultResponse& resp)
void CWSSashaEx::setSuccess(ISashaCmdExecutor* executor, IEspResultResponse& resp)
{
if (lastServerMessage)
{
resp.setResult(lastServerMessage);
return;
}
StringBuffer results;
executor->getLastServerMessage(results);
resp.setResult(results);
}

void CWSSashaEx::setFailure(const char* wuid, const char* action, IEspResultResponse& resp)
{
StringBuffer results;
if (isEmptyString(wuid))
results.appendf("No workunits %s.", action);
Expand All @@ -98,19 +99,22 @@ bool CWSSashaEx::onArchiveWU(IEspContext& context, IEspArchiveWURequest& req, IE
bool sashaCmdSuccess = false;
if (req.getDeleteOnSuccess())
{
if ((wuType == CWUTypes_ECL))
if (wuType == CWUTypes_ECL)
sashaCmdSuccess = executor->archiveECLWorkUnit(isEmptyString(wuid) ? "*" : wuid);
else
sashaCmdSuccess = executor->archiveDFUWorkUnit(isEmptyString(wuid) ? "*" : wuid);
}
else
{
if ((wuType == CWUTypes_ECL))
if (wuType == CWUTypes_ECL)
sashaCmdSuccess = executor->backupECLWorkUnit(isEmptyString(wuid) ? "*" : wuid);
else
sashaCmdSuccess = executor->backupDFUWorkUnit(isEmptyString(wuid) ? "*" : wuid);
}
setResults(sashaCmdSuccess ? executor->getLastServerMessage().str() : nullptr, wuid, "archived", resp);
if (sashaCmdSuccess)
setSuccess(executor, resp);
else
setFailure(wuid, "archived", resp);
}
catch(IException* e)
{
Expand All @@ -134,7 +138,10 @@ bool CWSSashaEx::onRestoreWU(IEspContext& context, IEspRestoreWURequest& req, IE
sashaCmdSuccess = executor->restoreECLWorkUnit(isEmptyString(wuid) ? "*" : wuid);
else
sashaCmdSuccess = executor->restoreDFUWorkUnit(isEmptyString(wuid) ? "*" : wuid);
setResults(sashaCmdSuccess ? executor->getLastServerMessage().str() : nullptr, wuid, "restored", resp);
if (sashaCmdSuccess)
setSuccess(executor, resp);
else
setFailure(wuid, "restored", resp);
}
catch(IException* e)
{
Expand Down
3 changes: 2 additions & 1 deletion esp/services/ws_sasha/ws_sashaservice.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ class CWSSashaEx : public CWSSasha

ISashaCmdExecutor* createSashaCommandExecutor(const char* archiverType);
ISashaCmdExecutor* querySashaCommandExecutor(CWUTypes wuType);
void setResults(const char* lastServerMessage, const char* wuid, const char* action, IEspResultResponse& resp);
void setSuccess(ISashaCmdExecutor* executor, IEspResultResponse& resp);
void setFailure(const char* wuid, const char* action, IEspResultResponse& resp);

public:
virtual void init(IPropertyTree* cfg, const char* process, const char* service) override;
Expand Down

0 comments on commit a90e2a2

Please sign in to comment.