Ejemplo n.º 1
0
        SSER_LastRunTime = RunTime
        InfoDic['runTime'] = "%.3f" % RunTime
        print "In sser-unit: RUNTIME IS ",InfoDic['runTime']
    except AIRandomUtils.AIRandomError, e:
        print "AIRandomUtils.AIRandomError", e
        InfoDic['runTime'] = None
    except Exception, e:
        print "ERROR!", e, "Name", Name, "Params", ParamsList
        InfoDic['runTime'] = None
        
    if (InfoDic['runTime'] == None) or \
       (float(InfoDic['runTime']) < 0) or (float(InfoDic['runTime']) > SubmitDurationMS):
        # all workload units are started within at most SubmitDurationMS miliseconds
        print "Wrong arrival time of", InfoDic['runTime'], "generated by", Name, ParamsList
        print "Resetting to default U(0,%d)" % SubmitDurationMS
        InfoDic['runTime'] = str(AIRandomUtils.getRandomInt(0, SubmitDurationMS))
    return InfoDic
    
def generateJobComponents( UnitDir, UnitID, JobIndex, WLUnit, bGenerateRandom = 1, \
    Size = 0, N = 20, M = None, S = None, C = 10, MaxWallTime = 0):
        
    ComponentsList = []
    nValidComponents = 0
    for ComponentID in WLUnit['components'].keys():
        
        Component = WLUnit['components'][ComponentID]
        WLCompName = "%s-%d-%s" % ( UnitID, JobIndex, ComponentID ) # added multiplicity id
        
        #-- set component
        ComponentData = {}
        if bGenerateRandom > 0:
Ejemplo n.º 2
0
def runJob(data):
    # 1. check if the job can be run (deps & time)
    # 1.1. yes: run the job
    # 1.1.1.    if job run successfully
    # 1.1.1.1.  yes: mark job as correct
    # 1.1.1.2.  no: put the job back into the pool, if not failed (too many failures)
    # 1.2. no: put the job back into the pool

    # -- compute due sleep time - modified (corina): sleep time will always be 0
    # sleepDuration = max( 0, data['firstSubmission'] + data['startTime'] - time.time())
    sleepDuration = 0

    # 1. check if the job can be run (time)
    if sleepDuration <= 0:  # job is due to run
        # -- start timers
        result = {}
        result["start"] = time.time()
        result["wakeup"] = time.time()
        result["submit"] = time.time()
        # 1. check if the job can be run (time)
        JobID = data["id"]
        # print "##### [runJob] job is due to run: %s " % JobID

        CurrentCompositeApplicationData = data[".CompositeApplicationData"]
        if CurrentCompositeApplicationData.isRunnable(JobID):  # job can run
            # 1.1. yes: run the job
            patchSleepDuration = AIRandomUtils.getRandomInt(0, 10)
            time.sleep(patchSleepDuration)
            Command = data["commandLine"]
            outputString = "(" + data["id"] + ") runs command:\n    " + Command
            print outputString
            if data["NoSubmit"] != 1:
                try:
                    cmdOutput = AISystemUtil.getCommandOutput2(Command)
                    result["status"] = "SUCCEEDED"
                    CurrentCompositeApplicationData.triggerJobFinished(JobID)

                except RuntimeError, e:
                    print "Job", JobID, "returned:", e
                    cmdOutput = ""
                    # job failed ?
                    CurrentCompositeApplicationData.triggerJobFailure(JobID)
                    if CurrentCompositeApplicationData.isFailed(JobID):
                        result["status"] = "FAILED"
                        CurrentCompositeApplicationData.propagateFailure(JobID)
                        print "Job", JobID, "was declared failed (too many failures)"

                    else:
                        result["status"] = "RETRY"
                        print "Job", JobID, "failed... rescheduling"
                        return None

                outputString = "Output (" + JobID + "): '" + cmdOutput + "'"
                print outputString
            else:  # no submit -> just mark as succeessful
                result["status"] = "SUCCEEDED"

            result["exit"] = time.time()
            # -- return all the times
            ##print "Job", JobID, "Send good result", result['status']
            return result

        elif CurrentCompositeApplicationData.isFailed(JobID):
            result["exit"] = time.time()
            result["status"] = "FAILED"
            # -- return all the times
            ##print "Job", JobID, "Send good result", result['status']
            return result
Ejemplo n.º 3
0
def generateJDF(OutFileName, ListOfComponents):
    """ 
    Generate a OGF JSDL File for a given workload unit. 
    
    In:
        OutFileName      -- the target file for writing the JDF of this workload unit
        ListOfComponents -- a list of components
                            Each component is a dictionary and has defined at 
                            least the following keys:
                            id, executable, count, description, directory, 
                            maxWallTime, arguments, env, stagein, stageout,
                            stdout, stderr
    """

    print "STATUS! Write JDF file", OutFileName,
    OutFile = open(OutFileName, "w")

    index = 0
    nComponents = len(ListOfComponents)
    Component = ListOfComponents[0]  # one component

    writeJsdlHeader(OutFile)
    OutFile.write("<jsdl:JobDescription>\n")

    """
    <jsdl:Application>
      <jsdl:ApplicationName>ls</jsdl:ApplicationName>
      <jsdl-posix:POSIXApplication>
        <jsdl-posix:Executable>/bin/ls</jsdl-posix:Executable>
        <jsdl-posix:Argument>-la file.txt</jsdl-posix:Argument>
        <jsdl-posix:Environment name="LD_LIBRARY_PATH">/usr/local/lib</jsdl-posix:Environment>
        <jsdl-posix:Input>/dev/null</jsdl-posix:Input>
        <jsdl-posix:Output>stdout.${JOB_ID}</jsdl-posix:Output>
        <jsdl-posix:Error>stderr.${JOB_ID}</jsdl-posix:Error>
      </jsdl-posix:POSIXApplication>
    </jsdl:Application>
    """
    OutFile.write("<jsdl:Application>\n")
    OutFile.write("<jsdl:ApplicationName>")
    OutFile.write("sser" + str(AIRandomUtils.getRandomInt(0, int(2 ** 64))))
    OutFile.write("</jsdl:ApplicationName>\n")

    OutFile.write("<jsdl-posix:POSIXApplication>\n")
    OutFile.write("<jsdl-posix:Executable>")
    OutFile.write(str(Component["executable"]))
    OutFile.write("</jsdl-posix:Executable>\n")

    args = Component["arguments"]
    writeApplicationArguments(OutFile, args)
    stdout = Component["stdout"]
    OutFile.write("<jsdl-posix:Output>" + stdout + "</jsdl-posix:Output>\n")
    stderr = Component["stderr"]
    OutFile.write("<jsdl-posix:Error>" + stderr + "</jsdl-posix:Error>\n")
    # OutFile.write('<jsdl-posix:Input></jsdl-posix:Input>\n')

    writeApplicationEnvVariables(OutFile, Component["env"])

    OutFile.write('<jsdl-posix:Environment name="LD_LIBRARY_PATH">/usr/local/lib</jsdl-posix:Environment>')

    OutFile.write("\n</jsdl-posix:POSIXApplication>\n")

    OutFile.write("</jsdl:Application>\n")

    """
        <jsdl:DataStaging>
      <jsdl:FileName>file.txt</jsdl:FileName>
      <jsdl:CreationFlag>overwrite</jsdl:CreationFlag>
      <jsdl:DeleteOnTermination>true</jsdl:DeleteOnTermination>
      <jsdl:Source>
        <jsdl:URI>gsiftp://hydrus.dacya.ucm.es/home/jose/file1.txt</jsdl:URI>
      </jsdl:Source>
    </jsdl:DataStaging>
    """
    stagein = Component["stagein"]
    stageout = Component["stageout"]
    writeStageInFiles(OutFile, stagein)
    writeStageOutFiles(OutFile, stageout)

    OutFile.write("</jsdl:JobDescription>")
    writeJsdlFooter(OutFile)
    OutFile.close()
    print "...done"
Ejemplo n.º 4
0
def getWLName( Prefix = "WL" ):
    return "%s-%s-%3.3d" % \
        ( Prefix, strftime('%Y-%m-%d_%H-%M', gmtime(time()) ), 
          AIRandomUtils.getRandomInt(0,999) )