[nio-cvs] r59 - in branches/home/psmith/restructure: . src/nio-logger

psmith at common-lisp.net psmith at common-lisp.net
Tue Jan 30 04:43:01 UTC 2007


Author: psmith
Date: Mon Jan 29 23:43:00 2007
New Revision: 59

Added:
   branches/home/psmith/restructure/src/nio-logger/
   branches/home/psmith/restructure/src/nio-logger/ips.txt
      - copied unchanged from r58, branches/home/psmith/restructure/ips.txt
   branches/home/psmith/restructure/src/nio-logger/run-logging-client.lisp
      - copied, changed from r55, branches/home/psmith/restructure/run-yarpc-client.lisp
   branches/home/psmith/restructure/src/nio-logger/run-logging-server.lisp
      - copied, changed from r58, branches/home/psmith/restructure/run-yarpc.lisp
Removed:
   branches/home/psmith/restructure/ips.txt
   branches/home/psmith/restructure/run-yarpc-client.lisp
   branches/home/psmith/restructure/run-yarpc.lisp
Modified:
   branches/home/psmith/restructure/TODO
Log:
nio-logger first stab

Modified: branches/home/psmith/restructure/TODO
==============================================================================
--- branches/home/psmith/restructure/TODO	(original)
+++ branches/home/psmith/restructure/TODO	Mon Jan 29 23:43:00 2007
@@ -11,8 +11,4 @@
 
 Create UDP server
 
-Create RPC server / client
-
 Non blocking connects
-
-Allow large packets

Copied: branches/home/psmith/restructure/src/nio-logger/run-logging-client.lisp (from r55, branches/home/psmith/restructure/run-yarpc-client.lisp)
==============================================================================
--- branches/home/psmith/restructure/run-yarpc-client.lisp	(original)
+++ branches/home/psmith/restructure/src/nio-logger/run-logging-client.lisp	Mon Jan 29 23:43:00 2007
@@ -1,12 +1,44 @@
-(push :nio-debug *features*)
-(require :asdf)
-(require :nio-yarpc)
+#|
+Copyright (c) 2007
+All rights reserved.
 
-;;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 "127.0.0.1" 16323 'nio-yarpc:yarpc-client-state-machine)))
-  (nio-utils:format-log t "toplevel adding conn ~A~%" sm)
-  (loop
-    (nio-utils:format-log t "Toplevel Submitting job~%" )
-    (nio-utils:format-log t "Result of remote-execute ~A~%" (nio-yarpc:remote-execute sm "(nio-yarpc:test-rpc-list)"))))
+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)
+    	(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)))))))

Copied: branches/home/psmith/restructure/src/nio-logger/run-logging-server.lisp (from r58, branches/home/psmith/restructure/run-yarpc.lisp)
==============================================================================
--- branches/home/psmith/restructure/run-yarpc.lisp	(original)
+++ branches/home/psmith/restructure/src/nio-logger/run-logging-server.lisp	Mon Jan 29 23:43:00 2007
@@ -1,12 +1,44 @@
+#|
+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)))
+
+
 ;Runs a multithreaded system with an IO thread dealing with IO only and a 'job'  thread taking and executing jobs
 
-(push :nio-debug *features*)
-(require :asdf)
-(require :nio-yarpc)
-
-(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
+(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:run-job)))
+
+(defremote log(destination control-string &rest format-arguments)
+  (format-log destination control-string format-arguments))



More information about the Nio-cvs mailing list