-
Notifications
You must be signed in to change notification settings - Fork 304
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HPCC-30809 Add ESP WsSasha service and implement 3 methods
1. Add ws_sasha framework 2. Add GetVersion/Archive/Restore Revise based on review: 1. Remove 2 constructors. 2. Merge BackupWU into ArchiveWU with an optional 'deleteOnSuccess' option. 3. Store the sasha server response into the lastServerMessage and allow a caller to query it. 4. Store the ISashaCmdExecutors as members to avoid recreating. 5. Roll back the changes in esp_service_WsSMC.xsl. 6. Change the getLastServerMessage() to match with the pattern of the getVersion(). 7. Remove extra (). 8. Divide the setResults() to setSuccess and setFailure. Signed-off-by: wangkx <[email protected]>
- Loading branch information
wangkx
committed
Dec 18, 2023
1 parent
7552030
commit 27f36d9
Showing
15 changed files
with
572 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
################################################################################ | ||
# HPCC SYSTEMS software Copyright (C) 2023 HPCC Systems®. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
################################################################################ | ||
|
||
|
||
# Component: saruncmdlib | ||
##################################################### | ||
# Description: | ||
# ------------ | ||
# Cmake Input File for saruncmdlib | ||
##################################################### | ||
|
||
project( saruncmdlib ) | ||
|
||
set ( SRCS | ||
sacmd.cpp | ||
saruncmd.cpp | ||
) | ||
|
||
include_directories ( | ||
. | ||
${HPCC_SOURCE_DIR}/system/mp | ||
${HPCC_SOURCE_DIR}/system/include | ||
${HPCC_SOURCE_DIR}/system/jlib | ||
) | ||
|
||
ADD_DEFINITIONS ( -D_USRDLL -DSASHACLI_API_EXPORTS ) | ||
|
||
HPCC_ADD_LIBRARY( saruncmdlib SHARED ${SRCS} ) | ||
install ( TARGETS saruncmdlib RUNTIME DESTINATION ${EXEC_DIR} LIBRARY DESTINATION ${LIB_DIR} ) | ||
target_link_libraries ( saruncmdlib | ||
jlib | ||
mp | ||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
#include "platform.h" | ||
#include "jlib.hpp" | ||
#include "mpbase.hpp" | ||
#include "sacmd.hpp" | ||
#include "saruncmd.hpp" | ||
|
||
class CSashaCmdExecutor : public CInterfaceOf<ISashaCmdExecutor> | ||
{ | ||
Owned<INode> node; | ||
unsigned defaultTimeoutMs = 60; | ||
StringBuffer nodeText; | ||
mutable StringBuffer lastServerMessage; | ||
bool restoreWorkunit(const char *wuid, bool dfu) const | ||
{ | ||
lastServerMessage.clear(); | ||
Owned<ISashaCommand> cmd = createSashaCommand(); | ||
cmd->setAction(SCA_RESTORE); | ||
if (dfu) | ||
cmd->setDFU(true); | ||
cmd->addId(wuid); | ||
if (!cmd->send(node, defaultTimeoutMs)) | ||
throw makeStringExceptionV(-1, "Could not connect to Sasha server on %s", nodeText.str()); | ||
if (cmd->numIds()==0) | ||
{ | ||
// nothing restored | ||
return false; | ||
} | ||
cmd->getId(0, lastServerMessage); | ||
return true; | ||
} | ||
bool archiveWorkunit(const char *wuid, bool dfu, bool deleteAfterArchiving) const | ||
{ | ||
lastServerMessage.clear(); | ||
Owned<ISashaCommand> cmd = createSashaCommand(); | ||
cmd->setAction(SCA_ARCHIVE); | ||
if (dfu) | ||
cmd->setDFU(true); | ||
cmd->addId(wuid); | ||
if (!cmd->send(node, defaultTimeoutMs)) | ||
throw makeStringExceptionV(-1, "Could not connect to Sasha server on %s", nodeText.str()); | ||
if (cmd->numIds()==0) | ||
{ | ||
// nothing archived | ||
return false; | ||
} | ||
cmd->getId(0, lastServerMessage); | ||
return true; | ||
} | ||
|
||
public: | ||
CSashaCmdExecutor(const SocketEndpoint &ep, unsigned _defaultTimeoutSecs = 60) | ||
{ | ||
ep.getEndpointHostText(nodeText); | ||
node.setown(createINode(ep)); | ||
defaultTimeoutMs = _defaultTimeoutSecs * 1000; | ||
} | ||
virtual StringBuffer &getVersion(StringBuffer &version) const override | ||
{ | ||
Owned<ISashaCommand> cmd = createSashaCommand(); | ||
cmd->setAction(SCA_GETVERSION); | ||
if (!cmd->send(node, defaultTimeoutMs)) | ||
throw makeStringExceptionV(-1, "Could not connect to Sasha server on %s", nodeText.str()); | ||
if (!cmd->getId(0, version)) | ||
throw makeStringExceptionV(-1, "Sasha server[%s]: Protocol error", nodeText.str()); | ||
return version; | ||
} | ||
virtual StringBuffer &getLastServerMessage(StringBuffer &message) const override | ||
{ | ||
message.append(lastServerMessage); | ||
return message; | ||
} | ||
virtual bool restoreECLWorkUnit(const char *wuid) const override | ||
{ | ||
return restoreWorkunit(wuid, false); | ||
} | ||
virtual bool restoreDFUWorkUnit(const char *wuid) const override | ||
{ | ||
return restoreWorkunit(wuid, true); | ||
} | ||
virtual bool archiveECLWorkUnit(const char *wuid) const override | ||
{ | ||
return archiveWorkunit(wuid, false, true); | ||
} | ||
virtual bool archiveDFUWorkUnit(const char *wuid) const override | ||
{ | ||
return archiveWorkunit(wuid, true, true); | ||
} | ||
virtual bool backupECLWorkUnit(const char *wuid) const override | ||
{ | ||
return archiveWorkunit(wuid, false, false); | ||
} | ||
virtual bool backupDFUWorkUnit(const char *wuid) const override | ||
{ | ||
return archiveWorkunit(wuid, true, false); | ||
} | ||
}; | ||
|
||
ISashaCmdExecutor *createSashaCmdExecutor(const SocketEndpoint &ep, unsigned defaultTimeoutSecs) | ||
{ | ||
return new CSashaCmdExecutor(ep, defaultTimeoutSecs); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#ifndef SARUNCMD_HPP | ||
#define SARUNCMD_HPP | ||
|
||
#ifdef SARUNCMD_API_EXPORTS | ||
#define SARUNCMD_API DECL_EXPORT | ||
#else | ||
#define SARUNCMD_API DECL_IMPORT | ||
#endif | ||
|
||
interface ISashaCmdExecutor : extends IInterface | ||
{ | ||
virtual StringBuffer &getVersion(StringBuffer &version) 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; | ||
virtual bool archiveDFUWorkUnit(const char *wuid) const = 0; | ||
virtual bool backupECLWorkUnit(const char *wuid) const = 0; | ||
virtual bool backupDFUWorkUnit(const char *wuid) const = 0; | ||
}; | ||
|
||
extern SARUNCMD_API ISashaCmdExecutor *createSashaCmdExecutor(const SocketEndpoint &ep, unsigned defaultTimeoutSecs=60); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,5 +17,6 @@ application: | |
- ws_codesign | ||
- ws_resources | ||
- WSDali | ||
- WSSasha | ||
- ws_logaccess | ||
- WsCloud |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/*############################################################################## | ||
|
||
HPCC SYSTEMS software Copyright (C) 2023 HPCC Systems. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
############################################################################## */ | ||
|
||
EspInclude(common); | ||
|
||
ESPenum WUTypes : string | ||
{ | ||
ECL("ECL"), | ||
DFU("DFU"), | ||
}; | ||
|
||
ESPrequest [nil_remove] GetVersionRequest | ||
{ | ||
}; | ||
|
||
ESPresponse [exceptions_inline, nil_remove] ResultResponse | ||
{ | ||
string Result; | ||
}; | ||
|
||
ESPrequest [nil_remove] ArchiveWURequest | ||
{ | ||
string Wuid; | ||
ESPenum WUTypes WUType; | ||
bool DeleteOnSuccess(true); | ||
}; | ||
|
||
ESPrequest [nil_remove] RestoreWURequest | ||
{ | ||
string Wuid; | ||
ESPenum WUTypes WUType; | ||
}; | ||
|
||
ESPservice [auth_feature("DEFERRED"), //This declares that the method logic handles feature level authorization | ||
version("1.00"), default_client_version("1.00"), exceptions_inline("./smc_xslt/exceptions.xslt")] WSSasha | ||
{ | ||
ESPmethod [auth_feature("SashaAccess:Access")] GetVersion(GetVersionRequest, ResultResponse); | ||
ESPmethod [auth_feature("SashaAccess:FULL")] ArchiveWU(ArchiveWURequest, ResultResponse); //archive ECL WUs or DFU WUs | ||
ESPmethod [auth_feature("SashaAccess:FULL")] RestoreWU(RestoreWURequest, ResultResponse); //restore ECL WUs or DFU WUs | ||
}; | ||
|
||
SCMexportdef(WSSasha); | ||
SCMapi(WSSasha) IClientWSSasha *createWSSashaClient(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
################################################################################ | ||
# HPCC SYSTEMS software Copyright (C) 2023 HPCC Systems. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
################################################################################ | ||
|
||
# Component: ws_sasha | ||
##################################################### | ||
# Description: | ||
# ------------ | ||
# Cmake Input File for ws_sasha | ||
##################################################### | ||
|
||
project( ws_sasha ) | ||
|
||
include(${HPCC_SOURCE_DIR}/esp/scm/espscm.cmake) | ||
|
||
set ( SRCS | ||
${HPCC_SOURCE_DIR}/dali/sasha/sacmd.cpp | ||
${ESPSCM_GENERATED_DIR}/ws_sasha_esp.cpp | ||
ws_sashaplugin.cpp | ||
ws_sashaservice.cpp | ||
) | ||
|
||
include_directories ( | ||
${HPCC_SOURCE_DIR}/esp/platform | ||
${HPCC_SOURCE_DIR}/esp/bindings | ||
${HPCC_SOURCE_DIR}/esp/bindings/SOAP/xpp | ||
${HPCC_SOURCE_DIR}/esp/clients | ||
${HPCC_SOURCE_DIR}/esp/smc/SMCLib | ||
${HPCC_SOURCE_DIR}/system/include | ||
${HPCC_SOURCE_DIR}/system/jlib | ||
${HPCC_SOURCE_DIR}/system/xmllib | ||
${HPCC_SOURCE_DIR}/system/security/securesocket | ||
${HPCC_SOURCE_DIR}/system/security/LdapSecurity | ||
${HPCC_SOURCE_DIR}/system/security/shared | ||
${HPCC_SOURCE_DIR}/system/mp | ||
${HPCC_SOURCE_DIR}/common/thorhelper | ||
${HPCC_SOURCE_DIR}/common/environment | ||
${HPCC_SOURCE_DIR}/dali/base | ||
${HPCC_SOURCE_DIR}/dali/sasha | ||
) | ||
|
||
ADD_DEFINITIONS( -D_USRDLL -DWSSasha_API_LOCAL -DESP_SERVICE_WSSasha) | ||
|
||
HPCC_ADD_LIBRARY( ws_sasha SHARED ${SRCS} ) | ||
install ( TARGETS ws_sasha RUNTIME DESTINATION ${EXEC_DIR} LIBRARY DESTINATION ${LIB_DIR} ) | ||
target_link_libraries ( ws_sasha | ||
jlib | ||
xmllib | ||
esphttp | ||
SMCLib | ||
saruncmdlib | ||
${COMMON_ESP_SERVICE_LIBS} | ||
) | ||
|
||
IF (USE_OPENSSL) | ||
target_link_libraries ( ws_sasha | ||
securesocket | ||
) | ||
ENDIF() |
Oops, something went wrong.