Commit 960234ba authored by mevenson@1c010e3e-69d0-11dd-93a8-456734b0d56f's avatar mevenson@1c010e3e-69d0-11dd-93a8-456734b0d56f
Browse files

Fix compile errors of the thread pool abstraction.

parent 4fd69354
......@@ -9,7 +9,8 @@
(defparameter *server-running-p* nil)
;;; XXX possibly need multiple thread pools
(defparameter *thread-pool* nil)
(defparameter *thread-pool* nil
"The current JVM class implementing the ScheduledThreadPool abstraction.")
(defparameter *scheduled-futures* nil)
(defparameter *incoming-scheduled-future* nil)
(defparameter *watch-queue-future* nil)
......@@ -23,11 +24,16 @@
(defparameter *incoming* (merge-pathnames "incoming/" *root*))
(defparameter *dirs* (list *incoming*))
(defparameter *queue* (merge-pathnames "queue/" *root*))
(defparameter *processed* (merge-pathnames "processed/" *root*))
;;;; A simple logging abstraction.
(defconstant +month-names+ '("Jan" "Feb" "Mar" "Apr" "May" "Jun"
"Jul" "Aug" "Sep" "Oct" "Nov" "Dec"))
(defconstant +seconds+ (java:jfield "java.util.concurrent.TimeUnit" "SECONDS"))
(defparameter *log* *standard-output*)
(defun format-time (universal-time)
......@@ -90,3 +96,38 @@
*thread-pool*
(make-process-incoming) 1 1 +seconds+)))
(defun make-process-incoming ()
(java:jinterface-implementation "java.lang.Runnable" "run" #'process-incoming))
(defun process-incoming ()
(flet ((reject-input (file invalid)
(warn (format nil "~A is ~A" file invalid))))
(let ((incoming (directory (merge-pathnames *incoming* "*"))))
(unless incoming
(return-from process-incoming))
(log "Processing ~A incoming items." (length incoming))
(let (table error)
(dolist (file incoming)
(setf error nil)
(log "Analyzing ~A." file)
(setf table
(handler-case
(load-table file)
(t (e)
(log "Failed to process ~A because ~A" file e)
(setf error e))))
(if error
(reject-input file (if (listp error) error (list error)))
(multiple-value-bind (valid invalid)
(validate table)
(if invalid
(progn
(log "Rejecting ~A because of invalid rows." file)
(reject-input file invalid))
(let ((incoming
(make-pathname :defaults *queue*
:name (pathname-name file)
:type (pathname-type file))))
(log "Inserting ~A." incoming)
(rename-file file incoming))))))))))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment