Commit d8225ec1 authored by Cristiano Urban's avatar Cristiano Urban
Browse files

Added code to set job 'startTime' and 'endTime' parameters.

parent 724bec4a
Loading
Loading
Loading
Loading
+22 −0
Original line number Diff line number Diff line
@@ -324,6 +324,28 @@ class DbConnector(object):
                 json.dumps(jobObj.results),))
            self.conn.commit()
            
    def setStartTime(self, jobId):
        """Sets the job 'start_time' parameter."""
        if self.conn:
            startTime = datetime.datetime.today().isoformat()
            self.cursor.execute("""
                UPDATE job SET start_time = %s
                WHERE job_id = %s;
                """,
                (startTime, jobId,))
            self.conn.commit()
 
    def setEndTime(self, jobId):
        """Sets the job 'end_time' parameter."""
        if self.conn:
            endTime = datetime.datetime.today().isoformat()
            self.cursor.execute("""
                UPDATE job SET end_time = %s
                WHERE job_id = %s;
                """,
                (endTime, jobId,))
            self.conn.commit()

    def setPhase(self, jobId, phase):
        """Sets the job 'phase' parameter."""
        if self.conn:
+2 −0
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ class RetrieveExecutor(TaskExecutor):
        fileList = []
        self.dbConn.connect()
        self.dbConn.setPhase(self.jobId, "EXECUTING")
        self.dbConn.setStartTime(self.jobId)
        for vospacePath in self.nodeList:
            [srcPath, storageType, username, osRelPath] = self.dbConn.getOSPath(vospacePath)
            if storageType == "cold":
@@ -88,6 +89,7 @@ class RetrieveExecutor(TaskExecutor):
        self.dbConn.setResults(self.jobId, results)
        self.jobObj.setPhase("COMPLETED")
        self.dbConn.setPhase(self.jobId, "COMPLETED")
        self.dbConn.setEndTime(self.jobId)
        self.dbConn.disconnect()
        
    def cleanup(self):
+2 −0
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@ class StoreExecutor(TaskExecutor):
    def copyData(self):
        self.dbConn.connect()
        self.dbConn.setPhase(self.jobId, "EXECUTING")
        self.dbConn.setStartTime(self.jobId)
        srcPathPrefix = self.storageStorePath.replace("{username}", self.username)
        srcData = os.listdir(srcPathPrefix)
        destPathPrefix = self.dbConn.getStorageBasePath(self.storageId) + '/' + self.username
@@ -78,6 +79,7 @@ class StoreExecutor(TaskExecutor):
            self.dbConn.setBusyState(nodeVOSPath, False);
        self.jobObj.setPhase("COMPLETED")
        self.dbConn.setPhase(self.jobId, "COMPLETED")
        self.dbConn.setEndTime(self.jobId)
        out.close()
        self.dbConn.disconnect()