Skip to content

Commit

Permalink
Add time data to job queries
Browse files Browse the repository at this point in the history
If the data stream contains time data (job submit, job start, job
complete), parse it and store it in output properties.

Refs #7946
  • Loading branch information
rgmiller committed Sep 18, 2013
1 parent a5db9db commit 4ae755e
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 10 deletions.
45 changes: 35 additions & 10 deletions Code/Mantid/Framework/RemoteAlgorithms/src/QueryAllRemoteJobs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,11 @@ void QueryAllRemoteJobs::init()
declareProperty( new ArrayProperty<std::string>("ScriptName", nullValidator, Direction::Output));
declareProperty( new ArrayProperty<std::string>("TransID", nullValidator, Direction::Output));

// These aren't implemented on the server side, yet
// declareProperty( new ArrayProperty<std::string>("JobStartTime", nullValidator, Direction::Output));
// declareProperty( new ArrayProperty<std::string>("JobCompletionTime", nullValidator, Direction::Output));
// Times for job submit, job start and job complete (may be empty depending
// on the server-side implementation)
declareProperty( new ArrayProperty<std::string>("SubmitTime", nullValidator, Direction::Output));
declareProperty( new ArrayProperty<std::string>("StartTime", nullValidator, Direction::Output));
declareProperty( new ArrayProperty<std::string>("CompletionTime", nullValidator, Direction::Output));
}

void QueryAllRemoteJobs::exec()
Expand Down Expand Up @@ -76,10 +78,9 @@ void QueryAllRemoteJobs::exec()
std::vector<std::string> jobNames;
std::vector<std::string> scriptNames;
std::vector<std::string> transIds;

// These haven't been implemented on the server side yet
// std::vector<std::string> jobStartTimes;
// std::vector<std::string> jobCompletionTimes;
std::vector<std::string> submitTimes;
std::vector<std::string> startTimes;
std::vector<std::string> completionTimes;

JSONObject::const_iterator it = resp.begin();
while (it != resp.end())
Expand All @@ -101,6 +102,30 @@ void QueryAllRemoteJobs::exec()
jobData["TransID"].getValue( value);
transIds.push_back(value);


// The time stuff is actually an optional extension. We could check the info
// URL and see if the server implements it, but it's easier to just look in
// the output and see if the values are there...
if (jobData.find( "SubmitTime") != jobData.end())
{
jobData["SubmitTime"].getValue( value);
submitTimes.push_back( value);

jobData["StartTime"].getValue( value);
startTimes.push_back( value);

jobData["CompletionTime"].getValue( value);
completionTimes.push_back( value);
}
else
{
// push back empty strings just so all the array properties have the same
// number of elements
submitTimes.push_back( "");
startTimes.push_back( "");
completionTimes.push_back( "");
}

it++;
}

Expand All @@ -109,9 +134,9 @@ void QueryAllRemoteJobs::exec()
setProperty( "JobName", jobNames);
setProperty( "ScriptName", scriptNames);
setProperty( "TransID", transIds);

// setProperty( "JobStartTime", jobStartTimes);
// setProperty( "JobCompletionTime", jobCompletionTimes);
setProperty( "SubmitTime", submitTimes);
setProperty( "StartTime", startTimes);
setProperty( "CompletionTime", completionTimes);

}
else
Expand Down
21 changes: 21 additions & 0 deletions Code/Mantid/Framework/RemoteAlgorithms/src/QueryRemoteJob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ void QueryRemoteJob::init()
// Transaction ID this job is associated with
declareProperty( "TransID", "", nullValidator, "", Direction::Output);

// Times for job submit, job start and job complete (may be empty depending
// on the server-side implementation)
declareProperty( "SubmitTime", "", nullValidator, "", Direction::Output);
declareProperty( "StartTime", "", nullValidator, "", Direction::Output);
declareProperty( "CompletionTime", "", nullValidator, "", Direction::Output);

}

void QueryRemoteJob::exec()
Expand Down Expand Up @@ -88,6 +94,21 @@ void QueryRemoteJob::exec()

status["TransID"].getValue( value);
setProperty( "TransID", value);

// The time stuff is actually an optional extension. We could check the info
// URL and see if the server implements it, but it's easier to just look in
// the output and see if the values are there...
if (status.find( "SubmitTime") != status.end())
{
status["SubmitTime"].getValue( value);
setProperty( "SubmitTime", value);

status["StartTime"].getValue( value);
setProperty( "StartTime", value);

status["CompletionTime"].getValue( value);
setProperty( "CompletionTime", value);
}
}
else
{
Expand Down

0 comments on commit 4ae755e

Please sign in to comment.