65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
(if (and (> count 10)
(> queries-per-second 10))
(begin
(debug:print-info 1 "db write rate too high, starting a server, count=" count " start=" start " run-id=" run-id " queries-per-second=" queries-per-second)
#t)
#f))))
(define (rmt:get-connection-info run-id)
(let ((cinfo (hash-table-ref/default *runremote* run-id #f)))
(if cinfo
cinfo
;; NB// can cache the answer for server running for 10 seconds ...
;; ;; (and (not (rmt:write-frequency-over-limit? cmd run-id))
(if (tasks:server-running-or-starting? (db:delay-if-busy (tasks:open-db)) run-id)
|
>
>
>
|
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
(if (and (> count 10)
(> queries-per-second 10))
(begin
(debug:print-info 1 "db write rate too high, starting a server, count=" count " start=" start " run-id=" run-id " queries-per-second=" queries-per-second)
#t)
#f))))
;; if a server is either running or in the process of starting call client:setup
;; else return #f to let the calling proc know that there is no server available
;;
(define (rmt:get-connection-info run-id)
(let ((cinfo (hash-table-ref/default *runremote* run-id #f)))
(if cinfo
cinfo
;; NB// can cache the answer for server running for 10 seconds ...
;; ;; (and (not (rmt:write-frequency-over-limit? cmd run-id))
(if (tasks:server-running-or-starting? (db:delay-if-busy (tasks:open-db)) run-id)
|
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
|
;; no longer killing the server in http-transport:client-api-send-receive
;; may kill it here but what are the criteria?
;; start with three calls then kill server
;; (if (eq? attemptnum 3)(tasks:kill-server-run-id run-id))
;; (thread-sleep! 2)
(rmt:send-receive cmd run-id params attemptnum: (+ attemptnum 1)))))
;; no connection info? try to start a server
(if (and (< attemptnum 15)
(member cmd api:write-queries))
(begin
(hash-table-delete! *runremote* run-id)
;; (mutex-unlock! *send-receive-mutex*)
(tasks:start-and-wait-for-server (db:delay-if-busy (tasks:open-db)) run-id 10)
;; (client:setup run-id) ;; client setup happens in rmt:get-connection-info
|
|
>
>
>
>
|
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
|
;; no longer killing the server in http-transport:client-api-send-receive
;; may kill it here but what are the criteria?
;; start with three calls then kill server
;; (if (eq? attemptnum 3)(tasks:kill-server-run-id run-id))
;; (thread-sleep! 2)
(rmt:send-receive cmd run-id params attemptnum: (+ attemptnum 1)))))
;; no connection info? try to start a server, or access locally if no
;; server and the query is read-only
;;
;; Note: The tasks db was checked for a server in starting mode in the rmt:get-connection-info call
;;
(if (and (< attemptnum 15)
(member cmd api:write-queries))
(begin
(hash-table-delete! *runremote* run-id)
;; (mutex-unlock! *send-receive-mutex*)
(tasks:start-and-wait-for-server (db:delay-if-busy (tasks:open-db)) run-id 10)
;; (client:setup run-id) ;; client setup happens in rmt:get-connection-info
|