Added: #1440 Build task finished result handling

--HG--
branch : build_pipeline_v3
hg/feature/build_pipeline_v3
kaetemi 13 years ago
parent 11038a8832
commit 70c7dd27cd

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

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

@ -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:

@ -8,6 +8,7 @@
<doc line=""/>
<param type="uint8" name="errorLevel" />
<param type="std::string" name="errorMessage" byref="true" />
</method>
<method name="slaveAbortedBuildTask" msg="RE_BT_ABORTED">

@ -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)
{

@ -24,6 +24,7 @@
</method>
<method name="reloadSheets" msg="RELOAD_SHEETS">
<doc line=""/>
</method>
<method name="enterBuildReadyState" msg="BRT_ENTER">

Loading…
Cancel
Save