X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FBasics%2FKernelBasis.cxx;h=ed6837dc80a49f81387163fb96a0ea3fd07a43bf;hb=3ce0546302001755828c8476425a60c6ab61ac92;hp=db29c9d87f055eb6a4390096f79c9afef12e6891;hpb=b397830a2104a47d47a190819eca35a269b32b8f;p=modules%2Fkernel.git diff --git a/src/Basics/KernelBasis.cxx b/src/Basics/KernelBasis.cxx index db29c9d87..ed6837dc8 100644 --- a/src/Basics/KernelBasis.cxx +++ b/src/Basics/KernelBasis.cxx @@ -19,6 +19,9 @@ #include "KernelBasis.hxx" +#include +#include + static bool DEFAULT_SSL_MODE = true; static bool GUI_MODE = false; @@ -81,6 +84,10 @@ namespace SALOME static constexpr char OUT_OF_PROCESS_NO_REPLAY_VALUE_STR[] = "OutOfProcessNoReplay"; static constexpr char OUT_OF_PROCESS_WITH_REPLAY_VALUE = 2; static constexpr char OUT_OF_PROCESS_WITH_REPLAY_VALUE_STR[] = "OutOfProcessWithReplay"; + static constexpr char OUT_OF_PROCESS_NO_REPLAY_FT_VALUE = 3; + static constexpr char OUT_OF_PROCESS_NO_REPLAY_FT_VALUE_STR[] = "OutOfProcessNoReplayFT"; + static constexpr char OUT_OF_PROCESS_WITH_REPLAY_FT_VALUE = 4; + static constexpr char OUT_OF_PROCESS_WITH_REPLAY_FT_VALUE_STR[] = "OutOfProcessWithReplayFT"; static PyExecutionMode FromIntToPyExecutionMode(char value) { @@ -92,6 +99,10 @@ namespace SALOME return PyExecutionMode::OutOfProcessNoReplay; case OUT_OF_PROCESS_WITH_REPLAY_VALUE: return PyExecutionMode::OutOfProcessWithReplay; + case OUT_OF_PROCESS_NO_REPLAY_FT_VALUE: + return PyExecutionMode::OutOfProcessNoReplayFT; + case OUT_OF_PROCESS_WITH_REPLAY_FT_VALUE: + return PyExecutionMode::OutOfProcessWithReplayFT; } throw std::range_error("FromIntToPyExecutionMode : Invalid value for Py Execution Mode ! Must be in 0 (InProcess), 1 (OutOfProcessNoReplay) or 2 (OutOfProcessWithReplay) !"); } @@ -104,6 +115,10 @@ namespace SALOME return PyExecutionMode::OutOfProcessNoReplay; if(value == OUT_OF_PROCESS_WITH_REPLAY_VALUE_STR) return PyExecutionMode::OutOfProcessWithReplay; + if(value == OUT_OF_PROCESS_NO_REPLAY_FT_VALUE_STR) + return PyExecutionMode::OutOfProcessNoReplayFT; + if(value == OUT_OF_PROCESS_WITH_REPLAY_FT_VALUE_STR) + return PyExecutionMode::OutOfProcessWithReplayFT; throw std::range_error("FromStrToPyExecutionMode : Invalid str value for py execution mode !"); } @@ -117,12 +132,133 @@ namespace SALOME return OUT_OF_PROCESS_NO_REPLAY_VALUE_STR; case PyExecutionMode::OutOfProcessWithReplay: return OUT_OF_PROCESS_WITH_REPLAY_VALUE_STR; + case PyExecutionMode::OutOfProcessNoReplayFT: + return OUT_OF_PROCESS_NO_REPLAY_FT_VALUE_STR; + case PyExecutionMode::OutOfProcessWithReplayFT: + return OUT_OF_PROCESS_WITH_REPLAY_FT_VALUE_STR; default: throw std::range_error("FromExecutionModeToStr : Invalid str value for py execution mode !"); } } } +constexpr int SALOME_BIG_OBJ_ON_DISK_THRES_DFT = 50000000; + +static int SALOME_BIG_OBJ_ON_DISK_THRES = SALOME_BIG_OBJ_ON_DISK_THRES_DFT; + +std::string SALOME_REPLAY_FILES_DIR; + +int SALOME::GetBigObjOnDiskThreshold() +{ + return SALOME_BIG_OBJ_ON_DISK_THRES; +} + +void SALOME::SetBigObjOnDiskThreshold(int newThresholdInByte) +{ + SALOME_BIG_OBJ_ON_DISK_THRES = newThresholdInByte; +} + +constexpr char SALOME_FILE_BIG_OBJ_DIR_SEP = '@'; + +static std::string SALOME_FILE_BIG_OBJ_DIR; + +constexpr int DFT_SALOME_NB_RETRY = 1; + +static int SALOME_NB_RETRY = DFT_SALOME_NB_RETRY; + +SALOME::BigObjTransferProtocol SALOME::FromIntToBigObjOnDiskProtocol(char protocol) +{ + switch( protocol ) + { + case SALOME::SHARED_FILE_SYSTEM_PROTOCOL: + return SALOME::BigObjTransferProtocol::SharedFileSystem; + case SALOME::SSD_COPY_FILE_SYSTEM_PROTOCOL: + return SALOME::BigObjTransferProtocol::SSDCopyFileSystem; + default: + throw std::runtime_error("FromIntToBigObjOnDiskProtocol unrecognized protocol ! should be in [0,1] !"); + } +} + +SALOME::BigObjTransferProtocol SALOME::BigObjOnDiskProtocolFromStr(const std::string& protocol) +{ + if( protocol == SALOME::SHARED_FILE_SYSTEM_PROTOCOL_STR ) + return SALOME::BigObjTransferProtocol::SharedFileSystem; + if( protocol == SALOME::SSD_COPY_FILE_SYSTEM_PROTOCOL_STR ) + return SALOME::BigObjTransferProtocol::SSDCopyFileSystem; + throw std::runtime_error("BigObjOnDiskProtocolFromStr unrecognized protocol !"); +} + +std::string SALOME::BigObjOnDiskProtocolToStr(BigObjTransferProtocol protocol) +{ + switch( protocol ) + { + case SALOME::BigObjTransferProtocol::SharedFileSystem: + return SALOME::SHARED_FILE_SYSTEM_PROTOCOL_STR; + case SALOME::BigObjTransferProtocol::SSDCopyFileSystem: + return SALOME::SSD_COPY_FILE_SYSTEM_PROTOCOL_STR; + default: + throw std::runtime_error("BigObjOnDiskProtocolToStr unrecognized protocol ! should be in [0,1] !"); + } +} + +/*! + * This method returns the protocol of proxy transfert and the directory + */ +SALOME::BigObjTransferProtocol SALOME::GetBigObjOnDiskProtocolAndDirectory(std::string& directory) +{ + if(SALOME_FILE_BIG_OBJ_DIR.size() < 3) + { + directory = SALOME_FILE_BIG_OBJ_DIR; + return SALOME::BigObjTransferProtocol::SharedFileSystem; + } + std::string protocol = SALOME_FILE_BIG_OBJ_DIR.substr(0,3); + directory = SALOME_FILE_BIG_OBJ_DIR.substr(3); + if( protocol[0]!=SALOME_FILE_BIG_OBJ_DIR_SEP || protocol[2]!=SALOME_FILE_BIG_OBJ_DIR_SEP) + { + directory = SALOME_FILE_BIG_OBJ_DIR; + return SALOME::BigObjTransferProtocol::SharedFileSystem; + } + std::istringstream iss(protocol.substr(1,1)); iss.exceptions(std::istringstream::failbit | std::istringstream::badbit); + short iproxyprot = 0; + iss >> iproxyprot; + return FromIntToBigObjOnDiskProtocol( iproxyprot ); +} + +std::string SALOME::GetBigObjOnDiskDirectoryCoarse() +{ + return SALOME_FILE_BIG_OBJ_DIR; +} + +std::string SALOME::GetDirectoryForReplayFiles() +{ + return SALOME_REPLAY_FILES_DIR; +} + +void SALOME::SetDirectoryForReplayFiles(const std::string& directory) +{ + SALOME_REPLAY_FILES_DIR = directory; +} + +void SALOME::SetBigObjOnDiskDirectory(const std::string& directory) +{ + SALOME_FILE_BIG_OBJ_DIR = directory; +} + +bool SALOME::BigObjOnDiskDirectoryDefined() +{ + return ! SALOME_FILE_BIG_OBJ_DIR.empty(); +} + +void SALOME::SetNumberOfRetry(int nbRetry) +{ + SALOME_NB_RETRY = nbRetry; +} + +int SALOME::GetNumberOfRetry() +{ + return SALOME_NB_RETRY; +} + static SALOME::PyExecutionMode DefaultPyExecMode = SALOME::PyExecutionMode::NotSet; void SALOME::SetPyExecutionMode(PyExecutionMode mode)