From 98c9ffff8856634819005cfe550d2070bf38b7ff Mon Sep 17 00:00:00 2001 From: kaetemi Date: Sat, 3 Mar 2012 21:32:45 +0100 Subject: [PATCH] Added: #1440 Slave request to master for ensuring database status is up to date for given paths --HG-- branch : build_pipeline_v3 --- .../pipeline/plugin_library/process_info.h | 4 +- .../pipeline/service/database_status.cpp | 21 +++++++--- .../service/module_pipeline_master.cpp | 36 +++++++++++++++--- .../service/module_pipeline_master_itf.cpp | Bin 8278 -> 14104 bytes .../service/module_pipeline_master_itf.h | Bin 9568 -> 11464 bytes .../service/module_pipeline_master_itf.xml | 14 ++++++- .../service/module_pipeline_slave.cpp | 5 +++ .../service/module_pipeline_slave_itf.cpp | Bin 6230 -> 9018 bytes .../service/module_pipeline_slave_itf.h | Bin 8922 -> 9838 bytes .../service/module_pipeline_slave_itf.xml | 6 ++- .../pipeline/service/pipeline_service.cpp | 13 ++++--- .../tools/pipeline/service/pipeline_service.h | 14 ++----- 12 files changed, 80 insertions(+), 33 deletions(-) diff --git a/code/nel/tools/pipeline/plugin_library/process_info.h b/code/nel/tools/pipeline/plugin_library/process_info.h index 0495af92e..50a1fbef4 100644 --- a/code/nel/tools/pipeline/plugin_library/process_info.h +++ b/code/nel/tools/pipeline/plugin_library/process_info.h @@ -63,9 +63,9 @@ public: /// A process handler is not allowed to depend on any files it does not list here. /// Must return all directories on which the process handler depends, these are NOT RECURSIVE. - virtual void getDependentDirectories(std::vector &result) = 0; + virtual void getDependentDirectories(std::vector &resultAppend) = 0; /// Must return all files on which the process handler depends, ONLY if these are not in dependent directories. - virtual void getDependentFiles(std::vector &result) = 0; + virtual void getDependentFiles(std::vector &resultAppend) = 0; }; /* class IProcessInfo */ diff --git a/code/nel/tools/pipeline/service/database_status.cpp b/code/nel/tools/pipeline/service/database_status.cpp index 50d1dcf0b..071813b55 100644 --- a/code/nel/tools/pipeline/service/database_status.cpp +++ b/code/nel/tools/pipeline/service/database_status.cpp @@ -251,17 +251,18 @@ public: IRunnable *CDatabaseStatus::updateFileStatus(const TFileStatusCallback &callback, const std::string &filePath) { -#if defined(PIPELINE_MASTER) + if (!g_IsMaster) + { + nlerror("Not master, not allowed."); + return NULL; + } + CUpdateFileStatus *ufs = new CUpdateFileStatus(); ufs->StatusMutex = &m_StatusMutex; ufs->FilePath = unMacroPath(filePath); ufs->Callback = callback; CAsyncFileManager::getInstance().addLoadTask(ufs); return ufs; -#else - nlerror("Not master, not allowed."); - return NULL; -#endif } // ****************************************************************** @@ -386,6 +387,11 @@ void updateDirectoryStatus(CDatabaseStatus* ds, CDatabaseStatusUpdater &updater, void CDatabaseStatus::updateDatabaseStatus(const CCallback &callback) { + if (!g_IsMaster) + { + nlerror("Not master, not allowed."); + } + std::vector paths; paths.push_back(g_DatabaseDirectory); updateDatabaseStatus(callback, paths, false, true); @@ -393,6 +399,11 @@ void CDatabaseStatus::updateDatabaseStatus(const CCallback &callback) void CDatabaseStatus::updateDatabaseStatus(const CCallback &callback, const std::vector &paths, bool wait, bool recurse) { + if (!g_IsMaster) + { + nlerror("Not master, not allowed."); + } + CDatabaseStatusUpdater *updater = new CDatabaseStatusUpdater(); updater->Callback = callback; updater->FilesRequested = 0; diff --git a/code/nel/tools/pipeline/service/module_pipeline_master.cpp b/code/nel/tools/pipeline/service/module_pipeline_master.cpp index a43f2e7d2..30de28ea5 100644 --- a/code/nel/tools/pipeline/service/module_pipeline_master.cpp +++ b/code/nel/tools/pipeline/service/module_pipeline_master.cpp @@ -37,6 +37,8 @@ // Project includes #include "module_pipeline_slave_itf.h" +#include "pipeline_service.h" +#include "database_status.h" using namespace std; using namespace NLMISC; @@ -57,12 +59,19 @@ class CModulePipelineMaster : struct CSlave { public: - CSlave(IModuleProxy *moduleProxy) - : Proxy(moduleProxy), - ActiveTaskId(0) { } - + CSlave(CModulePipelineMaster *master, IModuleProxy *moduleProxy) + : Master(master), + Proxy(moduleProxy), + ActiveTaskId(0) { } + CModulePipelineMaster *Master; CModulePipelineSlaveProxy Proxy; + std::vector Vector; uint32 ActiveTaskId; + + void cbUpdateDatabaseStatus() + { + + } }; protected: @@ -73,11 +82,13 @@ protected: public: CModulePipelineMaster() { - + g_IsMaster = true; } virtual ~CModulePipelineMaster() { + g_IsMaster = false; + m_SlavesMutex.lock(); for (TSlaveMap::iterator it = m_Slaves.begin(), end = m_Slaves.end(); it != end; ++it) @@ -104,7 +115,7 @@ public: m_SlavesMutex.lock(); - CSlave *slave = new CSlave(moduleProxy); + CSlave *slave = new CSlave(this, moduleProxy); m_Slaves[moduleProxy] = slave; m_SlavesMutex.unlock(); @@ -149,6 +160,19 @@ public: // TODO } + virtual void vectorPushString(NLNET::IModuleProxy *sender, const std::string &str) + { + CSlave *slave = m_Slaves[sender]; + slave->Vector.push_back(str); + } + + virtual void updateDatabaseStatusByVector(NLNET::IModuleProxy *sender) + { + CSlave *slave = m_Slaves[sender]; + g_DatabaseStatus->updateDatabaseStatus(CCallback(slave, &CSlave::cbUpdateDatabaseStatus), slave->Vector, false, false); + slave->Vector.clear(); + } + }; /* 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 171c2ccf85f204e80b40e9df3b272f106e200de6..9da26b338d90f5704acdd18ec1a2da436c9d9ecb 100644 GIT binary patch delta 1349 zcmccSFe7h+922cs~ugd2k+gC~Q}=Kt)ujFWe< zrih0DbvXld1Tcg$1T%O5S;0UPf`Gam<;xgS8Il=F81fm4fbyjb#S9rh*%BZxlOc~G zee*=NbVmMApp*+xn+wotpytVc*`3Wx844Iu7!rX>Q-R_jI*}m>h>L-IkO3eOka127 zl?-7BOMnJ4Gj7h|{KJCona%lp{!G|BGC7~GbF!bH-((MdH$v{69M5~(m4KgsUceC| z44Mqq47?0n44e#{lkc*NvvUGH01S)CuLT@E!7OAI420~_00%}MFql$-;i%%BJQ8!aM%sQ}5xz~~|>O6AbwlmW$~o4W<)b55Qk7(_6x9*P-H{>RTV z`5wC%rvif-G;}s{32$}~S7RioyQhf=vb%40+&)Q2=EK)M%RgOGXW6;i4|So>Hk1I(v|#|7C8!2u i+W|2s^?(W-&CQjvjg*AQMqYQ2lY}u-xzc1#1z!O1{3dh& delta 141 zcmbP{cgFv{doVdu!EH`giPKo z(mDBztjcCK;YExOlwAJF**5(S#b5VASZ@G|4%f4W?g|Hv6k{-7o_ Y`GADTT}hE#@Rh7yK+h9ZUlhEj%Nh75*aAiszqlOc~GeezlUh32IU z1q>++i9pd*1{W}$$dCl2i-CNQT96D#rxQaZLm0w5px)`5^#pIRO!gDiA!yM;0Z;j2 zpg}1NRzL`1L7l*$z@P@3$R2^oa)M%;rzndsPF};WGQ^rE)kP(6Be`F62t_v3>n-DlV}qTvkWT=0h7)s3X`l4B9lB95R;G+ NCbNzw%mI^ - + - + + + + + + + + + + + diff --git a/code/nel/tools/pipeline/service/module_pipeline_slave.cpp b/code/nel/tools/pipeline/service/module_pipeline_slave.cpp index 5817d6ec4..09cc7a9ee 100644 --- a/code/nel/tools/pipeline/service/module_pipeline_slave.cpp +++ b/code/nel/tools/pipeline/service/module_pipeline_slave.cpp @@ -104,6 +104,11 @@ public: CModulePipelineMasterProxy master(sender); master.slaveRefusedBuildTask(this, taskId); } + + virtual void masterUpdatedDatabaseStatus(NLNET::IModuleProxy *sender) + { + + } }; /* class CModulePipelineSlave */ diff --git a/code/nel/tools/pipeline/service/module_pipeline_slave_itf.cpp b/code/nel/tools/pipeline/service/module_pipeline_slave_itf.cpp index e26d319d00e011ad2ada02006d5114f189f64904..829328a04bd804b83b1b69946f1a4b148681daf2 100644 GIT binary patch delta 663 zcmca+u*+?O1RJY6gFi$3W=Xb0#>rb)Q$&LpTp8jSLKy-WT!6F-gAz480WN{fGlX9- mLF2Ab>^$RUDG>{Djm#A_pZtJZXmXU8nk24>P@2ps;R^s6%8^b0 delta 54 zcmdnxcFkae1RG=UW?8mG#?1ws*I0mTZ$4wD%?(16SSQyBux&mdlfncP)RaHZ$X3h1 I%fQ6|0O92itpET3 diff --git a/code/nel/tools/pipeline/service/module_pipeline_slave_itf.h b/code/nel/tools/pipeline/service/module_pipeline_slave_itf.h index 6d031f5b28b4435e77468751202166c463998b5c..05a534a5b09d28a4033884cf369c4703731d2c6e 100644 GIT binary patch delta 285 zcmccR`p##Ao518QelF8ohD3&9h7yKUh9ZVgh608ZARoj_VQ>Mn5*d=fDpDDOf#M*! zQikHq>-n`=Czr{KOx`0bL7owlFG}i8mJ#9Ed`4ssH_#{(RGxf6o@aA|f(p~- W9t9CbbFzHIpfQ - + @@ -12,6 +12,10 @@ + + + + diff --git a/code/nel/tools/pipeline/service/pipeline_service.cpp b/code/nel/tools/pipeline/service/pipeline_service.cpp index b1027842c..c7470bca3 100644 --- a/code/nel/tools/pipeline/service/pipeline_service.cpp +++ b/code/nel/tools/pipeline/service/pipeline_service.cpp @@ -65,9 +65,11 @@ namespace PIPELINE { std::string g_DatabaseDirectory; std::string g_PipelineDirectory; bool g_IsExiting = false; +bool g_IsMaster = false; NLGEORGES::UFormLoader *g_FormLoader = NULL; -CPipelineWorkspace *g_PipelineWorkspace; +CPipelineWorkspace *g_PipelineWorkspace = NULL; +CDatabaseStatus *g_DatabaseStatus = NULL; std::string unMacroPath(const std::string &path) { @@ -112,7 +114,6 @@ enum EState /// Data CTaskManager *s_TaskManager = NULL; -CDatabaseStatus *s_DatabaseStatus = NULL; CPipelineInterfaceImpl *s_PipelineInterfaceImpl = NULL; CPipelineProcessImpl *s_PipelineProcessImpl = NULL; @@ -253,7 +254,7 @@ class CUpdateDatabaseStatus : public IRunnable virtual void run() { - s_DatabaseStatus->updateDatabaseStatus(CCallback(this, &CUpdateDatabaseStatus::databaseStatusUpdated)); + g_DatabaseStatus->updateDatabaseStatus(CCallback(this, &CUpdateDatabaseStatus::databaseStatusUpdated)); } }; CUpdateDatabaseStatus s_UpdateDatabaseStatus; @@ -315,7 +316,7 @@ public: initSheets(); - s_DatabaseStatus = new CDatabaseStatus(); + g_DatabaseStatus = new CDatabaseStatus(); s_PipelineInterfaceImpl = new CPipelineInterfaceImpl(); s_PipelineProcessImpl = new CPipelineProcessImpl(NULL); // Create a singleton impl for global usage without running project for test purposes. @@ -364,8 +365,8 @@ public: delete s_PipelineInterfaceImpl; s_PipelineInterfaceImpl = NULL; - delete s_DatabaseStatus; - s_DatabaseStatus = NULL; + delete g_DatabaseStatus; + g_DatabaseStatus = NULL; releaseSheets(); diff --git a/code/nel/tools/pipeline/service/pipeline_service.h b/code/nel/tools/pipeline/service/pipeline_service.h index 2d018132d..8e6f4e885 100644 --- a/code/nel/tools/pipeline/service/pipeline_service.h +++ b/code/nel/tools/pipeline/service/pipeline_service.h @@ -46,21 +46,12 @@ namespace NLGEORGES { namespace PIPELINE { class CPipelineWorkspace; - -/* -#if defined(PIPELINE_MASTER) -# if defined(PIPELINE_SLAVE) -# error Cannot define both PIPELINE_MASTER and PIPELINE_SLAVE at the same time. -# endif -#elif defined (PIPELINE_SLAVE) -#else -# error Must define either PIPELINE_MASTER or PIPELINE_SLAVE. Create 2 projects that output pipeline_service_master and pipeline_service_slave executables. -#endif -*/ + class CDatabaseStatus; #define PIPELINE_MASTER extern bool g_IsExiting; +extern bool g_IsMaster; extern std::string g_DatabaseDirectory; extern std::string g_PipelineDirectory; @@ -81,6 +72,7 @@ void endedRunnableTask(); extern NLGEORGES::UFormLoader *g_FormLoader; extern CPipelineWorkspace *g_PipelineWorkspace; +extern CDatabaseStatus *g_DatabaseStatus; } /* namespace PIPELINE */