Changed: #1440 Some debugging and info display

--HG--
branch : build_pipeline_v3
hg/feature/build_pipeline_v3
kaetemi 13 years ago
parent 9e39a5ffef
commit 4d47d78eae

@ -61,7 +61,7 @@ DisplayedVariables =
{ {
"Status|pipelineServiceState", "FileQueue|asyncFileQueueCount", "Status|pipelineServiceState", "FileQueue|asyncFileQueueCount",
"", "InfoFlags|infoFlags", "", "InfoFlags|infoFlags",
"", "@Reload Sheets|reloadSheets", "@Busy Test|busyTestState" , "", "@Reload Sheets|reloadSheets", "@Busy Test|busyTestState" , "@Plug Slave|slave.plug gw", "@Unplug Slave|slave.unplug gw",
}; };
DontUseAES = 1; DontUseAES = 1;

@ -23,5 +23,5 @@ StartCommands +=
DisplayedVariables += DisplayedVariables +=
{ {
"", "@Master Reload Sheets|master.reloadSheets", "@Status Update All|updateDatabaseStatus", "", "@Build|master.build", "@Verify|master.build --verifyOnly", "@Abort|master.abort", "@Master Reload Sheets|master.reloadSheets", "@Status Update All|updateDatabaseStatus", "@Plug Master|master.plug gw", "@Unplug Master|master.unplug gw",
}; };

@ -41,6 +41,7 @@
#include "pipeline_service.h" #include "pipeline_service.h"
#include "database_status.h" #include "database_status.h"
#include "build_task_queue.h" #include "build_task_queue.h"
#include "pipeline_workspace.h"
using namespace std; using namespace std;
using namespace NLMISC; using namespace NLMISC;
@ -126,6 +127,9 @@ public:
virtual ~CModulePipelineMaster() virtual ~CModulePipelineMaster()
{ {
if (m_BuildWorking)
this->abort();
g_IsMaster = false; g_IsMaster = false;
m_SlavesMutex.lock(); m_SlavesMutex.lock();
@ -158,6 +162,8 @@ public:
m_Slaves[moduleProxy] = slave; m_Slaves[moduleProxy] = slave;
m_SlavesMutex.unlock(); m_SlavesMutex.unlock();
slave->Proxy.submitToMaster(this);
} }
} }
@ -222,6 +228,13 @@ public:
it->second->ActiveTaskId = taskInfo->Id.Global; it->second->ActiveTaskId = taskInfo->Id.Global;
it->second->Proxy.startBuildTask(this, taskInfo->ProjectName, taskInfo->ProcessPluginId); it->second->Proxy.startBuildTask(this, taskInfo->ProjectName, taskInfo->ProcessPluginId);
// the slave may either reject; or not answer until it's finished with this task // the slave may either reject; or not answer until it's finished with this task
// Display information to user terminals
{
// TODO_TERMINAL_SYNC
CProcessPluginInfo pluginInfo;
g_PipelineWorkspace->getProcessPlugin(pluginInfo, taskInfo->ProcessPluginId);
nlinfo("Dispatching task '%i' ('%s': '%s') to slave '%s'", taskInfo->Id.Global, taskInfo->ProjectName.c_str(), pluginInfo.Handler.c_str(), it->second->Proxy.getModuleProxy()->getModuleName().c_str());
}
} }
} }
} }
@ -243,7 +256,7 @@ public:
} }
m_SlavesMutex.unlock(); m_SlavesMutex.unlock();
PIPELINE::endedBuildReady(); PIPELINE::endedBuildReadyMaster();
} }
} }
} }
@ -262,7 +275,10 @@ public:
virtual void slaveRefusedBuildTask(NLNET::IModuleProxy *sender) virtual void slaveRefusedBuildTask(NLNET::IModuleProxy *sender)
{ {
// TODO // TODO
//m_SlavesMutex.lock();
CSlave *slave = m_Slaves[sender]; CSlave *slave = m_Slaves[sender];
if (slave == NULL) { nlerror("Received 'slaveRefusedBuildTask' from unknown slave at '%s'", sender->getModuleName().c_str()); m_Slaves.erase(sender); /*m_SlavesMutex.unlock();*/ return; }
//m_SlavesMutex.unlock();
m_BuildTaskQueue.rejectedTask(slave->ActiveTaskId); m_BuildTaskQueue.rejectedTask(slave->ActiveTaskId);
slave->ActiveTaskId = 0; slave->ActiveTaskId = 0;
--slave->SaneBehaviour; --slave->SaneBehaviour;
@ -272,20 +288,29 @@ public:
virtual void slaveReloadedSheets(NLNET::IModuleProxy *sender) virtual void slaveReloadedSheets(NLNET::IModuleProxy *sender)
{ {
//m_SlavesMutex.lock();
CSlave *slave = m_Slaves[sender]; CSlave *slave = m_Slaves[sender];
if (slave == NULL) { nlerror("Received 'slaveReloadedSheets' from unknown slave at '%s'", sender->getModuleName().c_str()); m_Slaves.erase(sender); /*m_SlavesMutex.unlock();*/ return; }
//m_SlavesMutex.unlock();
slave->SheetsOk = true; slave->SheetsOk = true;
CInfoFlags::getInstance()->removeFlag(PIPELINE_INFO_MASTER_RELOAD_SHEETS); CInfoFlags::getInstance()->removeFlag(PIPELINE_INFO_MASTER_RELOAD_SHEETS);
} }
virtual void slaveBuildReadySuccess(NLNET::IModuleProxy *sender) virtual void slaveBuildReadySuccess(NLNET::IModuleProxy *sender)
{ {
//m_SlavesMutex.lock();
CSlave *slave = m_Slaves[sender]; CSlave *slave = m_Slaves[sender];
if (slave == NULL) { nlerror("Received 'slaveBuildReadySuccess' from unknown slave at '%s'", sender->getModuleName().c_str()); m_Slaves.erase(sender); /*m_SlavesMutex.unlock();*/ return; }
//m_SlavesMutex.unlock();
slave->BuildReadyState = 2; slave->BuildReadyState = 2;
} }
virtual void slaveBuildReadyFail(NLNET::IModuleProxy *sender) virtual void slaveBuildReadyFail(NLNET::IModuleProxy *sender)
{ {
//m_SlavesMutex.lock();
CSlave *slave = m_Slaves[sender]; CSlave *slave = m_Slaves[sender];
if (slave == NULL) { nlerror("Received 'slaveBuildReadyFail' from unknown slave at '%s'", sender->getModuleName().c_str()); m_Slaves.erase(sender); /*m_SlavesMutex.unlock();*/ return; }
//m_SlavesMutex.unlock();
slave->BuildReadyState = 0; slave->BuildReadyState = 0;
--slave->SaneBehaviour; --slave->SaneBehaviour;
CInfoFlags::getInstance()->addFlag(PIPELINE_INFO_SLAVE_REJECTED); CInfoFlags::getInstance()->addFlag(PIPELINE_INFO_SLAVE_REJECTED);
@ -293,13 +318,19 @@ public:
virtual void vectorPushString(NLNET::IModuleProxy *sender, const std::string &str) virtual void vectorPushString(NLNET::IModuleProxy *sender, const std::string &str)
{ {
//m_SlavesMutex.lock();
CSlave *slave = m_Slaves[sender]; CSlave *slave = m_Slaves[sender];
if (slave == NULL) { nlerror("Received 'vectorPushString' from unknown slave at '%s'", sender->getModuleName().c_str()); m_Slaves.erase(sender); /*m_SlavesMutex.unlock();*/ return; }
//m_SlavesMutex.unlock();
slave->Vector.push_back(str); slave->Vector.push_back(str);
} }
virtual void updateDatabaseStatusByVector(NLNET::IModuleProxy *sender) virtual void updateDatabaseStatusByVector(NLNET::IModuleProxy *sender)
{ {
//m_SlavesMutex.lock();
CSlave *slave = m_Slaves[sender]; CSlave *slave = m_Slaves[sender];
if (slave == NULL) { nlerror("Received 'updateDatabaseStatusByVector' from unknown slave at '%s'", sender->getModuleName().c_str()); m_Slaves.erase(sender); /*m_SlavesMutex.unlock();*/ return; }
//m_SlavesMutex.unlock();
CInfoFlags::getInstance()->addFlag(PIPELINE_INFO_MASTER_UPDATE_DATABASE_FOR_SLAVE); CInfoFlags::getInstance()->addFlag(PIPELINE_INFO_MASTER_UPDATE_DATABASE_FOR_SLAVE);
bool ok = true; bool ok = true;
@ -325,13 +356,16 @@ public:
void setAvailablePlugins(NLNET::IModuleProxy *sender, const std::vector<uint32> &pluginsAvailable) void setAvailablePlugins(NLNET::IModuleProxy *sender, const std::vector<uint32> &pluginsAvailable)
{ {
//m_SlavesMutex.lock();
CSlave *slave = m_Slaves[sender]; CSlave *slave = m_Slaves[sender];
if (slave == NULL) { nlerror("Received 'setAvailablePlugins' from unknown slave at '%s'", sender->getModuleName().c_str()); m_Slaves.erase(sender); /*m_SlavesMutex.unlock();*/ return; }
//m_SlavesMutex.unlock();
slave->PluginsAvailable = pluginsAvailable; slave->PluginsAvailable = pluginsAvailable;
} }
bool build(bool bypassEros, bool verifyOnly) bool build(bool bypassEros, bool verifyOnly)
{ {
if (PIPELINE::tryBuildReady()) if (PIPELINE::tryBuildReadyMaster())
{ {
m_BuildWorking = true; m_BuildWorking = true;
m_BypassErrors = bypassEros; m_BypassErrors = bypassEros;
@ -345,18 +379,25 @@ public:
bool abort() bool abort()
{ {
m_BuildTaskQueue.abortQueue(); if (m_BuildWorking)
{
m_BuildTaskQueue.abortQueue();
m_SlavesMutex.lock(); m_SlavesMutex.lock();
// Abort all slaves. // Abort all slaves.
for (TSlaveMap::iterator it = m_Slaves.begin(), end = m_Slaves.end(); it != end; ++it) for (TSlaveMap::iterator it = m_Slaves.begin(), end = m_Slaves.end(); it != end; ++it)
{
if (it->second->ActiveTaskId != 0)
it->second->Proxy.abortBuildTask(this);
}
m_SlavesMutex.unlock();
return true;
}
else
{ {
if (it->second->ActiveTaskId != 0) return false;
it->second->Proxy.abortBuildTask(this);
} }
m_SlavesMutex.unlock();
return true;
} }
protected: protected:
@ -429,14 +470,30 @@ protected:
} }
else else
{ {
return build(bypassErrors, verifyOnly); if (build(bypassErrors, verifyOnly))
{
return true;
}
else
{
log.displayNL("Bad command usage");
return false;
}
} }
} }
NLMISC_CLASS_COMMAND_DECL(abort) NLMISC_CLASS_COMMAND_DECL(abort)
{ {
if (args.size() != 0) return false; if (args.size() != 0) return false;
return this->abort(); if (this->abort())
{
return true;
}
else
{
log.displayNL("Bad command usage");
return false;
}
} }
}; /* class CModulePipelineMaster */ }; /* class CModulePipelineMaster */

@ -70,16 +70,20 @@ public:
CModulePipelineMasterProxy *m_Master; CModulePipelineMasterProxy *m_Master;
bool m_TestCommand; bool m_TestCommand;
TRequestState m_ReloadSheetsState; TRequestState m_ReloadSheetsState;
bool m_BuildReadyState;
public: public:
CModulePipelineSlave() : m_Master(NULL), m_TestCommand(false), m_ReloadSheetsState(REQUEST_NONE) CModulePipelineSlave() : m_Master(NULL), m_TestCommand(false), m_ReloadSheetsState(REQUEST_NONE), m_BuildReadyState(false)
{ {
} }
virtual ~CModulePipelineSlave() virtual ~CModulePipelineSlave()
{ {
// TODO: IF MASTER STILL CONNECTED, NOTIFY INSANITY
// TODO: ABORT RUNNING BUILD PROCESS
abortBuildTask(NULL);
leaveBuildReadyState(NULL);
} }
virtual bool initModule(const TParsedCommandLine &initInfo) virtual bool initModule(const TParsedCommandLine &initInfo)
@ -98,12 +102,16 @@ public:
nlassert(m_Master == NULL); nlassert(m_Master == NULL);
m_Master = new CModulePipelineMasterProxy(moduleProxy); m_Master = new CModulePipelineMasterProxy(moduleProxy);
// TODO: AUTHENTICATE OR GATEWAY SECURITY?
sendMasterAvailablePlugins();
} }
} }
virtual void submitToMaster(NLNET::IModuleProxy *sender)
{
// TODO: AUTHENTICATE OR GATEWAY SECURITY?
CModulePipelineMasterProxy master(sender);
sendMasterAvailablePlugins(&master);
}
virtual void onModuleDown(IModuleProxy *moduleProxy) virtual void onModuleDown(IModuleProxy *moduleProxy)
{ {
if (moduleProxy->getModuleClassName() == "ModulePipelineMaster") if (moduleProxy->getModuleClassName() == "ModulePipelineMaster")
@ -113,6 +121,8 @@ public:
nlassert(m_Master->getModuleProxy() == moduleProxy); nlassert(m_Master->getModuleProxy() == moduleProxy);
// TODO: ABORT RUNNING BUILD PROCESS // TODO: ABORT RUNNING BUILD PROCESS
abortBuildTask(NULL);
leaveBuildReadyState(NULL); // leave state if building
delete m_Master; delete m_Master;
m_Master = NULL; m_Master = NULL;
@ -133,7 +143,7 @@ public:
if (PIPELINE::isServiceStateIdle()) if (PIPELINE::isServiceStateIdle())
{ {
m_ReloadSheetsState = REQUEST_NONE; m_ReloadSheetsState = REQUEST_NONE;
sendMasterAvailablePlugins(); sendMasterAvailablePlugins(m_Master);
m_Master->slaveReloadedSheets(this); m_Master->slaveReloadedSheets(this);
CInfoFlags::getInstance()->removeFlag(PIPELINE_INFO_SLAVE_RELOAD_SHEETS); CInfoFlags::getInstance()->removeFlag(PIPELINE_INFO_SLAVE_RELOAD_SHEETS);
} }
@ -175,8 +185,9 @@ public:
virtual void enterBuildReadyState(NLNET::IModuleProxy *sender) virtual void enterBuildReadyState(NLNET::IModuleProxy *sender)
{ {
if (PIPELINE::tryBuildReady()) if (!m_BuildReadyState && PIPELINE::tryBuildReady())
{ {
m_BuildReadyState = true;
m_Master->slaveBuildReadySuccess(this); m_Master->slaveBuildReadySuccess(this);
} }
else else
@ -187,14 +198,18 @@ public:
virtual void leaveBuildReadyState(NLNET::IModuleProxy *sender) virtual void leaveBuildReadyState(NLNET::IModuleProxy *sender)
{ {
PIPELINE::endedBuildReady(); if (m_BuildReadyState)
{
m_BuildReadyState = false;
PIPELINE::endedBuildReady();
}
} }
void sendMasterAvailablePlugins() void sendMasterAvailablePlugins(CModulePipelineMasterProxy *master)
{ {
std::vector<uint32> availablePlugins; std::vector<uint32> availablePlugins;
g_PipelineWorkspace->listAvailablePlugins(availablePlugins); g_PipelineWorkspace->listAvailablePlugins(availablePlugins);
m_Master->setAvailablePlugins(this, availablePlugins); master->setAvailablePlugins(this, availablePlugins);
} }
protected: protected:

@ -4,6 +4,10 @@
<module_interface name="CModulePipelineSlave"> <module_interface name="CModulePipelineSlave">
<method name="submitToMaster" msg="M_HELLO">
<doc line=""/>
</method>
<method name="startBuildTask" msg="GO_BT"> <method name="startBuildTask" msg="GO_BT">
<doc line=""/> <doc line=""/>

@ -261,6 +261,36 @@ void endedDirectTask()
endedRunnableTask(STATE_DIRECT_CODE); endedRunnableTask(STATE_DIRECT_CODE);
} }
bool tryBuildReadyMaster()
{
bool result = false;
s_StateMutex.enter();
result = (s_State == STATE_IDLE);
if (result)
{
s_State = STATE_BUILD_READY;
++s_BuildReadyRecursive;
}
s_StateMutex.leave();
if (!result) return false;
nlassert((s_State == STATE_BUILD_READY) && (s_BuildReadyRecursive > 0));
return true;
}
void endedBuildReadyMaster()
{
nlassert((s_State == STATE_BUILD_READY) && (s_BuildReadyRecursive > 0));
s_StateMutex.enter();
--s_BuildReadyRecursive;
s_State = STATE_IDLE;
s_StateMutex.leave();
nlassert(s_BuildReadyRecursive == 0);
}
bool tryBuildReady() bool tryBuildReady()
{ {
bool result = false; bool result = false;
@ -275,14 +305,14 @@ bool tryBuildReady()
s_StateMutex.leave(); s_StateMutex.leave();
if (!result) return false; if (!result) return false;
nlassert(s_State == STATE_BUILD_READY && s_BuildReadyRecursive > 0); nlassert((s_State == STATE_BUILD_READY) && (s_BuildReadyRecursive > 0));
return true; return true;
} }
void endedBuildReady() void endedBuildReady()
{ {
nlassert(s_State == STATE_BUILD_READY && s_BuildReadyRecursive > 0); nlassert((s_State == STATE_BUILD_READY) && (s_BuildReadyRecursive > 0));
s_StateMutex.enter(); s_StateMutex.enter();
--s_BuildReadyRecursive; --s_BuildReadyRecursive;

@ -76,6 +76,9 @@ void endedDirectTask();
bool tryBuildReady(); bool tryBuildReady();
void endedBuildReady(); void endedBuildReady();
bool tryBuildReadyMaster();
void endedBuildReadyMaster();
bool tryBuildProcess(const std::string &stateName); bool tryBuildProcess(const std::string &stateName);
void endedBuildProcess(); void endedBuildProcess();

@ -12,9 +12,7 @@
<STRUCT> <STRUCT>
<ATOM Name="Description" Value="Builds interface textures"/> <ATOM Name="Description" Value="Builds interface textures"/>
<ATOM Name="Process" Value="Interface"/> <ATOM Name="Process" Value="Interface"/>
<ARRAY Name="ProcessDependencies">
<ATOM Value="Dummy"/>
</ARRAY>
<ATOM Name="HandlerType" Value="RegisteredClass"/> <ATOM Name="HandlerType" Value="RegisteredClass"/>
<ATOM Name="Handler" Value="CProcessInterface"/> <ATOM Name="Handler" Value="CProcessInterface"/>
<ATOM Name="Info" Value="CProcessInterfaceInfo"/> <ATOM Name="Info" Value="CProcessInterfaceInfo"/>

Loading…
Cancel
Save