Skip to content

Commit

Permalink
afwatch: jobs: job item understands that block added.
Browse files Browse the repository at this point in the history
References: #514.
  • Loading branch information
timurhai committed Aug 4, 2021
1 parent ec7d539 commit 8cba033
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
2 changes: 2 additions & 0 deletions afanasy/src/server/jobaf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1704,4 +1704,6 @@ void JobAf::appendBlocks(Action & i_action, const JSON & i_operation)

checkDepends();
checkStatesOnAppend();

i_action.monitors->addJobEvent(af::Monitor::EVT_jobs_change, getId(), getUid());
}
22 changes: 19 additions & 3 deletions afanasy/src/watch/itemjob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,31 @@ ItemJob::~ItemJob()

void ItemJob::v_updateValues(af::Node * i_afnode, int i_msgType)
{
af::Job *job = (af::Job*)i_afnode;
af::Job *job = static_cast<af::Job*>(i_afnode);

if (m_blocks.size() != job->getBlocksNum())
if (m_serial != job->getSerial())
{
AFERROR("ItemJob::v_updateValues: Blocks number mismatch, deleting invalid item.")
AFERROR("ItemJob::v_updateValues: Job serial number mismatch, deleting item.")
resetId();
return;
}

if (m_blocks.size() > job->getBlocksNum())
{
AFERROR("ItemJob::v_updateValues: Constructed job blocks size is greater than arrived from server, deleting item.")
resetId();
return;
}

if (m_blocks.size() < job->getBlocksNum())
for (int b = m_blocks.size(); b < job->getBlocksNum(); b++)
{
const af::BlockData * blockdata = job->getBlock(b);
BlockInfo * blockinfo = new BlockInfo(blockdata, this, m_list_nodes);
QObject::connect(blockinfo, SIGNAL(sig_BlockAction(int, QString)), m_list_nodes, SLOT(slot_BlockAction(int, QString)));
m_blocks.append(blockinfo);
}

// Store previous state to check difference for notifications.
int64_t prev_state = state;

Expand Down

0 comments on commit 8cba033

Please sign in to comment.