Megatest

Diff
Login

Differences From Artifact [ee5770769f]:

To Artifact [df51662aee]:


163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
	(let* (;; (dbfile   (db:run-id->path apath run-id))
	       (newdbdat (db:open-dbdat apath dbfile db:initialize-db)))
	  (dbr:dbstruct-dbdat-put! dbstruct dbfile newdbdat)
	  newdbdat))))

;; get the inmem db for actual db operations
;;
(define (db:get-inmem dbstruct dbfile)
  (dbr:dbdat-inmem (db:get-dbdat dbstruct dbfile)))

;; get the handle for the on-disk db
;;
(define (db:get-ddb dbstruct apath dbfile)
  (dbr:dbdat-db (db:get-dbdat dbstruct apath dbfile)))

;; open or create the disk db file







|
|







163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
	(let* (;; (dbfile   (db:run-id->path apath run-id))
	       (newdbdat (db:open-dbdat apath dbfile db:initialize-db)))
	  (dbr:dbstruct-dbdat-put! dbstruct dbfile newdbdat)
	  newdbdat))))

;; get the inmem db for actual db operations
;;
(define (db:get-inmem dbstruct apath dbfile)
  (dbr:dbdat-inmem (db:get-dbdat dbstruct apath dbfile)))

;; get the handle for the on-disk db
;;
(define (db:get-ddb dbstruct apath dbfile)
  (dbr:dbdat-db (db:get-dbdat dbstruct apath dbfile)))

;; open or create the disk db file
323
324
325
326
327
328
329

330
331
332
333
334
335
336
337
		     ))

;; (db:with-db dbstruct run-id sqlite3:exec "select blah fgrom blaz;")
;; r/w is a flag to indicate if the db is modified by this query #t = yes, #f = no
;;
(define (db:with-db dbstruct run-id r/w proc . params)
  (assert (dbr:dbstruct? dbstruct) "FATAL: db:with-db called with bad dbstruct")

  (let* ((dbdat     (db:get-dbdat dbstruct run-id))
	 (db        (dbr:dbdat-inmem dbdat))
	 (fname     (dbr:dbdat-fname dbdat))
	 (use-mutex (> *api-process-request-count* 25))) ;; was 25
    (if (and use-mutex
	     (common:low-noise-print 120 "over-50-parallel-api-requests"))
	(debug:print-info 0 *default-log-port* *api-process-request-count* " parallel api requests being processed in process " (current-process-id) ", throttling access"))
    (if (common:low-noise-print 600 (conc "parallel-api-requests" *max-api-process-requests*))







>
|







323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
		     ))

;; (db:with-db dbstruct run-id sqlite3:exec "select blah fgrom blaz;")
;; r/w is a flag to indicate if the db is modified by this query #t = yes, #f = no
;;
(define (db:with-db dbstruct run-id r/w proc . params)
  (assert (dbr:dbstruct? dbstruct) "FATAL: db:with-db called with bad dbstruct")
  (let* ((dbpath    (db:run-id->dbname run-id))
	 (dbdat     (db:get-dbdat dbstruct *toppath* dbpath))
	 (db        (dbr:dbdat-inmem dbdat))
	 (fname     (dbr:dbdat-fname dbdat))
	 (use-mutex (> *api-process-request-count* 25))) ;; was 25
    (if (and use-mutex
	     (common:low-noise-print 120 "over-50-parallel-api-requests"))
	(debug:print-info 0 *default-log-port* *api-process-request-count* " parallel api requests being processed in process " (current-process-id) ", throttling access"))
    (if (common:low-noise-print 600 (conc "parallel-api-requests" *max-api-process-requests*))
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538

5539
5540
5541
5542
5543
  (db:with-db
   dbstruct
   #f #f
   (lambda (db)
     (sqlite3:execute db "INSERT INTO servers (host,port,servkey,pid,ipaddr,dbpath) VALUES (?,?,?,?,?,?);"
		      host port servkey pid ipaddr dbpath))))

(define (db:get-server-info dbstruct dbpath)
  (db:with-db
   dbstruct
   #f #f
   (lambda (db)
     (sqlite3:fold-row
      (lambda (res host port servkey pid ipaddr dbpath)
	(list host port servkey pid ipaddr dbpath))
      '()

      db
      "SELECT host,port,servkey,pid,ipaddr,dbpath FROM servers WHERE dbpath=?;"
      dbpath))))

)







|







<
>


|


5524
5525
5526
5527
5528
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538

5539
5540
5541
5542
5543
5544
  (db:with-db
   dbstruct
   #f #f
   (lambda (db)
     (sqlite3:execute db "INSERT INTO servers (host,port,servkey,pid,ipaddr,dbpath) VALUES (?,?,?,?,?,?);"
		      host port servkey pid ipaddr dbpath))))

(define (db:get-server-info dbstruct apath dbname)
  (db:with-db
   dbstruct
   #f #f
   (lambda (db)
     (sqlite3:fold-row
      (lambda (res host port servkey pid ipaddr dbpath)
	(list host port servkey pid ipaddr dbpath))

      #f
      db
      "SELECT host,port,servkey,pid,ipaddr,dbpath FROM servers WHERE dbpath=?;"
      (conc apath "/" dbname)))))

)