summaryrefslogtreecommitdiffstats
path: root/gearman/controllerWorker/ControllerWorker/Boot.java
diff options
context:
space:
mode:
Diffstat (limited to 'gearman/controllerWorker/ControllerWorker/Boot.java')
-rw-r--r--gearman/controllerWorker/ControllerWorker/Boot.java120
1 files changed, 60 insertions, 60 deletions
diff --git a/gearman/controllerWorker/ControllerWorker/Boot.java b/gearman/controllerWorker/ControllerWorker/Boot.java
index 61dd6b4..3729afd 100644
--- a/gearman/controllerWorker/ControllerWorker/Boot.java
+++ b/gearman/controllerWorker/ControllerWorker/Boot.java
@@ -228,7 +228,7 @@ public class Boot extends Thread {
logger.error(client.getIp() + " User has been working");
client.setError("The user has been working.");
// user has been working, go in errorState
- client.setState(ClientState.ERROR);
+ client.setState(ClientState.BOOT_ERROR);
break;
case CLIENT_IS_DOWN:
@@ -249,7 +249,7 @@ public class Boot extends Thread {
break;
- case ERROR:
+ case BOOT_ERROR:
if (!client.isFinished()) {
logger.error(client.getIp() + " Booting failed"); // errorState
client.finish();
@@ -258,7 +258,7 @@ public class Boot extends Thread {
break;
- case SUCCESS:
+ case BOOT_SUCCESS:
if (!client.isFinished()) {
logger.info(client.getIp() + " Booting finished"); // successState
client.finish();
@@ -328,7 +328,7 @@ public class Boot extends Thread {
} else {
logger.error(client.getIp() + " Cannot send the ping message.");
client.setError("Sending the ping message has been failed.");
- client.setState(ClientState.ERROR);
+ client.setState(ClientState.BOOT_ERROR);
pingJobs.remove(client.getId());
}
}
@@ -366,7 +366,7 @@ public class Boot extends Thread {
if (alive.equals("true")) {
logger.info(client.getIp() + " is alive after WoL");
// alive, go in successState
- client.setState(ClientState.SUCCESS);
+ client.setState(ClientState.BOOT_SUCCESS);
pingWoLJobs.remove(client.getId());
} else if (alive.equals("false")) {
logger.info("ping again " + client.getIp());
@@ -380,7 +380,7 @@ public class Boot extends Thread {
* sending the ping after wake on LAN
* message has been failed, go to errorState
*/
- client.setState(ClientState.ERROR);
+ client.setState(ClientState.BOOT_ERROR);
pingWoLJobs.remove(client.getId());
}
}
@@ -389,55 +389,11 @@ public class Boot extends Thread {
logger.error(client.getIp() + " is not alive after WoL");
client.setError("The wake on LAN has been failed.");
// not alive, go in errorState
- client.setState(ClientState.ERROR);
+ client.setState(ClientState.BOOT_ERROR);
pingWoLJobs.remove(client.getId());
}
}
}
-
- private void checkCheckosProgress(Client client) throws Exception, IOException {
- GearmanJob osJob = osJobs.get(client.getId());
-
- if (osJob != null) {
- GearmanJobStatus jobStatus = gearmanClient.getJobStatus(osJob);
-
- if (!jobStatus.isKnown() && osJob.isDone()) {
- GearmanJobResult osJobRes = osJob.get();
- String result = ByteUtils.fromUTF8Bytes(osJobRes.getResults());
-
- if (!result.isEmpty()) {
- JSONObject resultObj = (JSONObject) JSONValue.parse(result);
- if (!resultObj.containsKey("err")) {
- /*
- * String release =
- * resultObj.get("Release").toString(); String
- * distriputorID =
- * resultObj.get("Distributor ID").toString();
- */
- String description = resultObj.get(
- "Description").toString();
-
- if (description.equals(bootOS)) {
- logger.info(client.getIp() + " right OS");
- // right os, go to successState
- client.setState(ClientState.SUCCESS);
- osJobs.remove(client.getId());
- } else {
- logger.info(client.getIp() + " wrong OS");
- client.setState(ClientState.WRONG_OS);
- osJobs.remove(client.getId());
- }
- } else {
- logger.error(client.getIp() + " Cannot check os");
- client.setError("The check for correct operating system has been failed.");
- // cannot check os, go in errorState
- client.setState(ClientState.ERROR);
- osJobs.remove(client.getId());
- }
- }
- }
- }
- }
private void pingRestartShutdown(Client client) {
GearmanJob job = GearmanJobImpl.createJob("ping", client.getIp()
@@ -483,7 +439,7 @@ public class Boot extends Thread {
* sending the ping after restart message
* has been failed
*/
- client.setState(ClientState.ERROR);
+ client.setState(ClientState.BOOT_ERROR);
pingRestartShutdownJobs.remove(client.getId());
}
}
@@ -492,7 +448,7 @@ public class Boot extends Thread {
logger.error(client.getIp() + " shutdown failed");
client.setError("The shutdown has been failed.");
// still alive, go in errorState
- client.setState(ClientState.ERROR);
+ client.setState(ClientState.BOOT_ERROR);
pingRestartShutdownJobs.remove(client.getId());
}
}
@@ -536,7 +492,7 @@ public class Boot extends Thread {
logger.info(client.getIp()
+ " is alive after restart");
// alive, go to success state
- client.setState(ClientState.SUCCESS);
+ client.setState(ClientState.BOOT_SUCCESS);
pingRestartBootJobs.remove(client
.getId());
} else if (alive.equals("false")) {
@@ -556,7 +512,7 @@ public class Boot extends Thread {
* sending the ping after shutdown message
* has been failed
*/
- client.setState(ClientState.ERROR);
+ client.setState(ClientState.BOOT_ERROR);
}
}
}
@@ -565,7 +521,7 @@ public class Boot extends Thread {
+ " is not alive after reboot");
client.setError("The reboot has been failed.");
// not alive, go in errorState
- client.setState(ClientState.ERROR);
+ client.setState(ClientState.BOOT_ERROR);
pingRestartBootJobs.remove(client.getId());
}
}
@@ -599,7 +555,7 @@ public class Boot extends Thread {
logger.error(client.getIp() + " Cannot send magic packet.");
client.setError("Sending the magic packet has been failed.");
// cannot send magic packet, go in errorState
- client.setState(ClientState.ERROR);
+ client.setState(ClientState.BOOT_ERROR);
wolJobs.remove(client.getId());
}
}
@@ -614,6 +570,50 @@ public class Boot extends Thread {
osJobs.put(client.getId(), job);
logger.info("check OS " + client.getIp());
}
+
+ private void checkCheckosProgress(Client client) throws Exception, IOException {
+ GearmanJob osJob = osJobs.get(client.getId());
+
+ if (osJob != null) {
+ GearmanJobStatus jobStatus = gearmanClient.getJobStatus(osJob);
+
+ if (!jobStatus.isKnown() && osJob.isDone()) {
+ GearmanJobResult osJobRes = osJob.get();
+ String result = ByteUtils.fromUTF8Bytes(osJobRes.getResults());
+
+ if (!result.isEmpty()) {
+ JSONObject resultObj = (JSONObject) JSONValue.parse(result);
+ if (!resultObj.containsKey("err")) {
+ /*
+ * String release =
+ * resultObj.get("Release").toString(); String
+ * distriputorID =
+ * resultObj.get("Distributor ID").toString();
+ */
+ String description = resultObj.get(
+ "Description").toString();
+
+ if (description.equals(bootOS)) {
+ logger.info(client.getIp() + " right OS");
+ // right os, go to successState
+ client.setState(ClientState.BOOT_SUCCESS);
+ osJobs.remove(client.getId());
+ } else {
+ logger.info(client.getIp() + " wrong OS");
+ client.setState(ClientState.WRONG_OS);
+ osJobs.remove(client.getId());
+ }
+ } else {
+ logger.error(client.getIp() + " Cannot check os");
+ client.setError("The check for correct operating system has been failed.");
+ // cannot check os, go in errorState
+ client.setState(ClientState.BOOT_ERROR);
+ osJobs.remove(client.getId());
+ }
+ }
+ }
+ }
+ }
private void who(Client client) {
GearmanJob job = GearmanJobImpl.createJob("who", client.getIp()
@@ -665,7 +665,7 @@ public class Boot extends Thread {
* errorState
*/
//client
- client.setState(ClientState.ERROR);
+ client.setState(ClientState.BOOT_ERROR);
whoJobs.remove(client.getId());
}
}
@@ -735,7 +735,7 @@ public class Boot extends Thread {
* cannot check if user is working, go in
* errorState
*/
- client.setState(ClientState.ERROR);
+ client.setState(ClientState.BOOT_ERROR);
psJobs.remove(client.getId());
}
}
@@ -771,7 +771,7 @@ public class Boot extends Thread {
logger.error(client.getIp() + " Cannot send restart command");
client.setError("Sending the restart command has been failed.");
// cannot send restart command, go in errorState
- client.setState(ClientState.ERROR);
+ client.setState(ClientState.BOOT_ERROR);
restartJobs.remove(client.getId());
}
}