[Distributed Places] Renamed uses of vm to node, removed export of coercion functions
This commit is contained in:
parent
97b76d474e
commit
f777020eef
|
@ -18,10 +18,10 @@
|
|||
|
||||
;; New Design Pattern 2 API
|
||||
message-router
|
||||
spawn-vm-supervise-dynamic-place-at
|
||||
spawn-vm-supervise-place-thunk-at
|
||||
spawn-vm-with-dynamic-place-at
|
||||
spawn-vm-with-place-thunk-at
|
||||
spawn-node-supervise-dynamic-place-at
|
||||
spawn-node-supervise-place-thunk-at
|
||||
spawn-node-with-dynamic-place-at
|
||||
spawn-node-with-place-thunk-at
|
||||
supervise-named-dynamic-place-at
|
||||
supervise-named-place-thunk-at
|
||||
supervise-place-thunk-at
|
||||
|
@ -35,7 +35,7 @@
|
|||
|
||||
connect-to-named-place
|
||||
|
||||
spawn-remote-racket-vm
|
||||
spawn-remote-racket-node
|
||||
node-send-exit
|
||||
node-get-first-place
|
||||
dplace-put
|
||||
|
@ -49,13 +49,6 @@
|
|||
log-message
|
||||
start-spawned-node-router
|
||||
|
||||
;;Coercion Routines
|
||||
->string
|
||||
->path
|
||||
->number
|
||||
->length
|
||||
|
||||
|
||||
;; Old Design Pattern 1 API
|
||||
dcg-get-cg
|
||||
dcg-send
|
||||
|
@ -370,7 +363,7 @@
|
|||
(init-field [socket-ports null])
|
||||
(init-field [sub-ecs null])
|
||||
(init-field [psbs null])
|
||||
(init-field [spawned-vms null])
|
||||
(init-field [spawned-nodes null])
|
||||
(init-field [named-places (make-hash)])
|
||||
(init-field [beacon #f])
|
||||
(init-field [owner #f])
|
||||
|
@ -382,8 +375,8 @@
|
|||
(set! socket-ports (append socket-ports (list pair))))
|
||||
(define/public (add-sub-ec ec)
|
||||
(set! sub-ecs (append sub-ecs (list ec))))
|
||||
(define (add-spawned-vm ec)
|
||||
(set! spawned-vms (append spawned-vms (list ec))))
|
||||
(define (add-spawned-node ec)
|
||||
(set! spawned-nodes (append spawned-nodes (list ec))))
|
||||
(define (add-psb ec)
|
||||
(set! psbs (append psbs (list ec))))
|
||||
(define (add-named-place name np)
|
||||
|
@ -447,13 +440,13 @@
|
|||
[(th-place-channel? pch)
|
||||
(th-place-channel-put pch msg)])]
|
||||
[(dcgm 6 #;(== DCGM-TYPE-SPAWN-REMOTE-PROCESS) src (list node-name node-port mod-path funcname) ch1)
|
||||
(define vm
|
||||
(define node
|
||||
(new remote-node%
|
||||
[host-name node-name]
|
||||
[listen-port node-port]
|
||||
[cmdline-list (list (ssh-bin-path) node-name (racket-path) "-tm" (->string distributed-launch-path) "spawn" (->string node-port))]))
|
||||
(add-spawned-vm vm)
|
||||
(send vm launch-place
|
||||
(add-spawned-node node)
|
||||
(send node launch-place
|
||||
(list 'dynamic-place mod-path funcname)
|
||||
;#:initial-message initial-message
|
||||
#:one-sided-place? ch1
|
||||
|
@ -549,8 +542,8 @@
|
|||
(send x register n))
|
||||
nes)]
|
||||
[nes
|
||||
(if spawned-vms
|
||||
(for/fold ([n nes]) ([x spawned-vms])
|
||||
(if spawned-nodes
|
||||
(for/fold ([n nes]) ([x spawned-nodes])
|
||||
(send x register n))
|
||||
nes)]
|
||||
[nes (register-beacon nes)]
|
||||
|
@ -723,14 +716,14 @@
|
|||
|
||||
[(? eof-object?)
|
||||
(define-values (lh lp rh rp) (send sc addresses))
|
||||
(log-debug (format "EOF on vm socket connection pid to ~a ~a:~a CONNECTION ~a:~a -> ~a:~a" (get-sp-pid) host-name listen-port lh lp rh rp))
|
||||
(log-debug (format "EOF on node socket connection pid to ~a ~a:~a CONNECTION ~a:~a -> ~a:~a" (get-sp-pid) host-name listen-port lh lp rh rp))
|
||||
(set! sc #f)]
|
||||
|
||||
[else (log-debug (format"received message ~a" it))]))
|
||||
|
||||
(define/public (get-log-prefix) (format "PLACE ~a:~a" host-name listen-port))
|
||||
(define/public (process-died child)
|
||||
(log-debug (format "Remote VM pid ~a ~a:~a died" (get-sp-pid) host-name listen-port))
|
||||
(log-debug (format "Remote node pid ~a ~a:~a died" (get-sp-pid) host-name listen-port))
|
||||
(set! sp #f)
|
||||
(cond
|
||||
[restart-on-exit
|
||||
|
@ -753,13 +746,13 @@
|
|||
(sconn-remove-subchannel sc scid))
|
||||
|
||||
(define/public (launch-place place-exec #:restart-on-exit [restart-on-exit #f] #:one-sided-place? [one-sided-place? #f])
|
||||
(define rp (new remote-place% [vm this] [place-exec place-exec] [restart-on-exit restart-on-exit]
|
||||
(define rp (new remote-place% [node this] [place-exec place-exec] [restart-on-exit restart-on-exit]
|
||||
[one-sided-place? one-sided-place?]))
|
||||
(add-remote-place rp)
|
||||
rp)
|
||||
|
||||
(define/public (remote-connect name #:restart-on-exit [restart-on-exit #f])
|
||||
(define rp (new remote-connection% [vm this] [name name] [restart-on-exit restart-on-exit]))
|
||||
(define rp (new remote-connection% [node this] [name name] [restart-on-exit restart-on-exit]))
|
||||
(add-remote-place rp)
|
||||
rp)
|
||||
|
||||
|
@ -802,7 +795,7 @@
|
|||
(backlink
|
||||
(class*
|
||||
object% (event-container<%>)
|
||||
(init-field vm)
|
||||
(init-field node)
|
||||
(init-field [place-exec #f])
|
||||
(init-field [restart-on-exit #f])
|
||||
(init-field [one-sided-place? #f])
|
||||
|
@ -822,11 +815,11 @@
|
|||
(set! rpc pch1)
|
||||
(set! pc pch2)])
|
||||
|
||||
(set! psb (send vm spawn-remote-place place-exec rpc))
|
||||
(set! psb (send node spawn-remote-place place-exec rpc))
|
||||
|
||||
(define (restart-place)
|
||||
(send vm drop-sc-id (send psb get-sc-id))
|
||||
(set! psb (send vm spawn-remote-place place-exec rpc)))
|
||||
(send node drop-sc-id (send psb get-sc-id))
|
||||
(set! psb (send node spawn-remote-place place-exec rpc)))
|
||||
|
||||
(define/public (stop) (void))
|
||||
(define/public (get-channel) pc)
|
||||
|
@ -841,10 +834,10 @@
|
|||
(send restart-on-exit restart restart-place))]
|
||||
[else
|
||||
(log-debug (format "No restart condition for ~a:~a"
|
||||
(send vm get-log-prefix)
|
||||
(send node get-log-prefix)
|
||||
(send psb get-sc-id)))]))
|
||||
(define (on-channel-event e)
|
||||
(log-debug (format "~a ~a" (send vm get-log-prefix) e)))
|
||||
(log-debug (format "~a ~a" (send node get-log-prefix) e)))
|
||||
(define/public (register es)
|
||||
(let* ([es (if (and handle-channel pc)
|
||||
(cons (wrap-evt pc
|
||||
|
@ -895,7 +888,7 @@
|
|||
(backlink
|
||||
(class*
|
||||
object% (event-container<%>)
|
||||
(init-field vm)
|
||||
(init-field node)
|
||||
(init-field name)
|
||||
(init-field [restart-on-exit #f])
|
||||
(init-field [on-channel #f])
|
||||
|
@ -905,7 +898,7 @@
|
|||
(field [k #f])
|
||||
|
||||
(define-values (pch1 pch2) (place-channel))
|
||||
(set! psb (send vm spawn-remote-connection name pch1))
|
||||
(set! psb (send node spawn-remote-connection name pch1))
|
||||
(set! pc pch2)
|
||||
|
||||
(define/public (stop) (void))
|
||||
|
@ -914,10 +907,10 @@
|
|||
(define/public (get-sc-id) (send psb get-sc-id))
|
||||
(define/public (place-died)
|
||||
(log-debug (format "No restart condition for ~a:~a"
|
||||
(send vm get-log-prefix)
|
||||
(send node get-log-prefix)
|
||||
(send psb get-sc-id))))
|
||||
(define (on-channel-event e)
|
||||
(log-debug (format "~a ~a" (send vm get-log-prefix) e)))
|
||||
(log-debug (format "~a ~a" (send node get-log-prefix) e)))
|
||||
(define/public (register es)
|
||||
(let* ([es (if pc (cons (wrap-evt pc
|
||||
(cond
|
||||
|
@ -1196,105 +1189,106 @@
|
|||
(begin (thread-wait thr) cv)
|
||||
(loop (sub1 cnt) thr cv)))))
|
||||
|
||||
(define (supervise-process-at host #:listen-port [listen-port DEFAULT-ROUTER-PORT]
|
||||
(define (supervise-process-at host
|
||||
#:listen-port [listen-port DEFAULT-ROUTER-PORT]
|
||||
#:restart-on-exit [restart-on-exit #f]
|
||||
. command-line-list)
|
||||
(void)
|
||||
)
|
||||
|
||||
(define (supervise-named-place-thunk-at vm name place-path place-func
|
||||
(define (supervise-named-place-thunk-at node name place-path place-func
|
||||
#:initial-message [initial-message #f]
|
||||
#:restart-on-exit [restart-on-exit #f])
|
||||
(send vm launch-place
|
||||
(list 'place (->module-path-bytes place-path) place-func (->string name))
|
||||
;#:initial-message initial-message
|
||||
#:restart-on-exit restart-on-exit
|
||||
))
|
||||
(send node launch-place
|
||||
(list 'place (->module-path-bytes place-path) place-func (->string name))
|
||||
;#:initial-message initial-message
|
||||
#:restart-on-exit restart-on-exit
|
||||
))
|
||||
|
||||
(define (supervise-named-dynamic-place-at vm name place-path place-func
|
||||
(define (supervise-named-dynamic-place-at node name place-path place-func
|
||||
#:initial-message [initial-message #f]
|
||||
#:restart-on-exit [restart-on-exit #f])
|
||||
(send vm launch-place
|
||||
(list 'dynamic-place (->module-path-bytes place-path) place-func (->string name))
|
||||
;#:initial-message initial-message
|
||||
#:restart-on-exit restart-on-exit
|
||||
))
|
||||
(send node launch-place
|
||||
(list 'dynamic-place (->module-path-bytes place-path) place-func (->string name))
|
||||
;#:initial-message initial-message
|
||||
#:restart-on-exit restart-on-exit
|
||||
))
|
||||
|
||||
(define (spawn-vm-with-dynamic-place-at host place-path place-func #:listen-port [listen-port DEFAULT-ROUTER-PORT]
|
||||
(define (spawn-node-with-dynamic-place-at host place-path place-func #:listen-port [listen-port DEFAULT-ROUTER-PORT]
|
||||
#:initial-message [initial-message #f]
|
||||
#:racket-path [racketpath (racket-path)]
|
||||
#:ssh-bin-path [sshpath (ssh-bin-path)]
|
||||
#:distributed-launch-path [distributedlaunchpath (->module-path-bytes distributed-launch-path)]
|
||||
#:restart-on-exit [restart-on-exit #f])
|
||||
(define-values (vm pl)
|
||||
(spawn-vm-supervise-place-at/exec host (list 'dynamic-place (->module-path-bytes place-path) place-func) #:listen-port listen-port
|
||||
(define-values (node pl)
|
||||
(spawn-node-supervise-place-at/exec host (list 'dynamic-place (->module-path-bytes place-path) place-func) #:listen-port listen-port
|
||||
#:initial-message initial-message
|
||||
#:racket-path racketpath
|
||||
#:ssh-bin-path sshpath
|
||||
#:distributed-launch-path distributedlaunchpath
|
||||
#:restart-on-exit restart-on-exit))
|
||||
vm)
|
||||
node)
|
||||
|
||||
(define (spawn-vm-with-place-thunk-at host place-path place-func #:listen-port [listen-port DEFAULT-ROUTER-PORT]
|
||||
(define (spawn-node-with-place-thunk-at host place-path place-func #:listen-port [listen-port DEFAULT-ROUTER-PORT]
|
||||
#:initial-message [initial-message #f]
|
||||
#:racket-path [racketpath (racket-path)]
|
||||
#:ssh-bin-path [sshpath (ssh-bin-path)]
|
||||
#:distributed-launch-path [distributedlaunchpath (->module-path-bytes distributed-launch-path)]
|
||||
#:restart-on-exit [restart-on-exit #f])
|
||||
(define-values (vm pl)
|
||||
(spawn-vm-supervise-place-at/exec host (list 'place (->module-path-bytes place-path) place-func) #:listen-port listen-port
|
||||
(define-values (node pl)
|
||||
(spawn-node-supervise-place-at/exec host (list 'place (->module-path-bytes place-path) place-func) #:listen-port listen-port
|
||||
#:initial-message initial-message
|
||||
#:racket-path racketpath
|
||||
#:ssh-bin-path sshpath
|
||||
#:distributed-launch-path distributedlaunchpath
|
||||
#:restart-on-exit restart-on-exit))
|
||||
vm)
|
||||
node)
|
||||
|
||||
(define (spawn-vm-supervise-dynamic-place-at host place-path place-func #:listen-port [listen-port DEFAULT-ROUTER-PORT]
|
||||
(define (spawn-node-supervise-dynamic-place-at host place-path place-func #:listen-port [listen-port DEFAULT-ROUTER-PORT]
|
||||
#:initial-message [initial-message #f]
|
||||
#:racket-path [racketpath (racket-path)]
|
||||
#:ssh-bin-path [sshpath (ssh-bin-path)]
|
||||
#:distributed-launch-path [distributedlaunchpath (->module-path-bytes distributed-launch-path)]
|
||||
#:restart-on-exit [restart-on-exit #f])
|
||||
(spawn-vm-supervise-place-at/exec host (list 'dynamic-place (->module-path-bytes place-path) place-func) #:listen-port listen-port
|
||||
(spawn-node-supervise-place-at/exec host (list 'dynamic-place (->module-path-bytes place-path) place-func) #:listen-port listen-port
|
||||
#:initial-message initial-message
|
||||
#:racket-path racketpath
|
||||
#:ssh-bin-path sshpath
|
||||
#:distributed-launch-path distributedlaunchpath
|
||||
#:restart-on-exit restart-on-exit))
|
||||
|
||||
(define (spawn-vm-supervise-place-thunk-at host place-path place-func #:listen-port [listen-port DEFAULT-ROUTER-PORT]
|
||||
(define (spawn-node-supervise-place-thunk-at host place-path place-func #:listen-port [listen-port DEFAULT-ROUTER-PORT]
|
||||
#:initial-message [initial-message #f]
|
||||
#:racket-path [racketpath (racket-path)]
|
||||
#:ssh-bin-path [sshpath (ssh-bin-path)]
|
||||
#:distributed-launch-path [distributedlaunchpath (->module-path-bytes distributed-launch-path)]
|
||||
#:restart-on-exit [restart-on-exit #f])
|
||||
(spawn-vm-supervise-place-at/exec host (list 'place (->module-path-bytes place-path) place-func) #:listen-port listen-port
|
||||
(spawn-node-supervise-place-at/exec host (list 'place (->module-path-bytes place-path) place-func) #:listen-port listen-port
|
||||
#:initial-message initial-message
|
||||
#:racket-path racketpath
|
||||
#:ssh-bin-path sshpath
|
||||
#:distributed-launch-path distributedlaunchpath
|
||||
#:restart-on-exit restart-on-exit))
|
||||
|
||||
(define (spawn-vm-supervise-place-at/exec host place-exec #:listen-port [listen-port DEFAULT-ROUTER-PORT]
|
||||
(define (spawn-node-supervise-place-at/exec host place-exec #:listen-port [listen-port DEFAULT-ROUTER-PORT]
|
||||
#:initial-message [initial-message #f]
|
||||
#:racket-path [racketpath (racket-path)]
|
||||
#:ssh-bin-path [sshpath (ssh-bin-path)]
|
||||
#:distributed-launch-path [distributedlaunchpath (->module-path-bytes distributed-launch-path)]
|
||||
#:restart-on-exit [restart-on-exit #f])
|
||||
(define vm (spawn-remote-racket-vm host
|
||||
#:listen-port listen-port
|
||||
#:racket-path racketpath
|
||||
#:ssh-bin-path sshpath
|
||||
#:distributed-launch-path distributedlaunchpath))
|
||||
(define node (spawn-remote-racket-node host
|
||||
#:listen-port listen-port
|
||||
#:racket-path racketpath
|
||||
#:ssh-bin-path sshpath
|
||||
#:distributed-launch-path distributedlaunchpath))
|
||||
(define dp
|
||||
(send vm launch-place
|
||||
(send node launch-place
|
||||
place-exec
|
||||
;#:initial-message initial-message
|
||||
#:restart-on-exit restart-on-exit
|
||||
))
|
||||
|
||||
(values vm dp))
|
||||
(values node dp))
|
||||
|
||||
(define (message-router #:node [_nc #f] #:listen-port [listen-port DEFAULT-ROUTER-PORT] . event-containers)
|
||||
(define listener (tcp-listen listen-port 4 #t))
|
||||
|
@ -1305,23 +1299,23 @@
|
|||
(send nc sync-events))
|
||||
|
||||
|
||||
(define (spawn-remote-racket-vm host #:listen-port [listen-port DEFAULT-ROUTER-PORT]
|
||||
#:racket-path [racketpath (racket-path)]
|
||||
#:ssh-bin-path [sshpath (ssh-bin-path)]
|
||||
#:distributed-launch-path [distributedlaunchpath (->module-path-bytes distributed-launch-path)])
|
||||
(define (spawn-remote-racket-node host #:listen-port [listen-port DEFAULT-ROUTER-PORT]
|
||||
#:racket-path [racketpath (racket-path)]
|
||||
#:ssh-bin-path [sshpath (ssh-bin-path)]
|
||||
#:distributed-launch-path [distributedlaunchpath (->module-path-bytes distributed-launch-path)])
|
||||
(new remote-node%
|
||||
[host-name host]
|
||||
[listen-port listen-port]
|
||||
[cmdline-list (list sshpath host racketpath "-tm" distributedlaunchpath "spawn" (->string listen-port))]))
|
||||
|
||||
(define (supervise-dynamic-place-at remote-vm place-path place-func)
|
||||
(send remote-vm launch-place (list 'dynamic-place (->module-path-bytes place-path) place-func)))
|
||||
(define (supervise-dynamic-place-at remote-node place-path place-func)
|
||||
(send remote-node launch-place (list 'dynamic-place (->module-path-bytes place-path) place-func)))
|
||||
|
||||
(define (supervise-place-thunk-at remote-vm place-path place-func)
|
||||
(send remote-vm launch-place (list 'place (->module-path-bytes place-path) place-func)))
|
||||
(define (supervise-place-thunk-at remote-node place-path place-func)
|
||||
(send remote-node launch-place (list 'place (->module-path-bytes place-path) place-func)))
|
||||
|
||||
(define (supervise-thread-at remote-vm place-path place-func)
|
||||
(send remote-vm launch-place (list 'thread (->module-path-bytes place-path) place-func)))
|
||||
(define (supervise-thread-at remote-node place-path place-func)
|
||||
(send remote-node launch-place (list 'thread (->module-path-bytes place-path) place-func)))
|
||||
|
||||
(define-syntax-rule (every-seconds _seconds _body ...)
|
||||
(new respawn-and-fire% [seconds _seconds] [thunk (lambda () _body ...)]))
|
||||
|
@ -1329,8 +1323,8 @@
|
|||
(define-syntax-rule (after-seconds _seconds _body ...)
|
||||
(new after-seconds% [seconds _seconds] [thunk (lambda () _body ...)]))
|
||||
|
||||
(define (connect-to-named-place vm name)
|
||||
(send vm remote-connect name))
|
||||
(define (connect-to-named-place node name)
|
||||
(send node remote-connect name))
|
||||
|
||||
(define (restart-every seconds #:retry [retry #f] #:on-fail-email [fail-email-address #f]
|
||||
#:on-final-fail [on-final-fail #f])
|
||||
|
|
|
@ -13,13 +13,13 @@
|
|||
|
||||
|
||||
(module+ main
|
||||
(define-values (vm pl)
|
||||
(spawn-vm-supervise-place-thunk-at "localhost"
|
||||
#:listen-port 6344
|
||||
(quote-module-path "..")
|
||||
'hello-world))
|
||||
(define-values (node pl)
|
||||
(spawn-node-supervise-place-thunk-at "localhost"
|
||||
#:listen-port 6344
|
||||
(quote-module-path "..")
|
||||
'hello-world))
|
||||
(message-router
|
||||
vm
|
||||
node
|
||||
(after-seconds 2
|
||||
(dplace-put pl "Hello")
|
||||
(printf "message-router received: ~a\n" (dplace-get pl)))
|
||||
|
|
|
@ -11,20 +11,20 @@
|
|||
(provide main)
|
||||
|
||||
(define (main)
|
||||
(define remote-vm (spawn-remote-racket-vm "localhost" #:listen-port 6344))
|
||||
(define tuple-place (supervise-named-dynamic-place-at remote-vm 'tuple-server tuple-path 'make-tuple-server))
|
||||
(define bank-place (supervise-dynamic-place-at remote-vm bank-path 'make-bank))
|
||||
(define remote-node (spawn-remote-racket-node "localhost" #:listen-port 6344))
|
||||
(define tuple-place (supervise-named-dynamic-place-at remote-node 'tuple-server tuple-path 'make-tuple-server))
|
||||
(define bank-place (supervise-dynamic-place-at remote-node bank-path 'make-bank))
|
||||
|
||||
(message-router
|
||||
remote-vm
|
||||
remote-node
|
||||
(after-seconds 4
|
||||
(displayln (bank-new-account bank-place 'user1))
|
||||
(displayln (bank-add bank-place 'user1 10))
|
||||
(displayln (bank-removeM bank-place 'user1 5)))
|
||||
|
||||
(after-seconds 2
|
||||
(define c (connect-to-named-place remote-vm 'tuple-server))
|
||||
(define d (connect-to-named-place remote-vm 'tuple-server))
|
||||
(define c (connect-to-named-place remote-node 'tuple-server))
|
||||
(define d (connect-to-named-place remote-node 'tuple-server))
|
||||
(displayln (tuple-server-set c "user0" 100))
|
||||
(displayln (tuple-server-set d "user2" 200))
|
||||
(displayln (tuple-server-get c "user0"))
|
||||
|
@ -32,6 +32,6 @@
|
|||
(displayln (tuple-server-get d "user0"))
|
||||
(displayln (tuple-server-get c "user2")))
|
||||
(after-seconds 6
|
||||
(node-send-exit remote-vm))
|
||||
(node-send-exit remote-node))
|
||||
(after-seconds 8
|
||||
(exit 0))))
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
wait-place-thunk)
|
||||
|
||||
(define (spawn-place-worker-at port message)
|
||||
(spawn-vm-with-dynamic-place-at "localhost" #:listen-port port place-worker-path 'place-worker #:initial-message message #:restart-on-exit #f))
|
||||
(spawn-node-with-dynamic-place-at "localhost" #:listen-port port place-worker-path 'place-worker #:initial-message message #:restart-on-exit #f))
|
||||
|
||||
(define (wait-place-thunk)
|
||||
(place ch
|
||||
|
@ -25,14 +25,14 @@
|
|||
|
||||
|
||||
(define (main)
|
||||
(define bank-vm (spawn-vm-with-dynamic-place-at "localhost" #:listen-port 6344 bank-path 'make-bank))
|
||||
(define bank-place (send bank-vm get-first-place))
|
||||
(define bank-node (spawn-node-with-dynamic-place-at "localhost" #:listen-port 6344 bank-path 'make-bank))
|
||||
(define bank-place (send bank-node get-first-place))
|
||||
(message-router
|
||||
(spawn-place-worker-at 6341 "ONE")
|
||||
(spawn-place-worker-at 6342 "TWO")
|
||||
(spawn-place-worker-at 6343 "THREE")
|
||||
bank-vm
|
||||
(spawn-vm-with-place-thunk-at "localhost" #:listen-port 6345 (quote-module-name) 'wait-place-thunk #:restart-on-exit #t)
|
||||
bank-node
|
||||
(spawn-node-with-place-thunk-at "localhost" #:listen-port 6345 (quote-module-name) 'wait-place-thunk #:restart-on-exit #t)
|
||||
(every-seconds 3.3 (printf "Hello from every-seconds\n") (flush-output))
|
||||
(after-seconds 2
|
||||
(displayln (bank-new-account bank-place 'user0))
|
||||
|
|
|
@ -11,20 +11,20 @@
|
|||
(provide main)
|
||||
|
||||
(define (main)
|
||||
(define remote-vm (spawn-remote-racket-vm "localhost" #:listen-port 6344))
|
||||
(define tuple-place (supervise-named-dynamic-place-at remote-vm 'tuple-server tuple-path 'make-tuple-server))
|
||||
(define bank-place (supervise-dynamic-place-at remote-vm bank-path 'make-bank))
|
||||
(define remote-node (spawn-remote-racket-node "localhost" #:listen-port 6344))
|
||||
(define tuple-place (supervise-named-dynamic-place-at remote-node 'tuple-server tuple-path 'make-tuple-server))
|
||||
(define bank-place (supervise-dynamic-place-at remote-node bank-path 'make-bank))
|
||||
|
||||
(message-router
|
||||
remote-vm
|
||||
remote-node
|
||||
(after-seconds 4
|
||||
(displayln (bank-new-account bank-place 'user0))
|
||||
(displayln (bank-add bank-place 'user0 10))
|
||||
(displayln (bank-removeM bank-place 'user0 5)))
|
||||
|
||||
(after-seconds 2
|
||||
(define c (connect-to-named-place remote-vm 'tuple-server))
|
||||
(define d (connect-to-named-place remote-vm 'tuple-server))
|
||||
(define c (connect-to-named-place remote-node 'tuple-server))
|
||||
(define d (connect-to-named-place remote-node 'tuple-server))
|
||||
(tuple-server-hello c)
|
||||
(tuple-server-hello d)
|
||||
(displayln (tuple-server-set c "user0" 100))
|
||||
|
@ -35,6 +35,6 @@
|
|||
(displayln (tuple-server-get c "user2"))
|
||||
)
|
||||
(after-seconds 8
|
||||
(node-send-exit remote-vm))
|
||||
(node-send-exit remote-node))
|
||||
(after-seconds 10
|
||||
(exit 0))))
|
||||
|
|
|
@ -15,6 +15,6 @@
|
|||
|
||||
(define (main)
|
||||
(message-router
|
||||
(spawn-vm-with-place-thunk-at "localhost" #:listen-port 6345 (quote-module-name) 'wait-place-thunk #:restart-on-exit #t)
|
||||
(spawn-node-with-place-thunk-at "localhost" #:listen-port 6345 (quote-module-name) 'wait-place-thunk #:restart-on-exit #t)
|
||||
(after-seconds 50
|
||||
(exit 0))))
|
||||
|
|
|
@ -15,5 +15,5 @@
|
|||
|
||||
(define (main)
|
||||
(message-router
|
||||
(spawn-vm-with-place-thunk-at "localhost" #:listen-port 6345 (quote-module-name) 'wait-place-thunk
|
||||
(spawn-node-with-place-thunk-at "localhost" #:listen-port 6345 (quote-module-name) 'wait-place-thunk
|
||||
#:restart-on-exit (restart-every 5 #:retry 3))))
|
||||
|
|
|
@ -43,17 +43,17 @@
|
|||
(provide main)
|
||||
|
||||
(define (main)
|
||||
(define remote-vm (spawn-remote-racket-vm "localhost" #:listen-port 6344))
|
||||
(define bank-place (supervise-thread-at remote-vm (quote-module-name) 'make-bank))
|
||||
(define remote-node (spawn-remote-racket-node "localhost" #:listen-port 6344))
|
||||
(define bank-place (supervise-thread-at remote-node (quote-module-name) 'make-bank))
|
||||
|
||||
(message-router
|
||||
remote-vm
|
||||
remote-node
|
||||
(after-seconds 2
|
||||
(displayln (bank-new-account bank-place 'user0))
|
||||
(displayln (bank-add bank-place 'user0 10))
|
||||
(displayln (bank-removeM bank-place 'user0 5)))
|
||||
|
||||
(after-seconds 6
|
||||
(node-send-exit remote-vm))
|
||||
(node-send-exit remote-node))
|
||||
(after-seconds 8
|
||||
(exit 0))))
|
||||
|
|
|
@ -60,8 +60,7 @@ The use of Distributed Places is predicated on a couple assumptions:
|
|||
(require racket/place/distributed
|
||||
racket/place)
|
||||
|
||||
(provide main
|
||||
hello-world)
|
||||
(provide hello-world)
|
||||
|
||||
(define (hello-world)
|
||||
(place ch
|
||||
|
@ -71,21 +70,20 @@ The use of Distributed Places is predicated on a couple assumptions:
|
|||
(printf "hello-world sent: ~a\n" HW)))
|
||||
|
||||
|
||||
(define (main)
|
||||
(define-values (vm pl)
|
||||
(spawn-vm-supervise-place-thunk-at "localhost"
|
||||
(module+ main
|
||||
(define-values (node pl)
|
||||
(spawn-node-supervise-place-thunk-at "localhost"
|
||||
#:listen-port 6344
|
||||
(get-current-module-path)
|
||||
(quote-module-path "..")
|
||||
'hello-world))
|
||||
(message-router
|
||||
vm
|
||||
node
|
||||
(after-seconds 2
|
||||
(dplace-put pl "Hello")
|
||||
(printf "message-router received: ~a\n" (dplace-get pl)))
|
||||
|
||||
(after-seconds 6
|
||||
(exit 0))
|
||||
)))
|
||||
(exit 0)))))
|
||||
|
||||
(require 'hello-world-example)
|
||||
]
|
||||
|
@ -101,13 +99,13 @@ The use of Distributed Places is predicated on a couple assumptions:
|
|||
}
|
||||
|
||||
@(define (p . l) (decode-paragraph l))
|
||||
@(define spawn-vm-note
|
||||
@(define spawn-node-note
|
||||
(make-splice
|
||||
(list
|
||||
@p{This function returns a @racket[remote-node%] instance not a @racket[remote-place%]
|
||||
Call @racket[(send vm get-first-place)] to obtain the @racket[remote-place%] instance.})) )
|
||||
Call @racket[(send node get-first-place)] to obtain the @racket[remote-place%] instance.})) )
|
||||
|
||||
@(define spawn-vm-dynamic-note
|
||||
@(define spawn-node-dynamic-note
|
||||
(make-splice
|
||||
(list
|
||||
@p{
|
||||
|
@ -117,7 +115,7 @@ parameters. This procedure constructs the new remote-place by calling
|
|||
@racket[(dynamic-place instance-module-path instance-place-function-name)].
|
||||
})))
|
||||
|
||||
@defproc[(spawn-vm-with-dynamic-place-at
|
||||
@defproc[(spawn-node-with-dynamic-place-at
|
||||
[hostname string?]
|
||||
[instance-module-path module-path?]
|
||||
[instance-place-function-name symbol?]
|
||||
|
@ -127,11 +125,11 @@ parameters. This procedure constructs the new remote-place by calling
|
|||
[#:ssh-bin-path sshpath string-path? (ssh-bin-path)]
|
||||
[#:launcher-path launcherpath string-path? (->string distributed-launch-path)]
|
||||
[#:restart-on-exit restart-on-exit any/c #f]) remote-place?]{
|
||||
@|spawn-vm-dynamic-note|
|
||||
@|spawn-vm-note|
|
||||
@|spawn-node-dynamic-note|
|
||||
@|spawn-node-note|
|
||||
}
|
||||
|
||||
@defproc[(spawn-vm-supervise-dynamic-place-at
|
||||
@defproc[(spawn-node-supervise-dynamic-place-at
|
||||
[hostname string?]
|
||||
[instance-module-path module-path?]
|
||||
[instance-place-function-name symbol?]
|
||||
|
@ -141,8 +139,8 @@ parameters. This procedure constructs the new remote-place by calling
|
|||
[#:ssh-bin-path sshpath string-path? (ssh-bin-path)]
|
||||
[#:launcher-path launcherpath string-path? (->string distributed-launch-path)]
|
||||
[#:restart-on-exit restart-on-exit any/c #f]) (values remote-node%? remote-place%?)]{
|
||||
@|spawn-vm-dynamic-note|
|
||||
The new @racket[remote-vm%] and @racket[remote-place%] instances make up the two return values.
|
||||
@|spawn-node-dynamic-note|
|
||||
The new @racket[remote-node%] and @racket[remote-place%] instances make up the two return values.
|
||||
}
|
||||
|
||||
@(define place-thunk-function
|
||||
|
@ -157,7 +155,7 @@ accomplish this by calling either @racket[dynamic-place] or
|
|||
@racket[place] inside the thunk.
|
||||
})) )
|
||||
|
||||
@(define spawn-vm-thunk-note
|
||||
@(define spawn-node-thunk-note
|
||||
(make-splice
|
||||
(list
|
||||
@p{
|
||||
|
@ -171,7 +169,7 @@ dynamically requiring the
|
|||
@p{
|
||||
@racket[((dynamic-require instance-module-path instance-thunk-function-name))]
|
||||
})))
|
||||
@defproc[(spawn-vm-with-place-thunk-at
|
||||
@defproc[(spawn-node-with-place-thunk-at
|
||||
[hostname string?]
|
||||
[instance-module-path module-path?]
|
||||
[instance-thunk-function-name symbol?]
|
||||
|
@ -181,11 +179,11 @@ dynamically requiring the
|
|||
[#:ssh-bin-path sshpath string-path? (ssh-bin-path)]
|
||||
[#:launcher-path launcherpath string-path? (->string distributed-launch-path)]
|
||||
[#:restart-on-exit restart-on-exit any/c #f]) remote-place%?]{
|
||||
@|spawn-vm-thunk-note|
|
||||
@|spawn-node-thunk-note|
|
||||
@|place-thunk-function|
|
||||
@|spawn-vm-note|
|
||||
@|spawn-node-note|
|
||||
}
|
||||
@defproc[(spawn-vm-supervise-place-thunk-at
|
||||
@defproc[(spawn-node-supervise-place-thunk-at
|
||||
[hostname string?]
|
||||
[instance-module-path module-path?]
|
||||
[instance-thunk-function-name symbol?]
|
||||
|
@ -194,13 +192,13 @@ dynamically requiring the
|
|||
[#:racket-path racketpath string-path? (racket-path)]
|
||||
[#:ssh-bin-path sshpath string-path? (ssh-bin-path)]
|
||||
[#:launcher-path launcherpath string-path? (->string distributed-launch-path)]
|
||||
[#:restart-on-exit restart-on-exit any/c #f]) (values remote-vm%? remote-place%?)]{
|
||||
@|spawn-vm-thunk-note|
|
||||
[#:restart-on-exit restart-on-exit any/c #f]) (values remote-node%? remote-place%?)]{
|
||||
@|spawn-node-thunk-note|
|
||||
@|place-thunk-function|
|
||||
The new @racket[remote-vm%] and @racket[remote-place%] instances make up the two return values.
|
||||
The new @racket[remote-node%] and @racket[remote-place%] instances make up the two return values.
|
||||
}
|
||||
|
||||
@defproc[(spawn-remote-racket-vm
|
||||
@defproc[(spawn-remote-racket-node
|
||||
[hostname string?]
|
||||
[#:listen-port port non-negative-integer? DEFAULT-ROUTER-PORT]
|
||||
[#:racket-path racketpath string-path? (racket-path)]
|
||||
|
@ -209,22 +207,22 @@ The new @racket[remote-vm%] and @racket[remote-place%] instances make up the two
|
|||
Spawns a new remote node at @racket[hostname] and returns a @racket[remote-node%] handle.
|
||||
}
|
||||
@defproc[(supervise-dynamic-place-at
|
||||
[remote-vm remote-vm?]
|
||||
[remote-node remote-node?]
|
||||
[instance-module-path module-path?]
|
||||
[instance-place-function-name symbol?]
|
||||
[#:restart-on-exit restart-on-exit any/c #f]) remote-place%?]{
|
||||
Creates a new place on the @racket[remote-vm] by using
|
||||
Creates a new place on the @racket[remote-node] by using
|
||||
@racket[dynamic-place] to invoke
|
||||
@racket[instance-place-function-name] from the module
|
||||
@racket[instance-module-path].
|
||||
}
|
||||
|
||||
@defproc[(supervise-place-thunk-at
|
||||
[remote-vm remote-vm?]
|
||||
[remote-node remote-node?]
|
||||
[instance-module-path module-path?]
|
||||
[instance-thunk-function-name symbol?]
|
||||
[#:restart-on-exit restart-on-exit any/c #f]) remote-place%?]{
|
||||
Creates a new place on the @racket[remote-vm] by executing the thunk
|
||||
Creates a new place on the @racket[remote-node] by executing the thunk
|
||||
@racket[instance-thunk-function-name] from the module
|
||||
@racket[instance-module-path].
|
||||
|
||||
|
@ -239,12 +237,12 @@ Spawns an attached external process at host @racket[hostname].
|
|||
}
|
||||
|
||||
@defproc[(supervise-named-dynamic-place-at
|
||||
[remote-vm remote-vm?]
|
||||
[remote-node remote-node?]
|
||||
[place-name symbol?]
|
||||
[instance-module-path module-path?]
|
||||
[instance-place-function-name symbol?]
|
||||
[#:restart-on-exit restart-on-exit any/c #f]) remote-place%?]{
|
||||
Creates a new place on the @racket[remote-vm] by using
|
||||
Creates a new place on the @racket[remote-node] by using
|
||||
@racket[dynamic-place] to invoke
|
||||
@racket[instance-place-function-name] from the module
|
||||
@racket[instance-module-path]. The @racket[place-name] symbol
|
||||
|
@ -252,12 +250,12 @@ is used to establish later connections to the named place.
|
|||
}
|
||||
|
||||
@defproc[(supervise-named-place-thunk-at
|
||||
[remote-vm remote-vm?]
|
||||
[remote-node remote-node?]
|
||||
[place-name symbol?]
|
||||
[instance-module-path module-path?]
|
||||
[instance-thunk-function-name symbol?]
|
||||
[#:restart-on-exit restart-on-exit any/c #f]) remote-place%?]{
|
||||
Creates a new place on the @racket[remote-vm] by executing the thunk
|
||||
Creates a new place on the @racket[remote-node] by executing the thunk
|
||||
@racket[instance-thunk-function-name] from the module
|
||||
@racket[instance-module-path]. The @racket[place-name] symbol
|
||||
is used to establish later connections to the named place.
|
||||
|
@ -283,8 +281,8 @@ Returns a @racket[after-seconds%] instance that should be supplied to a @racket[
|
|||
Executes the body expressions after a delay of @racket[seconds] from the start of the event loop.
|
||||
}
|
||||
|
||||
@defproc[(connect-to-named-place [vm remote-node%?] [name symbol?]) remote-connection%?]{
|
||||
Connects to a named place on the @racket[vm] named @racket[name] and returns a @racket[remote-connection%] object.
|
||||
@defproc[(connect-to-named-place [node remote-node%?] [name symbol?]) remote-connection%?]{
|
||||
Connects to a named place on the @racket[node] named @racket[name] and returns a @racket[remote-connection%] object.
|
||||
}
|
||||
|
||||
@defproc[(log-message [severity symbol?] [msg string?]) void?]{
|
||||
|
@ -405,9 +403,9 @@ node's message router.
|
|||
launches compute places and routes inter-node place messages in the
|
||||
distributed system. This is the remote api to a distributed places
|
||||
node. Instances of @racket[remote-node%] are returned by
|
||||
@racket[spawn-remote-racket-vm],
|
||||
@racket[spawn-vm-supervise-dynamic-place-at], and
|
||||
@racket[spawn-vm-supervise-place-thunk-at].
|
||||
@racket[spawn-remote-racket-node],
|
||||
@racket[spawn-node-supervise-dynamic-place-at], and
|
||||
@racket[spawn-node-supervise-place-thunk-at].
|
||||
|
||||
@defconstructor[([listen-port tcp-listen-port? #f]
|
||||
[restart-on-exit any/c #f])]{
|
||||
|
@ -455,7 +453,7 @@ The @racket[remote-place%] instance provides a remote api to a place
|
|||
running on a remote distributed places node. It launches a compute
|
||||
places and routes inter-node place messages to the remote place.
|
||||
|
||||
@defconstructor[([vm remote-node%?]
|
||||
@defconstructor[([node remote-node%?]
|
||||
[place-exec list?]
|
||||
[restart-on-exit #f]
|
||||
[one-sided-place? #f]
|
||||
|
@ -490,7 +488,7 @@ The @racket[remote-connection%] instance provides a remote api to a named place
|
|||
running on a remote distributed places node. It connects to a named compute
|
||||
places and routes inter-node place messages to the remote place.
|
||||
|
||||
@defconstructor[([vm remote-node%?]
|
||||
@defconstructor[([node remote-node%?]
|
||||
[name string?]
|
||||
[restart-on-exit #f]
|
||||
[on-channel #f])]{
|
||||
|
@ -512,7 +510,7 @@ places and routes inter-node place messages to the remote place.
|
|||
distributed places node at that node. It launches a compute places and
|
||||
routes inter-node place messages to the place.
|
||||
|
||||
@defconstructor[([vm remote-place%?]
|
||||
@defconstructor[([node remote-place%?]
|
||||
[place-exec list?]
|
||||
[ch-id exact-positive-integer?]
|
||||
[sc socket-connection%?]
|
||||
|
@ -543,7 +541,7 @@ The @racket[connection%] instance represents a connection to a
|
|||
named-place instance running on the current node. It routes inter-node
|
||||
place messages to the named place.
|
||||
|
||||
@defconstructor[([vm remote-node%?]
|
||||
@defconstructor[([node remote-node%?]
|
||||
[name string?]
|
||||
[ch-id exact-positive-integer?]
|
||||
[sc socket-connection%?])]{
|
||||
|
|
|
@ -24,15 +24,15 @@
|
|||
(eprintf "ERROR\n"))
|
||||
ok?)))
|
||||
|
||||
(define remote-vm (spawn-remote-racket-vm "localhost" #:listen-port 6344))
|
||||
(define tuple-place (supervise-named-dynamic-place-at remote-vm 'tuple-server tuple-path 'make-tuple-server))
|
||||
(define bank-place (supervise-dynamic-place-at remote-vm bank-path 'make-bank))
|
||||
(define remote-node (spawn-remote-racket-node "localhost" #:listen-port 6344))
|
||||
(define tuple-place (supervise-named-dynamic-place-at remote-node 'tuple-server tuple-path 'make-tuple-server))
|
||||
(define bank-place (supervise-dynamic-place-at remote-node bank-path 'make-bank))
|
||||
|
||||
(message-router
|
||||
remote-vm
|
||||
remote-node
|
||||
(after-seconds 2
|
||||
(define c (connect-to-named-place remote-vm 'tuple-server))
|
||||
(define d (connect-to-named-place remote-vm 'tuple-server))
|
||||
(define c (connect-to-named-place remote-node 'tuple-server))
|
||||
(define d (connect-to-named-place remote-node 'tuple-server))
|
||||
(tuple-server-hello c)
|
||||
(tuple-server-hello d)
|
||||
(test 100 tuple-server-set c "user0" 100)
|
||||
|
@ -49,6 +49,6 @@
|
|||
)
|
||||
|
||||
(after-seconds 15
|
||||
(node-send-exit remote-vm))
|
||||
(node-send-exit remote-node))
|
||||
(after-seconds 20
|
||||
(exit 0))))
|
||||
|
|
|
@ -15,8 +15,13 @@
|
|||
|
||||
(define (main)
|
||||
(message-router
|
||||
(spawn-vm-with-place-thunk-at "localhost" #:listen-port 6345 (quote-module-name) 'wait-place-thunk
|
||||
#:restart-on-exit (restart-every 5 #:retry 3
|
||||
#:on-final-fail (lambda ()
|
||||
(printf "Failed 3 times exititing\n")
|
||||
(exit 1))))))
|
||||
(spawn-node-with-place-thunk-at
|
||||
"localhost"
|
||||
#:listen-port 6345
|
||||
(quote-module-name)
|
||||
'wait-place-thunk
|
||||
#:restart-on-exit (restart-every 5
|
||||
#:retry 3
|
||||
#:on-final-fail (lambda ()
|
||||
(printf "Failed 3 times exititing\n")
|
||||
(exit 1))))))
|
||||
|
|
Loading…
Reference in New Issue
Block a user