Skip to content

Commit

Permalink
tickets: blocks and pools/renders just got this property
Browse files Browse the repository at this point in the history
AfWatch GUI can edit tickets in a left parametes panel.
References #459.
  • Loading branch information
timurhai committed Feb 17, 2020
1 parent 75ab8d5 commit 4d11b5c
Show file tree
Hide file tree
Showing 58 changed files with 1,850 additions and 959 deletions.
28 changes: 14 additions & 14 deletions afanasy/browser/pools.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,10 @@ PoolNode.prototype.update = function(i_obj) {
params += ' NewRender:<b>Nimby</b>';
if (this.params.new_paused)
params += ' NewRender:<b>Paused</b>';
if (this.params.max_tasks_per_host != null)
params += ' MaxTasksPerHost:<b>' + this.params.max_tasks_per_host + '</b>';
if (this.params.max_capacity_per_host != null)
params += ' MaxCapacityPerHost:<b>' + this.params.max_capacity_per_host + '</b>';
if (this.params.host_max_tasks != null)
params += ' HostMaxTasks:<b>' + this.params.host_max_tasks + '</b>';
if (this.params.host_capacity != null)
params += ' HostCapacity:<b>' + this.params.host_capacity + '</b>';
params += ' Priority:<b>' + this.params.priority + '</b>';
}
else if (cm_IsJedi())
Expand All @@ -102,10 +102,10 @@ PoolNode.prototype.update = function(i_obj) {
params += ' New:<b>Nimby</b>';
if (this.params.new_paused)
params += ' New:<b>Paused</b>';
if (this.params.max_tasks_per_host)
params += ' maxTasksPH:<b>' + this.params.max_tasks_per_host + '</b>';
if (this.params.max_capacity_per_host)
params += ' maxCapPH:<b>' + this.params.max_capacity_per_host + '</b>';
if (this.params.host_max_tasks)
params += ' HostTasks:<b>' + this.params.host_max_tasks + '</b>';
if (this.params.host_capacity)
params += ' HostCapacity:<b>' + this.params.host_capacity + '</b>';
params += ' Pri:<b>' + this.params.priority + '</b>';
}
else
Expand All @@ -114,10 +114,10 @@ PoolNode.prototype.update = function(i_obj) {
params += ' n:<b>n</b>';
if (this.params.new_paused)
params += ' n:<b>p</b>';
if (this.params.max_tasks_per_host)
params += ' tph:<b>' + this.params.max_tasks_per_host + '</b>';
if (this.params.max_capacity_per_host)
params += ' cph:<b>' + this.params.max_capacity_per_host + '</b>';
if (this.params.host_max_tasks)
params += ' ht:<b>' + this.params.host_max_tasks + '</b>';
if (this.params.host_capacity)
params += ' hc:<b>' + this.params.host_capacity + '</b>';
params += ' p<b>' + this.params.priority + '</b>';
}
this.elParams.innerHTML = params;
Expand Down Expand Up @@ -337,8 +337,8 @@ PoolNode.prototype.onDoubleClick = function(e) {
PoolNode.params_pool = {
pattern : {'type':'str', 'label':'Pattern'},
priority : {'type':'num', 'label':'Priority'},
max_tasks_per_host : {'type':'num', 'label':'Max Tasks Per Host'},
max_capacity_per_host : {'type':'num', 'label':'Max Capacity Per Host'},
host_max_tasks : {'type':'num', 'label':'Host Max Tasks'},
host_capacity : {'type':'num', 'label':'Host Max Capacity'},
annotation : {'type':'str', 'label':'Annotation'},

idle_wolsleep_time : {'type':'num', 'label':'Idle WOL sleep time'},
Expand Down
12 changes: 12 additions & 0 deletions afanasy/python/af.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,18 @@ def setEnv(self, i_name, i_value):

self.data["environment"][i_name] = i_value

def addTicket(self, i_name, i_count):
"""Missing DocString
:param i_name:
:param i_count:
:return:
"""
if "tickets" not in self.data:
self.data["tickets"] = dict()

self.data["tickets"][i_name] = i_count

def setName(self, value):
"""Missing DocString
Expand Down
2 changes: 2 additions & 0 deletions afanasy/src/include/afanasy.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ namespace AFPOOL
{
const int MAXCOUNT = 1000;
const char STORE_FOLDER[] = "pools";
const int ROOT_HOST_MAX_TASKS = 4;
const int ROOT_HOST_CAPACITY = 1100;
}

/// Users options:
Expand Down
2 changes: 1 addition & 1 deletion afanasy/src/include/afversion.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@

#pragma once

static const int AFVERSION = 64;
static const int AFVERSION = 65;

10 changes: 9 additions & 1 deletion afanasy/src/libafanasy/affarm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,18 @@ void Farm::readwrite(Msg *msg)
{
rw_StringVect(m_services, msg);
rw_StringVect(m_services_disabled, msg);

rw_IntMap(m_tickets_pool, msg);
rw_IntMap(m_tickets_host, msg);
}

void Farm::jsonRead(const JSON &i_object, std::string *io_changes)
{
jr_stringvec("services", m_services, i_object);
jr_stringvec("services_disabled", m_services_disabled, i_object);
jr_intmap ("tickets_pool", m_tickets_pool, i_object);

jr_intmap("tickets_pool", m_tickets_pool, i_object);
jr_intmap("tickets_host", m_tickets_host, i_object);
}

void Farm::jsonWrite(std::ostringstream &o_str, int i_type) const
Expand All @@ -54,6 +59,9 @@ void Farm::jsonWrite(std::ostringstream &o_str, int i_type) const

if (m_tickets_pool.size())
jw_intmap("tickets_pool", m_tickets_pool, o_str);

if (m_tickets_host.size())
jw_intmap("tickets_host", m_tickets_host, o_str);
}

int Farm::calcWeight() const
Expand Down
1 change: 1 addition & 0 deletions afanasy/src/libafanasy/affarm.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,6 @@ class Farm
std::vector<std::string> m_services_disabled;

std::map<std::string, int32_t> m_tickets_pool;
std::map<std::string, int32_t> m_tickets_host;
};
}
12 changes: 12 additions & 0 deletions afanasy/src/libafanasy/blockdata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ void BlockData::jsonRead(const JSON &i_object, std::string *io_changes)
jr_int64("time_started" /***********/, m_time_started /***********/, i_object, io_changes);
jr_int64("time_done" /**************/, m_time_done /**************/, i_object, io_changes);
jr_stringmap("environment" /********/, m_environment /************/, i_object, io_changes);
jr_intmap("tickets", m_tickets, i_object, io_changes);

if (m_capacity < 1) m_capacity = 1;

Expand Down Expand Up @@ -422,6 +423,8 @@ void BlockData::jsonWrite(std::ostringstream &o_str, int i_type) const
o_str << ",\n\"hosts_mask_exclude\":\"" << m_hosts_mask_exclude.getPattern() << "\"";
if (hasNeedProperties())
o_str << ",\n\"need_properties\":\"" << m_need_properties.getPattern() << "\"";
if (m_tickets.size()) af::jw_intmap("tickets", m_tickets, o_str);

o_str << ',';

case Msg::TBlocksProgress:
Expand Down Expand Up @@ -581,6 +584,7 @@ void BlockData::v_readwrite(Msg *msg)
rw_int32_t(m_task_progress_change_timeout, msg);
rw_int32_t(m_task_max_run_time, msg);
rw_int32_t(m_task_min_run_time, msg);
rw_IntMap(m_tickets, msg);

case Msg::TBlocksProgress:

Expand Down Expand Up @@ -1480,3 +1484,11 @@ void BlockData::setTimeDone(long long value)
{
m_time_done = value;
}

void BlockData::editTicket(std::string & i_name, int32_t & i_count)
{
if (i_count == -1)
m_tickets.erase(i_name);
else
m_tickets[i_name] = i_count;
}
5 changes: 5 additions & 0 deletions afanasy/src/libafanasy/blockdata.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ class BlockData : public Af
{
return m_environment;
}
inline const std::map<std::string, int32_t> & getTickets() const { return m_tickets;}

inline bool hasDependMask() const { return m_depend_mask.notEmpty(); } ///< Whether depend mask is set.
inline bool hasTasksDependMask() const
Expand Down Expand Up @@ -283,6 +284,8 @@ class BlockData : public Af

const TaskData * getTaskData(int i_num_task) const;

void editTicket(std::string & i_name, int32_t & i_count);

protected:
/// Read or write block.
virtual void v_readwrite(Msg *msg);
Expand Down Expand Up @@ -331,6 +334,8 @@ class BlockData : public Af
std::string m_working_directory; ///< Block tasks working directory.
std::map<std::string, std::string> m_environment; ///< Block tasks extra environment.

std::map<std::string, int32_t> m_tickets;

std::string m_command_pre; ///< Pre command.
std::string m_command_post; ///< Post command.

Expand Down
2 changes: 1 addition & 1 deletion afanasy/src/libafanasy/environment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -865,7 +865,7 @@ bool Environment::initAfterLoad()
// Check whether server address is configured:
if(( servername == std::string(AFADDR::SERVER_NAME)) && ( isServer() != true ))
{
printf("WARNING: SERVER ADDRESS ID NOT CONFIGURED, USING %s\n", AFADDR::SERVER_NAME);
printf("WARNING: SERVER ADDRESS IS NOT CONFIGURED, USING %s\n", AFADDR::SERVER_NAME);
}

// Solve server name
Expand Down
1 change: 1 addition & 0 deletions afanasy/src/libafanasy/name_af.h
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ namespace af
void w_StringList( const std::list<std::string> & stringList, Msg * msg);
void rw_StringVect( std::vector<std::string> & stringVect, Msg * msg);
void rw_StringMap( std::map< std::string, std::string > & stringMap, Msg * msg);
void rw_IntMap(std::map<std::string, int32_t> & io_map, Msg * io_msg);

void rw_RegExp( RegExp & regExp, Msg * msg);

Expand Down
2 changes: 1 addition & 1 deletion afanasy/src/libafanasy/name_afjson.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#include "name_af.h"

#include "../include/afjob.h"

Expand All @@ -10,6 +9,7 @@
#define AFOUTPUT
#undef AFOUTPUT
#include "../include/macrooutput.h"
#include "../libafanasy/logger.h"

char * af::jsonParseMsg( rapidjson::Document & o_doc, const af::Msg * i_msg, std::string * o_err)
{
Expand Down
23 changes: 23 additions & 0 deletions afanasy/src/libafanasy/name_afnet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#define AFOUTPUT
#undef AFOUTPUT
#include "../include/macrooutput.h"
#include "logger.h"

af::MsgStat mgstat;

Expand Down Expand Up @@ -881,6 +882,28 @@ void af::rw_StringMap( std::map< std::string, std::string > & stringMap, Msg * m
}
}

void af::rw_IntMap(std::map<std::string, int32_t> & io_map, Msg * io_msg)
{
uint32_t size = io_map.size();
rw_uint32_t(size, io_msg);

if (io_msg->isWriting())
for (std::map<std::string, int32_t>::iterator it = io_map.begin(); it != io_map.end(); it++)
{
w_String ((*it).first, io_msg);
rw_int32_t((*it).second, io_msg);
}
else
for (unsigned i = 0; i < size; i++)
{
std::string key;
rw_String(key, io_msg);
int32_t value;
rw_int32_t(value, io_msg);
io_map[key] = value;
}
}

void af::rw_Int32_List( std::list<int32_t> &list, Msg * msg)
{
uint32_t count;
Expand Down
42 changes: 16 additions & 26 deletions afanasy/src/libafanasy/pool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,10 @@ void Pool::initDefaultValues()
m_new_paused = false;

m_run_tasks = 0;
m_max_tasks = -1;
m_max_tasks_per_host = -1;

m_run_capacity = 0;
m_max_capacity = -1;
m_max_capacity_per_host = -1;

m_host_max_tasks = -1;
m_host_capacity = -1;

m_task_start_finish_time = 0;

Expand Down Expand Up @@ -113,17 +111,13 @@ void Pool::v_jsonWrite(std::ostringstream & o_str, int i_type) const // Thread-s
*/
if (m_run_tasks >= 0)
o_str << ",\n\"run_tasks\":" << m_run_tasks;
if (m_max_tasks >= 0)
o_str << ",\n\"max_tasks\":" << m_max_tasks;
if (m_max_tasks_per_host >= 0)
o_str << ",\n\"max_tasks_per_host\":" << m_max_tasks_per_host;

if (m_run_capacity >= 0)
o_str << ",\n\"run_capacity\":" << m_run_capacity;
if (m_max_capacity >= 0)
o_str << ",\n\"max_capacity\":" << m_max_capacity;
if (m_max_capacity_per_host >= 0)
o_str << ",\n\"max_capacity_per_host\":" << m_max_capacity_per_host;

if (m_host_max_tasks >= 0)
o_str << ",\n\"host_max_tasks\":" << m_host_max_tasks;
if (m_host_capacity >= 0)
o_str << ",\n\"host_capacity\":" << m_host_capacity;

o_str << ",\n\"task_start_finish_time\":" << m_task_start_finish_time;

Expand Down Expand Up @@ -168,14 +162,12 @@ bool Pool::jsonRead(const JSON &i_object, std::string * io_changes)
jr_bool ("new_nimby", m_new_nimby, i_object, io_changes);
jr_bool ("new_paused", m_new_paused, i_object, io_changes);

jr_int32 ("max_tasks", m_max_tasks, i_object, io_changes);
jr_int32 ("max_tasks_per_host", m_max_tasks_per_host, i_object, io_changes);
jr_int32 ("max_capacity", m_max_capacity, i_object, io_changes);
jr_int32 ("max_capacity_per_host", m_max_capacity_per_host, i_object, io_changes);
jr_int32 ("host_max_tasks", m_host_max_tasks, i_object, io_changes);
jr_int32 ("host_capacity", m_host_capacity, i_object, io_changes);

jr_int32 ("idle_wolsleep_time", m_idle_wolsleep_time, i_object, io_changes);
jr_int32 ("idle_free_time", m_idle_free_time, i_object, io_changes);
jr_int32 ("busy_nimby_time", m_busy_nimby_time, i_object, io_changes);
jr_int32 ("busy_nimby_time", m_busy_nimby_time, i_object, io_changes);
jr_int32 ("idle_cpu", m_idle_cpu, i_object, io_changes);
jr_int32 ("busy_cpu", m_busy_cpu, i_object, io_changes);
jr_int32 ("idle_mem", m_idle_mem, i_object, io_changes);
Expand All @@ -194,8 +186,8 @@ bool Pool::jsonRead(const JSON &i_object, std::string * io_changes)
setPaused(paused);

// There can`t be infinite max tasks per host on farm (on root pool).
if (isRoot() && (m_max_tasks_per_host < 0))
m_max_tasks_per_host = 0;
if (isRoot() && (m_host_max_tasks < 0))
m_host_max_tasks = 0;

// Paramers below are not editable and read only on creation
// (but they can be changes by other actions, like disable service)
Expand Down Expand Up @@ -236,12 +228,10 @@ void Pool::v_readwrite(Msg * msg)
rw_int32_t(m_renders_total, msg);

rw_int32_t(m_run_tasks, msg);
rw_int32_t(m_max_tasks, msg);
rw_int32_t(m_max_tasks_per_host, msg);

rw_int32_t(m_run_capacity, msg);
rw_int32_t(m_max_capacity, msg);
rw_int32_t(m_max_capacity_per_host, msg);

rw_int32_t(m_host_max_tasks, msg);
rw_int32_t(m_host_capacity, msg);

rw_int64_t(m_task_start_finish_time, msg);

Expand Down
21 changes: 10 additions & 11 deletions afanasy/src/libafanasy/pool.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,14 @@ class Pool : public Node, public Farm
inline int32_t getRendersNum() const { return m_renders_num; }
inline int32_t getRendersTotal() const { return m_renders_total; }

inline int getRunTasks() const { return m_run_tasks; }
inline int getMaxTasks() const { return m_max_tasks; }
inline int getMaxTasksPerHost() const { return m_max_tasks_per_host;}
inline int getRunTasks() const { return m_run_tasks; }
inline int getRunCapacity() const { return m_run_capacity;}

inline int getRunCapacity() const { return m_run_capacity; }
inline int getMaxCapacity() const { return m_max_capacity; }
inline int getMaxCapacityPerHost() const { return m_max_capacity_per_host;}
inline int getHostMaxTasks() const { return m_host_max_tasks;}
inline int getHostCapacity() const { return m_host_capacity; }

inline const std::map<std::string, int32_t> getTicketsPool() const {return m_tickets_pool;}
inline const std::map<std::string, int32_t> getTicketsHost() const {return m_tickets_host;}

public:
enum State
Expand Down Expand Up @@ -103,12 +104,10 @@ class Pool : public Node, public Farm
int64_t m_time_empty;

int32_t m_run_tasks;
int32_t m_max_tasks;
int32_t m_max_tasks_per_host;

int32_t m_run_capacity;
int32_t m_max_capacity;
int32_t m_max_capacity_per_host;

int32_t m_host_max_tasks;
int32_t m_host_capacity;

int64_t m_task_start_finish_time; ///< Task start or finish time.

Expand Down
Loading

0 comments on commit 4d11b5c

Please sign in to comment.