ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/cms/source/server/uk/org/iscream/cms/server/filter/TCPReaderInit.java
(Generate patch)

Comparing projects/cms/source/server/uk/org/iscream/cms/server/filter/TCPReaderInit.java (file contents):
Revision 1.6 by tdb, Wed Nov 29 20:59:09 2000 UTC vs.
Revision 1.11 by tdb, Fri Jan 12 00:45:25 2001 UTC

# Line 9 | Line 9 | import java.io.InputStream;
9   import java.io.OutputStream;
10   import java.io.IOException;
11   import java.io.*;
12 < import org.omg.CORBA.*;
13 < import org.omg.CosNaming.*;
12 > import uk.ac.ukc.iscream.util.*;
13  
14   /**
15 < * <ONE LINE DESCRIPTION>
17 < * <DETAILED DESCRIPTION>
15 > * This provides Host heartbeat functionality
16   *
17   * @author  $Author$
18   * @version $Id$
# Line 32 | Line 30 | class TCPReaderInit extends Thread {
30  
31   //---CONSTRUCTORS---
32  
33 <    public TCPReaderInit(Socket socket, ConfigurationManager configManager, Logger logRef, Filter parent) throws IOException {
36 <        _configManager = configManager;
37 <        _logRef = logRef;
33 >    public TCPReaderInit(Socket socket, Queue queue) throws IOException {
34          _socket = socket;
35 <        _parent = parent;
35 >        _queue = queue;
36          _socketIn = new BufferedReader(new InputStreamReader(_socket.getInputStream()));
37          _socketOut = new PrintWriter(_socket.getOutputStream());
38 <        _logRef.write(toString(), Logger.SYSINIT, "created");
38 >        _logger.write(toString(), Logger.SYSINIT, "created");
39      }
40      
41   //---PUBLIC METHODS---
42  
47    //NEED TO MAJORILY CHANGE THIS BIT !
43      public void run() {
44          try {
45              //variables
# Line 105 | Line 100 | class TCPReaderInit extends Thread {
100              String ipadd = _socket.getInetAddress().getHostAddress();
101              String xml = "<packet type=\"heartbeat\" machine_name=\""+hostname+"\" date=\""+date+"\" ip=\""+ipadd+"\"></packet>";
102              
103 <            FilterThread t = new FilterThread(xml, _parent, _logRef);
109 <            t.start();
103 >            _queue.add(xml);
104              
105          } catch (Exception e) {
106 <            _logRef.write(toString(), Logger.ERROR, "ERROR: " + e.getMessage());
106 >            _logger.write(toString(), Logger.ERROR, "ERROR: " + e.getMessage());
107          }
108          
109          _socketOut.flush();
# Line 119 | Line 113 | class TCPReaderInit extends Thread {
113              _socketOut.close();
114              _socket.close();
115          } catch (IOException e) {
116 <            _logRef.write(toString(), Logger.ERROR, "exception on socket close");
116 >            _logger.write(toString(), Logger.ERROR, "exception on socket close");
117          }
118 <        _logRef.write(toString(), Logger.SYSMSG, "finished");
118 >        _logger.write(toString(), Logger.SYSMSG, "finished");
119      }
120      
121      /**
122       * Overrides the {@link java.lang.Object#toString() Object.toString()}
123       * method to provide clean logging (every class should have this).
124       *
125 +     * This uses the uk.ac.ukc.iscream.util.NameFormat class
126 +     * to format the toString()
127 +     *
128       * @return the name of this class and its CVS revision
129       */
130      public String toString() {
131 <        return this.getClass().getName() + "{" + _socket.getInetAddress().getHostName()
132 <         + "}(" + REVISION.substring(11, REVISION.length() - 2) + ")";
133 <        
131 >        return FormatName.getName(
132 >            _name,
133 >            getClass().getName(),
134 >            REVISION);
135      }
136  
137   //---PRIVATE METHODS---
# Line 142 | Line 140 | class TCPReaderInit extends Thread {
140  
141   //---ATTRIBUTES---
142  
143 <    ConfigurationManager _configManager;
144 <    Logger _logRef;
143 >    /**
144 >     * A reference to the configuration manager
145 >     */
146 >    ConfigurationManager _configManager = ReferenceManager.getInstance().getCM();
147 >    
148 >    /**
149 >     * This is the friendly identifier of the
150 >     * component this class is running in.
151 >     * eg, a Filter may be called "filter1",
152 >     * If this class does not have an owning
153 >     * component,  a name from the configuration
154 >     * can be placed here.  This name could also
155 >     * be changed to null for utility classes.
156 >     */
157 >    private String _name = FilterMain.NAME;
158 >
159 >    /**
160 >     * This holds a reference to the
161 >     * system logger that is being used.
162 >     */
163 >    private Logger _logger = ReferenceManager.getInstance().getLogger();
164 >    
165 >    /**
166 >     * The socket we are talking on
167 >     */
168      Socket _socket;
169 +    
170 +    /**
171 +     * The input from the socket
172 +     */
173      BufferedReader _socketIn;
174 +    
175 +    /**
176 +     * The output from the socket
177 +     */
178      PrintWriter _socketOut;
179 <    Filter _parent;
179 >    
180 >    /**
181 >     * A reference to our Queue
182 >     */
183 >    Queue _queue;
184   //---STATIC ATTRIBUTES---
185  
186   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines