Changeset 82 for branches/home
- Timestamp:
- 02/10/07 23:52:32 (18 years ago)
- Location:
- branches/home/psmith/restructure/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified branches/home/psmith/restructure/src/io/nio-server.lisp ¶
r81 r82 69 69 &key 70 70 (protocol :inet) 71 (port (+ (random 60000) 1024))71 (port 0) ;//if set then listen 72 72 (host "127.0.0.1") 73 73 (accept-connection #'trivial-accept)) … … 77 77 ) 78 78 79 (when (not ( null connection-type))79 (when (not (eql port 0)) 80 80 (format t "Binding to ~A:~A~%" host port) 81 81 (setq sock (ecase protocol … … 162 162 #+nio-debug (format-log t "nio-server:start-server - adding connection to nio thread ~A~%" new-fd) 163 163 (setf (gethash (async-fd-read-fd new-fd) client-hash) new-fd) 164 (setf (active-conn a-node) new-fd) 164 165 (add-async-fd event-queue new-fd :read-write)))) 165 166 -
TabularUnified branches/home/psmith/restructure/src/nio-logger/nio-logger.lisp ¶
r81 r82 55 55 (nio-utils:format-log t "Toplevel Submitting job~A~%" rpc) 56 56 (nio:with-connected-nodes (node) 57 (nio-utils:format-log t "Toplevel sending ~A to ~A~%" rpc node) 57 58 (nio-yarpc:remote-execute (nio:active-conn node) rpc #'callback))))) 58 59 … … 65 66 (setf +log-file-name+ out-file) 66 67 (nio:load-ips allowed-ips) 67 (sb-thread:make-thread #'(lambda()(nio:start-server 'nio-yarpc:yarpc-state-machine :host listen-ip : accept-connection 'nio:check-ip)) :name "nio-server")68 (sb-thread:make-thread #'(lambda()(nio:start-server 'nio-yarpc:yarpc-state-machine :host listen-ip :port 16323 :accept-connection 'nio:check-ip)) :name "nio-server") 68 69 (loop 69 70 ;;block waiting for jobs -
TabularUnified branches/home/psmith/restructure/src/nio-logger/run-logging-client.lisp ¶
r77 r82 37 37 38 38 ;;shouldn't be listenting on the client hence nil for accept SM to start-server 39 (nio:start-server nil))39 (nio:start-server 'nio-yarpc:yarpc-client-state-machine)) -
TabularUnified branches/home/psmith/restructure/src/protocol/yarpc/yarpc-client-state-machine.lisp ¶
r81 r82 42 42 43 43 (defclass remote-job() 44 ((callback :accessor callback 44 ((callback :initarg :callback 45 :accessor callback 45 46 :documentation "A function accepting one argument to call with the result of the remote operation") 46 47 (start-time :initform (get-universal-high-res) … … 73 74 74 75 (defmethod process-outgoing-packet((sm yarpc-client-state-machine)) 75 #+nio-debug 2(format-log t "yarpc-client-state-machine:process-outgoing-packet called, polling the job-queue ~%")76 #+nio-debug (format-log t "yarpc-client-state-machine:process-outgoing-packet called, polling the job-queue ~%") 76 77 (let ((ttd (nio-compat:take (job-queue sm) :blocking-call nil))) 77 78 (when ttd … … 89 90 ;Execute the call-string on the remote node and call callback with the result 90 91 (defmethod remote-execute ((sm yarpc-client-state-machine) call-string callback) 91 (nio-compat:add (job-queue sm) '((remote-job callback) call-string))) 92 (format-log t "yarpc-client-state-machine:remote-execute called :sm ~A :call-string ~A :callback ~A~%" sm call-string callback) 93 (nio-compat:add (job-queue sm) (list (remote-job callback) call-string))) -
TabularUnified branches/home/psmith/restructure/src/protocol/yarpc/yarpc-packet-factory.lisp ¶
r81 r82 41 41 (defconstant +PACKET-ID-SIZE+ 1) 42 42 (defconstant +PACKET-LENGTH-SIZE+ 4) 43 ;(defconstant +PACKET-REQUEST-ID+ 4)43 (defconstant +PACKET-REQUEST-ID-SIZE+ 4) 44 44 45 45 (defconstant +yarpc-packet-header-size+ … … 54 54 (let* ((packet-request-id (bytebuffer-read-32 buf)) 55 55 (ret-packet (ecase packet-id 56 (0 (progn (format-log t "yarpc-packet-factory:get-packet - got CALL-METHOD-PACKET-ID~%") (call-method-packet (bytebuffer-read-string buf (- packet-length +yarpc-packet-header-size+ )) :request-id packet-request-id)))57 (1 (progn (format-log t "yarpc-packet-factory:get-packet - got METHOD-RESPONSE-PACKET-ID~%") (method-response-packet (bytebuffer-read-string buf (- packet-length +yarpc-packet-header-size+ )) :request-id packet-request-id))))))56 (0 (progn (format-log t "yarpc-packet-factory:get-packet - got CALL-METHOD-PACKET-ID~%") (call-method-packet (bytebuffer-read-string buf (- packet-length +yarpc-packet-header-size+ +PACKET-REQUEST-ID-SIZE+)) :request-id packet-request-id))) 57 (1 (progn (format-log t "yarpc-packet-factory:get-packet - got METHOD-RESPONSE-PACKET-ID~%") (method-response-packet (bytebuffer-read-string buf (- packet-length +yarpc-packet-header-size+ +PACKET-REQUEST-ID-SIZE+)) :request-id packet-request-id)))))) 58 58 (compact buf) 59 59 #+nio-debug (format-log t "yarpc-packet-factory:get-packet - after compact ~%~A~%" buf) … … 71 71 :reader request-id))) 72 72 73 (defclass call-method-packet (yarpc-packet)((call-string :initarg :call-string 74 :accessor call-string))) 75 (defun call-method-packet (call-string) 76 (make-instance 'call-method-packet :call-string call-string)) 73 (defclass call-method-packet (yarpc-packet) 74 ((call-string :initarg :call-string 75 :accessor call-string))) 76 77 (defun call-method-packet (call-string &key request-id) 78 (make-instance 'call-method-packet :call-string call-string :request-id request-id)) 77 79 78 80 (defmethod print-object ((packet call-method-packet) stream) … … 104 106 :accessor response))) 105 107 106 (defun method-response-packet (response )107 (make-instance 'method-response-packet :response response ))108 (defun method-response-packet (response &key request-id) 109 (make-instance 'method-response-packet :response response :request-id request-id)) 108 110 109 111 (defmethod print-object ((packet method-response-packet) stream) -
TabularUnified branches/home/psmith/restructure/src/protocol/yarpc/yarpc-state-machine.lisp ¶
r81 r82 61 61 (defun run-job(&key (blocking t)) 62 62 (format-log t "yarpc-state-machine:run-job - Server toplevel waiting for job~%") 63 (destructuring-bind (job request-id result-queue) (nio-compat:take nio-yarpc:job-queue :blocking-call blocking) 64 (format-log t "yarpc-state-machine:run-job - Server received job ~A~%" job) 65 (nio-compat:add result-queue (list request-id (nio-yarpc:execute-call job))))) 63 (let ((server-job (nio-compat:take nio-yarpc:job-queue :blocking-call blocking))) 64 (when server-job 65 (destructuring-bind (job request-id result-queue) server-job 66 (format-log t "yarpc-state-machine:run-job - Server received job ~A~%" job) 67 (nio-compat:add result-queue (list request-id (nio-yarpc:execute-call job))))))) 66 68 67 69 68 70 (defmethod process-outgoing-packet((sm yarpc-state-machine)) 69 71 (format-log t "yarpc-state-machine:process-outgoing-packet - called, polling the results-queue ~%" ) 70 (destructuring-bind (request-id result) (nio-compat:take (result-queue sm) :blocking-call nil) 71 (format-log t "yarpc-state-machine:process-outgoing-packet - got :request-id ~A result ~A ~%" request-id result) 72 (when result 73 (method-response-packet result :request-id request-id)))) 72 (let ((server-job (nio-compat:take (result-queue sm) :blocking-call nil))) 73 (when server-job 74 (destructuring-bind (request-id result) server-job 75 (format-log t "yarpc-state-machine:process-outgoing-packet - got :request-id ~A result ~A ~%" request-id result) 76 (method-response-packet result :request-id request-id))))) 74 77 75 78 ;Process a call method packet by placing it in the job-queue
Note: See TracChangeset
for help on using the changeset viewer.