|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "tfarmtask.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// TnzBase includes
|
|
Toshihiro Shimizu |
890ddd |
#include "toutputproperties.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// TnzCore includes
|
|
Toshihiro Shimizu |
890ddd |
#include "tconvert.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "texception.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tstream.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tsystem.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tutil.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// QT includes
|
|
Toshihiro Shimizu |
890ddd |
#include <qstringlist></qstringlist>
|
|
Toshihiro Shimizu |
890ddd |
#include <qsettings></qsettings>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// MACOSX includes
|
|
Shinya Kitaoka |
d4642c |
#ifdef _WIN32
|
|
Shinya Kitaoka |
d4642c |
#include <winsock.h></winsock.h>
|
|
Shinya Kitaoka |
d4642c |
#else
|
|
Toshihiro Shimizu |
890ddd |
#include <netdb.h> // gethostbyname</netdb.h>
|
|
Toshihiro Shimizu |
890ddd |
#include <arpa inet.h=""> // inet_ntoa</arpa>
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//*************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// TFarmTask::Dependencies implementation
|
|
Toshihiro Shimizu |
890ddd |
//*************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class TFarmTask::Dependencies::Data
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
Data() : m_tasks() {}
|
|
Toshihiro Shimizu |
890ddd |
~Data() {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
3bfa54 |
std::vector<tfarmtask::id> m_tasks;</tfarmtask::id>
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TFarmTask::Dependencies::Dependencies() : m_data(new Data) {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TFarmTask::Dependencies::Dependencies(const Dependencies &rhs) : m_data(new Data)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
m_data->m_tasks = rhs.m_data->m_tasks;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TFarmTask::Dependencies::~Dependencies() { delete m_data; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TFarmTask::Dependencies &TFarmTask::Dependencies::operator=(const Dependencies &rhs)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (this != &rhs) {
|
|
Toshihiro Shimizu |
890ddd |
m_data->m_tasks = rhs.m_data->m_tasks;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
return *this;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool TFarmTask::Dependencies::operator==(const Dependencies &rhs)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return m_data->m_tasks == rhs.m_data->m_tasks;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool TFarmTask::Dependencies::operator!=(const Dependencies &rhs)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return !operator==(rhs);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void TFarmTask::Dependencies::add(const TFarmTask::Id &id)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
m_data->m_tasks.push_back(id);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void TFarmTask::Dependencies::remove(const TFarmTask::Id &id)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
std::vector<tfarmtask::id>::iterator it =</tfarmtask::id>
|
|
Toshihiro Shimizu |
890ddd |
std::find(m_data->m_tasks.begin(), m_data->m_tasks.end(), id);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (it != m_data->m_tasks.end())
|
|
Toshihiro Shimizu |
890ddd |
m_data->m_tasks.erase(it);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
int TFarmTask::Dependencies::getTaskCount() const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return m_data->m_tasks.size();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TFarmTask::Id TFarmTask::Dependencies::getTaskId(int i) const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (i >= 0 && i < (int)m_data->m_tasks.size())
|
|
Toshihiro Shimizu |
890ddd |
return m_data->m_tasks[i];
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
return "";
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//*************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// TFarmTask implementation
|
|
Toshihiro Shimizu |
890ddd |
//*************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TFarmTask::TFarmTask(const QString &name)
|
|
Toshihiro Shimizu |
890ddd |
: m_isComposerTask(), m_name(name), m_priority(), m_status(Suspended), m_successfullSteps(), m_failedSteps(), m_stepCount(), m_from(-1), m_to(-1), m_step(-1), m_shrink(-1), m_chunkSize(-1), m_multimedia(0) // Full render, no multimedia
|
|
Toshihiro Shimizu |
890ddd |
,
|
|
Toshihiro Shimizu |
890ddd |
m_threadsIndex(2) // All threads
|
|
Toshihiro Shimizu |
890ddd |
,
|
|
Toshihiro Shimizu |
890ddd |
m_maxTileSizeIndex(0) // No tiling
|
|
Toshihiro Shimizu |
890ddd |
,
|
|
Toshihiro Shimizu |
890ddd |
m_overwrite(), m_onlyVisible(), m_platform(NoPlatform), m_dependencies()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TFarmTask::TFarmTask(
|
|
Toshihiro Shimizu |
890ddd |
const QString &id, const QString &name, bool composerTask,
|
|
Toshihiro Shimizu |
890ddd |
const QString &user, const QString &host,
|
|
Toshihiro Shimizu |
890ddd |
int stepCount, int priority, const TFilePath &taskFilePath,
|
|
Toshihiro Shimizu |
890ddd |
const TFilePath &outputPath,
|
|
Toshihiro Shimizu |
890ddd |
int from, int to, int step, int shrink, int multimedia, int chunksize,
|
|
Toshihiro Shimizu |
890ddd |
int threadsIndex, int maxTileSizeIndex,
|
|
Toshihiro Shimizu |
890ddd |
OverwriteBehavior overwrite, bool onlyvisible)
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
: m_isComposerTask(composerTask), m_id(id), m_name(name), m_user(user), m_hostName(host), m_priority(priority), m_successfullSteps(0), m_failedSteps(0), m_stepCount(stepCount), m_platform(NoPlatform), m_dependencies(new Dependencies), m_taskFilePath(taskFilePath), m_outputPath(outputPath), m_from(from), m_to(to), m_step(step), m_shrink(shrink), m_multimedia(multimedia), m_threadsIndex(threadsIndex), m_maxTileSizeIndex(maxTileSizeIndex), m_chunkSize(chunksize), m_overwrite(overwrite), m_onlyVisible(onlyvisible), m_status(Suspended), m_callerMachineName()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TFarmTask::TFarmTask(const QString &id, const QString &name, const QString &cmdline, const QString &user, const QString &host, int stepCount, int priority)
|
|
Toshihiro Shimizu |
890ddd |
: m_id(id), m_name(name), m_user(user), m_hostName(host), m_priority(priority), m_successfullSteps(0), m_failedSteps(0), m_stepCount(stepCount), m_platform(NoPlatform), m_dependencies(new Dependencies), m_status(Suspended), m_callerMachineName()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
parseCommandLine(cmdline);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TFarmTask::TFarmTask(const TFarmTask &rhs)
|
|
Toshihiro Shimizu |
890ddd |
: m_dependencies()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
*this = rhs;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TFarmTask &TFarmTask::operator=(const TFarmTask &rhs)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (this != &rhs) {
|
|
Toshihiro Shimizu |
890ddd |
m_name = rhs.m_name;
|
|
Toshihiro Shimizu |
890ddd |
m_priority = rhs.m_priority;
|
|
Toshihiro Shimizu |
890ddd |
m_user = rhs.m_user;
|
|
Toshihiro Shimizu |
890ddd |
m_hostName = rhs.m_hostName;
|
|
Toshihiro Shimizu |
890ddd |
m_id = rhs.m_id;
|
|
Toshihiro Shimizu |
890ddd |
m_parentId = rhs.m_parentId;
|
|
Toshihiro Shimizu |
890ddd |
m_status = rhs.m_status;
|
|
Toshihiro Shimizu |
890ddd |
m_server = rhs.m_server;
|
|
Toshihiro Shimizu |
890ddd |
m_submissionDate = rhs.m_submissionDate;
|
|
Toshihiro Shimizu |
890ddd |
m_startDate = rhs.m_startDate;
|
|
Toshihiro Shimizu |
890ddd |
m_completionDate = rhs.m_completionDate;
|
|
Toshihiro Shimizu |
890ddd |
m_successfullSteps = rhs.m_successfullSteps;
|
|
Toshihiro Shimizu |
890ddd |
m_failedSteps = rhs.m_failedSteps;
|
|
Toshihiro Shimizu |
890ddd |
m_stepCount = rhs.m_stepCount;
|
|
Toshihiro Shimizu |
890ddd |
m_from = rhs.m_from;
|
|
Toshihiro Shimizu |
890ddd |
m_to = rhs.m_to;
|
|
Toshihiro Shimizu |
890ddd |
m_step = rhs.m_step;
|
|
Toshihiro Shimizu |
890ddd |
m_shrink = rhs.m_shrink;
|
|
Toshihiro Shimizu |
890ddd |
m_onlyVisible = rhs.m_onlyVisible;
|
|
Toshihiro Shimizu |
890ddd |
m_overwrite = rhs.m_overwrite;
|
|
Toshihiro Shimizu |
890ddd |
m_multimedia = rhs.m_multimedia;
|
|
Toshihiro Shimizu |
890ddd |
m_threadsIndex = rhs.m_threadsIndex;
|
|
Toshihiro Shimizu |
890ddd |
m_maxTileSizeIndex = rhs.m_maxTileSizeIndex;
|
|
Toshihiro Shimizu |
890ddd |
m_chunkSize = rhs.m_chunkSize;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
delete m_dependencies;
|
|
Toshihiro Shimizu |
890ddd |
m_dependencies = 0;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (rhs.m_dependencies)
|
|
Toshihiro Shimizu |
890ddd |
m_dependencies = new Dependencies(*rhs.m_dependencies);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
return *this;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool TFarmTask::operator==(const TFarmTask &task)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
bool equalDependencies;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (!task.m_dependencies && !m_dependencies)
|
|
Toshihiro Shimizu |
890ddd |
equalDependencies = true;
|
|
Toshihiro Shimizu |
890ddd |
else if (task.m_dependencies && !m_dependencies)
|
|
Toshihiro Shimizu |
890ddd |
equalDependencies = false;
|
|
Toshihiro Shimizu |
890ddd |
else if (!task.m_dependencies && m_dependencies)
|
|
Toshihiro Shimizu |
890ddd |
equalDependencies = false;
|
|
Toshihiro Shimizu |
890ddd |
else
|
|
Toshihiro Shimizu |
890ddd |
equalDependencies = (task.m_dependencies == m_dependencies);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
return (
|
|
Toshihiro Shimizu |
890ddd |
task.m_name == m_name &&
|
|
Toshihiro Shimizu |
890ddd |
task.m_priority == m_priority &&
|
|
Toshihiro Shimizu |
890ddd |
task.m_user == m_user &&
|
|
Toshihiro Shimizu |
890ddd |
task.m_hostName == m_hostName &&
|
|
Toshihiro Shimizu |
890ddd |
task.m_id == m_id &&
|
|
Toshihiro Shimizu |
890ddd |
task.m_parentId == m_parentId &&
|
|
Toshihiro Shimizu |
890ddd |
task.m_status == m_status &&
|
|
Toshihiro Shimizu |
890ddd |
task.m_server == m_server &&
|
|
Toshihiro Shimizu |
890ddd |
task.m_submissionDate == m_submissionDate &&
|
|
Toshihiro Shimizu |
890ddd |
task.m_startDate == m_startDate &&
|
|
Toshihiro Shimizu |
890ddd |
task.m_completionDate == m_completionDate &&
|
|
Toshihiro Shimizu |
890ddd |
task.m_successfullSteps == m_successfullSteps &&
|
|
Toshihiro Shimizu |
890ddd |
task.m_failedSteps == m_failedSteps &&
|
|
Toshihiro Shimizu |
890ddd |
task.m_stepCount == m_stepCount &&
|
|
Toshihiro Shimizu |
890ddd |
task.m_from == m_from &&
|
|
Toshihiro Shimizu |
890ddd |
task.m_to == m_to &&
|
|
Toshihiro Shimizu |
890ddd |
task.m_step == m_step &&
|
|
Toshihiro Shimizu |
890ddd |
task.m_shrink == m_shrink &&
|
|
Toshihiro Shimizu |
890ddd |
task.m_onlyVisible == m_onlyVisible &&
|
|
Toshihiro Shimizu |
890ddd |
task.m_overwrite == m_overwrite &&
|
|
Toshihiro Shimizu |
890ddd |
task.m_multimedia == m_multimedia &&
|
|
Toshihiro Shimizu |
890ddd |
task.m_threadsIndex == m_threadsIndex &&
|
|
Toshihiro Shimizu |
890ddd |
task.m_maxTileSizeIndex == m_maxTileSizeIndex &&
|
|
Toshihiro Shimizu |
890ddd |
task.m_chunkSize == m_chunkSize &&
|
|
Toshihiro Shimizu |
890ddd |
equalDependencies);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void TFarmTask::loadData(TIStream &is)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Shinya Kitaoka |
3bfa54 |
std::string tagName;
|
|
Toshihiro Shimizu |
890ddd |
while (is.matchTag(tagName)) {
|
|
Toshihiro Shimizu |
890ddd |
if (tagName == "taskId") {
|
|
Toshihiro Shimizu |
890ddd |
is >> m_id;
|
|
Toshihiro Shimizu |
890ddd |
} else if (tagName == "parentId") {
|
|
Toshihiro Shimizu |
890ddd |
is >> m_parentId;
|
|
Toshihiro Shimizu |
890ddd |
} else if (tagName == "name") {
|
|
Toshihiro Shimizu |
890ddd |
is >> m_name;
|
|
Toshihiro Shimizu |
890ddd |
} else if (tagName == "cmdline") {
|
|
Toshihiro Shimizu |
890ddd |
QString commandLine;
|
|
Toshihiro Shimizu |
890ddd |
is >> commandLine;
|
|
Toshihiro Shimizu |
890ddd |
parseCommandLine(commandLine);
|
|
Toshihiro Shimizu |
890ddd |
} else if (tagName == "priority") {
|
|
Toshihiro Shimizu |
890ddd |
is >> m_priority;
|
|
Toshihiro Shimizu |
890ddd |
} else if (tagName == "submittedBy") {
|
|
Toshihiro Shimizu |
890ddd |
is >> m_user;
|
|
Toshihiro Shimizu |
890ddd |
} else if (tagName == "submittedOn") {
|
|
Toshihiro Shimizu |
890ddd |
is >> m_hostName;
|
|
Toshihiro Shimizu |
890ddd |
} else if (tagName == "submissionDate") {
|
|
Toshihiro Shimizu |
890ddd |
QString date;
|
|
Toshihiro Shimizu |
890ddd |
is >> date;
|
|
Toshihiro Shimizu |
890ddd |
m_submissionDate = QDateTime::fromString(date);
|
|
Toshihiro Shimizu |
890ddd |
} else if (tagName == "stepCount") {
|
|
Toshihiro Shimizu |
890ddd |
is >> m_stepCount;
|
|
Toshihiro Shimizu |
890ddd |
} else if (tagName == "chunkSize") {
|
|
Toshihiro Shimizu |
890ddd |
assert(dynamic_cast<tfarmtaskgroup *="">(this));</tfarmtaskgroup>
|
|
Toshihiro Shimizu |
890ddd |
is >> m_chunkSize;
|
|
Toshihiro Shimizu |
890ddd |
} else if (tagName == "threadsIndex") {
|
|
Toshihiro Shimizu |
890ddd |
assert(dynamic_cast<tfarmtaskgroup *="">(this));</tfarmtaskgroup>
|
|
Toshihiro Shimizu |
890ddd |
is >> m_threadsIndex;
|
|
Toshihiro Shimizu |
890ddd |
} else if (tagName == "maxTileSizeIndex") {
|
|
Toshihiro Shimizu |
890ddd |
assert(dynamic_cast<tfarmtaskgroup *="">(this));</tfarmtaskgroup>
|
|
Toshihiro Shimizu |
890ddd |
is >> m_maxTileSizeIndex;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
else if (tagName == "platform") {
|
|
Toshihiro Shimizu |
890ddd |
int val;
|
|
Toshihiro Shimizu |
890ddd |
is >> val;
|
|
Toshihiro Shimizu |
890ddd |
m_platform = (TFarmPlatform)val;
|
|
Toshihiro Shimizu |
890ddd |
} else if (tagName == "dependencies") {
|
|
Toshihiro Shimizu |
890ddd |
m_dependencies = new Dependencies();
|
|
Toshihiro Shimizu |
890ddd |
while (!is.eos()) {
|
|
Toshihiro Shimizu |
890ddd |
is.matchTag(tagName);
|
|
Toshihiro Shimizu |
890ddd |
if (tagName == "taskId") {
|
|
Toshihiro Shimizu |
890ddd |
QString dependsOn;
|
|
Toshihiro Shimizu |
890ddd |
is >> dependsOn;
|
|
Toshihiro Shimizu |
890ddd |
m_dependencies->add(dependsOn);
|
|
Toshihiro Shimizu |
890ddd |
} else
|
|
Toshihiro Shimizu |
890ddd |
throw TException(tagName + " : unexpected tag");
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (!is.matchEndTag())
|
|
Toshihiro Shimizu |
890ddd |
throw TException(tagName + " : missing end tag");
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
} else {
|
|
Toshihiro Shimizu |
890ddd |
throw TException(tagName + " : unexpected tag");
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (!is.matchEndTag())
|
|
Toshihiro Shimizu |
890ddd |
throw TException(tagName + " : missing end tag");
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void TFarmTask::saveData(TOStream &os)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
os.child("taskId") << m_id;
|
|
Toshihiro Shimizu |
890ddd |
os.child("parentId") << m_parentId;
|
|
Toshihiro Shimizu |
890ddd |
os.child("name") << m_name;
|
|
Toshihiro Shimizu |
890ddd |
os.child("cmdline") << getCommandLine();
|
|
Toshihiro Shimizu |
890ddd |
os.child("priority") << m_priority;
|
|
Toshihiro Shimizu |
890ddd |
os.child("submittedBy") << m_user;
|
|
Toshihiro Shimizu |
890ddd |
os.child("submittedOn") << m_hostName;
|
|
Toshihiro Shimizu |
890ddd |
os.child("submissionDate") << m_submissionDate.toString();
|
|
Toshihiro Shimizu |
890ddd |
os.child("stepCount") << m_stepCount;
|
|
Toshihiro Shimizu |
890ddd |
if (dynamic_cast<tfarmtaskgroup *="">(this))</tfarmtaskgroup>
|
|
Toshihiro Shimizu |
890ddd |
os.child("chunkSize") << m_chunkSize;
|
|
Toshihiro Shimizu |
890ddd |
os.child("threadsIndex") << m_threadsIndex;
|
|
Toshihiro Shimizu |
890ddd |
os.child("maxTileSizeIndex") << m_maxTileSizeIndex;
|
|
Toshihiro Shimizu |
890ddd |
os.child("platform") << m_platform;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
os.openChild("dependencies");
|
|
Toshihiro Shimizu |
890ddd |
if (m_dependencies) {
|
|
Toshihiro Shimizu |
890ddd |
for (int i = 0; i < m_dependencies->getTaskCount(); ++i) {
|
|
Toshihiro Shimizu |
890ddd |
TFarmTask::Id id = m_dependencies->getTaskId(i);
|
|
Toshihiro Shimizu |
890ddd |
os.child("taskId") << id;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
os.closeChild(); // "dependencies"
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
namespace
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
QString getExeName(bool isComposer)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
QString name = isComposer ? "tcomposer" : "tcleanup";
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
9f5a1b |
#ifdef _WIN32
|
|
Toshihiro Shimizu |
890ddd |
return name + ".exe ";
|
|
Toshihiro Shimizu |
890ddd |
#else
|
|
Toshihiro Shimizu |
890ddd |
return "\"./Toonz 7.1.app/Contents/MacOS/" + name + "\" ";
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
QString toString(int value, int w, char c = ' ')
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
QString s = QString::number(value);
|
|
Toshihiro Shimizu |
890ddd |
while (s.size() < w)
|
|
Toshihiro Shimizu |
890ddd |
s = c + s;
|
|
Toshihiro Shimizu |
890ddd |
return s;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
} //namespace
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TFilePath getFilePath(const QStringList &l, int &i)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
QString outStr = l.at(i++);
|
|
Toshihiro Shimizu |
890ddd |
if (outStr.startsWith('"')) {
|
|
Toshihiro Shimizu |
890ddd |
outStr = outStr.remove(0, 1);
|
|
Toshihiro Shimizu |
890ddd |
if (!outStr.endsWith('"')) {
|
|
Toshihiro Shimizu |
890ddd |
do
|
|
Toshihiro Shimizu |
890ddd |
outStr += " " + l.at(i);
|
|
Toshihiro Shimizu |
890ddd |
while (i < l.size() && !l.at(i++).endsWith('"'));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
outStr.chop(1);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
return TFilePath(outStr.toStdString());
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void TFarmTask::parseCommandLine(QString commandLine)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
QStringList l = commandLine.split(" ", QString::SkipEmptyParts);
|
|
Toshihiro Shimizu |
890ddd |
assert(l.size() >= 2);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// serve per skippare il path dell'eseguibile su mac che contiene spazi
|
|
Toshihiro Shimizu |
890ddd |
int i = 0;
|
|
Toshihiro Shimizu |
890ddd |
while (i < l.size() && (!l.at(i).contains("tcomposer") && !l.at(i).contains("tcleanup")))
|
|
Toshihiro Shimizu |
890ddd |
++i;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
m_isComposerTask = l.at(i++).contains("tcomposer");
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (i < l.size() && !l.at(i).startsWith('-'))
|
|
Toshihiro Shimizu |
890ddd |
m_taskFilePath = getFilePath(l, i);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
m_step = 1;
|
|
Toshihiro Shimizu |
890ddd |
m_shrink = 1;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
while (i < l.size()) {
|
|
Toshihiro Shimizu |
890ddd |
QString str = l.at(i);
|
|
Toshihiro Shimizu |
890ddd |
if (l.at(i) == "-o")
|
|
Toshihiro Shimizu |
890ddd |
m_outputPath = getFilePath(l, ++i);
|
|
Toshihiro Shimizu |
890ddd |
else if (l.at(i) == "-range") {
|
|
Toshihiro Shimizu |
890ddd |
m_from = (l.at(i + 1).toInt());
|
|
Toshihiro Shimizu |
890ddd |
m_to = (l.at(i + 2).toInt());
|
|
Toshihiro Shimizu |
890ddd |
i += 3;
|
|
Toshihiro Shimizu |
890ddd |
} else if (l.at(i) == "-step") {
|
|
Toshihiro Shimizu |
890ddd |
m_step = (l.at(i + 1).toInt());
|
|
Toshihiro Shimizu |
890ddd |
i += 2;
|
|
Toshihiro Shimizu |
890ddd |
} else if (l.at(i) == "-shrink") {
|
|
Toshihiro Shimizu |
890ddd |
m_shrink = (l.at(i + 1).toInt());
|
|
Toshihiro Shimizu |
890ddd |
i += 2;
|
|
Toshihiro Shimizu |
890ddd |
} else if (l.at(i) == "-multimedia") {
|
|
Toshihiro Shimizu |
890ddd |
m_multimedia = (l.at(i + 1).toInt());
|
|
Toshihiro Shimizu |
890ddd |
i += 2;
|
|
Toshihiro Shimizu |
890ddd |
} else if (l.at(i) == "-nthreads") {
|
|
Toshihiro Shimizu |
890ddd |
QString str(l.at(i + 1));
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
m_threadsIndex = (str == "single") ? 0 : (str == "half") ? 1 : 2;
|
|
Toshihiro Shimizu |
890ddd |
i += 2;
|
|
Toshihiro Shimizu |
890ddd |
} else if (l.at(i) == "-maxtilesize") {
|
|
Toshihiro Shimizu |
890ddd |
QString str(l.at(i + 1));
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
const QString maxTileSizeIndexes[3] = {
|
|
Toshihiro Shimizu |
890ddd |
QString::number(TOutputProperties::LargeVal),
|
|
Toshihiro Shimizu |
890ddd |
QString::number(TOutputProperties::MediumVal),
|
|
Toshihiro Shimizu |
890ddd |
QString::number(TOutputProperties::SmallVal)};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
m_maxTileSizeIndex =
|
|
Toshihiro Shimizu |
890ddd |
(str == maxTileSizeIndexes[2]) ? 3 : (str == maxTileSizeIndexes[1]) ? 2 : (str == maxTileSizeIndexes[0]) ? 1 : 0;
|
|
Toshihiro Shimizu |
890ddd |
i += 2;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
else if (l.at(i) == "-overwriteAll")
|
|
Toshihiro Shimizu |
890ddd |
m_overwrite = Overwrite_All, i++;
|
|
Toshihiro Shimizu |
890ddd |
else if (l.at(i) == "-overwriteNoPaint")
|
|
Toshihiro Shimizu |
890ddd |
m_overwrite = Overwrite_NoPaint, i++;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
else if (l.at(i) == "-onlyvisible")
|
|
Toshihiro Shimizu |
890ddd |
m_onlyVisible = true, ++i;
|
|
Toshihiro Shimizu |
890ddd |
else if (l.at(i) == "-farm" || l.at(i) == "-id")
|
|
Toshihiro Shimizu |
890ddd |
i += 2;
|
|
Toshihiro Shimizu |
890ddd |
else if (l.at(i) == "-tmsg") {
|
|
Toshihiro Shimizu |
890ddd |
m_callerMachineName = l.at(i + 1);
|
|
Toshihiro Shimizu |
890ddd |
i += 2;
|
|
Toshihiro Shimizu |
890ddd |
} else
|
|
Toshihiro Shimizu |
890ddd |
assert(false);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
QString TFarmTask::getCommandLine(bool isFarmTask) const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
QString cmdline = getExeName(m_isComposerTask);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (!m_taskFilePath.isEmpty())
|
|
Toshihiro Shimizu |
890ddd |
cmdline += " \"" + QString::fromStdWString(TSystem::toUNC(m_taskFilePath).getWideString()) + "\"";
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (m_callerMachineName != "") {
|
|
Toshihiro Shimizu |
890ddd |
#if QT_VERSION >= 0x050500
|
|
Toshihiro Shimizu |
890ddd |
struct hostent *he = gethostbyname(m_callerMachineName.toLatin1());
|
|
Toshihiro Shimizu |
890ddd |
#else
|
|
Toshihiro Shimizu |
890ddd |
struct hostent *he = gethostbyname(m_callerMachineName.toAscii());
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
if (he) {
|
|
Toshihiro Shimizu |
890ddd |
char *ipAddress = inet_ntoa(*(struct in_addr *)*(he->h_addr_list));
|
|
Toshihiro Shimizu |
890ddd |
#if QT_VERSION >= 0x050500
|
|
Toshihiro Shimizu |
890ddd |
cmdline += " -tmsg " + QString::fromUtf8(ipAddress);
|
|
Toshihiro Shimizu |
890ddd |
#else
|
|
Toshihiro Shimizu |
890ddd |
cmdline += " -tmsg " + QString::fromAscii(ipAddress);
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (!m_isComposerTask) {
|
|
Toshihiro Shimizu |
890ddd |
if (m_overwrite == Overwrite_All)
|
|
Toshihiro Shimizu |
890ddd |
cmdline += " -overwriteAll ";
|
|
Toshihiro Shimizu |
890ddd |
else if (m_overwrite == Overwrite_NoPaint)
|
|
Toshihiro Shimizu |
890ddd |
cmdline += " -overwriteNoPaint ";
|
|
Toshihiro Shimizu |
890ddd |
if (m_onlyVisible)
|
|
Toshihiro Shimizu |
890ddd |
cmdline += " -onlyvisible ";
|
|
Toshihiro Shimizu |
890ddd |
return cmdline;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (!m_outputPath.isEmpty()) {
|
|
Toshihiro Shimizu |
890ddd |
TFilePath outputPath;
|
|
Toshihiro Shimizu |
890ddd |
try {
|
|
Toshihiro Shimizu |
890ddd |
outputPath = TSystem::toUNC(m_outputPath);
|
|
Toshihiro Shimizu |
890ddd |
} catch (TException &) {
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
cmdline += " -o \"" + QString::fromStdWString(outputPath.getWideString()) + "\"";
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
cmdline += " -range " + QString::number(m_from) + " " + QString::number(m_to);
|
|
Toshihiro Shimizu |
890ddd |
cmdline += " -step " + QString::number(m_step);
|
|
Toshihiro Shimizu |
890ddd |
cmdline += " -shrink " + QString::number(m_shrink);
|
|
Toshihiro Shimizu |
890ddd |
cmdline += " -multimedia " + QString::number(m_multimedia);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
const QString threadCounts[3] = {"single", "half", "all"};
|
|
Toshihiro Shimizu |
890ddd |
cmdline += " -nthreads " + threadCounts[m_threadsIndex];
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
const QString maxTileSizes[4] = {
|
|
Toshihiro Shimizu |
890ddd |
"none",
|
|
Toshihiro Shimizu |
890ddd |
QString::number(TOutputProperties::LargeVal),
|
|
Toshihiro Shimizu |
890ddd |
QString::number(TOutputProperties::MediumVal),
|
|
Toshihiro Shimizu |
890ddd |
QString::number(TOutputProperties::SmallVal)};
|
|
Toshihiro Shimizu |
890ddd |
cmdline += " -maxtilesize " + maxTileSizes[m_maxTileSizeIndex];
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
QString appname = QSettings().applicationName();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
return cmdline;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
namespace
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class TFarmTaskDeclaration : public TPersistDeclaration
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
3bfa54 |
TFarmTaskDeclaration(const std::string &id)
|
|
Toshihiro Shimizu |
890ddd |
: TPersistDeclaration(id) {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TPersist *create() const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return new TFarmTask;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
} FarmTaskDeclaration("ttask");
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
} // namespace
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
const TPersistDeclaration *TFarmTask::getDeclaration() const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return &FarmTaskDeclaration;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool TFarmTask::operator!=(const TFarmTask &task)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return !operator==(task);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//==============================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class TFarmTaskGroup::Imp
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
Imp() {}
|
|
Toshihiro Shimizu |
890ddd |
~Imp()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
//clearPointerContainer(m_tasks);
|
|
Toshihiro Shimizu |
890ddd |
std::vector<tfarmtask *="">::iterator it = m_tasks.begin();</tfarmtask>
|
|
Toshihiro Shimizu |
890ddd |
for (; it != m_tasks.end(); ++it)
|
|
Toshihiro Shimizu |
890ddd |
delete *it;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
3bfa54 |
std::vector<tfarmtask *=""> m_tasks;</tfarmtask>
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TFarmTaskGroup::TFarmTaskGroup()
|
|
Toshihiro Shimizu |
890ddd |
: m_imp(new Imp())
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TFarmTaskGroup::TFarmTaskGroup(const QString &id, const QString &name, const QString &cmdline,
|
|
Toshihiro Shimizu |
890ddd |
const QString &user, const QString &host, int stepCount, int priority)
|
|
Toshihiro Shimizu |
890ddd |
: TFarmTask(id, name, cmdline, user, host, stepCount, priority), m_imp(new Imp())
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool TFarmTaskGroup::changeChunkSize(int chunksize)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
m_chunkSize = chunksize;
|
|
Toshihiro Shimizu |
890ddd |
int subCount = tceil((m_to - m_from + 1) / (double)m_chunkSize);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (subCount > 1) {
|
|
Toshihiro Shimizu |
890ddd |
int ra = m_from;
|
|
Toshihiro Shimizu |
890ddd |
for (int i = 1; i <= subCount; ++i) {
|
|
Shinya Kitaoka |
12c444 |
int rb = std::min(ra + m_chunkSize - 1, m_to);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
try {
|
|
Toshihiro Shimizu |
890ddd |
QString subName = m_name + " " + toString(ra, 2, '0') + "-" + toString(rb, 2, '0');
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TFarmTask *subTask = new TFarmTask(m_id + "." + toString(i, 2, '0'),
|
|
Toshihiro Shimizu |
890ddd |
subName,
|
|
Toshihiro Shimizu |
890ddd |
true,
|
|
Toshihiro Shimizu |
890ddd |
m_user,
|
|
Toshihiro Shimizu |
890ddd |
m_hostName,
|
|
Toshihiro Shimizu |
890ddd |
rb - ra + 1,
|
|
Toshihiro Shimizu |
890ddd |
m_priority,
|
|
Toshihiro Shimizu |
890ddd |
m_taskFilePath,
|
|
Toshihiro Shimizu |
890ddd |
m_outputPath,
|
|
Toshihiro Shimizu |
890ddd |
ra,
|
|
Toshihiro Shimizu |
890ddd |
rb,
|
|
Toshihiro Shimizu |
890ddd |
m_step,
|
|
Toshihiro Shimizu |
890ddd |
m_shrink,
|
|
Toshihiro Shimizu |
890ddd |
m_multimedia,
|
|
Toshihiro Shimizu |
890ddd |
m_chunkSize,
|
|
Toshihiro Shimizu |
890ddd |
m_threadsIndex,
|
|
Toshihiro Shimizu |
890ddd |
m_maxTileSizeIndex,
|
|
Toshihiro Shimizu |
890ddd |
Overwrite_Off,
|
|
Toshihiro Shimizu |
890ddd |
false);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
subTask->m_parentId = m_id;
|
|
Toshihiro Shimizu |
890ddd |
addTask(subTask);
|
|
Toshihiro Shimizu |
890ddd |
} catch (TException &) {
|
|
Toshihiro Shimizu |
890ddd |
//TMessage::error(toString(e.getMessage()));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
ra = rb + 1;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
return true;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TFarmTaskGroup::TFarmTaskGroup(
|
|
Toshihiro Shimizu |
890ddd |
const QString &id, const QString &name, const QString &user, const QString &host,
|
|
Toshihiro Shimizu |
890ddd |
int stepCount, int priority, const TFilePath &taskFilePath,
|
|
Toshihiro Shimizu |
890ddd |
const TFilePath &outputPath,
|
|
Toshihiro Shimizu |
890ddd |
int from, int to, int step, int shrink, int multimedia, int chunksize,
|
|
Toshihiro Shimizu |
890ddd |
int threadsIndex, int maxTileSizeIndex)
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
: TFarmTask(id, name, true, user, host, stepCount, priority, taskFilePath, outputPath,
|
|
Toshihiro Shimizu |
890ddd |
from, to, step, shrink, multimedia, chunksize, threadsIndex, maxTileSizeIndex, Overwrite_Off, false),
|
|
Toshihiro Shimizu |
890ddd |
m_imp(new Imp())
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
int subCount = 0;
|
|
Toshihiro Shimizu |
890ddd |
if (chunksize > 0)
|
|
Toshihiro Shimizu |
890ddd |
subCount = tceil((to - from + 1) / (double)chunksize);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
int ra = from;
|
|
Toshihiro Shimizu |
890ddd |
if (subCount > 1) {
|
|
Toshihiro Shimizu |
890ddd |
for (int i = 1; i <= subCount; ++i) {
|
|
Shinya Kitaoka |
12c444 |
int rb = std::min(ra + chunksize - 1, to);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
try {
|
|
Toshihiro Shimizu |
890ddd |
QString subName = name + " " + toString(ra, 2, '0') + "-" + toString(rb, 2, '0');
|
|
Toshihiro Shimizu |
890ddd |
stepCount = rb - ra + 1;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TFarmTask *subTask = new TFarmTask(id + "." + toString(i, 2, '0'),
|
|
Toshihiro Shimizu |
890ddd |
subName, true, user, host, stepCount, priority, taskFilePath, outputPath, ra, rb, step, shrink, multimedia, chunksize,
|
|
Toshihiro Shimizu |
890ddd |
threadsIndex, maxTileSizeIndex, Overwrite_Off, false);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
subTask->m_parentId = id;
|
|
Toshihiro Shimizu |
890ddd |
addTask(subTask);
|
|
Toshihiro Shimizu |
890ddd |
} catch (TException &) {
|
|
Toshihiro Shimizu |
890ddd |
//TMessage::error(toString(e.getMessage()));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
ra = rb + 1;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TFarmTaskGroup::TFarmTaskGroup(
|
|
Toshihiro Shimizu |
890ddd |
const QString &id, const QString &name, const QString &user, const QString &host,
|
|
Toshihiro Shimizu |
890ddd |
int stepCount, int priority, const TFilePath &taskFilePath,
|
|
Toshihiro Shimizu |
890ddd |
OverwriteBehavior overwrite, bool onlyvisible)
|
|
Toshihiro Shimizu |
890ddd |
: TFarmTask(id, name, false, user, host, stepCount, priority, taskFilePath, TFilePath(),
|
|
Toshihiro Shimizu |
890ddd |
0, 0, 0, 0, 0, 0, 0, 0, overwrite, onlyvisible),
|
|
Toshihiro Shimizu |
890ddd |
m_imp(new Imp())
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TFarmTaskGroup::TFarmTaskGroup(const TFarmTaskGroup &src)
|
|
Toshihiro Shimizu |
890ddd |
: TFarmTask(src), m_imp(new TFarmTaskGroup::Imp())
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
int count = src.getTaskCount();
|
|
Toshihiro Shimizu |
890ddd |
for (int i = 0; i < count; ++i) {
|
|
Toshihiro Shimizu |
890ddd |
TFarmTaskGroup &ssrc = const_cast<tfarmtaskgroup &="">(src);</tfarmtaskgroup>
|
|
Toshihiro Shimizu |
890ddd |
addTask(new TFarmTask(*ssrc.getTask(i)));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TFarmTaskGroup::~TFarmTaskGroup()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void TFarmTaskGroup::addTask(TFarmTask *task)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
m_imp->m_tasks.push_back(task);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void TFarmTaskGroup::removeTask(TFarmTask *task)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
std::vector<tfarmtask *="">::iterator it =</tfarmtask>
|
|
Toshihiro Shimizu |
890ddd |
std::find(m_imp->m_tasks.begin(), m_imp->m_tasks.end(), task);
|
|
Toshihiro Shimizu |
890ddd |
if (it != m_imp->m_tasks.end())
|
|
Toshihiro Shimizu |
890ddd |
m_imp->m_tasks.erase(it);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
int TFarmTaskGroup::getTaskCount() const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return m_imp->m_tasks.size();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TFarmTask *TFarmTaskGroup::getTask(int index)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
std::vector<tfarmtask *="">::iterator it = m_imp->m_tasks.begin();</tfarmtask>
|
|
Toshihiro Shimizu |
890ddd |
std::advance(it, index);
|
|
Toshihiro Shimizu |
890ddd |
return it != m_imp->m_tasks.end() ? *it : 0;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void TFarmTaskGroup::loadData(TIStream &is)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Shinya Kitaoka |
3bfa54 |
std::string tagName;
|
|
Toshihiro Shimizu |
890ddd |
while (is.matchTag(tagName)) {
|
|
Toshihiro Shimizu |
890ddd |
if (tagName == "info") {
|
|
Toshihiro Shimizu |
890ddd |
TFarmTask::loadData(is);
|
|
Toshihiro Shimizu |
890ddd |
} else if (tagName == "tasks") {
|
|
Toshihiro Shimizu |
890ddd |
while (!is.eos()) {
|
|
Toshihiro Shimizu |
890ddd |
TPersist *p = 0;
|
|
Toshihiro Shimizu |
890ddd |
is >> p;
|
|
Toshihiro Shimizu |
890ddd |
TFarmTask *task = dynamic_cast<tfarmtask *="">(p);</tfarmtask>
|
|
Toshihiro Shimizu |
890ddd |
if (task)
|
|
Toshihiro Shimizu |
890ddd |
addTask(task);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
} else {
|
|
Toshihiro Shimizu |
890ddd |
throw TException(tagName + " : unexpected tag");
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (!is.matchEndTag())
|
|
Toshihiro Shimizu |
890ddd |
throw TException(tagName + " : missing end tag");
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void TFarmTaskGroup::saveData(TOStream &os)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
os.openChild("info");
|
|
Toshihiro Shimizu |
890ddd |
TFarmTask::saveData(os);
|
|
Toshihiro Shimizu |
890ddd |
os.closeChild();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
os.openChild("tasks");
|
|
Toshihiro Shimizu |
890ddd |
std::vector<tfarmtask *="">::iterator it = m_imp->m_tasks.begin();</tfarmtask>
|
|
Toshihiro Shimizu |
890ddd |
for (; it != m_imp->m_tasks.end(); ++it)
|
|
Toshihiro Shimizu |
890ddd |
os << *it;
|
|
Toshihiro Shimizu |
890ddd |
os.closeChild();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
namespace
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class TFarmTaskGroupDeclaration : public TPersistDeclaration
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
3bfa54 |
TFarmTaskGroupDeclaration(const std::string &id)
|
|
Toshihiro Shimizu |
890ddd |
: TPersistDeclaration(id) {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TPersist *create() const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return new TFarmTaskGroup;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
} FarmTaskGroupDeclaration("ttaskgroup");
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
} // namespace
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
const TPersistDeclaration *TFarmTaskGroup::getDeclaration() const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return &FarmTaskGroupDeclaration;
|
|
Toshihiro Shimizu |
890ddd |
}
|