Skip to content

Commit

Permalink
afserver: skip refresh of DONE jobs.
Browse files Browse the repository at this point in the history
Next refresh can be forced with JobAf::forceRefresh() function.
It called from job and block actions (user restarted some task(s)).

Testing needed.

References #599.
  • Loading branch information
timurhai committed Apr 21, 2024
1 parent 4065681 commit 055ba62
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
2 changes: 2 additions & 0 deletions afanasy/src/server/block.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -716,6 +716,8 @@ void Block::tasksOperation(const std::string & i_message, const Action & i_actio
}

m_tasks[t]->operation(i_message, i_action.renders, i_action.monitors, i_with_state, i_set_state);

m_job->forceRefresh();
}
}

Expand Down
16 changes: 15 additions & 1 deletion afanasy/src/server/jobaf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ void JobAf::readStore()

void JobAf::initializeValues()
{
m_force_refresh = true;

m_branch_srv = NULL;
m_user = NULL;
m_blocks = NULL;
Expand Down Expand Up @@ -519,6 +521,7 @@ void JobAf::v_action( Action & i_action)
if (job_changed)
{
i_action.monitors->addJobEvent( af::Monitor::EVT_jobs_change, getId(), getUid());
m_force_refresh = true;
store();
}

Expand Down Expand Up @@ -610,6 +613,7 @@ void JobAf::v_action( Action & i_action)
}
appendLog("Operation \"" + type + "\" by " + i_action.author);
i_action.monitors->addJobEvent( af::Monitor::EVT_jobs_change, getId(), getUid());
m_force_refresh = true;
store();
return;
}
Expand Down Expand Up @@ -672,6 +676,7 @@ void JobAf::v_action( Action & i_action)
{
// Not empty log means some parameter change:
store();
m_force_refresh = true;
i_action.monitors->addJobEvent( af::Monitor::EVT_jobs_change, getId(), getUid());
}
}
Expand Down Expand Up @@ -1117,7 +1122,13 @@ void JobAf::v_refresh( time_t currentTime, AfContainer * pointer, MonitorContain
// No more calculations needed for a locked job:
if (isLocked())
return;


// Skip DONE job refresh if it is not forced:
if (isDone() && (false == m_force_refresh))
return;

printf("%s - refresh.\n", name().c_str());

// for database and monitoring
uint32_t old_state = m_state;
uint32_t jobchanged = 0;
Expand Down Expand Up @@ -1287,6 +1298,9 @@ void JobAf::v_refresh( time_t currentTime, AfContainer * pointer, MonitorContain
}

if(( monitoring ) && ( jobchanged )) monitoring->addJobEvent( jobchanged, getId(), getUid());

if (isDone())
m_force_refresh = false;
}

void JobAf::emitEvents(const std::vector<std::string> & i_events) const
Expand Down
5 changes: 5 additions & 0 deletions afanasy/src/server/jobaf.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ class JobAf : public af::Job , public AfNodeSolve

inline Block * getBlock(int i_num) {if ((i_num < 0) || (i_num >= m_blocks_num)) return NULL; return m_blocks[i_num];}

/// Force refresh, that can be skipped on DONE job.
inline void forceRefresh() {m_force_refresh = true;}

public:
/// Set Jobs Container.
inline static void setJobContainer( JobContainer *Jobs){ ms_jobs = Jobs;}
Expand All @@ -141,6 +144,8 @@ class JobAf : public af::Job , public AfNodeSolve
private:
bool m_deletion; ///< Whether the job is deleting.

bool m_force_refresh;

BranchSrv * m_branch_srv;

std::string m_store_dir_tasks; ///< Tasks store directory.
Expand Down

0 comments on commit 055ba62

Please sign in to comment.