Changeset 2611

Show
Ignore:
Timestamp:
02/24/08 00:54:44 (11 months ago)
Author:
hans
Message:

Provide restarts to allow for skipping or reinitializing random state
that can't be read.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/bknr/datastore/src/data/txn.lisp

    r2610 r2611  
    138138  (merge-pathnames #P"random-state" (store-current-directory store))) 
    139139 
     140(defun initialize-store-random-state (store) 
     141  (with-open-file (f (store-random-state-pathname store) 
     142                     :direction :output :if-does-not-exist :create :if-exists :supersede) 
     143    (format t "initializing store random state~%") 
     144    (with-standard-io-syntax 
     145      (prin1 (setf (store-random-state store) (make-random-state t)) f)))) 
     146 
    140147(defmethod ensure-store-random-state ((store store)) 
    141148  (if (probe-file (store-random-state-pathname store)) 
    142149      (with-open-file (f (store-random-state-pathname store)) 
    143         (setf (store-random-state store) (read f))) 
    144       (with-open-file (f (store-random-state-pathname store) 
    145                          :direction :output :if-does-not-exist :create :if-exists :supersede) 
    146         (format t "initializing store random state~%") 
    147         (with-standard-io-syntax 
    148           (prin1 (setf (store-random-state store) (make-random-state t)) f))))) 
     150        (restart-case 
     151            (setf (store-random-state store) 
     152                  (handler-case 
     153                      (read f) 
     154                    (error (e) (error "Invalid store random state")))) 
     155          (initialize-store-random-state () 
     156            :report "Initialize the random state of the store" 
     157            (initialize-store-random-state store)) 
     158          (ignore-store-random-state () 
     159            :report "Ignore the on-disk random state of the store)" 
     160            (setf (store-random-state store) (make-random-state t))))) 
     161      (initialize-store-random-state store))) 
    149162 
    150163(defmethod update-store-random-state ((store store))