Ignore:
Timestamp:
Mar 30, 2016, 6:08:17 AM (9 years ago)
Author:
gah
Message:

fix: register https/tls to stop http cache query from hanging. fix: fix status=xxx on Middleware timestamp

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/1.6/lang/tcl/scripts/task.tcl

    r6205 r6221  
    2626    private method GetSignal { signal }
    2727    private method GetSimulationCommand { driverFile }
     28    private method GetUQErrors {}
    2829    private method GetUQSimulationCommand { driverFile }
    2930    private method GetUQTemplateFile {}
     
    6869
    6970    public common _resources
    70     public proc setAppName {name}   { set _resources(-appname) $name }
    71     public proc setHubName {name}   { set _resources(-hubname) $name }
    72     public proc setHubURL {name}    { set _resources(-huburl) $name }
    73     public proc setSession {name}   { set _resources(-session) $name }
    74     public proc setJobPrt {name}    { set _resources(-jobprotocol) $name }
    75     public proc setResultDir {name} { set _resources(-resultdir) $name }
    76     public proc setCacheHost {name} { set _resources(-cachehost) $name }
     71    public proc setAppName {name}    { set _resources(-appname) $name }
     72    public proc setHubName {name}    { set _resources(-hubname) $name }
     73    public proc setHubURL {name}     { set _resources(-huburl) $name }
     74    public proc setSession {name}    { set _resources(-session) $name }
     75    public proc setJobPrt {name}     { set _resources(-jobprotocol) $name }
     76    public proc setResultDir {name}  { set _resources(-resultdir) $name }
     77    public proc setCacheHosts {name} { set _resources(-cachehosts) $name }
    7778
    7879    # default method for -jobstats control
     
    9091        job_protocol      Rappture::Task::setJobPrt \
    9192        results_directory Rappture::Task::setResultDir \
    92         cache_host        Rappture::Task::setCacheHost
     93        cache_hosts       Rappture::Task::setCacheHosts
    9394}
    9495
     
    110111    }
    111112    set _installdir $installdir
     113    package require http
     114    package require tls
     115    http::register https 443 [list ::tls::socket -tls1 1]
    112116
    113117    eval configure $args
     
    216220    # Initialize job array variables
    217221    array set _job {
    218         control ""
    219         mesg    ""
    220         runfile ""
    221         stderr  ""
    222         stdout  ""
    223         success 0
    224         xmlobj  ""
     222        control  ""
     223        exitcode 0
     224        mesg     ""
     225        runfile  ""
     226        stderr   ""
     227        stdout   ""
     228        success  0
     229        xmlobj   ""
    225230    }
    226231
     
    457462
    458463itcl::body Rappture::Task::IsCacheable {} {
    459     if { ![info exists _resources(-cachehost)] ||
    460          $_resources(-cachehost) == "" } {
     464    if { ![info exists _resources(-cachehosts)] ||
     465         $_resources(-cachehosts) == "" } {
     466puts stderr cachehosts=[info exists _resources(-cachehosts)]
    461467        return 0
    462468    }
    463469if 0 {
    464470    set state [$_xmlobj get "tool.cache"]
     471puts stderr "cache tag is \"$state\""
    465472    if { $state == "" } {
    466473        return 0
     
    484491        exec puq.sh get_params $pid $_uq(varlist) $_uq(type) $_uq(args)
    485492    } errs] != 0 } {
    486         set contents {}
    487         if { [file exists "uq_debug.err"] } {
    488             set f [open "uq_debug.err" r]
    489             set contents [read $f]
    490             close $f
    491         }
    492         puts stderr "get_params.py failed: $contents"
    493         error "get_params.py failed: $errs\n$contents"
    494     }
    495     return "params[pid].csv"
     493        error "get_params.py failed: $errs\n[GetUQErrors]"
     494    }
     495    return "params${pid}.csv"
    496496}
    497497
     
    589589    set _job(runfile) ""
    590590    set _job(success) 0
     591    set _job(exitcode) 0
    591592
    592593    # Step 1.  Write the command into the run file.
     
    601602        set _job(stdout) [string range $cmd 5 end]
    602603        set _job(success) 1
     604        set _job(exitcode) 0
    603605        set _job(mesg) ""
    604606        return 1;                       # Success
     
    618620    # Step 4. Check the token and the exit code.
    619621    set logmesg $result
    620     foreach { token pid code mesg } $_job(control) break
     622    foreach { token _job(pid) _job(exitcode) mesg } $_job(control) break
    621623    if { $token == "EXITED" } {
    622         if { $code != 0 } {
     624        if { $_job(exitcode) != 0 } {
    623625            # This means that the program exited normally but returned a
    624626            # non-zero exitcode.  Consider this an invalid result from the
    625627            # program.  Append the stderr from the program to the message.
    626628            if {$code > 128} {
    627                 set logmesg "Program signaled: signal was [GetSignal $code]"
     629                set logmesg "Program signaled: signal was [GetSignal $_job(exitcode)]"
    628630            } else {
    629                 set logmesg "Program finished: non-zero exit code is $code"
     631                set logmesg "Program finished: non-zero exit code is $_job(exitcode)"
    630632            }
    631633            set _job(mesg) "$logmesg\n\n$_job(stderr)"
     
    684686            "walltime" $times(walltime) \
    685687            "cputime"  $times(cputime) \
    686             "status"   $_job(success)
     688            "status"   $_job(exitcode)
    687689        uplevel #0 $jobstats $args
    688690    }
     
    775777            "walltime" $times(walltime) \
    776778            "cputime"  $times(cputime) \
    777             "status"   $_job(success)
     779            "status"   $_job(exitcode)
    778780        uplevel #0 $jobstats $args
    779781    }
     
    860862
    861863    # Read the driver file and collect its contents as the query.
    862     set url http://$_resources(-cachehost)/cache/request
     864    set url http://$_resources(-cachehosts)/cache/request
    863865    set f [open $driverFile "r"]
    864866    set query [read $f]
     
    867869    # Make the query
    868870    if { [catch {
    869         http::geturl $url -query $query -timeout 60000 -binary yes
     871        http::geturl $url -query $query -timeout 6000 -binary yes
    870872    } token] != 0 } {
    871873        puts stderr "error performing cache query: token=$token"
     
    896898    set _job(stderr) "Loading cached results\n"
    897899    OnOutput "Loading cached results\n"
     900    update
    898901    return 1
     902}
     903
     904itcl::body Rappture::Task::GetUQErrors {} {
     905    set contents {}
     906    if { [file exists "uq_debug.err"] } {
     907        set f [open "uq_debug.err" r]
     908        set contents [read $f]
     909        close $f
     910    }
     911    return $contents
    899912}
    900913
     
    906919        exec puq.sh analyze $hdfFile
    907920    } results] != 0 } {
    908         set rdata {}
    909         if { [file exists "uq_debug.err" ] } {
    910             set f [open "uq_debug.err" r]
    911             set rdata [read $f]
    912             close $f
    913         }
    914         puts stderr "UQ analysis failed: $results\n$rdata"
    915         error "UQ analysis failed: $results\n$rdata"
     921        error "UQ analysis failed: $results\n[GetUQErrors]"
    916922    } else {
    917923        set _job(stdout) $results
Note: See TracChangeset for help on using the changeset viewer.