1 |
|
//---PACKAGE DECLARATION--- |
2 |
+ |
package uk.ac.ukc.iscream.filter; |
3 |
|
|
4 |
|
//---IMPORTS--- |
5 |
|
import uk.ac.ukc.iscream.core.*; |
47 |
|
//NEED TO MAJORILY CHANGE THIS BIT ! |
48 |
|
public void run() { |
49 |
|
try { |
50 |
+ |
//variables |
51 |
+ |
String filelist = ""; |
52 |
+ |
String lastModified = ""; |
53 |
+ |
String inBound = ""; |
54 |
|
|
55 |
+ |
inBound = _socketIn.readLine(); |
56 |
+ |
if(!inBound.equals("HEARTBEAT")) { |
57 |
+ |
_socketOut.println("ERROR"); |
58 |
+ |
_socketOut.flush(); |
59 |
+ |
throw new IOException("protocol error - expecting:HEARTBEAT got:" + inBound); |
60 |
+ |
} else { |
61 |
+ |
_socketOut.println("OK"); |
62 |
+ |
_socketOut.flush(); |
63 |
+ |
} |
64 |
+ |
|
65 |
+ |
inBound = _socketIn.readLine(); |
66 |
+ |
if(!inBound.equals("CONFIG")) { |
67 |
+ |
_socketOut.println("ERROR"); |
68 |
+ |
_socketOut.flush(); |
69 |
+ |
throw new IOException("protocol error - expecting:CONFIG got:" + inBound); |
70 |
+ |
} else { |
71 |
+ |
_socketOut.println("OK"); |
72 |
+ |
_socketOut.flush(); |
73 |
+ |
} |
74 |
+ |
|
75 |
+ |
inBound = _socketIn.readLine(); |
76 |
+ |
filelist = inBound; |
77 |
+ |
_socketOut.println("OK"); |
78 |
+ |
_socketOut.flush(); |
79 |
+ |
|
80 |
+ |
inBound = _socketIn.readLine(); |
81 |
+ |
lastModified = inBound; |
82 |
+ |
|
83 |
+ |
boolean newConfig = _configManager.isModified(filelist, Long.parseLong(lastModified)); |
84 |
+ |
|
85 |
+ |
if(newConfig) { |
86 |
+ |
_socketOut.println("ERROR"); |
87 |
+ |
} |
88 |
+ |
else { |
89 |
+ |
_socketOut.println("OK"); |
90 |
+ |
} |
91 |
+ |
_socketOut.flush(); |
92 |
+ |
|
93 |
+ |
inBound = _socketIn.readLine(); |
94 |
+ |
if(!inBound.equals("ENDHEARTBEAT")) { |
95 |
+ |
_socketOut.println("ERROR"); |
96 |
+ |
_socketOut.flush(); |
97 |
+ |
throw new IOException("protocol error - expecting:ENDHEARTBEAT got:" + inBound); |
98 |
+ |
} else { |
99 |
+ |
_socketOut.println("OK"); |
100 |
+ |
_socketOut.flush(); |
101 |
+ |
} |
102 |
+ |
|
103 |
+ |
// NEED TO LOG THE HEARTBEAT IN XML HERE. |
104 |
|
|
105 |
|
} catch (Exception e) { |
106 |
|
_logRef.write(toString(), Logger.ERROR, "ERROR: " + e.getMessage()); |