Added: #1440 Example cfg for master and slave pipeline service

--HG--
branch : build_pipeline_v3
hg/feature/build_pipeline_v3
kaetemi 13 years ago
parent 4196ceff00
commit 6274912902

@ -0,0 +1,2 @@
cd R:\build\dev\bin\Release\
start R:\build\dev\bin\Release\pipeline_service.exe -CR:\code\nel\tools\pipeline\service\example_cfg\master\

@ -0,0 +1,2 @@
cd R:\build\dev\bin\Release\
start R:\build\dev\bin\Release\pipeline_service.exe -CR:\code\nel\tools\pipeline\service\example_cfg\slave\

@ -0,0 +1,35 @@
WorkspaceSheet = "ryzom_core.pipeline_workspace";
DatabaseDirectory = "W:/database";
PipelineDirectory = "W:/pipeline";
LeveldesignDirectory = "L:/leveldesign";
LeveldesignDfnDirectory = "L:/leveldesign/dfn";
LeveldesignPipelineDirectory = "L:/leveldesign/pipeline";
LeveldesignWorldDirectory = "L:/leveldesign/world";
// PrimitivesDirectory = "L:/primitives";
// ToolDirectories = { "R:/build/dev/bin/Release", "D:/libraries/external/bin" };
// ToolSuffix = ".exe";
// Ignored process plugins, like CProcessMaxShape, which should be completely ignored by the master service, even if they are configured to be used inside the process sheets.
// MasterIgnoreProcessPlugins = { }; // Only used by the master service. NOT USED, USE WORKSPACE INTEAD!
// MasterTerminalPassword = "MASTERCLIENTPASSWORD"; // Only used by the master service.
// MasterSlavePassword = "MASTERSLAVEPASSWORD";
MasterAddress = "192.168.150.1";
MasterPort = 50123;
UsedPlugins = { "pipeline_plugin_max", "pipeline_plugin_nel" };
// MaxPath = "C:/Program Files (x86)/Autodesk/3ds Max 2010";
// MaxExecutable = "3dsmax.exe";
DontUseNS = 1;
NSHost = "localhost";
WindowStyle = "WIN";
DisplayedVariables = { "Status|pipelineServiceState", "FileQueue|asyncFileQueueCount" };
DontUseAES = 1;

@ -0,0 +1,21 @@
#include "pipeline_service_default.cfg"
#include "user/pipeline_service_user.cfg"
StartCommands +=
{
// Create a gateway module
"moduleManager.createModule StandardGateway gw",
// Create a layer 3 server transport
"gw.transportAdd L3Server l3s",
"gw.transportCmd l3s(open port="+MasterPort+")",
// Create the master module (MASTER ONLY)
"moduleManager.createModule ModulePipelineMaster master",
"master.plug gw",
// Create the slave module
"moduleManager.createModule ModulePipelineSlave slave",
"slave.plug gw",
};

@ -0,0 +1,17 @@
#include "pipeline_service_default.cfg"
#include "user/pipeline_service_user.cfg"
StartCommands +=
{
// Create a gateway module
"moduleManager.createModule StandardGateway gw",
// Create a layer 3 client transport (SLAVE ONLY)
"gw.transportAdd L3Client l3c",
"gw.transportCmd l3c(connect addr="+MasterAddress+":"+MasterPort+")",
// Create the slave module
"moduleManager.createModule ModulePipelineSlave slave",
"slave.plug gw",
};

@ -0,0 +1,2 @@
RootConfigFilename = "../pipeline_service_default.cfg";

@ -29,11 +29,14 @@
#include "module_pipeline_master_itf.h" #include "module_pipeline_master_itf.h"
// STL includes // STL includes
#include <map>
#include <boost/thread/mutex.hpp>
// NeL includes // NeL includes
// #include <nel/misc/debug.h> #include <nel/misc/debug.h>
// Project includes // Project includes
#include "module_pipeline_slave_itf.h"
using namespace std; using namespace std;
using namespace NLMISC; using namespace NLMISC;
@ -48,15 +51,25 @@ namespace PIPELINE {
* CModulePipelineMaster * CModulePipelineMaster
*/ */
class CModulePipelineMaster : class CModulePipelineMaster :
public CEmptyModuleServiceBehav<CEmptyModuleCommBehav<CEmptySocketBehav<CModuleBase> > >, public CModulePipelineMasterSkel,
public CModulePipelineMasterSkel public CEmptyModuleServiceBehav<CEmptyModuleCommBehav<CEmptySocketBehav<CModuleBase> > >
{ {
struct CSlave
{
public:
CSlave(IModuleProxy *moduleProxy)
: Proxy(moduleProxy),
ActiveTaskId(0) { }
CModulePipelineSlaveProxy Proxy;
uint32 ActiveTaskId;
};
protected: protected:
// pointers typedef std::map<IModuleProxy *, CSlave *> TSlaveMap;
// ... TSlaveMap m_Slaves;
mutable boost::mutex m_SlavesMutex;
// instances
// ...
public: public:
CModulePipelineMaster() CModulePipelineMaster()
{ {
@ -65,13 +78,77 @@ public:
virtual ~CModulePipelineMaster() virtual ~CModulePipelineMaster()
{ {
m_SlavesMutex.lock();
for (TSlaveMap::iterator it = m_Slaves.begin(), end = m_Slaves.end(); it != end; ++it)
delete it->second;
m_Slaves.clear();
m_SlavesMutex.unlock();
}
virtual bool initModule(const TParsedCommandLine &initInfo)
{
CModuleBase::initModule(initInfo);
CModulePipelineMasterSkel::init(this);
return true;
}
virtual void onModuleUp(IModuleProxy *moduleProxy)
{
if (moduleProxy->getModuleClassName() == "ModulePipelineSlave")
{
nlassert(m_Slaves.find(moduleProxy) == m_Slaves.end());
nlinfo("Slave UP (%s)", moduleProxy->getModuleName().c_str());
m_SlavesMutex.lock();
CSlave *slave = new CSlave(moduleProxy);
m_Slaves[moduleProxy] = slave;
m_SlavesMutex.unlock();
}
}
virtual void onModuleDown(IModuleProxy *moduleProxy)
{
if (moduleProxy->getModuleClassName() == "ModulePipelineSlave")
{
nlinfo("Slave DOWN (%s)", moduleProxy->getModuleName().c_str());
m_SlavesMutex.lock();
TSlaveMap::iterator slaveIt = m_Slaves.find(moduleProxy);
CSlave *slave = slaveIt->second;
if (slave->ActiveTaskId)
{
// ...
}
m_Slaves.erase(slaveIt);
delete slave;
m_SlavesMutex.unlock();
}
}
virtual void onModuleUpdate()
{
// if state build, iterate trough all slaves to see if any is free, and check if there's any waiting tasks
} }
virtual void slaveFinishedBuildTask(NLNET::IModuleProxy *sender, uint32 taskId) virtual void slaveFinishedBuildTask(NLNET::IModuleProxy *sender, uint32 taskId)
{ {
// TODO
}
virtual void slaveRefusedBuildTask(NLNET::IModuleProxy *sender, uint32 taskId)
{
// TODO
} }
}; /* class CModulePipelineMaster */ }; /* class CModulePipelineMaster */
void module_pipeline_master_forceLink() { } void module_pipeline_master_forceLink() { }

@ -10,6 +10,12 @@
<param type="uint32" name="taskId" /> <param type="uint32" name="taskId" />
</method> </method>
<method name="slaveRefusedBuildTask" msg="SRBT">
<doc line=""/>
<param type="uint32" name="taskId" />
</method>
</module_interface> </module_interface>
</namespace> </namespace>

@ -31,9 +31,10 @@
// STL includes // STL includes
// NeL includes // NeL includes
// #include <nel/misc/debug.h> #include <nel/misc/debug.h>
// Project includes // Project includes
#include "module_pipeline_master_itf.h"
using namespace std; using namespace std;
using namespace NLMISC; using namespace NLMISC;
@ -52,13 +53,10 @@ class CModulePipelineSlave :
public CModulePipelineSlaveSkel public CModulePipelineSlaveSkel
{ {
protected: protected:
// pointers CModulePipelineMasterProxy *m_Master;
// ...
// instances
// ...
public: public:
CModulePipelineSlave() CModulePipelineSlave() : m_Master(NULL)
{ {
} }
@ -68,9 +66,43 @@ public:
} }
virtual void startBuildTask(NLNET::IModuleProxy *sender, uint32 taskId, const std::string &projectName, const std::string &processHandler) virtual bool initModule(const TParsedCommandLine &initInfo)
{
CModuleBase::initModule(initInfo);
CModulePipelineSlaveSkel::init(this);
return true;
}
virtual void onModuleUp(IModuleProxy *moduleProxy)
{
if (moduleProxy->getModuleClassName() == "ModulePipelineMaster")
{
nlassert(m_Master == NULL);
m_Master = new CModulePipelineMasterProxy(moduleProxy);
nlinfo("Master UP (%s)", moduleProxy->getModuleName().c_str());
}
}
virtual void onModuleDown(IModuleProxy *moduleProxy)
{ {
if (moduleProxy->getModuleClassName() == "ModulePipelineMaster")
{
nlassert(m_Master->getModuleProxy() == moduleProxy);
delete m_Master;
m_Master = NULL;
nlinfo("Slave DOWN (%s)", moduleProxy->getModuleName().c_str());
}
}
virtual void startBuildTask(NLNET::IModuleProxy *sender, uint32 taskId, const std::string &projectName, const std::string &processHandler)
{
//this->queueModuleTask
CModulePipelineMasterProxy master(sender);
master.slaveRefusedBuildTask(this, taskId);
} }
}; /* class CModulePipelineSlave */ }; /* class CModulePipelineSlave */

Loading…
Cancel
Save