Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

RunToolClientPrivate.H

Go to the documentation of this file.
00001 // Copyright (C) 2001, Compaq Computer Corporation
00002 // 
00003 // This file is part of Vesta.
00004 // 
00005 // Vesta is free software; you can redistribute it and/or
00006 // modify it under the terms of the GNU Lesser General Public
00007 // License as published by the Free Software Foundation; either
00008 // version 2.1 of the License, or (at your option) any later version.
00009 // 
00010 // Vesta is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013 // Lesser General Public License for more details.
00014 // 
00015 // You should have received a copy of the GNU Lesser General Public
00016 // License along with Vesta; if not, write to the Free Software
00017 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 
00019 // Last modified on Mon May 23 22:20:16 EDT 2005 by ken@xorian.net  
00020 //      modified on Fri Jul 14 18:35:45 PDT 2000 by mann  
00021 //      modified on Tue Apr 29 09:35:05 PDT 1997 by heydon
00022 //      modified on Wed Apr 10 17:16:05 PDT 1996 by levin
00023 
00024 // This file contains definitions relevant only to the implementation
00025 // of the RunTool facilities.
00026 
00027 /*****************************/
00028 /*  Configuration Parameters */
00029 /*****************************/
00030 
00031 #define RUN_TOOL_CONFIG_SECTION "Run_Tool"
00032 #define RUN_TOOL_INTERFACE_VERSION 4
00033 //first versions of the interface that support features
00034 #define RUN_TOOL_LOAD_VERSION 3
00035 #define RUN_TOOL_CORE_VERSION 4
00036 
00037 // Procedure numbers in interface
00038 #define RUN_TOOL_DOIT    1
00039 #define RUN_TOOL_OLDINFO 3
00040 #define RUN_TOOL_INFO    4
00041 
00042 // The Tool_Relay class handles relaying output from stdout or stderr
00043 // on a remotely-executing tool.
00044 
00045 class Tool_Relay {
00046 public:
00047   Tool_Relay();
00048   ~Tool_Relay();
00049 
00050   void setup(std::ostream* report, std::ostream* value,
00051              Basics::mutex* mu, const Text& label)
00052     throw(TCP_sock::failure);
00053     // report and value are the streams to which the data is to be written.  
00054     // If either is NULL, it is not used.
00055     // mu must be held to write on report, and label is prepended to
00056     // each line of report.
00057 
00058   bool finish(bool wait) throw(TCP_sock::failure, FS::Failure);
00059     // Closes down the relay.  Returns true if the relay has written
00060     // any data.  If wait is true, waits for the tool to finish writing
00061     // data and close its end of the socket; if wait is false, does not.
00062     // Must not be called concurrently with setup().  No-op if called
00063     // before setup().
00064 
00065   void get_sockaddr(sockaddr_in &sock);
00066     // computes the socket address to transmit to the server
00067 
00068   void body();
00069     // The main body of the thread that relays output from socket 's'
00070     // to file 'out_fd'.
00071     // (for internal use only, but can't be private)
00072 
00073 private:
00074   Basics::mutex m;  // synchronization between finish() and body thread.
00075   TCP_sock *listener;
00076   TCP_sock *s;
00077   Basics::thread relay;
00078   std::ostream *report;
00079   std::ostream *value;
00080   Basics::mutex *mu;
00081   Text label;
00082   char *buffer;
00083   int buff_len;
00084   int remaining;
00085   bool written;
00086   TCP_sock::failure tcp_f;
00087 
00088   bool write_failed;         // Has there been a write failure?
00089   FS::Failure write_failure; // Saved write failure
00090 
00091   // A Tool_Relay object should neither be copied nor assigned.
00092 
00093   Tool_Relay(Tool_Relay &);
00094 
00095   void operator=(Tool_Relay &);
00096 
00097 };
00098 
00099 const int RELAY_BUFFER_SIZE = 512;
00100 
00101 // Calling sequences, marshalled type in parentheses:
00102 
00103 // Run a tool
00104 // Procid:
00105 //   RUN_TOOL_DOIT
00106 // Arguments:
00107 //   stdin_file  (Text):       "" => /dev/null
00108 //   stdout_sock (chars):      socket for stdout (all 0's => discard)
00109 //   stderr_sock (chars):      socket for stderr (all 0's => discard)
00110 //   fsroot_sock (chars):      socket for fsroot server
00111 //   fsroot_fh   (bytes):      32-byte NFS file handle for fsroot
00112 //   wd          (Text):       fsroot-relative path for working directory
00113 //   ev          (chars_seq):  environment variables
00114 //   argv        (chars_seq):  command line
00115 // Results:
00116 //   status      (int):        exit status from tool
00117 //   sigval      (int):        signal number, if terminated by signal
00118 
00119 // Get server and platform information
00120 // Procid:
00121 //  RUN_TOOL_INFO
00122 // Arguments:
00123 //   None
00124 // Results:
00125 //   sysname     (Text):       Operating system implementation (uname -s)
00126 //   release     (Text):       Operating system release (uname -r)
00127 //   version     (Text):       Operating system version (uname -v)
00128 //   machine     (Text):       Type of machine (uname -m)
00129 //   cpus        (int):        Number of cpus
00130 //   cpuMHz      (int):        Clock rate of cpu(s) in MHz
00131 //   memKB       (int):        Physical memory in kilobytes
00132 //   max_tools   (int):        Maximum number of concurrent tools allowed
00133 //   cur_tools   (int):        Number of tools currently running
00134 //   load        (float):      32-bit fp load average
00135 //   cur_pending (int):        Number of tools currently on the pending queue
00136 //   max_pending (int):        Maximum number of tools allowed on the pending queue
00137 //   id          (bytes):      16-byte UniqueId for this server instance

Generated on Mon May 8 00:48:56 2006 for Vesta by  doxygen 1.4.2