Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
dcdb
dcdb
Commits
a042e498
Commit
a042e498
authored
Dec 13, 2018
by
Micha Mueller
Browse files
Refactor upcoming jobdatastore interface for libdcdb
parent
2344db72
Changes
3
Hide whitespace changes
Inline
Side-by-side
lib/include/dcdb/jobdatastore.h
View file @
a042e498
...
...
@@ -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
remov
eJob
(
Job
Id
jid
);
JDError
updat
eJob
(
Job
Data
&
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
s
etNodeList
(
JobId
jid
,
NodeList
nodes
);
JDError
g
etNodeList
(
NodeList
&
nodes
,
JobId
jid
);
/**
* @brief A shortcut constructor for a JobDataStore object that allows
...
...
lib/include_internal/jobdatastore_internal.h
View file @
a042e498
...
...
@@ -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
();
};
...
...
lib/src/jobdatastore.cpp
View file @
a042e498
...
...
@@ -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
&
j
ob
,
JobId
jid
)
{
JDError
JobDataStoreImpl
::
updateJob
(
JobData
&
j
data
)
{
//TODO
return
JD_UNKNOWNERROR
;
}
/**
* @details
* //
TODO
* //
unnecessary but kept for completeness
*/
JDError
JobDataStoreImpl
::
getJobsByUser
(
std
::
list
<
JobData
>&
jobs
,
User
Id
u
id
)
{
JDError
JobDataStoreImpl
::
removeJob
(
Job
Id
j
id
)
{
//TODO
return
JD_UNKNOWNERROR
;
}
...
...
@@ -144,18 +125,18 @@ JDError JobDataStoreImpl::getJobsByUser(std::list<JobData>& jobs, UserId uid) {
* @details
* //TODO
*/
JDError
JobDataStoreImpl
::
get
NodeList
(
NodeList
&
nodes
,
JobId
jid
)
{
JDError
JobDataStoreImpl
::
get
JobById
(
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
::
s
etNodeList
(
JobId
jid
,
NodeList
nodes
)
{
JDError
JobDataStoreImpl
::
g
etNodeList
(
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
::
remov
eJob
(
Job
Id
jid
)
{
return
impl
->
remov
eJob
(
j
i
d
);
JDError
JobDataStore
::
updat
eJob
(
Job
Data
&
jdata
)
{
return
impl
->
updat
eJob
(
jd
ata
);
}
/**
...
...
@@ -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
->
get
Job
s
(
j
obs
);
JDError
JobDataStore
::
removeJob
(
JobId
jid
)
{
return
impl
->
remove
Job
(
j
id
);
}
/**
...
...
@@ -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 des
c
tructor deallocates the
* The JobDataStore destructor deallocates the
* JobDataStoreImpl and CassandraBackend objects.
*/
JobDataStore
::~
JobDataStore
()
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment