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.1 by tdb, Mon Nov 27 00:43:26 2000 UTC vs.
Revision 1.4 by tdb, Wed Nov 29 01:23:28 2000 UTC

# Line 46 | Line 46 | class TCPReaderInit extends Thread {
46      //NEED TO MAJORILY CHANGE THIS BIT !
47      public void run() {
48          try {
49 <            String inBound = _socketIn.readLine();
50 <            if (!inBound.equals("STARTCONFIG")) {
49 >            //variables
50 >            String filelist = "";
51 >            String lastModified = "";
52 >            String inBound = "";
53 >            
54 >            inBound = _socketIn.readLine();
55 >            if(!inBound.equals("HEARTBEAT")) {
56                  _socketOut.println("ERROR");
57                  _socketOut.flush();
58 <                throw new IOException("protocol error - expected:STARTCONFIG got:" + inBound);
58 >                throw new IOException("protocol error - expecting:HEARTBEAT got:" + inBound);
59 >            } else {
60 >                _socketOut.println("OK");
61 >                _socketOut.flush();
62              }
63 <
64 <            Configuration myConfig = _configManager.getConfiguration(_socket.getInetAddress().getHostName().toLowerCase());
65 <            if (myConfig == null) {
63 >            
64 >            inBound = _socketIn.readLine();
65 >            if(!inBound.equals("CONFIG")) {
66                  _socketOut.println("ERROR");
67 <                throw new IOException("error in host configuration");
67 >                _socketOut.flush();
68 >                throw new IOException("protocol error - expecting:CONFIG got:" + inBound);
69              } else {
70                  _socketOut.println("OK");
71                  _socketOut.flush();
72 <                
73 <                // get lastmodified
74 <                inBound = _socketIn.readLine();
75 <                if(!inBound.equals("LASTMODIFIED")) {
76 <                        // protocol error
77 <                    _socketOut.println("ERROR");
78 <                    _socketOut.flush();
79 <                    throw new IOException("protocol error - expected:LASTMODIFIED got:" + inBound);
80 <                }
81 <                else {
82 <                        // send info
83 <                        _socketOut.println(myConfig.getLastModified());
84 <                        _socketOut.flush();
85 <                }
86 <                
87 <                // get config fileList
79 <                inBound = _socketIn.readLine();
80 <                if(!inBound.equals("FILELIST")) {
81 <                        // protocol error
82 <                    _socketOut.println("ERROR");
83 <                    _socketOut.flush();
84 <                    throw new IOException("protocol error - expected:FILELIST got:" + inBound);
85 <                }
86 <                else {
87 <                        // send info
88 <                        _socketOut.println(myConfig.getFileList());
89 <                        _socketOut.flush();
90 <                }
91 <
92 <                // get properties
93 <                inBound = _socketIn.readLine();
94 <                while(!inBound.equals("ENDCONFIG")) {
95 <                          
96 <                    // get the property
97 <                    try {
98 <                        String returnedProperty = myConfig.getProperty(inBound);    
99 <                        
100 <                        _socketOut.println(returnedProperty);
101 <                        _socketOut.flush();
102 <    
103 <                    } catch (org.omg.CORBA.MARSHAL e) {
104 <                        _socketOut.println("ERROR");
105 <                        _socketOut.flush();
106 <                    }
107 <                    inBound = _socketIn.readLine();
108 <                }
109 <                _logRef.write(toString(), Logger.SYSMSG, "configured host");
72 >            }
73 >            
74 >            inBound = _socketIn.readLine();
75 >            filelist = inBound;
76 >            _socketOut.println("OK");
77 >            _socketOut.flush();
78 >            
79 >            inBound = _socketIn.readLine();
80 >            lastModified = inBound;
81 >            
82 >            boolean newConfig = _configManager.isModified(filelist, Long.parseLong(lastModified));
83 >            
84 >            if(newConfig) {
85 >                _socketOut.println("ERROR");
86 >            }
87 >            else {
88                  _socketOut.println("OK");
89 +            }
90 +            _socketOut.flush();
91 +            
92 +            inBound = _socketIn.readLine();
93 +            if(!inBound.equals("ENDHEARTBEAT")) {
94 +                _socketOut.println("ERROR");
95                  _socketOut.flush();
96 <                
97 <                // get filter reference
98 <                inBound = _socketIn.readLine();
99 <                if(!inBound.equals("FILTER")) {
116 <                        // protocol error
117 <                    _socketOut.println("ERROR");
118 <                    _socketOut.flush();
119 <                    throw new IOException("protocol error - expected:FILTER got:" + inBound);
120 <                }
121 <                else {
122 <                        // send info
123 <                        String parentFilter =  myConfig.getProperty("Host.filter");
124 <                        _logRef.write(toString(), Logger.DEBUG, " looking for parent - " + parentFilter);
125 <                        org.omg.CORBA.Object objRef = _ncRef.resolve(_ncRef.to_name("iscream.Filter." + parentFilter));
126 <                    Filter filter = FilterHelper.narrow(objRef);
127 <                        _socketOut.println(filter.getHostName() + ";"
128 <                                         + filter.getUDPPort() + ";"
129 <                                         + filter.getTCPPort());
130 <                        _socketOut.flush();
131 <                }
132 <                
133 <                // confirm that all is ok
134 <                inBound = _socketIn.readLine();
135 <                if(!inBound.equals("END")) {
136 <                        // protocol error
137 <                    _socketOut.println("ERROR");
138 <                    _socketOut.flush();
139 <                    throw new IOException("protocol error - expected:END got:" + inBound);
140 <                }
141 <                else {
142 <                        // send ok
143 <                        _socketOut.println("OK");
144 <                        _socketOut.flush();
145 <                }
146 <
96 >                throw new IOException("protocol error - expecting:ENDHEARTBEAT got:" + inBound);
97 >            } else {
98 >                _socketOut.println("OK");
99 >                _socketOut.flush();
100              }
101 +
102 +            // NEED TO LOG THE HEARTBEAT IN XML HERE.
103              
104          } catch (Exception e) {
105              _logRef.write(toString(), Logger.ERROR, "ERROR: " + e.getMessage());

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines