summaryrefslogtreecommitdiffstats
path: root/gearman/controllerWorker/ControllerWorker/Shutdown.java
diff options
context:
space:
mode:
authorBjörn Geiger2011-08-16 14:54:09 +0200
committerBjörn Geiger2011-08-16 14:54:09 +0200
commitd2ef37d4495a6de1fbe37b1be429ce81a3c03ac3 (patch)
treec0201ac2c232c35bc76e868593af48b71bc4bbbd /gearman/controllerWorker/ControllerWorker/Shutdown.java
parentweiterer Fehelr (diff)
downloadpoolctrl-d2ef37d4495a6de1fbe37b1be429ce81a3c03ac3.tar.gz
poolctrl-d2ef37d4495a6de1fbe37b1be429ce81a3c03ac3.tar.xz
poolctrl-d2ef37d4495a6de1fbe37b1be429ce81a3c03ac3.zip
Fehler korrigiert
Diffstat (limited to 'gearman/controllerWorker/ControllerWorker/Shutdown.java')
-rw-r--r--gearman/controllerWorker/ControllerWorker/Shutdown.java170
1 files changed, 102 insertions, 68 deletions
diff --git a/gearman/controllerWorker/ControllerWorker/Shutdown.java b/gearman/controllerWorker/ControllerWorker/Shutdown.java
index b7e43cd..ab30b54 100644
--- a/gearman/controllerWorker/ControllerWorker/Shutdown.java
+++ b/gearman/controllerWorker/ControllerWorker/Shutdown.java
@@ -128,16 +128,30 @@ public class Shutdown extends Thread {
if (result != "") {
JSONObject resultObj = (JSONObject) JSONValue
.parse(result);
- String alive = resultObj.get("alive").toString();
+ if (resultObj.get("err").toString().isEmpty()) {
+ String alive = resultObj.get("alive")
+ .toString();
- if (alive.equals("true")) {
- System.out.println(ipAddress + " alive");
- status.put(clientID, 2); // alive, check Users
- pingJobs.remove(clientID);
+ if (alive.equals("true")) {
+ System.out.println(ipAddress + " alive");
+ status.put(clientID, 2); // alive, check
+ // Users
+ pingJobs.remove(clientID);
+ } else {
+ System.out
+ .println(ipAddress + " not alive");
+ // not alive, go in successState
+ status.put(clientID, 13);
+ pingJobs.remove(clientID);
+ }
} else {
- System.out.println(ipAddress + " not alive");
- // not alive, go in successState
- status.put(clientID, 13);
+ System.out.println(ipAddress
+ + " Cannot send the ping message.");
+ this.errors
+ .put(clientID,
+ "Sending the ping message has been failed.");
+ // sending the ping message has been failed
+ status.put(clientID, 12);
pingJobs.remove(clientID);
}
}
@@ -166,36 +180,41 @@ public class Shutdown extends Thread {
if (result != "") {
JSONObject resultObj = (JSONObject) JSONValue
.parse(result);
- String rawoutput = resultObj.get("rawoutput")
- .toString();
- StringTokenizer str = new StringTokenizer(
- rawoutput, " ");
- String user = "";
- if (str.hasMoreTokens()) {
- user = str.nextToken();
- }
+ if (resultObj.get("err").toString().isEmpty()) {
+ String rawoutput = resultObj.get("rawoutput")
+ .toString();
+ StringTokenizer str = new StringTokenizer(
+ rawoutput, " ");
+ String user = "";
+ if (str.hasMoreTokens()) {
+ user = str.nextToken();
+ }
- if (user.isEmpty()) {
- System.out.println(ipAddress + " right User");
- status.put(clientID, 4); // right user
- whoJobs.remove(clientID);
+ if (user.isEmpty()) {
+ System.out.println(ipAddress
+ + " right User");
+ status.put(clientID, 4); // right user
+ whoJobs.remove(clientID);
+ } else {
+ System.out.println(ipAddress
+ + " wrong User");
+ status.put(clientID, 9); // wrong user
+ whoJobs.remove(clientID);
+ }
} else {
- System.out.println(ipAddress + " wrong User");
- status.put(clientID, 9); // wrong user
+ System.out
+ .println(ipAddress
+ + " Cannot check if a user is logged in.");
+ this.errors
+ .put(clientID,
+ "The check if a user is logged in has been failed.");
+ /*
+ * cannot check if a user is logged in, go in
+ * errorState
+ */
+ status.put(clientID, 12);
whoJobs.remove(clientID);
}
- } else {
- System.out.println(ipAddress
- + " Cannot check if a user is logged in.");
- this.errors
- .put(clientID,
- "The check if a user is logged in has been failed.");
- /*
- * cannot check if a user is logged in, go in
- * errorState
- */
- status.put(clientID, 12);
- whoJobs.remove(clientID);
}
}
}
@@ -220,9 +239,7 @@ public class Shutdown extends Thread {
if (result != "") {
JSONObject resultObj = (JSONObject) JSONValue
.parse(result);
- String rawoutput = resultObj.get("rawoutput")
- .toString();
- if (rawoutput.equals("")) {
+ if (resultObj.get("err").toString().isEmpty()) {
System.out.println(ipAddress
+ " Shutdown command send");
status.put(clientID, 6); // shutdown command
@@ -277,21 +294,34 @@ public class Shutdown extends Thread {
if (result != "") {
JSONObject resultObj = (JSONObject) JSONValue
.parse(result);
- String alive = resultObj.get("alive")
- .toString();
- if (alive.equals("false")) {
- System.out
- .println(ipAddress
- + " is alive after shutdown. Ping again...");
- // alive, ping again
- status.put(clientID, 7);
- pingShutdownJobs.remove(clientID);
+ if (resultObj.get("err").toString().isEmpty()) {
+ String alive = resultObj.get("alive")
+ .toString();
+ if (alive.equals("false")) {
+ System.out
+ .println(ipAddress
+ + " is alive after shutdown. Ping again...");
+ // alive, ping again
+ status.put(clientID, 7);
+ pingShutdownJobs.remove(clientID);
+ } else {
+ System.out
+ .println("not alive after shutdown"
+ + ipAddress);
+ // go in successState
+ status.put(clientID, 13);
+ }
} else {
System.out
- .println("not alive after shutdown"
- + ipAddress);
- // go in successState
- status.put(clientID, 13);
+ .println(ipAddress
+ + " Cannot send the ping after shutdown message.");
+ this.errors
+ .put(clientID,
+ "Sending the ping after shutdown message has been failed.");
+ // sending the ping after shutdown message
+ // has been failed
+ status.put(clientID, 12);
+ pingJobs.remove(clientID);
}
}
}
@@ -328,28 +358,32 @@ public class Shutdown extends Thread {
if (result != "") {
JSONObject resultObj = (JSONObject) JSONValue
.parse(result);
- String rawoutput = resultObj.get("rawoutput")
- .toString();
- System.out.println(rawoutput);
- if (rawoutput.equals("is working")) {
- System.out.println(ipAddress + " is working");
- status.put(clientID, 11); // is working
- topJobs.remove(clientID);
+ if (resultObj.get("err").toString().isEmpty()) {
+ String rawoutput = resultObj.get("rawoutput")
+ .toString();
+ System.out.println(rawoutput);
+ if (rawoutput.equals("is working")) {
+ System.out.println(ipAddress
+ + " is working");
+ status.put(clientID, 11); // is working
+ topJobs.remove(clientID);
+ } else {
+ System.out.println(ipAddress
+ + " is not working");
+ status.put(clientID, 4); // is not working
+ topJobs.remove(clientID);
+ }
} else {
System.out.println(ipAddress
- + " is not working");
- status.put(clientID, 4); // is not working
+ + " Cannot check if user is working.");
+ this.errors
+ .put(clientID,
+ "The check if a user is working has been failed.");
+ // cannot check if user is working, go in
+ // errorState
+ status.put(clientID, 12);
topJobs.remove(clientID);
}
- } else {
- System.out.println(ipAddress
- + " Cannot check if user is working.");
- this.errors
- .put(clientID,
- "The check if a user is working has been failed.");
- // cannot check if user is working, go in errorState
- status.put(clientID, 12);
- topJobs.remove(clientID);
}
}
}