Changeset 82 for branches/home


Ignore:
Timestamp:
02/10/07 23:52:32 (18 years ago)
Author:
psmith
Message:

getting there...

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  
    6969                     &key
    7070                     (protocol :inet)
    71                      (port (+ (random 60000) 1024))
     71                     (port 0) ;//if set then listen
    7272                     (host "127.0.0.1")
    7373                     (accept-connection #'trivial-accept))
     
    7777        )
    7878
    79     (when (not (null connection-type))
     79    (when (not (eql port 0))
    8080      (format t "Binding to ~A:~A~%" host port)
    8181      (setq sock (ecase protocol
     
    162162#+nio-debug       (format-log t "nio-server:start-server - adding connection to nio thread ~A~%" new-fd)
    163163                   (setf (gethash (async-fd-read-fd new-fd) client-hash) new-fd)
     164                   (setf (active-conn a-node) new-fd)
    164165                   (add-async-fd event-queue new-fd :read-write))))
    165166             
  • TabularUnified branches/home/psmith/restructure/src/nio-logger/nio-logger.lisp

    r81 r82  
    5555      (nio-utils:format-log t "Toplevel Submitting job~A~%" rpc)
    5656      (nio:with-connected-nodes (node)
     57        (nio-utils:format-log t "Toplevel sending ~A to ~A~%" rpc node)
    5758        (nio-yarpc:remote-execute (nio:active-conn node) rpc #'callback)))))
    5859
     
    6566  (setf  +log-file-name+ out-file)
    6667  (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")
    6869  (loop
    6970    ;;block waiting for jobs
  • TabularUnified branches/home/psmith/restructure/src/nio-logger/run-logging-client.lisp

    r77 r82  
    3737
    3838  ;;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  
    4242
    4343(defclass remote-job()
    44   ((callback :accessor callback
     44  ((callback :initarg :callback
     45             :accessor callback
    4546             :documentation "A function accepting one argument to call with the result of the remote operation")
    4647   (start-time :initform (get-universal-high-res)
     
    7374
    7475(defmethod process-outgoing-packet((sm yarpc-client-state-machine))
    75 #+nio-debug2  (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 ~%")
    7677  (let ((ttd (nio-compat:take (job-queue sm) :blocking-call nil)))
    7778    (when ttd
     
    8990;Execute the call-string on the remote node and call callback with the result
    9091(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  
    4141(defconstant +PACKET-ID-SIZE+ 1)
    4242(defconstant +PACKET-LENGTH-SIZE+ 4)
    43 ;(defconstant +PACKET-REQUEST-ID+ 4)
     43(defconstant +PACKET-REQUEST-ID-SIZE+ 4)
    4444
    4545(defconstant +yarpc-packet-header-size+
     
    5454            (let* ((packet-request-id (bytebuffer-read-32 buf))
    5555                   (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))))))
    5858              (compact buf)
    5959              #+nio-debug  (format-log t "yarpc-packet-factory:get-packet - after compact ~%~A~%" buf)
     
    7171               :reader request-id)))
    7272
    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))
    7779
    7880(defmethod print-object ((packet call-method-packet) stream)
     
    104106             :accessor response)))
    105107
    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))
    108110
    109111(defmethod print-object ((packet method-response-packet) stream)
  • TabularUnified branches/home/psmith/restructure/src/protocol/yarpc/yarpc-state-machine.lisp

    r81 r82  
    6161(defun run-job(&key (blocking t))
    6262  (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)))))))
    6668
    6769
    6870(defmethod process-outgoing-packet((sm yarpc-state-machine))
    6971  (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)))))
    7477
    7578;Process a call method packet by placing it in the job-queue
Note: See TracChangeset for help on using the changeset viewer.