interface BasicDataServer
{
string getVarName();
+ void setReadOnlyStatus();
+ void setRWStatus();
};
interface StringDataServer : BasicDataServer
//
#include "SALOME_ContainerManager.hxx"
+#include "SALOME_ResourcesManager.hxx"
+#include "SALOME_LoadRateManager.hxx"
#include "SALOME_NamingService.hxx"
#include "SALOME_ModuleCatalog.hh"
#include "Basics_Utils.hxx"
#include "PaCOPP.hxx"
#endif
-#define TIME_OUT_TO_LAUNCH_CONT 60
+const int SALOME_ContainerManager::TIME_OUT_TO_LAUNCH_CONT=60;
const char *SALOME_ContainerManager::_ContainerManagerNameInNS =
"/ContainerManager";
logFilename += tmp.str();
logFilename += ".log" ;
command += " > " + logFilename + " 2>&1";
-#ifdef WIN32
- command = "%PYTHONBIN% -c \"import win32pm ; win32pm.spawnpid(r'" + command + "', '')\"";
-#else
- command += " &";
-#endif
+ MakeTheCommandToBeLaunchedASync(command);
// launch container with a system call
status=SystemThreadSafe(command.c_str());
else
{
// Step 4: Wait for the container
- int count = TIME_OUT_TO_LAUNCH_CONT;
- if (GetenvThreadSafe("TIMEOUT_TO_LAUNCH_CONTAINER") != 0)
- {
- std::string new_count_str = GetenvThreadSafe("TIMEOUT_TO_LAUNCH_CONTAINER");
- int new_count;
- std::istringstream ss(new_count_str);
- if (!(ss >> new_count))
- {
- INFOS("[LaunchContainer] TIMEOUT_TO_LAUNCH_CONTAINER should be an int");
- }
- else
- count = new_count;
- }
+ int count(GetTimeOutToLoaunchServer());
INFOS("[GiveContainer] waiting " << count << " second steps container " << containerNameInNS);
while (CORBA::is_nil(ret) && count)
{
-#ifndef WIN32
- sleep( 1 ) ;
-#else
- Sleep(1000);
-#endif
+ SleepInSecond(1);
count--;
MESSAGE("[GiveContainer] step " << count << " Waiting for container on " << resource_selected);
- CORBA::Object_var obj = _NS->Resolve(containerNameInNS.c_str());
+ CORBA::Object_var obj(_NS->Resolve(containerNameInNS.c_str()));
ret=Engines::Container::_narrow(obj);
}
if (CORBA::is_nil(ret))
void SALOME_ContainerManager::AddOmninamesParams(std::string& command) const
{
- CORBA::String_var iorstr = _NS->getIORaddr();
- command += "ORBInitRef NameService=";
- command += iorstr;
+ std::ostringstream oss;
+ AddOmninamesParams(oss);
+ command+=oss.str();
}
//=============================================================================
*/
//=============================================================================
-void SALOME_ContainerManager::AddOmninamesParams(std::ofstream& fileStream) const
+void SALOME_ContainerManager::AddOmninamesParams(std::ostream& fileStream) const
{
- CORBA::String_var iorstr = _NS->getIORaddr();
- fileStream << "ORBInitRef NameService=";
- fileStream << iorstr;
+ AddOmninamesParams(fileStream,_NS);
}
//=============================================================================
*/
//=============================================================================
-void SALOME_ContainerManager::AddOmninamesParams(std::ostringstream& oss) const
+void SALOME_ContainerManager::AddOmninamesParams(std::ostream& fileStream, SALOME_NamingService *ns)
+{
+ CORBA::String_var iorstr(ns->getIORaddr());
+ fileStream << "ORBInitRef NameService=";
+ fileStream << iorstr;
+}
+
+void SALOME_ContainerManager::MakeTheCommandToBeLaunchedASync(std::string& command)
{
- CORBA::String_var iorstr = _NS->getIORaddr();
- oss << "ORBInitRef NameService=";
- oss << iorstr;
+#ifdef WIN32
+ command = "%PYTHONBIN% -c \"import win32pm ; win32pm.spawnpid(r'" + command + "', '')\"";
+#else
+ command += " &";
+#endif
+}
+
+int SALOME_ContainerManager::GetTimeOutToLoaunchServer()
+{
+ int count(TIME_OUT_TO_LAUNCH_CONT);
+ if (GetenvThreadSafe("TIMEOUT_TO_LAUNCH_CONTAINER") != 0)
+ {
+ std::string new_count_str(GetenvThreadSafe("TIMEOUT_TO_LAUNCH_CONTAINER"));
+ int new_count;
+ std::istringstream ss(new_count_str);
+ if (!(ss >> new_count))
+ {
+ INFOS("[LaunchContainer] TIMEOUT_TO_LAUNCH_CONTAINER should be an int");
+ }
+ else
+ count = new_count;
+ }
+ return count;
+}
+
+void SALOME_ContainerManager::SleepInSecond(int ellapseTimeInSecond)
+{
+#ifndef WIN32
+ sleep( ellapseTimeInSecond ) ;
+#else
+ int timeInMS(1000*ellapseTimeInSecond);
+ Sleep(timeInMS);
+#endif
}
//=============================================================================
return container_proxy;
}
- int count = TIME_OUT_TO_LAUNCH_CONT;
+ int count(GetTimeOutToLoaunchServer());
CORBA::Object_var obj = CORBA::Object::_nil();
std::string containerNameInNS = _NS->BuildContainerNameForNS(params.container_name.in(),
hostname.c_str());
std::string container_node_name = name + proc_number;
std::string containerNameInNS = _NS->BuildContainerNameForNS((char*) container_node_name.c_str(), theMachine.c_str());
INFOS("[LaunchPaCONodeContainer] Waiting for Parallel Container node " << containerNameInNS << " on " << theMachine);
- int count = TIME_OUT_TO_LAUNCH_CONT;
+ int count(GetTimeOutToLoaunchServer());
while (CORBA::is_nil(obj) && count) {
- sleep(1) ;
+ SleepInSecond(1);
count-- ;
obj = _NS->Resolve(containerNameInNS.c_str());
}
#include <SALOMEconfig.h>
#include CORBA_CLIENT_HEADER(SALOME_Component)
#include CORBA_CLIENT_HEADER(SALOME_ContainerManager)
-#include "SALOME_ResourcesManager.hxx"
-#include "SALOME_LoadRateManager.hxx"
-
+#include "SALOME_ResourcesCatalog_Parser.hxx"
+#include "Utils_SALOME_Exception.hxx"
#include "Utils_Mutex.hxx"
#include <string>
#include <set>
class SALOME_NamingService;
+class SALOME_ResourcesManager;
class CONTAINER_EXPORT SALOME_ContainerManager : public POA_Engines::ContainerManager
{
void AddOmninamesParams(std::string& command) const;
- void AddOmninamesParams(std::ostringstream& oss) const;
-
- void AddOmninamesParams(std::ofstream& fileStream) const;
+ void AddOmninamesParams(std::ostream& fileStream) const;
static std::string BuildTemporaryFileName();
public:
static char *GetenvThreadSafe(const char *name);
static int SystemThreadSafe(const char *command);
-private:
+ static void AddOmninamesParams(std::ostream& fileStream, SALOME_NamingService *ns);
+ static void MakeTheCommandToBeLaunchedASync(std::string& command);
+ static int GetTimeOutToLoaunchServer();
+ static void SleepInSecond(int ellapseTimeInSecond);
+ private:
+ static const int TIME_OUT_TO_LAUNCH_CONT;
static Utils_Mutex _getenvMutex;
static Utils_Mutex _systemMutex;
};
#include "BatchTest.hxx"
#include "OpUtil.hxx"
#include "SALOME_ContainerManager.hxx"
+#include "SALOME_NamingService.hxx"
+#include "SALOME_ResourcesManager.hxx"
#include "Utils_CorbaException.hxx"
-
#include "Launcher_Job_Command.hxx"
#include "Launcher_Job_YACSFile.hxx"
#include "Launcher_Job_PythonSALOME.hxx"
+#include "utilities.h"
+
#ifdef WIN32
# include <process.h>
#else
#include <ServiceUnreachable.hxx>
#include "SALOME_LifeCycleCORBA.hxx"
+#include "SALOME_ResourcesManager.hxx"
+
#include CORBA_CLIENT_HEADER(SALOME_ModuleCatalog)
#include CORBA_CLIENT_HEADER(SALOME_Session)
#include CORBA_CLIENT_HEADER(DSC_Engines)
#include "SALOME_NamingService.hxx"
#include "SALOME_ContainerManager.hxx"
#include "SALOME_LifeCycleCORBA.hxx"
+#include "SALOME_ResourcesManager.hxx"
#include "NamingService_WaitForServerReadiness.hxx"
#include "OpUtil.hxx"
#include "Utils_ORB_INIT.hxx"
#
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
-#
+# Author : Anthony GEAY (EDF R&D)
INCLUDE_DIRECTORIES(
${OMNIORB_INCLUDE_DIR}
${PROJECT_BINARY_DIR}/salome_adm
${CMAKE_CURRENT_SOURCE_DIR}/../Utils
${CMAKE_CURRENT_SOURCE_DIR}/../NamingService
+ ${CMAKE_CURRENT_SOURCE_DIR}/../Container
+ ${CMAKE_CURRENT_SOURCE_DIR}/../ResourcesManager
)
ADD_DEFINITIONS(${OMNIORB_DEFINITIONS})
-SET(COMMON_LIBS SalomeNS SalomeIDLKernel ${OMNIORB_LIBRARIES})
+SET(COMMON_LIBS SalomeNS SalomeContainer SalomeIDLKernel ${OMNIORB_LIBRARIES})
SET(SalomeSDS_SOURCES
SALOMESDS_Exception.cxx
TARGET_LINK_LIBRARIES(SalomeSDS ${COMMON_LIBS} ${PTHREAD_LIBRARIES})
INSTALL(TARGETS SalomeSDS EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS})
-FILE(GLOB COMMON_HEADERS_HXX "${CMAKE_CURRENT_SOURCE_DIR}/*.hxx")
+ADD_EXECUTABLE(SALOME_DataScopeServer SALOME_DataScopeServer.cxx)
+TARGET_LINK_LIBRARIES(SALOME_DataScopeServer SalomeSDS)
+INSTALL(TARGETS SALOME_DataScopeServer DESTINATION ${SALOME_INSTALL_BINS})
+FILE(GLOB COMMON_HEADERS_HXX "${CMAKE_CURRENT_SOURCE_DIR}/*.hxx")
INSTALL(FILES ${COMMON_HEADERS_HXX} DESTINATION ${SALOME_INSTALL_HEADERS})
// Author : Anthony GEAY (EDF R&D)
#include "SALOMESDS_AnyDataServer.hxx"
+#include "SALOMESDS_Exception.hxx"
using namespace SALOMESDS;
*/
void AnyDataServer::setValueOf(const CORBA::Any& newValue)
{
+ checkReadOnlyStatusRegardingConstness("StringDataServer::setValueOf : read only var !");
delete _data;
_data=new CORBA::Any(newValue);
}
using namespace SALOMESDS;
-BasicDataServer::BasicDataServer(const std::string& varName):_var_name(varName)
+BasicDataServer::BasicDataServer(const std::string& varName):_is_read_only(false),_var_name(varName)
{
}
+/*!
+ * Called remotely -> to protect against throw
+ */
char *BasicDataServer::getVarName()
{
return CORBA::string_dup(_var_name.c_str());
}
+
+/*!
+ * Called remotely -> to protect against throw
+ */
+void BasicDataServer::setReadOnlyStatus()
+{
+ _is_read_only=true;
+}
+
+/*!
+ * Called remotely -> to protect against throw
+ */
+void BasicDataServer::setRWStatus()
+{
+ _is_read_only=false;
+}
+
+void BasicDataServer::checkReadOnlyStatusRegardingConstness(const char *sender) const
+{
+ if(isReadOnly())
+ throw Exception(sender);
+}
public:
BasicDataServer(const std::string& varName);
char *getVarName();
+ void setReadOnlyStatus();
+ void setRWStatus();
std::string getVarNameCpp() const { return _var_name; }
+ protected:
+ void checkReadOnlyStatusRegardingConstness(const char *sender) const;
+ bool isReadOnly() const { return _is_read_only; }
private:
+ //! false by default
+ bool _is_read_only;
std::string _var_name;
};
}
#include "SALOMESDS_DataServerManager.hxx"
#include "SALOMESDS_Exception.hxx"
+#include "SALOME_ContainerManager.hxx"
#include "SALOME_NamingService.hxx"
#include <sstream>
SALOME::DataScopeServer_ptr DataServerManager::createDataScope(const char *scopeName)
{
+ std::string scopeNameCpp(scopeName);
+ std::size_t sz(_scopes.size());
+ std::list< SALOME::DataScopeServer_var >::iterator it(_scopes.begin());
+ for(std::size_t i=0;i<sz;it++,i++)
+ {
+ CORBA::String_var zeName((*it)->getScopeName());
+ if(scopeNameCpp==(const char *)zeName)
+ {
+ std::ostringstream oss; oss << "DataServerManager::createDataScope : scope name \"" << scopeName << "\" already exists !";
+ throw Exception(oss.str());
+ }
+ }
+ //
+ SALOME_NamingService ns(_orb);
+ std::string fullScopeName(CreateAbsNameInNSFromScopeName(scopeName));
+ std::ostringstream oss; oss << "SALOME_DataScopeServer" << " " << scopeName;
+ SALOME_ContainerManager::AddOmninamesParams(oss,&ns);
+ std::string command(oss.str());
+ SALOME_ContainerManager::MakeTheCommandToBeLaunchedASync(command);
+ int status(SALOME_ContainerManager::SystemThreadSafe(command.c_str()));
+ int count(SALOME_ContainerManager::GetTimeOutToLoaunchServer());
+ SALOME::DataScopeServer_var ret(SALOME::DataScopeServer::_nil());
+ while (CORBA::is_nil(ret) && count)
+ {
+ CORBA::Object_var obj(ns.Resolve(fullScopeName.c_str()));
+ ret=SALOME::DataScopeServer::_narrow(obj);
+ }
+ if(!CORBA::is_nil(ret))
+ {
+ _scopes.push_back(ret);
+ }
+ return SALOME::DataScopeServer::_duplicate(ret);
}
SALOME::DataScopeServer_ptr DataServerManager::retriveDataScope(const char *scopeName)
{
+ std::list< SALOME::DataScopeServer_var >::iterator it(getScopePtrGivenName(scopeName));
+ return SALOME::DataScopeServer::_duplicate(*it);
}
SALOME::DataScopeServer_ptr DataServerManager::removeDataScope(const char *scopeName)
{
+ std::list< SALOME::DataScopeServer_var >::iterator it(getScopePtrGivenName(scopeName));
+ return SALOME::DataScopeServer::_duplicate(*it);
}
std::string DataServerManager::CreateAbsNameInNSFromScopeName(const std::string& scopeName)
std::ostringstream oss; oss << NAME_IN_NS << "/" << scopeName;
return oss.str();
}
+
+std::list< SALOME::DataScopeServer_var >::iterator DataServerManager::getScopePtrGivenName(const std::string& scopeName)
+{
+ std::size_t sz(_scopes.size());
+ std::list< SALOME::DataScopeServer_var >::iterator it(_scopes.begin());
+ bool found(false);
+ for(std::size_t i=0;i<sz;it++,i++)
+ {
+ CORBA::String_var zeName((*it)->getScopeName());
+ found=(scopeName==(const char *)zeName);
+ if(found)
+ break;
+ }
+ if(!found)
+ {
+ std::ostringstream oss; oss << "DataServerManager::getScopePtrGivenName : scope name \"" << scopeName << "\" does not exist !";
+ throw Exception(oss.str());
+ }
+ return it;
+}
public:
static const char NAME_IN_NS[];
static const char DFT_SCOPE_NAME_IN_NS[];
+ private:
+ std::list< SALOME::DataScopeServer_var >::iterator getScopePtrGivenName(const std::string& scopeName);
private:
AutoRefCountPtr<DataScopeServer> _dft_scope;
SALOME::DataScopeServer_var _ptr_dft_scope;
// Author : Anthony GEAY (EDF R&D)
#include "SALOMESDS_StringDataServer.hxx"
+#include "SALOMESDS_Exception.hxx"
using namespace SALOMESDS;
*/
void StringDataServer::setValueOf(const char *newValue)
{
+ checkReadOnlyStatusRegardingConstness("StringDataServer::setValueOf : read only var !");
_data=newValue;
}
--- /dev/null
+// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// Author : Anthony GEAY (EDF R&D)
+
+#include "SALOMESDS_DataScopeServer.hxx"
+#include "SALOMESDS_DataServerManager.hxx"
+#include "SALOMESDS_Exception.hxx"
+
+#include "SALOME_NamingService.hxx"
+
+#include <string>
+#include <sstream>
+
+int main(int argc, char* argv[])
+{
+ std::string scopeName;
+ if(argc<=1)
+ throw SALOMESDS::Exception("In the main of SALOME_DataScopeServer.cxx !");
+ scopeName=argv[1];
+ CORBA::ORB_var orb(CORBA::ORB_init(argc,argv));
+ CORBA::Object_var obj(orb->resolve_initial_references("RootPOA"));
+ PortableServer::POA_var poa(PortableServer::POA::_narrow(obj));
+ PortableServer::POAManager_var mgr(poa->the_POAManager());
+ mgr->activate();
+ SALOMESDS::DataScopeServer *server(new SALOMESDS::DataScopeServer(orb,scopeName));
+ //
+ CORBA::PolicyList policies;
+ policies.length(1);
+ PortableServer::ThreadPolicy_var threadPol(poa->create_thread_policy(PortableServer::SINGLE_THREAD_MODEL));
+ policies[0]=PortableServer::ThreadPolicy::_duplicate(threadPol);
+ PortableServer::POA_var poa2(poa->create_POA("SingleThPOA4SDS",mgr,policies));
+ threadPol->destroy();
+ PortableServer::ObjectId_var id(poa2->activate_object(server));
+ obj=poa2->id_to_reference(id);
+ SALOME::DataScopeServer_var serverPtr(SALOME::DataScopeServer::_narrow(obj));
+ //
+ std::ostringstream oss; oss << SALOMESDS::DataServerManager::NAME_IN_NS << "/" << scopeName;
+ std::string fullScopeName(oss.str());
+ SALOME_NamingService ns(orb);
+ ns.Register(serverPtr,fullScopeName.c_str());
+ //
+ orb->run();
+ server->decrRef();
+ return 0;
+}
+