diff options
Diffstat (limited to 'lorrycontroller/statedb.py')
-rw-r--r-- | lorrycontroller/statedb.py | 41 |
1 files changed, 31 insertions, 10 deletions
diff --git a/lorrycontroller/statedb.py b/lorrycontroller/statedb.py index 2d223e0..fd7857d 100644 --- a/lorrycontroller/statedb.py +++ b/lorrycontroller/statedb.py @@ -129,6 +129,7 @@ class StateDB(object): 'pid INT, ' 'started INT, ' 'ended INT, ' + 'updated INT, ' 'kill INT, ' 'path TEXT, ' 'exit TEXT, ' @@ -454,8 +455,8 @@ class StateDB(object): def get_job_info(self, job_id): c = self.get_cursor() c.execute( - 'SELECT job_id, host, pid, started, ended, kill, path, exit, ' - 'disk_usage, output FROM jobs WHERE job_id=?', + 'SELECT job_id, host, pid, started, ended, updated, kill, ' + 'path, exit, disk_usage, output FROM jobs WHERE job_id=?', (job_id,)) row = c.fetchone() return { @@ -464,11 +465,12 @@ class StateDB(object): 'pid': row[2], 'started': row[3], 'ended': row[4], - 'kill': row[5], - 'path': row[6], - 'exit': row[7], - 'disk_usage': row[8], - 'output': row[9], + 'updated': row[5], + 'kill': row[6], + 'path': row[7], + 'exit': row[8], + 'disk_usage': row[9], + 'output': row[10], } def add_new_job(self, job_id, host, pid, path, started): @@ -478,9 +480,10 @@ class StateDB(object): assert self.in_transaction c = self.get_cursor() c.execute( - 'INSERT INTO jobs (job_id, host, pid, path, started, kill) ' - 'VALUES (?, ?, ?, ?, ?, ?)', - (job_id, host, pid, path, started, 0)) + 'INSERT INTO jobs (job_id, host, pid, path, started, ' + 'updated, kill) ' + 'VALUES (?, ?, ?, ?, ?, ?, ?)', + (job_id, host, pid, path, started, started, 0)) def get_job_minion_host(self, job_id): c = self.get_cursor() @@ -514,6 +517,24 @@ class StateDB(object): row = c.fetchone() return row[0], row[1] + def get_job_updated(self, job_id): + c = self.get_cursor() + c.execute( + 'SELECT updated FROM jobs WHERE job_id IS ?', + (job_id,)) + row = c.fetchone() + return row[0] + + def set_job_updated(self, job_id, updated): + logging.debug( + 'StateDB.set_job_updated(%r, %r) called', + job_id, updated) + assert self.in_transaction + c = self.get_cursor() + c.execute( + 'UPDATE jobs SET updated=? WHERE job_id IS ?', + (updated, job_id)) + def get_job_exit(self, job_id): c = self.get_cursor() c.execute( |