Changeset 2080 for trunk/p2p


Ignore:
Timestamp:
Feb 2, 2011 4:51:29 PM (10 years ago)
Author:
mmc
Message:

Part 1 of a major reorganization of content. Moving "instant" to "builder"
and setting up "builder" more like the "gui" part as a package. Moving the
Rappture::object stuff from the builder into the main installation, so it
can be shared by the tester as well. Moving "driver" into gui/scripts
where it belongs. Creating a new "launcher.tcl" script that decides
which of the three parts to launch based on command line options. Still
need to sort out the Makefiles to get this all right...

Location:
trunk/p2p
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/p2p/client.tcl

    r1273 r2080  
    8686    public method send {message}
    8787    public method address {}
    88 
    89     protected method handlerType {}
    9088}
    9189
     
    10199            set _sid ""
    102100        } else {
    103             log debug "sending: $message"
     101            log debug "outgoing message to [address]: $message"
    104102            puts $_sid $message
    105103        }
     
    116114    return $_addr
    117115}
    118 
    119 # ----------------------------------------------------------------------
    120 #  USAGE: handlerType
    121 #
    122 #  Returns a descriptive string describing this handler.  Derived
    123 #  classes override this method to provide their own string.  Used
    124 #  for debug messages.
    125 # ----------------------------------------------------------------------
    126 itcl::body Client::handlerType {} {
    127     return "client"
    128 }
  • trunk/p2p/foreman.tcl

    r1273 r2080  
    119119
    120120    if {"" != [statedata authoritycnx]} {
     121        [statedata authoritycnx] send "identity foreman"
    121122        [statedata authoritycnx] send "workers"
    122123    } else {
     
    160161
    161162    if {"" != [statedata workercnx]} {
     163        [statedata workercnx] send "identity foreman"
    162164        [statedata workercnx] send "solicit -job [expr {rand()}]"
    163165    } else {
  • trunk/p2p/handler.tcl

    r1273 r2080  
    5959    protected method finalize {protocol}
    6060    protected method dropped {cid}
    61     protected method handlerType {}
    6261}
    6362
     
    196195                append mesg "exception: $result"
    197196            }
    198             log debug "[handlerType] message from [connectionName $cid]: [string trimright $request \n] $mesg"
     197            log debug "incoming message from [connectionName $cid]: [string trimright $request \n] $mesg"
    199198        }
    200199    }
     
    237236    catch {unset _cname($cid)}
    238237}
    239 
    240 # ----------------------------------------------------------------------
    241 #  USAGE: handlerType
    242 #
    243 #  Returns a descriptive string describing this handler.  Derived
    244 #  classes override this method to provide their own string.  Used
    245 #  for debug messages.
    246 # ----------------------------------------------------------------------
    247 itcl::body Handler::handlerType {} {
    248     return "handler"
    249 }
  • trunk/p2p/protocols.tcl

    r1273 r2080  
    8181            $obj protocol $name
    8282            $obj define $name exception {message} {
    83                 log error "ERROR from client:  $message"
     83                variable cid
     84                variable handler
     85                log error "ERROR from client [$handler connectionName $cid]:  $message"
     86            }
     87            $obj define $name identity {name} {
     88                variable cid
     89                variable handler
     90                $handler connectionName $cid $name
     91                return ""
    8492            }
    8593
  • trunk/p2p/server.tcl

    r1273 r2080  
    106106
    107107    protected method dropped {cid}
    108     protected method handlerType {}
    109 
    110108    private method accept {cid addr port}
    111109}
     
    235233    chain $cid
    236234}
    237 
    238 # ----------------------------------------------------------------------
    239 #  USAGE: handlerType
    240 #
    241 #  Returns a descriptive string describing this handler.  Derived
    242 #  classes override this method to provide their own string.  Used
    243 #  for debug messages.
    244 # ----------------------------------------------------------------------
    245 itcl::body Server::handlerType {} {
    246     return "server"
    247 }
  • trunk/p2p/test.tcl

    r1273 r2080  
    142142    # ------------------------------------------------------------------
    143143    public proc draw {canvas time} {
     144        global times
    144145        if {[info exists _shapesOnCanvas($canvas)]} {
     146            set y0 5
     147            if {[info exists times($time)]} {
     148                $canvas create text 5 $y0 -anchor nw -text $times($time)
     149                incr y0 15
     150            }
     151            $canvas create text 5 $y0 -anchor nw -tags entity
     152
    145153            foreach obj $_shapesOnCanvas($canvas) {
    146154                if {[$obj exists $time]} {
     
    222230pack .player.fwd -side left -padx 4 -pady 2
    223231
     232button .player.err -text "0 errors" -command {wm deiconify .errors; raise .errors}
     233pack .player.err -side right -padx 4 -pady 2
     234.player.err configure -state disabled
     235
    224236scale .player.scale -label "Frame" -orient horizontal \
    225237    -from 0 -to 1 -showvalue 0 -command {test_frame_go 1}
     
    242254after idle .view.traffic invoke
    243255
     256toplevel .errors
     257wm title .errors "Error Messages"
     258wm withdraw .errors
     259wm protocol .errors WM_DELETE_WINDOW {wm withdraw .errors}
     260scrollbar .errors.ysbar -orient vertical -command {.errors.info yview}
     261pack .errors.ysbar -side right -fill y
     262text .errors.info -yscrollcommand {.errors.ysbar set} -font {Courier 12}
     263pack .errors.info -expand yes -fill both
     264.errors.info tag configure timecode -foreground gray
     265.errors.info tag configure error -foreground red -font {Courier 12 bold}
     266
    244267proc test_stop {} {
    245268    global processes
     
    279302
    280303proc test_reload {} {
    281     global time0 nodes actions nodeRadius
     304    global time0 nodes actions times nodeRadius
    282305
    283306    array set colors {
    284307        authority blue
    285308        worker gray
     309        foreman red
    286310    }
    287311
    288312    Shape::clear .diagram.network
    289313    Shape::clear .diagram.traffic
     314    .errors.info configure -state normal
     315    .errors.info delete 1.0 end
    290316    set tmax 0
     317    set errs 0
    291318
    292319    #
     
    298325        close $fid
    299326
    300         if {[regexp -- {foreman<-} $info]} {
    301             # skip log file from foreman
     327        set lasttime ""
     328        set t0val ""; set first ""
     329        set t1val ""; set last ""
     330        set info [split $info \n]
     331        foreach line $info {
     332            if {[regexp {^([0-9]+/[0-9]+/[0-9]+ [0-9]+:[0-9]+:[0-9]+)} $line match tval]} {
     333                if {"" == $t0val} {
     334                    set first $line
     335                    set t0val [expr {([clock scan $tval]-$time0)*100}]
     336                } else {
     337                    set last $line
     338                    set t1val [expr {([clock scan $tval]-$time0)*100 + 99}]
     339                }
     340            }
     341        }
     342
     343        if {"" == $t0val || "" == $t1val} {
     344            # can't find any log statements -- skip this file!
    302345            continue
    303346        }
    304347
    305348        # get the address for this host
    306         regexp {started at port ([0-9]+)} $info match port
    307         if {[regexp {options [^\n]+ ip ([^ ]+)} $info match ip]} {
    308             set addr $ip:$port
     349        if {[regexp {started at port ([0-9]+)} $info match port]} {
     350            if {[regexp {options [^\n]+ ip ([^ ]+)} $info match ip]} {
     351                set addr $ip:$port
     352            } else {
     353                set addr 127.0.0.1:$port
     354            }
     355            set shape oval
     356            regexp {^([0-9]+/[0-9]+/[0-9]+ [0-9]+:[0-9]+:[0-9]+) +(authority|worker)} $first match t0 type
     357        } elseif {[regexp -- {foreman<-} $info]} {
     358            set shape rectangle
     359            set addr "foreman"
     360            set type "foreman"
    309361        } else {
    310             set addr 127.0.0.1:$port
    311         }
    312 
    313         set lasttime ""
    314         set info [split $info \n]
    315         set first [lindex $info 0]
    316         regexp {^([0-9]+/[0-9]+/[0-9]+ [0-9]+:[0-9]+:[0-9]+) +(authority|worker)} $first match t0 type
    317         set t0val [expr {([clock scan $t0]-$time0)*100}]
    318 
    319         set last [lindex $info end-1]
    320         regexp {^([0-9]+/[0-9]+/[0-9]+ [0-9]+:[0-9]+:[0-9]+)} $last match t1
    321         set t1val [expr {([clock scan $t1]-$time0)*100 + 99}]
     362            # unknown log file -- skip it
     363            continue
     364        }
    322365        set margin 20
    323366        set r $nodeRadius
     
    337380        foreach canv {.diagram.traffic .diagram.network} {
    338381            set s [Shape ::#auto $canv -command \
    339                 [list %c create oval [expr {$x-$r}] [expr {$y-$r}] \
     382                [list %c create $shape [expr {$x-$r}] [expr {$y-$r}] \
    340383                [expr {$x+$r}] [expr {$y+$r}] \
    341384                -outline black -fill $colors($type) \
     
    359402puts "\nscanning $fname"
    360403
    361         if {[regexp -- {foreman<-} $info]} {
    362             # skip log file from foreman
    363             continue
    364         }
    365 
    366404        catch {unset started}
    367405        set peerlist(addrs) ""
     
    380418                if {$tval > $tmax} { set tmax $tval }
    381419
     420                set cid ""
    382421                if {[regexp {accepted: +([^ ]+) +\((.+)\)} $mesg match addr cid]} {
    383422                    append actions($tval) $mesg \n
     
    386425
    387426                } elseif {[regexp {dropped: +([^ ]+) +\((.+)\)} $mesg match addr cid] && [info exists started(connect$cid-time)]} {
     427                    incr tval 99  ;# end of this second
    388428                    append actions($tval) $mesg \n
    389429                    set from $nodes($fname)
     
    399439                    unset started(connect$cid-addr)
    400440
    401                 } elseif {[regexp {(server|client) message from ([a-zA-Z0-9\.]+:[0-9]+) \(([a-z0-9]+)\): +(.+) => (.*)} $mesg match which addr cid cmd result]} {
    402                     if {![string match identity* $cmd]} {
    403                         append actions($tval) $mesg \n
    404                         set from $nodes($fname)
    405                         set x0 $nodes($from-x)
    406                         set y0 $nodes($from-y)
    407                         set x1 $nodes($addr-x)
    408                         set y1 $nodes($addr-y)
    409                         set w [expr {[winfo width .diagram]/2}]
    410 
    411                         set s [Shape ::#auto .diagram.traffic -command \
    412                             [list %c create line [expr $x0-3] [expr $y0-3] [expr $x1-3] [expr $y1-3] -fill black -arrow first -tags transient]]
    413                         $s addRange $tval $tval
    414 
    415                         set s [Shape ::#auto .diagram.traffic -command \
    416                             [list %c create text [expr {0.5*($x0+$x1)}] [expr {0.5*($y0+$y1)-1}] -width $w -fill black -anchor s -text $cmd -tags transient]]
    417                         $s addRange $tval $tval
    418 
    419                         if {"" != [string trim $result]} {
    420                             if {[regexp {^ok:} $result]} {
    421                                 set color black
    422                             } else {
    423                                 set color red
    424                             }
    425                             set s [Shape ::#auto .diagram.traffic -command \
    426                                 [list %c create line [expr $x0+3] [expr $y0+3] [expr $x1+3] [expr $y1+3] -fill $color -arrow last -tags transient]]
    427                             $s addRange $tval $tval
    428 
    429                             set s [Shape ::#auto .diagram.traffic -command \
    430                                 [list %c create text [expr {0.5*($x0+$x1)}] [expr {0.5*($y0+$y1)+1}] -width $w -fill $color -anchor n -text $result -tags transient]]
    431                             $s addRange $tval $tval
     441                } elseif {[regexp {(incoming) message from ([^ ]+) \((sock[0-9]+)\): +(.+) => (.*)} $mesg match which addr cid cmd result]
     442                       || [regexp {(outgoing) message to ([^ ]+): +(.+)} $mesg match which addr cmd]} {
     443                    switch -- $which {
     444                        outgoing {
     445                            set from $addr
     446                            set to $nodes($fname)
     447                        }
     448                        incoming {
     449                            set from $nodes($fname)
     450                            set to $addr
     451                            # show incoming messages later in time
     452                            incr tval 50
    432453                        }
    433454                    }
     455                    append actions($tval) $mesg \n
     456                    set x0 $nodes($from-x)
     457                    set y0 $nodes($from-y)
     458                    set x1 $nodes($to-x)
     459                    set y1 $nodes($to-y)
     460                    set w [expr {[winfo width .diagram]/2}]
     461
     462                    set s [Shape ::#auto .diagram.traffic -command \
     463                        [list %c create line [expr $x0-3] [expr $y0-3] [expr $x1-3] [expr $y1-3] -fill black -arrow first -tags transient]]
     464                    $s addRange $tval $tval
     465
     466                    set s [Shape ::#auto .diagram.traffic -command \
     467                        [list %c create text [expr {0.5*($x0+$x1)}] [expr {0.5*($y0+$y1)-1}] -width $w -fill black -anchor s -text $cmd -tags transient]]
     468                    $s addRange $tval $tval
     469
     470                    if {$which == "incoming" && "" != [string trim $result]} {
     471                        if {[regexp {^ok:} $result]} {
     472                            set color black
     473                        } else {
     474                            set color red
     475                        }
     476                        set s [Shape ::#auto .diagram.traffic -command \
     477                            [list %c create line [expr $x0+3] [expr $y0+3] [expr $x1+3] [expr $y1+3] -fill $color -arrow last -tags transient]]
     478                        $s addRange $tval $tval
     479
     480                        set s [Shape ::#auto .diagram.traffic -command \
     481                            [list %c create text [expr {0.5*($x0+$x1)}] [expr {0.5*($y0+$y1)+1}] -width $w -fill $color -anchor n -text $result -tags transient]]
     482                        $s addRange $tval $tval
     483                    }
    434484
    435485                    # no address for this client yet?  then save this info
    436                     if {[info exists started(connect$cid-addr)]
     486                    if {"" != $cid
     487                           && [info exists started(connect$cid-addr)]
    437488                           && $started(connect$cid-addr) == "?"} {
    438489                        set started(connect$cid-addr) $addr
     
    466517                    set peerlist(addrs) $plist
    467518                    set peerlist(time) $tval
     519                } elseif {[regexp {ERROR} $mesg match addr]} {
     520                    .errors.info insert end $time timecode $mesg error "\n"
     521                    incr errs
    468522                }
     523                set times($tval) $time
    469524            }
    470525        }
     
    497552            %W itemconfigure $fname-cnx -fill red
    498553            %W raise $fname-cnx
     554            %W itemconfigure entity -text {$nodes($fname)}
    499555        "
    500556        .diagram.traffic bind $fname <Leave> "
     
    502558            %W itemconfigure $fname-cnx -fill gray
    503559            %W raise transient
     560            %W itemconfigure entity -text {}
    504561        "
    505562
     
    537594    }
    538595    .player.scale configure -to $tmax
     596    .errors.info configure -state disabled
     597    if {$errs == 0} {
     598        .player.err configure -state normal -text "0 errors"
     599        .player.err configure -state disabled
     600    } else {
     601        .player.err configure -state normal -text "$errs error[expr {($errs == 1) ? {} : {s}}]"
     602    }
    539603
    540604    after cancel test_visualize
     
    565629
    566630proc test_frame_go {dir position} {
    567     global actions
     631    global actions times
    568632
    569633    set tmax [.player.scale cget -to]
  • trunk/p2p/worker.tcl

    r1273 r2080  
    118118    # ------------------------------------------------------------------
    119119    define solicit {args} {
    120 log debug "SOLICIT from foreman: $args"
    121120        variable cid
    122121        log debug "solicitation request from foreman: $args"
     
    161160    # ------------------------------------------------------------------
    162161    define solicit {args} {
    163 log debug "SOLICIT from peer: $args"
    164162        variable cid
    165163        log debug "solicitation request from peer: $args"
     
    177175    # ------------------------------------------------------------------
    178176    define proffer {token details} {
    179 log debug "PROFFER from peer: $token $details"
    180177        Solicitation::proffer $token $details
    181178        return ""
     
    226223    # ------------------------------------------------------------------
    227224    define solicit {args} {
    228 log debug "SOLICIT from peer: $args"
    229225        variable cid
    230226        log debug "solicitation request from peer: $args"
     
    242238    # ------------------------------------------------------------------
    243239    define proffer {token details} {
    244 log debug "PROFFER from peer: $token $details"
    245240        Solicitation::proffer $token $details
    246241        return ""
     
    636631            set mesg [list solicit -job $job -path $path -avoid "$avoid @RECIPIENTS" -token $_serial]
    637632            set _waitfor [broadcast_to_peers $mesg $avoid]
    638 log debug "WAIT FOR: $_waitfor"
    639633
    640634            if {$_waitfor > 0} {
     
    643637            }
    644638        }
    645 log debug "TIMEOUT: $delay"
    646639        set _timeout [after $delay [itcl::code $this finalize]]
    647640    }
     
    656649        append _response $details "\n"
    657650        if {[incr _waitfor -1] <= 0} {
    658 log debug "ALL RESPONSES"
    659651            finalize
    660652        }
     
    676668        # add details about this client to the message
    677669        append block "$myaddress -job $job -cost 1 -wonks [p2p::wonks::current]"
    678 log debug "FINALIZE {$block}"
    679670
    680671        # send the composite results back to the caller
Note: See TracChangeset for help on using the changeset viewer.