summaryrefslogtreecommitdiffstats
path: root/gearman/controllerWorker/ControllerWorker/Boot.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/Boot.java
parentweiterer Fehelr (diff)
downloadpoolctrl-d2ef37d4495a6de1fbe37b1be429ce81a3c03ac3.tar.gz
poolctrl-d2ef37d4495a6de1fbe37b1be429ce81a3c03ac3.tar.xz
poolctrl-d2ef37d4495a6de1fbe37b1be429ce81a3c03ac3.zip
Fehler korrigiert
Diffstat (limited to 'gearman/controllerWorker/ControllerWorker/Boot.java')
-rw-r--r--gearman/controllerWorker/ControllerWorker/Boot.java258
1 files changed, 154 insertions, 104 deletions
diff --git a/gearman/controllerWorker/ControllerWorker/Boot.java b/gearman/controllerWorker/ControllerWorker/Boot.java
index f009432..067aa99 100644
--- a/gearman/controllerWorker/ControllerWorker/Boot.java
+++ b/gearman/controllerWorker/ControllerWorker/Boot.java
@@ -149,28 +149,37 @@ public class Boot extends Thread {
case 1:
GearmanJob pingJob = pingJobs.get(clientID);
-
if (pingJob != null) {
GearmanJobStatus jobStatus = gearmanClient
.getJobStatus(pingJob);
-
if (!jobStatus.isKnown() && pingJob.isDone()) {
GearmanJobResult pingJobRes = pingJob.get();
String result = ByteUtils.fromUTF8Bytes(pingJobRes
.getResults());
-
if (result != "") {
JSONObject resultObj = (JSONObject) JSONValue
.parse(result);
- String alive = resultObj.get("alive").toString();
-
- if (alive.equals("true")) {
- System.out.println(ipAddress + " alive");
- status.put(clientID, 2); // alive
- pingJobs.remove(clientID);
+ 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
+ pingJobs.remove(clientID);
+ } else {
+ System.out
+ .println(ipAddress + " not alive");
+ status.put(clientID, 3); // not alive
+ pingJobs.remove(clientID);
+ }
} else {
- System.out.println(ipAddress + " not alive");
- status.put(clientID, 3); // not alive
+ 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, 19);
pingJobs.remove(clientID);
}
}
@@ -251,18 +260,33 @@ public class Boot extends Thread {
if (result != "") {
JSONObject resultObj = (JSONObject) JSONValue
.parse(result);
- String alive = resultObj.get("alive")
- .toString();
- if (alive.equals("true")) {
- System.out.println(ipAddress
- + " is alive after WoL");
- // alive, go in successState
- status.put(clientID, 20);
- pingWoLJobs.remove(clientID);
+ if (resultObj.get("err").toString().isEmpty()) {
+ String alive = resultObj.get("alive")
+ .toString();
+ if (alive.equals("true")) {
+ System.out.println(ipAddress
+ + " is alive after WoL");
+ // alive, go in successState
+ status.put(clientID, 20);
+ pingWoLJobs.remove(clientID);
+ } else {
+ System.out.println("ping again "
+ + ipAddress);
+ status.put(clientID, 6); // again ping
+ pingWoLJobs.remove(clientID);
+ }
} else {
- System.out.println("ping again "
- + ipAddress);
- status.put(clientID, 6); // again ping
+ System.out
+ .println(ipAddress
+ + " Cannot send the ping after wake on LAN message.");
+ this.errors
+ .put(clientID,
+ "Sending the ping after wake on LAN message has been failed.");
+ /*
+ * sending the ping after wake on LAN
+ * message has been failed
+ */
+ status.put(clientID, 19);
pingWoLJobs.remove(clientID);
}
}
@@ -294,32 +318,35 @@ public class Boot extends Thread {
if (result != "") {
JSONObject resultObj = (JSONObject) JSONValue
.parse(result);
- /*
- * String release =
- * resultObj.get("Release").toString(); String
- * distriputorID =
- * resultObj.get("Distributor ID").toString();
- */
- String description = resultObj.get("Description")
- .toString();
-
- if (description.equals(this.bootOS)) {
- System.out.println(ipAddress + " right OS");
- status.put(clientID, 20); // right os
- osJobs.remove(clientID);
+ if (resultObj.get("err").toString().isEmpty()) {
+ /*
+ * String release =
+ * resultObj.get("Release").toString(); String
+ * distriputorID =
+ * resultObj.get("Distributor ID").toString();
+ */
+ String description = resultObj.get(
+ "Description").toString();
+
+ if (description.equals(this.bootOS)) {
+ System.out.println(ipAddress + " right OS");
+ status.put(clientID, 20); // right os
+ osJobs.remove(clientID);
+ } else {
+ System.out.println(ipAddress + " wrong OS");
+ status.put(clientID, 9); // wrong os
+ osJobs.remove(clientID);
+ }
} else {
- System.out.println(ipAddress + " wrong OS");
- status.put(clientID, 9); // wrong os
+ System.out.println(ipAddress
+ + " Cannot check os");
+ this.errors
+ .put(clientID,
+ "The check for correct operating system has been failed.");
+ // cannot check os, go in errorState
+ status.put(clientID, 19);
osJobs.remove(clientID);
}
- } else {
- System.out.println(ipAddress + " Cannot check os");
- this.errors
- .put(clientID,
- "The check for correct operating system has been failed.");
- // cannot check os, go in errorState
- status.put(clientID, 19);
- osJobs.remove(clientID);
}
}
}
@@ -346,36 +373,41 @@ public class Boot 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, 13); // right user
- whoJobs.remove(clientID);
+ if (user.isEmpty()) {
+ System.out.println(ipAddress
+ + " right User");
+ status.put(clientID, 13); // right user
+ whoJobs.remove(clientID);
+ } else {
+ System.out.println(ipAddress
+ + " wrong User");
+ status.put(clientID, 11); // wrong user
+ whoJobs.remove(clientID);
+ }
} else {
- System.out.println(ipAddress + " wrong User");
- status.put(clientID, 11); // 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, 19);
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, 19);
- whoJobs.remove(clientID);
}
}
}
@@ -402,28 +434,32 @@ public class Boot 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, 18); // 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, 18); // is working
+ topJobs.remove(clientID);
+ } else {
+ System.out.println(ipAddress
+ + " is not working");
+ status.put(clientID, 13); // is not working
+ topJobs.remove(clientID);
+ }
} else {
System.out.println(ipAddress
- + " is not working");
- status.put(clientID, 13); // 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, 19);
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, 19);
- topJobs.remove(clientID);
}
}
}
@@ -448,9 +484,7 @@ public class Boot 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
+ " Restart command send");
status.put(clientID, 15); // restart command
@@ -462,7 +496,8 @@ public class Boot extends Thread {
this.errors
.put(clientID,
"Sending the restart command has been failed.");
- // cannot send restart command, go in errorState
+ // cannot send restart command, go in
+ // errorState
status.put(clientID, 19);
restartJobs.remove(clientID);
}
@@ -505,18 +540,33 @@ public class Boot extends Thread {
if (result != "") {
JSONObject resultObj = (JSONObject) JSONValue
.parse(result);
- String alive = resultObj.get("alive")
- .toString();
- if (alive.equals("true")) {
- System.out.println(ipAddress
- + " is alive after restart");
- // alive, go in successState
- status.put(clientID, 20);
- pingRestartJobs.remove(clientID);
+ if (resultObj.get("err").toString().isEmpty()) {
+ String alive = resultObj.get("alive")
+ .toString();
+ if (alive.equals("true")) {
+ System.out.println(ipAddress
+ + " is alive after restart");
+ // alive, go in successState
+ status.put(clientID, 20);
+ pingRestartJobs.remove(clientID);
+ } else {
+ System.out.println("ping again "
+ + ipAddress);
+ status.put(clientID, 16); // again ping
+ pingRestartJobs.remove(clientID);
+ }
} else {
- System.out.println("ping again "
- + ipAddress);
- status.put(clientID, 16); // again ping
+ System.out
+ .println(ipAddress
+ + " Cannot send the ping after restart message.");
+ this.errors
+ .put(clientID,
+ "Sending the ping after restart message has been failed.");
+ /*
+ * sending the ping after restart message
+ * has been failed
+ */
+ status.put(clientID, 19);
pingRestartJobs.remove(clientID);
}
}