Salome HOME
add method NameChanged to update title name
[modules/kernel.git] / src / LifeCycleCORBA / TestContainerManager.cxx
index fc09b92e657e55daae701af9224f2b3f7e142d77..7dddf3f01d7f20cc0143690a10a839636e530bb8 100644 (file)
@@ -1,24 +1,22 @@
-//  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2016  CEA/DEN, EDF R&D, OPEN CASCADE
 //
-//  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+// 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 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.
+// 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.
 //
-//  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
 //
-//  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
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
+
 //  SALOME TestContainer : test of container creation and its life cycle
 //  File   : TestContainer.cxx
 //  Author : Paul RASCLE, EDF - MARC TAJCHMAN, CEA
 //
 #include "utilities.h"
 #include <iostream>
-#ifndef WNT
+#ifndef WIN32
 #include <unistd.h>
 #endif
 #include <SALOMEconfig.h>
 #include "SALOME_NamingService.hxx"
+#include "SALOME_ResourcesManager.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"
@@ -47,7 +47,7 @@ int main (int argc, char * argv[])
   std::map<std::string, int> cycle;
   std::map<std::string, int> first;
   Engines::Container_ptr cont;
-  Engines::Component_ptr compo;
+  Engines::EngineComponent_ptr compo;
   bool error = false;
   bool bestImplemented;
   int status;
@@ -65,37 +65,39 @@ int main (int argc, char * argv[])
   ASSERT( !CORBA::is_nil(obj));
   Engines::ResourcesManager_var _ResManager=Engines::ResourcesManager::_narrow(obj);
 
-  Engines::MachineParameters p;
-  Engines::CompoList clist;
-  clist.length(2);
-  clist[0] = "MED";
-  clist[1] = "GEOM";
+  Engines::ContainerParameters p;
+  p.resource_params.componentList.length(2);
+  p.resource_params.componentList[0] = "MED";
+  p.resource_params.componentList[1] = "GEOM";
 
-  p.hostname = "";
-  p.OS = "LINUX";
-  p.mem_mb = 1000;
-  p.cpu_clock = 1000;
-  p.nb_proc_per_node = 1;
-  p.nb_node = 1;
+  p.resource_params.hostname = "";
+  p.resource_params.OS = "LINUX";
+  p.resource_params.mem_mb = 1000;
+  p.resource_params.cpu_clock = 1000;
+  p.resource_params.nb_proc_per_node = 1;
+  p.resource_params.nb_node = 1;
   p.isMPI = false;
 
   char st[10];
   for(int i=0;i<10;i++){
     sprintf(st,"cycl_%d",i);
     p.container_name = CORBA::string_dup(st);
-    cont = _ContManager->GiveContainer(p,Engines::P_CYCL,clist);
+    p.resource_params.policy="cycl";
+    cont = _ContManager->GiveContainer(p);
     if(CORBA::is_nil(cont)) error = true;
   }
 
   for(int i=0;i<10;i++){
     sprintf(st,"first_%d",i);
     p.container_name = CORBA::string_dup(st);
-    cont = _ContManager->GiveContainer(p,Engines::P_FIRST,clist);
+    p.resource_params.policy="first";
+    cont = _ContManager->GiveContainer(p);
     if(CORBA::is_nil(cont)) error = true;
   }
 
   p.container_name = CORBA::string_dup("best");
-  cont = _ContManager->GiveContainer(p,Engines::P_BEST,clist);
+  p.resource_params.policy="best";
+  cont = _ContManager->GiveContainer(p);
   if(CORBA::is_nil(cont)) bestImplemented = false;
   else bestImplemented = true;
 
@@ -125,9 +127,9 @@ int main (int argc, char * argv[])
     if(!CORBA::is_nil(cont)){
       std::string basename = Kernel_Utils::GetBaseName(cont->name());
       if(basename.compare(0,4,"cycl")==0)
-       cycle[cont->getHostName()]++;
+        cycle[cont->getHostName()]++;
       if(basename.compare(0,5,"first")==0)
-       first[cont->getHostName()]++;
+        first[cont->getHostName()]++;
     }
   }
   _ContManager->ShutdownContainers();
@@ -139,14 +141,14 @@ int main (int argc, char * argv[])
   int nbpmax;
   for(std::map<std::string,int>::iterator iter=cycle.begin();iter!=cycle.end();iter++){
     if(strcmp((*iter).first.c_str(),"localhost")!=0){
-      Engines::MachineParameters *p = _ResManager->GetMachineParameters((*iter).first.c_str());
+      Engines::ResourceDefinition *p = _ResManager->GetResourceDefinition((*iter).first.c_str());
       int nbproc = p->nb_node * p->nb_proc_per_node;
       if(cycle[(*iter).first]/nbproc<cmin) cmin=cycle[(*iter).first]/nbproc;
       if(cycle[(*iter).first]/nbproc>cmax) cmax=cycle[(*iter).first]/nbproc;
       if(first[(*iter).first]/nbproc<fmin) fmin=first[(*iter).first]/nbproc;
       if(first[(*iter).first]/nbproc>fmax){
-       fmax=first[(*iter).first]/nbproc;
-       nbpmax = nbproc;
+        fmax=first[(*iter).first]/nbproc;
+        nbpmax = nbproc;
       }
     }
   }