Added: #1440 Slave request to master for ensuring database status is up to date for given paths

--HG--
branch : build_pipeline_v3
hg/feature/build_pipeline_v3
kaetemi 13 years ago
parent 809cbe6c5a
commit 98c9ffff88

@ -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<std::string> &result) = 0;
virtual void getDependentDirectories(std::vector<std::string> &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<std::string> &result) = 0;
virtual void getDependentFiles(std::vector<std::string> &resultAppend) = 0;
}; /* class IProcessInfo */

@ -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<void> &callback)
{
if (!g_IsMaster)
{
nlerror("Not master, not allowed.");
}
std::vector<std::string> paths;
paths.push_back(g_DatabaseDirectory);
updateDatabaseStatus(callback, paths, false, true);
@ -393,6 +399,11 @@ void CDatabaseStatus::updateDatabaseStatus(const CCallback<void> &callback)
void CDatabaseStatus::updateDatabaseStatus(const CCallback<void> &callback, const std::vector<std::string> &paths, bool wait, bool recurse)
{
if (!g_IsMaster)
{
nlerror("Not master, not allowed.");
}
CDatabaseStatusUpdater *updater = new CDatabaseStatusUpdater();
updater->Callback = callback;
updater->FilesRequested = 0;

@ -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<std::string> 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<void>(slave, &CSlave::cbUpdateDatabaseStatus), slave->Vector, false, false);
slave->Vector.clear();
}
}; /* class CModulePipelineMaster */
void module_pipeline_master_forceLink() { }

@ -4,18 +4,28 @@
<module_interface name="CModulePipelineMaster">
<method name="slaveFinishedBuildTask" msg="SFBT">
<method name="slaveFinishedBuildTask" msg="RE_BT_OK">
<doc line=""/>
<param type="uint32" name="taskId" />
</method>
<method name="slaveRefusedBuildTask" msg="SRBT">
<method name="slaveRefusedBuildTask" msg="RE_BT_FAIL">
<doc line=""/>
<param type="uint32" name="taskId" />
</method>
<method name="vectorPushString" msg="VEC_PUSH_STR">
<doc line=""/>
<param type="std::string" name="str" byref="true"/>
</method>
<method name="updateDatabaseStatusByVector" msg="UPD_DB_ST">
<doc line=""/>
</method>
</module_interface>
</namespace>

@ -104,6 +104,11 @@ public:
CModulePipelineMasterProxy master(sender);
master.slaveRefusedBuildTask(this, taskId);
}
virtual void masterUpdatedDatabaseStatus(NLNET::IModuleProxy *sender)
{
}
}; /* class CModulePipelineSlave */

@ -4,7 +4,7 @@
<module_interface name="CModulePipelineSlave">
<method name="startBuildTask" msg="SBT">
<method name="startBuildTask" msg="GO_BT">
<doc line=""/>
<param type="uint32" name="taskId" />
@ -12,6 +12,10 @@
<param type="std::string" name="processHandler" byref="true"/>
</method>
<method name="masterUpdatedDatabaseStatus" msg="RE_UPD_DB_ST">
<doc line=""/>
</method>
</module_interface>
</namespace>

@ -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<void>(this, &CUpdateDatabaseStatus::databaseStatusUpdated));
g_DatabaseStatus->updateDatabaseStatus(CCallback<void>(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();

@ -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 */

Loading…
Cancel
Save