Commit a042e498 authored by Micha Mueller's avatar Micha Mueller
Browse files

Refactor upcoming jobdatastore interface for libdcdb

parent 2344db72
......@@ -53,22 +53,24 @@ namespace DCDB {
using NodeList = std::list<std::string>;
/**
* @brief This class is a container for the information DCDB keeps about
* @brief This struct is a container for the information DCDB keeps about
* SLURM jobs.
*/
class JobData {
public:
struct JobData {
JobId jobId; /**< SLURM job id of the job. */
UserId userId; /**< Id of the user who submitted the job. */
TimeStamp startTime;/**< Time when the job started (started != submitted) */
TimeStamp endTime; /**< Time when the job finished. */
NodeList nodes; /**< List of nodes the job occupied. */
//TODO
/* extend as required */
};
typedef enum {
JD_OK,
JD_UNKNOWNERROR
JD_OK, /**< Everything went fine. */
JD_JOBIDNOTFOUND, /**< The given JobId was not found. */
JD_INVALIDJOBDATA, /**< The provided JobData object is invalid. Either
because the data is erroneous or incomplete. */
JD_UNKNOWNERROR /**< An unknown error occurred. */
//TODO
} JDError;
......@@ -83,39 +85,43 @@ namespace DCDB {
public:
/**
* @brief This function inserts a single job into the database.
* @param jid Id of the job.
* @param uid Id of the user the job belongs to.
* @param startTs The starting timestamp of the job.
* @param endTs The end timestamp of the job.
* @param nodes List of nodes which were used by the job.
*
* @param jdata Reference to a JobData object filled with all the
* information about the job.
* @return See JDError
*/
JDError insertJob(JobId jid, UserId uid, TimeStamp startTs,
TimeStamp endTs, NodeList nodes);
JDError insertJob(JobData& jdata);
/**
* @brief This function inserts a single job which was submitted to SLURM
* but not yet executed into the database.
* @brief This function inserts a single job which was submitted but not
* yet executed into the database.
*
* @param jid Id of the job.
* @param uid Id of the user the job belongs to.
* @return See JDError
*/
JDError insertSubmittedJob(JobId jid, UserId uid);
/**
* @brief Removes a job from the job data list.
* @brief Update a job.
*
* @param jid JobId.
* @return See JDError.
* @details Updates the job in the database whose JobId matches
* jdata.JobId. If no such job is found, no job data is
* inserted.
*
* @param jdata Reference to a JobData object filled with all the
* information about the job.
* @return See JDError.
*/
JDError removeJob(JobId jid);
JDError updateJob(JobData& jdata);
/**
* @brief Get the entire list of jobs.
* @brief Removes a job from the job data list.
*
* @param jobData Reference to a list of JobData that will be populated
* with the jobs.
* @return See JDError.
* @param jid JobId.
* @return See JDError.
*/
JDError getJobs(std::list<JobData>& jobs);
JDError removeJob(JobId jid);
/**
* @brief Retrieve a job by id.
......@@ -128,50 +134,50 @@ namespace DCDB {
JDError getJobById(JobData& job, JobId jid);
/**
* @brief Retrieve a list of jobs which belong to a user.
* @brief Retrieve an exclusive list of jobs which were run in the given
* time interval.
*
* @param jobs Reference to a list of JobData that will be populated with
* the jobs.
* @param uid Id of the user whose jobs should be retrieved.
* @return See JDError.
*/
JDError getJobsByUser(std::list<JobData>& jobs, UserId uid);
/**
* @brief Retrieve the list of nodes which were used by a job.
* @details EXCLUSIVE version; only jobs whose start AND end time lay
* within the interval are returned. See also
* getJobsInIntervalIncl().
*
* @param nodes
* @param jid
* @return
*/
JDError getNodeList(NodeList& nodes, JobId jid);
/**
* @brief Set the startTime for a job. (Intended for jobs which were
* inserted via insertSubmittedJob())
* @param jid SLURM id of the job.
* @param startTime New starting time of the job.
* @return See JDError.
* @param jobs Reference to a list of JobData that will be
* populated with the jobs.
* @param intervalStart Starting time of the interval.
* @param intervalEnd End time of the interval.
* @return See JDError.
*/
JDError setStartTime(JobId jid, TimeStamp startTime);
JDError getJobsInIntervalExcl(std::list<JobData>& jobs,
TimeStamp intervalStart,
TimeStamp intervalEnd);
/**
* @brief Set the endTime for a job. (Intended for jobs which were
* inserted via insertSubmittedJob())
* @param jid SLURM id of the job.
* @param endTime New end time of the job.
* @return See JDError.
* @brief Retrieve an inclusive list of jobs which were run in the given
* time interval.
*
* @details INCLUSIVE version; all jobs whose start OR end time lay
* within the interval are returned. See also
* getJobsInIntervalExcl().
*
* @param jobs Reference to a list of JobData that will be
* populated with the jobs.
* @param intervalStart Starting time of the interval.
* @param intervalEnd End time of the interval.
* @return See JDError.
*/
JDError setEndTime(JobId jid, TimeStamp endTime);
JDError getJobsInIntervalIncl(std::list<JobData>& jobs,
TimeStamp intervalStart,
TimeStamp intervalEnd);
/**
* @brief Set the list of nodes for a job. (Intended for jobs which were
* inserted via insertSubmittedJob())
* @param jid SLURM id of the job.
* @param nodes List of nodes which were used by the job.
* @return See JDError.
* @brief Retrieve the list of nodes which were used by a job.
*
* @param nodes Reference to a NodeList which will be populated with
* the nodes.
* @param jid Id of the job whose nodes should be retrieved.
* @return See JDError.
*/
JDError setNodeList(JobId jid, NodeList nodes);
JDError getNodeList(NodeList& nodes, JobId jid);
/**
* @brief A shortcut constructor for a JobDataStore object that allows
......
......@@ -62,20 +62,21 @@ namespace DCDB {
public:
/* See jobdatastore.h for documentation */
JDError insertJob(JobId jid, UserId uid, TimeStamp startTs,
TimeStamp endTs, NodeList nodes);
JDError insertJob(JobData& jdata);
JDError insertSubmittedJob(JobId jid, UserId uid);
JDError updateJob(JobData& jdata);
JDError removeJob(JobId jid);
JDError getJobs(std::list<JobData>& jobs);
JDError getJobById(JobData& job, JobId jid);
JDError getJobsByUser(std::list<JobData>& jobs, UserId uid);
JDError getJobsInIntervalExcl(std::list<JobData>& jobs,
TimeStamp intervalStart,
TimeStamp intervalEnd);
JDError getJobsInIntervalIncl(std::list<JobData>& jobs,
TimeStamp intervalStart,
TimeStamp intervalEnd);
JDError getNodeList(NodeList& nodes, JobId jid);
JDError setStartTime(JobId jid, TimeStamp startTime);
JDError setEndTime(JobId jid, TimeStamp endTime);
JDError setNodeList(JobId jid, NodeList nodes);
JobDataStoreImpl(Connection* conn);
virtual ~JobDataStoreImpl();
};
......
......@@ -89,8 +89,7 @@ void JobDataStoreImpl::prepareInsert(uint64_t ttl) {
* @details
* //TODO
*/
JDError JobDataStoreImpl::insertJob(JobId jid, UserId uid, TimeStamp startTs,
TimeStamp endTs, NodeList nodes) {
JDError JobDataStoreImpl::insertJob(JobData& jdata) {
//TODO
return JD_UNKNOWNERROR;
}
......@@ -104,38 +103,20 @@ JDError JobDataStoreImpl::insertSubmittedJob(JobId jid, UserId uid) {
return JD_UNKNOWNERROR;
}
/**
* @details
* //TODO unnecessary
*/
JDError JobDataStoreImpl::removeJob(JobId jid) {
//TODO
return JD_UNKNOWNERROR;
}
/**
* @details
* //TODO unnecessary. Merge with getJobsByUser to getJobsByTime
*/
JDError JobDataStoreImpl::getJobs(std::list<JobData>& jobs) {
//TODO
return JD_UNKNOWNERROR;
}
/**
* @details
* //TODO
*/
JDError JobDataStoreImpl::getJobById(JobData& job, JobId jid) {
JDError JobDataStoreImpl::updateJob(JobData& jdata) {
//TODO
return JD_UNKNOWNERROR;
}
/**
* @details
* //TODO
* //unnecessary but kept for completeness
*/
JDError JobDataStoreImpl::getJobsByUser(std::list<JobData>& jobs, UserId uid) {
JDError JobDataStoreImpl::removeJob(JobId jid) {
//TODO
return JD_UNKNOWNERROR;
}
......@@ -144,18 +125,18 @@ JDError JobDataStoreImpl::getJobsByUser(std::list<JobData>& jobs, UserId uid) {
* @details
* //TODO
*/
JDError JobDataStoreImpl::getNodeList(NodeList& nodes, JobId jid) {
JDError JobDataStoreImpl::getJobById(JobData& job, JobId jid) {
//TODO
return JD_UNKNOWNERROR;
}
//TODO merge setter into one update method
/**
* @details
* //TODO
*/
JDError JobDataStoreImpl::setStartTime(JobId jid, TimeStamp startTime) {
JDError JobDataStoreImpl::getJobsInIntervalExcl(std::list<JobData>& jobs,
TimeStamp intervalStart,
TimeStamp intervalEnd) {
//TODO
return JD_UNKNOWNERROR;
}
......@@ -164,7 +145,9 @@ JDError JobDataStoreImpl::setStartTime(JobId jid, TimeStamp startTime) {
* @details
* //TODO
*/
JDError JobDataStoreImpl::setEndTime(JobId jid, TimeStamp endTime) {
JDError JobDataStoreImpl::getJobsInIntervalIncl(std::list<JobData>& jobs,
TimeStamp intervalStart,
TimeStamp intervalEnd) {
//TODO
return JD_UNKNOWNERROR;
}
......@@ -173,7 +156,7 @@ JDError JobDataStoreImpl::setEndTime(JobId jid, TimeStamp endTime) {
* @details
* //TODO
*/
JDError JobDataStoreImpl::setNodeList(JobId jid, NodeList nodes) {
JDError JobDataStoreImpl::getNodeList(NodeList& nodes, JobId jid) {
//TODO
return JD_UNKNOWNERROR;
}
......@@ -212,9 +195,8 @@ JobDataStoreImpl::~JobDataStoreImpl() {
* Instead of doing the actual work, this function simply forwards to the
* corresponding function of the JobDataStoreImpl class.
*/
JDError JobDataStore::insertJob(JobId jid, UserId uid, TimeStamp startTs,
TimeStamp endTs, NodeList nodes) {
return impl->insertJob(jid, uid, startTs, endTs, nodes);
JDError JobDataStore::insertJob(JobData& jdata) {
return impl->insertJob(jdata);
}
/**
......@@ -231,8 +213,8 @@ JDError JobDataStore::insertSubmittedJob(JobId jid, UserId uid) {
* Instead of doing the actual work, this function simply forwards to the
* corresponding function of the JobDataStoreImpl class.
*/
JDError JobDataStore::removeJob(JobId jid) {
return impl->removeJob(jid);
JDError JobDataStore::updateJob(JobData& jdata) {
return impl->updateJob(jdata);
}
/**
......@@ -240,8 +222,8 @@ JDError JobDataStore::removeJob(JobId jid) {
* Instead of doing the actual work, this function simply forwards to the
* corresponding function of the JobDataStoreImpl class.
*/
JDError JobDataStore::getJobs(std::list<JobData>& jobs) {
return impl->getJobs(jobs);
JDError JobDataStore::removeJob(JobId jid) {
return impl->removeJob(jid);
}
/**
......@@ -258,17 +240,10 @@ JDError JobDataStore::getJobById(JobData& job, JobId jid) {
* Instead of doing the actual work, this function simply forwards to the
* corresponding function of the JobDataStoreImpl class.
*/
JDError JobDataStore::getJobsByUser(std::list<JobData>& jobs, UserId uid) {
return impl->getJobsByUser(jobs, uid);
}
/**
* @details
* Instead of doing the actual work, this function simply forwards to the
* corresponding function of the JobDataStoreImpl class.
*/
JDError JobDataStore::getNodeList(NodeList& nodes, JobId jid) {
return impl->getNodeList(nodes, jid);
JDError JobDataStore::getJobsInIntervalExcl(std::list<JobData>& jobs,
TimeStamp intervalStart,
TimeStamp intervalEnd) {
return impl->getJobsInIntervalExcl(jobs, intervalStart, intervalEnd);
}
/**
......@@ -276,8 +251,10 @@ JDError JobDataStore::getNodeList(NodeList& nodes, JobId jid) {
* Instead of doing the actual work, this function simply forwards to the
* corresponding function of the JobDataStoreImpl class.
*/
JDError JobDataStore::setStartTime(JobId jid, TimeStamp startTime) {
return impl->setStartTime(jid, startTime);
JDError JobDataStore::getJobsInIntervalIncl(std::list<JobData>& jobs,
TimeStamp intervalStart,
TimeStamp intervalEnd) {
return impl->getJobsInIntervalIncl(jobs, intervalStart, intervalEnd);
}
/**
......@@ -285,17 +262,8 @@ JDError JobDataStore::setStartTime(JobId jid, TimeStamp startTime) {
* Instead of doing the actual work, this function simply forwards to the
* corresponding function of the JobDataStoreImpl class.
*/
JDError JobDataStore::setEndTime(JobId jid, TimeStamp endTime) {
return impl->setEndTime(jid, endTime);
}
/**
* @details
* Instead of doing the actual work, this function simply forwards to the
* corresponding function of the JobDataStoreImpl class.
*/
JDError JobDataStore::setNodeList(JobId jid, NodeList nodes) {
return impl->setNodeList(jid, nodes);
JDError JobDataStore::getNodeList(NodeList& nodes, JobId jid) {
return impl->getNodeList(nodes, jid);
}
/**
......@@ -309,7 +277,7 @@ JobDataStore::JobDataStore(Connection* conn) {
/**
* @details
* The JobDataStore desctructor deallocates the
* The JobDataStore destructor deallocates the
* JobDataStoreImpl and CassandraBackend objects.
*/
JobDataStore::~JobDataStore() {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment