return oss.str();
}
+void Container::start(const Task *askingNode,
+ const std::string& resource_name,
+ const std::string& container_name)
+{
+ return start(askingNode);
+}
+
+bool Container::canAcceptImposedResource()
+{
+ return false;
+}
+
/*!
* If \a val is equal to true the current container 'this' is not destined to be deeply copied on clone call.
* If \a val is equal to false the current container 'this' is destined to be deeply copied on clone call.
virtual std::string getDiscreminantStrOfThis(const Task *askingNode) const;
virtual bool isAlreadyStarted(const Task *askingNode) const = 0;
virtual void start(const Task *askingNode) = 0;
+ virtual void start(const Task *askingNode,
+ const std::string& resource_name,
+ const std::string& container_name);
+ virtual bool canAcceptImposedResource();
virtual std::string getPlacementId(const Task *askingNode) const = 0;
virtual std::string getFullPlacementId(const Task *askingNode) const = 0;
//Edition only methods
id++;
newResource.nbCores = res.second;
wm.addResource(newResource);
+ std::cerr << "Add resource " << newResource.name << " with "
+ << newResource.nbCores << " cores." << std::endl;
}
}
WorkloadManager::WorkloadManager wlm(algo);
loadResources(wlm);
wlm.start();
-
+
while (_toContinue)
{
DEBTRACE("--- executor main loop");
{
try
{
+ if(!_imposedResource.empty() && !_imposedContainer.empty())
+ container->start(reqNode, _imposedResource, _imposedContainer);
+ else
container->start(reqNode);
}
catch(Exception& e)
}
}
+void PythonNode::imposeResource(const std::string& resource_name,
+ const std::string& container_name)
+{
+ if(!resource_name.empty() && !container_name.empty())
+ {
+ _imposedResource = resource_name;
+ _imposedContainer = container_name;
+ }
+}
+
+bool PythonNode::canAcceptImposedResource()
+{
+ return _container != nullptr && _container->canAcceptImposedResource();
+}
+
Node *PythonNode::simpleClone(ComposedNode *father, bool editionOnly) const
{
return new PythonNode(*this,father);
}
}
+void PyFuncNode::imposeResource(const std::string& resource_name,
+ const std::string& container_name)
+{
+ if(!resource_name.empty() && !container_name.empty())
+ {
+ _imposedResource = resource_name;
+ _imposedContainer = container_name;
+ }
+}
+
+bool PyFuncNode::canAcceptImposedResource()
+{
+ return _container != nullptr && _container->canAcceptImposedResource();
+}
+
PyObject *_pyfuncSer;
PyObject *_pyfuncUnser;
PyObject *_pyfuncSimpleSer;
+ std::string _imposedResource;
+ std::string _imposedContainer;
public:
static const char SCRIPT_FOR_SIMPLE_SERIALIZATION[];
};
virtual void executeRemote();
virtual void executeLocal();
virtual void shutdown(int level);
+ void imposeResource(const std::string& resource_name,
+ const std::string& container_name) override;
+ bool canAcceptImposedResource()override;
std::string getContainerLog();
PythonNode* cloneNode(const std::string& name);
virtual std::string typeName() { return "YACS__ENGINE__PythonNode"; }
virtual void executeRemote();
virtual void executeLocal();
virtual void shutdown(int level);
+ void imposeResource(const std::string& resource_name,
+ const std::string& container_name) override;
+ bool canAcceptImposedResource()override;
std::string getContainerLog();
PyFuncNode* cloneNode(const std::string& name);
virtual std::string typeName() { return "YACS__ENGINE__PyFuncNode"; }
if(CORBA::is_nil(resManager))
throw Exception("SalomeContainerToolsSpreadOverTheResDecorator::getParameters : Internal error ! The entry attached to the res manager in NS does not have right type !");
std::vector< std::pair<std::string,int> > ret;
+ Engines::ResourceParameters params;
+ params.name = "";
+ params.hostname = "";
+ params.OS = "";
+ params.nb_proc = 0;
+ params.mem_mb = 0;
+ params.cpu_clock = 0;
+ params.nb_node = 0;
+ params.nb_proc_per_node = 0;
+ params.policy = "";
+ params.can_launch_batch_jobs = false;
+ params.can_run_containers = true;
+ params.componentList.length(0);
+ Engines::ResourceList_var resourceList;
+ resourceList = resManager->GetFittingResources(params);
+ ret.reserve(resourceList->length());
+ for(int i = 0; i<resourceList->length(); i++)
{
- Engines::ResourceList *rl(0);
- Engines::IntegerList *il(0);
- resManager->ListAllAvailableResources(rl,il);
- int sz(rl->length());
- if(il->length()!=sz)
- throw Exception("SalomeContainerToolsSpreadOverTheResDecorator::getParameters : Internal error ! Invalid size !");
- ret.resize(sz);
- for(int i=0;i<sz;i++)
- {
- std::string s((*rl)[i]);
- ret[i]=std::pair<std::string,int>(s,(*il)[i]);
- }
- delete rl;
- delete il;
+ const char* resource_name = resourceList[i];
+ std::string std_resource_name = resource_name;
+ Engines::ResourceDefinition_var resource_definition
+ = resManager->GetResourceDefinition(resource_name);
+ int nb_cores = resource_definition->nb_node *
+ resource_definition->nb_proc_per_node;
+ ret.push_back(std::pair<std::string,int>(resource_name, nb_cores));
}
+
return ret;
}
/*!
* \param inst the component instance
*/
-void SalomeContainer::start(const Task *askingNode)
+void SalomeContainer::start(const Task *askingNode)
{
SalomeContainerTools::Start(_componentNames,_launchModeType,_sct,_shutdownLevel,this,askingNode);
}
+void SalomeContainer::start(const Task *askingNode,
+ const std::string& resource_name,
+ const std::string& container_name)
+{
+ if(canAcceptImposedResource())
+ {
+ SalomeContainerTools tempSct = _sct;
+ tempSct.setProperty("name", resource_name);
+ tempSct.setProperty("container_name", container_name);
+ SalomeContainerTools::Start(_componentNames,_launchModeType,tempSct,_shutdownLevel,this,askingNode);
+ }
+ else
+ start(askingNode);
+}
+
+bool SalomeContainer::canAcceptImposedResource()
+{
+ return _launchModeType->getType() == SalomeContainerMultiHelper::TYPE_NAME;
+}
+
void SalomeContainer::shutdown(int level)
{
DEBTRACE("SalomeContainer::shutdown: " << _name << "," << level << "," << _shutdownLevel);
std::string getKind() const;
bool isAlreadyStarted(const Task *askingNode) const;
Engines::Container_ptr getContainerPtr(const Task *askingNode) const;
- void start(const Task *askingNode) ;
+ void start(const Task *askingNode) override;
+ void start(const Task *askingNode,
+ const std::string& resource_name,
+ const std::string& container_name) override;
+ bool canAcceptImposedResource() override;
Container *clone() const;
Container *cloneAlways() const;
std::string getPlacementId(const Task *askingNode) const;
{
ContainerType type;
Resource resource;
- unsigned int index; // worker index on the resource for this type
+ unsigned int index=0; // worker index on the resource for this type
};
/**
n1.edAddChild(n10)
n10.setScript("""
import time
-time.sleep(2)
+time.sleep(4)
o2=2*i1
""")
i1=n10.edAddInputPort("i1",ti)
myRun=threading.Thread(None, ex.RunW, None, (p,0))
myRun.start()
import time
- time.sleep(5)
+ time.sleep(7)
SALOMERuntime.schemaSaveState(p, ex, xmlStateFileName)
a,b,c=n1.getPassedResults(ex)
myRun.join()