grr/server/grr_response_server/databases/mysql_flows.py
def ReadFlowForProcessing(self,
                            client_id,
                            flow_id,
                            processing_time,
                            cursor=None):
    """Marks a flow as being processed on this worker and returns it."""
    query = ("SELECT " + self.FLOW_DB_FIELDS +
             "FROM flows WHERE client_id=%s AND flow_id=%s")
    cursor.execute(query, [
        mysql_utils.ClientIDToInt(client_id),
        mysql_utils.FlowIDToInt(flow_id)
    ])
    response = cursor.fetchall()
    if not response:
      raise db.UnknownFlowError(client_id, flow_id)

    row, = response
    rdf_flow = self._FlowObjectFromRow(row)

    now = rdfvalue.RDFDatetime.Now()
    if rdf_flow.processing_on and rdf_flow.processing_deadline > now:
      raise ValueError("Flow %s on client %s is already being processed." %
                       (client_id, flow_id))
    update_query = ("UPDATE flows SET processing_on=%s, processing_since=%s, "
                    "processing_deadline=%s WHERE client_id=%s and flow_id=%s")
    processing_deadline = now + processing_time
    process_id_string = utils.ProcessIdString()

    args = [
        process_id_string,
        mysql_utils.RDFDatetimeToMysqlString(now),
        mysql_utils.RDFDatetimeToMysqlString(processing_deadline),
        mysql_utils.ClientIDToInt(client_id),
        mysql_utils.FlowIDToInt(flow_id)
    ]
    cursor.execute(update_query, args)

    # This needs to happen after we are sure that the write has succeeded.
    rdf_flow.processing_on = process_id_string
    rdf_flow.processing_since = now
    rdf_flow.processing_deadline = processing_deadline
    return rdf_flow
Marks a flow as being processed on this worker and returns it.
Marks a flow as being processed on this worker and returns it.
Marks a flow as being processed on this worker and returns it .
def ReadFlowForProcessing(self,
                            client_id,
                            flow_id,
                            processing_time,
                            cursor=None):
    query = ("SELECT " + self.FLOW_DB_FIELDS +
             "FROM flows WHERE client_id=%s AND flow_id=%s")
    cursor.execute(query, [
        mysql_utils.ClientIDToInt(client_id),
        mysql_utils.FlowIDToInt(flow_id)
    ])
    response = cursor.fetchall()
    if not response:
      raise db.UnknownFlowError(client_id, flow_id)
    row, = response
    rdf_flow = self._FlowObjectFromRow(row)
    now = rdfvalue.RDFDatetime.Now()
    if rdf_flow.processing_on and rdf_flow.processing_deadline > now:
      raise ValueError("Flow %s on client %s is already being processed." %
                       (client_id, flow_id))
    update_query = ("UPDATE flows SET processing_on=%s, processing_since=%s, "
                    "processing_deadline=%s WHERE client_id=%s and flow_id=%s")
    processing_deadline = now + processing_time
    process_id_string = utils.ProcessIdString()
    args = [
        process_id_string,
        mysql_utils.RDFDatetimeToMysqlString(now),
        mysql_utils.RDFDatetimeToMysqlString(processing_deadline),
        mysql_utils.ClientIDToInt(client_id),
        mysql_utils.FlowIDToInt(flow_id)
    ]
    cursor.execute(update_query, args)
    rdf_flow.processing_on = process_id_string
    rdf_flow.processing_since = now
    rdf_flow.processing_deadline = processing_deadline
    return rdf_flow
def ReadFlowForProcessing ( self , client_id , flow_id , processing_time , cursor = None ) : query = ( "SELECT " + self . FLOW_DB_FIELDS + "FROM flows WHERE client_id=%s AND flow_id=%s" ) cursor . execute ( query , [ mysql_utils . ClientIDToInt ( client_id ) , mysql_utils . FlowIDToInt ( flow_id ) ] ) response = cursor . fetchall ( ) if not response : raise db . UnknownFlowError ( client_id , flow_id ) row , = response rdf_flow = self . _FlowObjectFromRow ( row ) now = rdfvalue . RDFDatetime . Now ( ) if rdf_flow . processing_on and rdf_flow . processing_deadline > now : raise ValueError ( "Flow %s on client %s is already being processed." % ( client_id , flow_id ) ) update_query = ( "UPDATE flows SET processing_on=%s, processing_since=%s, " "processing_deadline=%s WHERE client_id=%s and flow_id=%s" ) processing_deadline = now + processing_time process_id_string = utils . ProcessIdString ( ) args = [ process_id_string , mysql_utils . RDFDatetimeToMysqlString ( now ) , mysql_utils . RDFDatetimeToMysqlString ( processing_deadline ) , mysql_utils . ClientIDToInt ( client_id ) , mysql_utils . FlowIDToInt ( flow_id ) ] cursor . execute ( update_query , args ) rdf_flow . processing_on = process_id_string rdf_flow . processing_since = now rdf_flow . processing_deadline = processing_deadline return rdf_flow
Marks a flow as being processed on this worker and returns it.
Marks a flow as being processed on this worker and returns it .
"""Marks a flow as being processed on this worker and returns it.""" # This needs to happen after we are sure that the write has succeeded.
self
client_id
flow_id
processing_time
cursor