diff --git a/code/nel/tools/pipeline/service/example_cfg/example_run_master.bat b/code/nel/tools/pipeline/service/example_cfg/example_run_master.bat new file mode 100644 index 000000000..e47cd6e0b --- /dev/null +++ b/code/nel/tools/pipeline/service/example_cfg/example_run_master.bat @@ -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\ \ No newline at end of file diff --git a/code/nel/tools/pipeline/service/example_cfg/example_run_slave.bat b/code/nel/tools/pipeline/service/example_cfg/example_run_slave.bat new file mode 100644 index 000000000..3edba89a1 --- /dev/null +++ b/code/nel/tools/pipeline/service/example_cfg/example_run_slave.bat @@ -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\ \ No newline at end of file diff --git a/code/nel/tools/pipeline/service/example_cfg/master/pipeline_service.cfg b/code/nel/tools/pipeline/service/example_cfg/master/pipeline_service.cfg new file mode 100644 index 000000000..c6efae440 --- /dev/null +++ b/code/nel/tools/pipeline/service/example_cfg/master/pipeline_service.cfg @@ -0,0 +1,2 @@ + +#include "../pipeline_service_master.cfg" diff --git a/code/nel/tools/pipeline/service/example_cfg/modify_cfg_in_user_dir b/code/nel/tools/pipeline/service/example_cfg/modify_cfg_in_user_dir new file mode 100644 index 000000000..e69de29bb diff --git a/code/nel/tools/pipeline/service/example_cfg/pipeline_service_default.cfg b/code/nel/tools/pipeline/service/example_cfg/pipeline_service_default.cfg new file mode 100644 index 000000000..a0227733d --- /dev/null +++ b/code/nel/tools/pipeline/service/example_cfg/pipeline_service_default.cfg @@ -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; diff --git a/code/nel/tools/pipeline/service/example_cfg/pipeline_service_master.cfg b/code/nel/tools/pipeline/service/example_cfg/pipeline_service_master.cfg new file mode 100644 index 000000000..5ece8f6c9 --- /dev/null +++ b/code/nel/tools/pipeline/service/example_cfg/pipeline_service_master.cfg @@ -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", +}; diff --git a/code/nel/tools/pipeline/service/example_cfg/pipeline_service_slave.cfg b/code/nel/tools/pipeline/service/example_cfg/pipeline_service_slave.cfg new file mode 100644 index 000000000..1a9f077a7 --- /dev/null +++ b/code/nel/tools/pipeline/service/example_cfg/pipeline_service_slave.cfg @@ -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", +}; diff --git a/code/nel/tools/pipeline/service/example_cfg/slave/pipeline_service.cfg b/code/nel/tools/pipeline/service/example_cfg/slave/pipeline_service.cfg new file mode 100644 index 000000000..b9da270a8 --- /dev/null +++ b/code/nel/tools/pipeline/service/example_cfg/slave/pipeline_service.cfg @@ -0,0 +1,2 @@ + +#include "../pipeline_service_slave.cfg" diff --git a/code/nel/tools/pipeline/service/example_cfg/user/pipeline_service_user.cfg b/code/nel/tools/pipeline/service/example_cfg/user/pipeline_service_user.cfg new file mode 100644 index 000000000..1b9d6d3d8 --- /dev/null +++ b/code/nel/tools/pipeline/service/example_cfg/user/pipeline_service_user.cfg @@ -0,0 +1,2 @@ + +RootConfigFilename = "../pipeline_service_default.cfg"; diff --git a/code/nel/tools/pipeline/service/module_pipeline_master.cpp b/code/nel/tools/pipeline/service/module_pipeline_master.cpp index 7c71d2469..a43f2e7d2 100644 --- a/code/nel/tools/pipeline/service/module_pipeline_master.cpp +++ b/code/nel/tools/pipeline/service/module_pipeline_master.cpp @@ -29,11 +29,14 @@ #include "module_pipeline_master_itf.h" // STL includes +#include +#include // NeL includes -// #include +#include // Project includes +#include "module_pipeline_slave_itf.h" using namespace std; using namespace NLMISC; @@ -48,15 +51,25 @@ namespace PIPELINE { * CModulePipelineMaster */ class CModulePipelineMaster : - public CEmptyModuleServiceBehav > >, - public CModulePipelineMasterSkel + public CModulePipelineMasterSkel, + public CEmptyModuleServiceBehav > > { -protected: - // pointers - // ... + struct CSlave + { + public: + CSlave(IModuleProxy *moduleProxy) + : Proxy(moduleProxy), + ActiveTaskId(0) { } + + CModulePipelineSlaveProxy Proxy; + uint32 ActiveTaskId; + }; - // instances - // ... +protected: + typedef std::map TSlaveMap; + TSlaveMap m_Slaves; + mutable boost::mutex m_SlavesMutex; + public: CModulePipelineMaster() { @@ -65,13 +78,77 @@ public: 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) { + // TODO + } + virtual void slaveRefusedBuildTask(NLNET::IModuleProxy *sender, uint32 taskId) + { + // TODO } + }; /* class CModulePipelineMaster */ void module_pipeline_master_forceLink() { } diff --git a/code/nel/tools/pipeline/service/module_pipeline_master_itf.cpp b/code/nel/tools/pipeline/service/module_pipeline_master_itf.cpp index 99979e030..171c2ccf8 100644 Binary files a/code/nel/tools/pipeline/service/module_pipeline_master_itf.cpp and b/code/nel/tools/pipeline/service/module_pipeline_master_itf.cpp differ diff --git a/code/nel/tools/pipeline/service/module_pipeline_master_itf.h b/code/nel/tools/pipeline/service/module_pipeline_master_itf.h index 4e5b9ea73..2e120f439 100644 Binary files a/code/nel/tools/pipeline/service/module_pipeline_master_itf.h and b/code/nel/tools/pipeline/service/module_pipeline_master_itf.h differ diff --git a/code/nel/tools/pipeline/service/module_pipeline_master_itf.xml b/code/nel/tools/pipeline/service/module_pipeline_master_itf.xml index ca5098a26..24162135c 100644 --- a/code/nel/tools/pipeline/service/module_pipeline_master_itf.xml +++ b/code/nel/tools/pipeline/service/module_pipeline_master_itf.xml @@ -10,6 +10,12 @@ + + + + + + diff --git a/code/nel/tools/pipeline/service/module_pipeline_slave.cpp b/code/nel/tools/pipeline/service/module_pipeline_slave.cpp index d4edc7249..5817d6ec4 100644 --- a/code/nel/tools/pipeline/service/module_pipeline_slave.cpp +++ b/code/nel/tools/pipeline/service/module_pipeline_slave.cpp @@ -31,9 +31,10 @@ // STL includes // NeL includes -// #include +#include // Project includes +#include "module_pipeline_master_itf.h" using namespace std; using namespace NLMISC; @@ -50,15 +51,12 @@ namespace PIPELINE { class CModulePipelineSlave : public CEmptyModuleServiceBehav > >, public CModulePipelineSlaveSkel -{ +{ protected: - // pointers - // ... + CModulePipelineMasterProxy *m_Master; - // instances - // ... 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 */