Author: psmith Date: Tue Jan 30 00:45:18 2007 New Revision: 60
Added: branches/home/psmith/restructure/src/nio-logger/nio-logger-package.lisp - copied, changed from r49, branches/home/psmith/restructure/src/utils/nio-utils-package.lisp branches/home/psmith/restructure/src/nio-logger/nio-logger.asd - copied, changed from r49, branches/home/psmith/restructure/src/utils/nio-utils.asd branches/home/psmith/restructure/src/nio-logger/nio-logger.lisp branches/home/psmith/restructure/src/nio-logger/run.sh (contents, props changed) Modified: branches/home/psmith/restructure/src/nio-logger/run-logging-client.lisp branches/home/psmith/restructure/src/nio-logger/run-logging-server.lisp branches/home/psmith/restructure/src/protocol/yarpc/nio-yarpc-package.lisp Log: logging nearly there...
Copied: branches/home/psmith/restructure/src/nio-logger/nio-logger-package.lisp (from r49, branches/home/psmith/restructure/src/utils/nio-utils-package.lisp) ============================================================================== --- branches/home/psmith/restructure/src/utils/nio-utils-package.lisp (original) +++ branches/home/psmith/restructure/src/nio-logger/nio-logger-package.lisp Tue Jan 30 00:45:18 2007 @@ -24,10 +24,10 @@ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |# -(defpackage :nio-utils (:use :cl) +(defpackage :nio-logger (:use :cl) (:export
- ;;utils - format-log + ;;nio-logger + remote-log run-logging-server tail-log ))
Copied: branches/home/psmith/restructure/src/nio-logger/nio-logger.asd (from r49, branches/home/psmith/restructure/src/utils/nio-utils.asd) ============================================================================== --- branches/home/psmith/restructure/src/utils/nio-utils.asd (original) +++ branches/home/psmith/restructure/src/nio-logger/nio-logger.asd Tue Jan 30 00:45:18 2007 @@ -2,11 +2,11 @@
(in-package :asdf)
-(defsystem :nio-utils +(defsystem :nio-logger
- :components ((:file "nio-utils-package") - (:file "utils" :depends-on ("nio-utils-package")) + :components ((:file "nio-logger-package") + (:file "nio-logger" :depends-on ("nio-logger-package")) )
- :depends-on ()) + :depends-on (:nio-yarpc))
Added: branches/home/psmith/restructure/src/nio-logger/nio-logger.lisp ============================================================================== --- (empty file) +++ branches/home/psmith/restructure/src/nio-logger/nio-logger.lisp Tue Jan 30 00:45:18 2007 @@ -0,0 +1,57 @@ +#| +Copyright (c) 2007 +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. +3. The name of the author may not be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +|# + +(in-package :nio-logger) + +(declaim (optimize (debug 3) (speed 3) (space 0))) + +;;Tail the given log and write to remote logger +;;e.g. (tail-log "/var/log/httpd/access_log" "192.168.1.1") +(defun tail-log(filename ip-address) + ;;shouldn't be listenting on the client hence nil for accept SM to start-server + (sb-thread:make-thread #'(lambda()(nio:start-server 'identity 'identity nil :host "127.0.0.1" :port 9897)) :name "nio-server") + (sleep 4) + (let ((sm (nio:add-connection ip-address 16323 'nio-yarpc:yarpc-client-state-machine))) + (nio-utils:format-log t "toplevel adding conn ~A to ~A~%" sm ip-address) + (with-open-file (in filename :direction :input) + (loop for text = (read-line in nil nil) do + (let ((rpc (format nil "(nio-logger:log +log-file-name+ ~A" text))) + (nio-utils:format-log t "Toplevel Submitting job~A~%" rpc) + (nio-utils:format-log t "Result of remote-log ~A~%" (nio-yarpc:remote-execute sm rpc))))))) + +;Runs a multithreaded system with an IO thread dealing with IO only and a 'job' thread taking and executing jobs + +(defun run-logging-server() + (setf nio-yarpc:+process-jobs-inline+ nil) + (nio:load-ips "ips.txt") + (sb-thread:make-thread #'(lambda()(nio:start-server 'identity 'identity 'nio-yarpc:yarpc-state-machine :host "127.0.0.1" :accept-connection 'nio:check-ip)) :name "nio-server") + (loop + ;;block waiting for jobs + (nio-yarpc:run-job))) + +(nio-yarpc:defremote remote-log(destination control-string &rest format-arguments) + (format-log destination control-string format-arguments))
Modified: branches/home/psmith/restructure/src/nio-logger/run-logging-client.lisp ============================================================================== --- branches/home/psmith/restructure/src/nio-logger/run-logging-client.lisp (original) +++ branches/home/psmith/restructure/src/nio-logger/run-logging-client.lisp Tue Jan 30 00:45:18 2007 @@ -25,20 +25,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |#
-(in-package :nio-logger) - -(declaim (optimize (debug 3) (speed 3) (space 0))) - -;;Tail the given log and write to remote logger -;;e.g. (tail-log "/var/log/httpd/access_log" "192.168.1.1") -(defun tail-log(filename ip-address) - ;;shouldn't be listenting on the client hence nil for accept SM to start-server - (sb-thread:make-thread #'(lambda()(nio:start-server 'identity 'identity nil :host "127.0.0.1" :port 9897)) :name "nio-server") - (sleep 4) - (let ((sm (nio:add-connection ip-address 16323 'nio-yarpc:yarpc-client-state-machine))) - (nio-utils:format-log t "toplevel adding conn ~A to ~A~%" sm ip-address) - (with-open-file (in filename :direction :input) - (loop for text = (read-line in nil nil) - (let ((rpc (format nil "(nio-logger:log +log-file-name+ ~A" text))) - (nio-utils:format-log t "Toplevel Submitting job~A~%" rpc) - (nio-utils:format-log t "Result of remote-log ~A~%" (nio-yarpc:remote-execute sm rpc))))))) +(push :nio-debug *features*) +(require :asdf) +(require :nio-yarpc) +(nio-logger:tail-log)
Modified: branches/home/psmith/restructure/src/nio-logger/run-logging-server.lisp ============================================================================== --- branches/home/psmith/restructure/src/nio-logger/run-logging-server.lisp (original) +++ branches/home/psmith/restructure/src/nio-logger/run-logging-server.lisp Tue Jan 30 00:45:18 2007 @@ -25,20 +25,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |#
-(in-package :nio-logger) - -(declaim (optimize (debug 3) (speed 3) (space 0))) - - -;Runs a multithreaded system with an IO thread dealing with IO only and a 'job' thread taking and executing jobs - -(defun run-logging-server() - (setf nio-yarpc:+process-jobs-inline+ nil) - (nio:load-ips "ips.txt") - (sb-thread:make-thread #'(lambda()(nio:start-server 'identity 'identity 'nio-yarpc:yarpc-state-machine :host "127.0.0.1" :accept-connection 'nio:check-ip)) :name "nio-server") - (loop - ;;block waiting for jobs - (nio-yarpc:run-job))) - -(defremote log(destination control-string &rest format-arguments) - (format-log destination control-string format-arguments)) +(push :nio-debug *features*) +(require :asdf) +(require :nio-yarpc) +(nio-logger:run-logging-server)
Added: branches/home/psmith/restructure/src/nio-logger/run.sh ============================================================================== --- (empty file) +++ branches/home/psmith/restructure/src/nio-logger/run.sh Tue Jan 30 00:45:18 2007 @@ -0,0 +1,7 @@ +#!/bin/bash +# +# run.sh <http|yarpc> +# + +export LANG=en_US.UTF-8 +sbcl --load run-$1.lisp
Modified: branches/home/psmith/restructure/src/protocol/yarpc/nio-yarpc-package.lisp ============================================================================== --- branches/home/psmith/restructure/src/protocol/yarpc/nio-yarpc-package.lisp (original) +++ branches/home/psmith/restructure/src/protocol/yarpc/nio-yarpc-package.lisp Tue Jan 30 00:45:18 2007 @@ -34,7 +34,7 @@ ;; yarpc-state-machine yarpc-state-machine job-queue run-job +process-jobs-inline+ ;to be moved - test-rpc test-rpc-list test-rpc-string execute-call + test-rpc test-rpc-list test-rpc-string execute-call defremote ;;yarpc-client-state-machine yarpc-client-state-machine remote-execute