diff --git a/code/nel/tools/pipeline/plugin_library/pipeline_process.h b/code/nel/tools/pipeline/plugin_library/pipeline_process.h index 61cb600fe..1a8c7b4c6 100644 --- a/code/nel/tools/pipeline/plugin_library/pipeline_process.h +++ b/code/nel/tools/pipeline/plugin_library/pipeline_process.h @@ -39,6 +39,27 @@ namespace PIPELINE { +enum TProcessResult +{ + /// Invalid state. + FINISH_NOT = 0, + + /// Successfully built. + FINISH_SUCCESS = 1, + + /// Built successfully with warnings. + FINISH_WARNING = 2, + + /// Build failed. + FINISH_ERROR = 3, + + /// Task aborted by slave. For internal usage only. + FINISH_ABORT = 4, + + /// Task rejected by slave. For internal usage only. + FINISH_REJECT = 5, +}; + /** * \brief IPipelineProcess * \date 2012-03-03 09:22GMT diff --git a/code/nel/tools/pipeline/service/metadata_storage.h b/code/nel/tools/pipeline/service/metadata_storage.h index b090075f9..c64d2a0ed 100644 --- a/code/nel/tools/pipeline/service/metadata_storage.h +++ b/code/nel/tools/pipeline/service/metadata_storage.h @@ -48,11 +48,11 @@ namespace PIPELINE { enum TFileState { - Unknown = 0, - Success = 1, - Warning = 2, - Error = 3, - Removal = 4, + STATE_UNKNOWN = 0, + STATE_SUCCESS = 1, + STATE_WARNING = 2, + STATE_ERROR = 3, + STATE_REMOVAL = 4, }; /// Suffix for metafiles that contain the CRC32 etc diff --git a/code/nel/tools/pipeline/service/module_pipeline_master.cpp b/code/nel/tools/pipeline/service/module_pipeline_master.cpp index cee249230..c4567012f 100644 --- a/code/nel/tools/pipeline/service/module_pipeline_master.cpp +++ b/code/nel/tools/pipeline/service/module_pipeline_master.cpp @@ -44,6 +44,7 @@ #include "database_status.h" #include "build_task_queue.h" #include "pipeline_workspace.h" +#include "../plugin_library/pipeline_process.h" using namespace std; using namespace NLMISC; @@ -425,43 +426,62 @@ public: /////////////////////////////////////////////////////////////////// /// When the slave task finishes, with or without error - virtual void slaveFinishedBuildTask(NLNET::IModuleProxy *sender, uint8 errorLevel) + virtual void slaveFinishedBuildTask(NLNET::IModuleProxy *sender, uint8 errorLevel, const std::string &errorMessage) { - // TODO + //m_SlavesMutex.lock(); + TSlaveMap::iterator slaveIt = m_Slaves.find(sender); + if (slaveIt == m_Slaves.end()) { nlerror("Received 'slaveFinishedBuildTask' from unknown slave at '%s'", sender->getModuleName().c_str()); m_Slaves.erase(sender); /*m_SlavesMutex.unlock();*/ return; } + CSlave *slave = slaveIt->second; + //m_SlavesMutex.unlock(); + + switch ((TProcessResult)errorLevel) + { + case FINISH_WARNING: + case FINISH_SUCCESS: + m_BuildTaskQueue.successTask(slave->ActiveTaskId); + break; + case FINISH_ERROR: + m_BuildTaskQueue.erroredTask(slave->ActiveTaskId); + break; + default: + nlerror("Slave returned bad error level"); + break; + } + + notifyTerminalTaskState(slave->ActiveTaskId, (TProcessResult)errorLevel, errorMessage); + + slave->ActiveTaskId = 0; } /// When the user aborts slave-side, when slave-side exits, etc (assume the master requested abort or the slave crashed) virtual void slaveAbortedBuildTask(NLNET::IModuleProxy *sender) { - // TODO //m_SlavesMutex.lock(); TSlaveMap::iterator slaveIt = m_Slaves.find(sender); if (slaveIt == m_Slaves.end()) { nlerror("Received 'slaveAbortedBuildTask' from unknown slave at '%s'", sender->getModuleName().c_str()); m_Slaves.erase(sender); /*m_SlavesMutex.unlock();*/ return; } CSlave *slave = slaveIt->second; //m_SlavesMutex.unlock(); + m_BuildTaskQueue.abortedTask(slave->ActiveTaskId); + notifyTerminalTaskState(slave->ActiveTaskId, FINISH_ABORT, "The task has been aborted"); slave->ActiveTaskId = 0; - // --slave->SaneBehaviour; // legal behaviour - // slave->TimeOutStamp = NLMISC::CTime::getSecondsSince1970() + 30; // timeout for 30 seconds on this slave // no timeout - // CInfoFlags::getInstance()->addFlag(PIPELINE_INFO_SLAVE_ABORTED); // don't keep a count - // TODO } // in fact slaves are not allowed to refuse tasks, but they may do this if the user is toying around with the slave service virtual void slaveRefusedBuildTask(NLNET::IModuleProxy *sender) { - // TODO //m_SlavesMutex.lock(); TSlaveMap::iterator slaveIt = m_Slaves.find(sender); if (slaveIt == m_Slaves.end()) { nlerror("Received 'slaveRefusedBuildTask' from unknown slave at '%s'", sender->getModuleName().c_str()); m_Slaves.erase(sender); /*m_SlavesMutex.unlock();*/ return; } CSlave *slave = slaveIt->second; //m_SlavesMutex.unlock(); + m_BuildTaskQueue.rejectedTask(slave->ActiveTaskId); + notifyTerminalTaskState(slave->ActiveTaskId, FINISH_REJECT, "The slave service has rejected the task. This is a programming error"); slave->ActiveTaskId = 0; --slave->SaneBehaviour; slave->TimeOutStamp = NLMISC::CTime::getSecondsSince1970() + 3; // timeout for 3 seconds on this slave CInfoFlags::getInstance()->addFlag(PIPELINE_INFO_SLAVE_REJECTED); - // TODO } virtual void slaveReloadedSheets(NLNET::IModuleProxy *sender) @@ -512,6 +532,16 @@ public: /////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////// + void notifyTerminalTaskState(uint32 taskId, TProcessResult errorLevel, const std::string &errorMessage) + { + nlinfo("taskId: %i, errorLevel: %i, errorMessage: %s", taskId, (uint32)errorLevel, errorMessage.c_str()); + // TODO NOTIFY TERMINAL (send errorlevel as uint8 as usual) + } + + /////////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////// + class CUpdateDatabaseStatusSlaveCallback : public CDelayedCallback { public: 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 db7a9ddbf..35cfa69aa 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 ff8a88494..cbdf02b64 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 48413b6c8..1a1f7a2ff 100644 --- a/code/nel/tools/pipeline/service/module_pipeline_master_itf.xml +++ b/code/nel/tools/pipeline/service/module_pipeline_master_itf.xml @@ -7,7 +7,8 @@ - + + @@ -33,7 +34,7 @@ - + diff --git a/code/nel/tools/pipeline/service/module_pipeline_slave.cpp b/code/nel/tools/pipeline/service/module_pipeline_slave.cpp index 16a1749b9..0edc054b5 100644 --- a/code/nel/tools/pipeline/service/module_pipeline_slave.cpp +++ b/code/nel/tools/pipeline/service/module_pipeline_slave.cpp @@ -251,6 +251,7 @@ public: } if (bothReady) { + m_SlaveTaskState = SOMEWHERE_INBETWEEN; if (m_AbortRequested) { nlinfo("Aborted slave task after status update"); @@ -259,15 +260,17 @@ public: else { nlinfo("Slave task: Status update done"); - m_SlaveTaskState = SOMEWHERE_INBETWEEN; // Done with the status updating, now do something fancey // ... TODO ... // not implemented, so abort. - abortBuildTask(NULL); + // abortBuildTask(NULL); } } } break; + default: + finishedTask(FINISH_ERROR, "Task got lost somewhere inbetween the code of the slave service. This is a programming error. Implementation may be incomplete."); + break; } // Nothing to do here, move along @@ -377,6 +380,16 @@ public: CInfoFlags::getInstance()->removeFlag(PIPELINE_INFO_BUILD_TASK); } + void finishedTask(TProcessResult errorLevel, const std::string &errorMessage) + { + m_ActiveProject = NULL; + m_ActiveProcess = NULL; + m_SlaveTaskState = IDLE_WAIT_MASTER; + if (m_Master) // else was disconnect + m_Master->slaveFinishedBuildTask(this, (uint8)errorLevel, errorMessage); + CInfoFlags::getInstance()->removeFlag(PIPELINE_INFO_BUILD_TASK); + } + /// Master or user request to abort. virtual void abortBuildTask(NLNET::IModuleProxy *sender) { 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 f74930dfd..529c8cd0a 100644 Binary files a/code/nel/tools/pipeline/service/module_pipeline_slave_itf.cpp and b/code/nel/tools/pipeline/service/module_pipeline_slave_itf.cpp differ 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 41a089418..fd50c8fe9 100644 Binary files a/code/nel/tools/pipeline/service/module_pipeline_slave_itf.h and b/code/nel/tools/pipeline/service/module_pipeline_slave_itf.h differ diff --git a/code/nel/tools/pipeline/service/module_pipeline_slave_itf.xml b/code/nel/tools/pipeline/service/module_pipeline_slave_itf.xml index 9ad58a4cb..53f3572be 100644 --- a/code/nel/tools/pipeline/service/module_pipeline_slave_itf.xml +++ b/code/nel/tools/pipeline/service/module_pipeline_slave_itf.xml @@ -24,6 +24,7 @@ +