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.2 by tdb, Mon Nov 27 10:23:32 2000 UTC vs.
Revision 1.9 by ajm, Thu Nov 30 02:38:09 2000 UTC

# Line 1 | Line 1
1   //---PACKAGE DECLARATION---
2 + package uk.ac.ukc.iscream.filter;
3  
4   //---IMPORTS---
5   import uk.ac.ukc.iscream.core.*;
# Line 10 | Line 11 | import java.io.IOException;
11   import java.io.*;
12   import org.omg.CORBA.*;
13   import org.omg.CosNaming.*;
14 + import uk.ac.ukc.iscream.util.*;
15  
16   /**
17   * <ONE LINE DESCRIPTION>
# Line 31 | Line 33 | class TCPReaderInit extends Thread {
33  
34   //---CONSTRUCTORS---
35  
36 <    public TCPReaderInit(Socket socket, ConfigurationManager configManager, Logger logRef, Filter parent) throws IOException {
35 <        _configManager = configManager;
36 <        _logRef = logRef;
36 >    public TCPReaderInit(Socket socket, Filter parent) throws IOException {
37          _socket = socket;
38          _parent = parent;
39          _socketIn = new BufferedReader(new InputStreamReader(_socket.getInputStream()));
40          _socketOut = new PrintWriter(_socket.getOutputStream());
41 <        _logRef.write(toString(), Logger.SYSINIT, "created");
41 >        _logger.write(toString(), Logger.SYSINIT, "created");
42      }
43      
44   //---PUBLIC METHODS---
45  
46    //NEED TO MAJORILY CHANGE THIS BIT !
46      public void run() {
47          try {
48 +            //variables
49 +            String filelist = "";
50 +            String lastModified = "";
51 +            String inBound = "";
52              
53 +            inBound = _socketIn.readLine();
54 +            if(!inBound.equals("HEARTBEAT")) {
55 +                _socketOut.println("ERROR");
56 +                _socketOut.flush();
57 +                throw new IOException("protocol error - expecting:HEARTBEAT got:" + inBound);
58 +            } else {
59 +                _socketOut.println("OK");
60 +                _socketOut.flush();
61 +            }
62              
63 +            inBound = _socketIn.readLine();
64 +            if(!inBound.equals("CONFIG")) {
65 +                _socketOut.println("ERROR");
66 +                _socketOut.flush();
67 +                throw new IOException("protocol error - expecting:CONFIG got:" + inBound);
68 +            } else {
69 +                _socketOut.println("OK");
70 +                _socketOut.flush();
71 +            }
72 +            
73 +            inBound = _socketIn.readLine();
74 +            filelist = inBound;
75 +            _socketOut.println("OK");
76 +            _socketOut.flush();
77 +            
78 +            inBound = _socketIn.readLine();
79 +            lastModified = inBound;
80 +            
81 +            boolean newConfig = _configManager.isModified(filelist, Long.parseLong(lastModified));
82 +            
83 +            if(newConfig) {
84 +                _socketOut.println("ERROR");
85 +            }
86 +            else {
87 +                _socketOut.println("OK");
88 +            }
89 +            _socketOut.flush();
90 +            
91 +            inBound = _socketIn.readLine();
92 +            if(!inBound.equals("ENDHEARTBEAT")) {
93 +                _socketOut.println("ERROR");
94 +                _socketOut.flush();
95 +                throw new IOException("protocol error - expecting:ENDHEARTBEAT got:" + inBound);
96 +            } else {
97 +                _socketOut.println("OK");
98 +                _socketOut.flush();
99 +            }
100 +
101 +            String date = new Long(System.currentTimeMillis()).toString();
102 +            String hostname = _socket.getInetAddress().getHostName();
103 +            String ipadd = _socket.getInetAddress().getHostAddress();
104 +            String xml = "<packet type=\"heartbeat\" machine_name=\""+hostname+"\" date=\""+date+"\" ip=\""+ipadd+"\"></packet>";
105 +            
106 +            FilterThread t = new FilterThread(xml, _parent);
107 +            t.start();
108 +            
109          } catch (Exception e) {
110 <            _logRef.write(toString(), Logger.ERROR, "ERROR: " + e.getMessage());
110 >            _logger.write(toString(), Logger.ERROR, "ERROR: " + e.getMessage());
111          }
112          
113          _socketOut.flush();
# Line 59 | Line 117 | class TCPReaderInit extends Thread {
117              _socketOut.close();
118              _socket.close();
119          } catch (IOException e) {
120 <            _logRef.write(toString(), Logger.ERROR, "exception on socket close");
120 >            _logger.write(toString(), Logger.ERROR, "exception on socket close");
121          }
122 <        _logRef.write(toString(), Logger.SYSMSG, "finished");
122 >        _logger.write(toString(), Logger.SYSMSG, "finished");
123      }
124      
125      /**
# Line 82 | Line 140 | class TCPReaderInit extends Thread {
140  
141   //---ATTRIBUTES---
142  
143 <    ConfigurationManager _configManager;
144 <    Logger _logRef;
143 >    ConfigurationManager _configManager = ReferenceManager.getInstance().getCM();
144 >    Logger _logger = ReferenceManager.getInstance().getLogger();
145      Socket _socket;
146      BufferedReader _socketIn;
147      PrintWriter _socketOut;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines