Overview
Comment: | Moved the sleep from server to client' |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | v1.60 |
Files: | files | file ages | folders |
SHA1: |
30d0a746e2f2f8f192592fd22d5a7650 |
User & Date: | matt on 2015-06-20 13:37:01 |
Other Links: | branch diff | manifest | tags |
Context
2015-06-20
| ||
14:36 | Switched to simple piece-wise function for droop curve check-in: e42bd990aa user: matt tags: v1.60 | |
13:37 | Moved the sleep from server to client' check-in: 30d0a746e2 user: matt tags: v1.60 | |
2015-06-19
| ||
21:17 | Missing changes check-in: 0ee351862a user: matt tags: v1.60 | |
Changes
Modified loadwatch/queuefeeder-server.scm from [a13dabce08] to [2388ed6e77].
︙ | ︙ | |||
61 62 63 64 65 66 67 | (equal? (substring msg-in 0 4) "ping")) (nn-send soc (conc (current-process-id))) (loop (nn-recv soc)(+ count 1))) (else (mutex-lock! *current-delay-mutex*) (let ((current-delay *current-delay*)) (mutex-unlock! *current-delay-mutex*) | | | | 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | (equal? (substring msg-in 0 4) "ping")) (nn-send soc (conc (current-process-id))) (loop (nn-recv soc)(+ count 1))) (else (mutex-lock! *current-delay-mutex*) (let ((current-delay *current-delay*)) (mutex-unlock! *current-delay-mutex*) ;; (thread-sleep! current-delay) (nn-send soc (conc current-delay " hello " msg-in " you waited " current-delay " seconds")) (loop (nn-recv soc)(if (> count 20000000) 0 (+ count 1)))))))) (define (ping-self host port #!key (return-socket #t)) ;; send a random number along with pid and check that we get it back (let* ((req (nn-socket 'req)) |
︙ | ︙ |
Modified loadwatch/queuefeeder.scm from [2effd437a4] to [6ffa548735].
︙ | ︙ | |||
14 15 16 17 18 19 20 | ;;====================================================================== ;; Methodology ;; ;; Connect to the server, the server delays the appropriate time (if ;; any) and then launch the task. ;; | | | 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | ;;====================================================================== ;; Methodology ;; ;; Connect to the server, the server delays the appropriate time (if ;; any) and then launch the task. ;; (use nanomsg posix regex message-digest md5) (define req (nn-socket 'req)) ;; get needed stuff from commandline ;; (define hostport #f) (define cmd '()) |
︙ | ︙ | |||
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | (nn-connect req (conc "tcp://" hostport)) ;; xena:22022") (define (client-send-receive soc msg) (nn-send soc msg) (nn-recv soc)) ;; (define ((talk-to-server soc)) ;; (let loop ((cnt 200000)) ;; (let ((name (list-ref '("Matt" "Tom" "Bob" "Jill" "James" "Jane")(random 6)))) ;; ;; (print "Sending " name) ;; ;; (print ;; (client-send-receive req name) ;; ) ;; (if (> cnt 0)(loop (- cnt 1))))) ;; (print (client-send-receive req "quit")) ;; (nn-close req) ;; (exit)) ;; | > > > > > > > > > > > > > > > > > > > > > > > | | | | | | | > > > > | | 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | (nn-connect req (conc "tcp://" hostport)) ;; xena:22022") (define (client-send-receive soc msg) (nn-send soc msg) (nn-recv soc)) ;; Generate a unique signature for this client location ;; (define (make-signature) (message-digest-string (md5-primitive) (with-output-to-string (lambda () (write (current-directory)))))) ;; (define ((talk-to-server soc)) ;; (let loop ((cnt 200000)) ;; (let ((name (list-ref '("Matt" "Tom" "Bob" "Jill" "James" "Jane")(random 6)))) ;; ;; (print "Sending " name) ;; ;; (print ;; (client-send-receive req name) ;; ) ;; (if (> cnt 0)(loop (- cnt 1))))) ;; (print (client-send-receive req "quit")) ;; (nn-close req) ;; (exit)) ;; (define (get-delay signature) (let* ((full-msg (client-send-receive req (conc (current-user-name) "@" (get-host-name) ":" signature)))) (print "Got " full-msg) (let* ((reply-msg (string-match "^([\\d\\.]+)\\s+(.*)$" full-msg)) (delay-time (if (> (length reply-msg) 2) (string->number (cadr reply-msg)) 1)) ;; fall back to one sec delay (msg (if (> (length reply-msg) 2) (caddr reply-msg) full-msg))) (values delay-time msg)))) (let ((signature (make-signature))) (thread-start! (lambda () (thread-sleep! 60) (print "Give up on waiting for the server") (nn-close req) ;; (exit) )) (thread-join! (thread-start! (lambda () (let-values (((delay-time msg)(get-delay signature))) (print "INFO: sleeping " delay-time " seconds per request of queuefeeder server") (thread-sleep! delay-time) (print "INFO: done waiting, now executing requested task.")))))) (process-execute (car cmd) (cdr cmd)) |