summaryrefslogtreecommitdiffstats
path: root/gearman
diff options
context:
space:
mode:
authorSebastian Wagner2011-09-05 16:35:32 +0200
committerSebastian Wagner2011-09-05 16:35:32 +0200
commit70882436ca6a0636a14d97a7670cd7cb1a9faec4 (patch)
tree6a7f78af2073536b705a9486cc98363da0cf75b8 /gearman
parentall cases in functions (diff)
downloadpoolctrl-70882436ca6a0636a14d97a7670cd7cb1a9faec4.tar.gz
poolctrl-70882436ca6a0636a14d97a7670cd7cb1a9faec4.tar.xz
poolctrl-70882436ca6a0636a14d97a7670cd7cb1a9faec4.zip
two more final states added
Diffstat (limited to 'gearman')
-rw-r--r--gearman/controllerWorker/ControllerWorker/Boot.java120
-rw-r--r--gearman/controllerWorker/ControllerWorker/ClientState.java20
-rw-r--r--gearman/controllerWorker/ControllerWorker/Shutdown.java22
3 files changed, 84 insertions, 78 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());
}
}
diff --git a/gearman/controllerWorker/ControllerWorker/ClientState.java b/gearman/controllerWorker/ControllerWorker/ClientState.java
index 1615efb..f11f3ee 100644
--- a/gearman/controllerWorker/ControllerWorker/ClientState.java
+++ b/gearman/controllerWorker/ControllerWorker/ClientState.java
@@ -36,9 +36,11 @@ public enum ClientState {
PING_RESTART_BOOT_AGAIN(28),
//final states
- SUCCESS(29),
- ERROR(30);
-
+ BOOT_SUCCESS(29),
+ BOOT_ERROR(30),
+ SHUTDOWN_SUCCESS(31),
+ SHUTDOWN_ERROR(32);
+
ClientState(int state) {
this.state = state;
}
@@ -74,10 +76,6 @@ public enum ClientState {
return "[" + this.state + "] The check if the user is working has been intialized.";
case USER_IS_WORKING:
return "[" + this.state + "] The user is working.";
- case ERROR:
- return "[" + this.state + "] Shutdown of the client has not been finished, due to an error.";
- case SUCCESS:
- return "[" + this.state + "] Shutdown of the client has been finished.";
case CLIENT_NOT_ALIVE:
return "[" + this.state + "] The client is not alive.";
case CHECK_WAKE_ON_LAN_PROGRESS:
@@ -110,6 +108,14 @@ public enum ClientState {
return "[" + this.state + "] Doing ping after reboot again and again, until client is not alive or waitTime has been elapsed";
case CHECK_PING_RESTART_BOOT_PROGRESS:
return "[" + this.state + "] The ping after reboot has been initialized.";
+ case BOOT_ERROR:
+ return "[" + this.state + "] Booting of the client has not been finished, due to an error.";
+ case BOOT_SUCCESS:
+ return "[" + this.state + "] Booting of the client has been finished.";
+ case SHUTDOWN_ERROR:
+ return "[" + this.state + "] Shutdown of the client has not been finished, due to an error.";
+ case SHUTDOWN_SUCCESS:
+ return "[" + this.state + "] Shutdown of the client has been finished.";
default:
return "[" + this.state + "] Client is in unknown State";
}
diff --git a/gearman/controllerWorker/ControllerWorker/Shutdown.java b/gearman/controllerWorker/ControllerWorker/Shutdown.java
index cdd588f..e23f9f9 100644
--- a/gearman/controllerWorker/ControllerWorker/Shutdown.java
+++ b/gearman/controllerWorker/ControllerWorker/Shutdown.java
@@ -171,10 +171,10 @@ public class Shutdown extends Thread {
case USER_IS_WORKING:
logger.error(client.getIp() + " User has been working");
client.setError("The user has been working.");
- client.setState(ClientState.ERROR);
+ client.setState(ClientState.SHUTDOWN_ERROR);
break;
- case ERROR:
+ case SHUTDOWN_ERROR:
if (!client.isFinished()) {
logger.error(client.getIp() + " Shutdown failed"); // errorState
client.finish();
@@ -183,7 +183,7 @@ public class Shutdown extends Thread {
break;
- case SUCCESS:
+ case SHUTDOWN_SUCCESS:
if (!client.isFinished()) {
logger.info(client.getIp() + " Shutdown finished"); // successState
client.finish();
@@ -251,14 +251,14 @@ public class Shutdown extends Thread {
} else if (alive.equals("false")) {
logger.info(client.getIp() + " not alive");
// not alive, go in successState
- client.setState(ClientState.SUCCESS);
+ client.setState(ClientState.SHUTDOWN_SUCCESS);
pingJobs.remove(client.getId());
}
} else {
logger.error(client.getIp() + " Cannot send the ping message.");
client.setError("Sending the ping message has been failed.");
// sending the ping message has been failed
- client.setState(ClientState.ERROR);
+ client.setState(ClientState.SHUTDOWN_ERROR);
pingJobs.remove(client.getId());
}
}
@@ -316,7 +316,7 @@ public class Shutdown extends Thread {
/*
* cannot check if a user is logged in, go in errorState
*/
- client.setState(ClientState.ERROR);
+ client.setState(ClientState.SHUTDOWN_ERROR);
whoJobs.remove(client.getId());
}
}
@@ -355,7 +355,7 @@ public class Shutdown extends Thread {
client
.setError("Sending the shutdown command has been failed.");
//cannot send shutdown command, go in / errorState
- client.setState(ClientState.ERROR);
+ client.setState(ClientState.SHUTDOWN_ERROR);
doShutdownJobs.remove(client.getId());
}
}
@@ -393,7 +393,7 @@ public class Shutdown extends Thread {
String alive = resultObj.get("alive").toString();
if (alive.equals("false")) {
logger.info(client.getIp() + " is not alive anymore");
- client.setState(ClientState.SUCCESS);
+ client.setState(ClientState.SHUTDOWN_SUCCESS);
pingShutdownJobs.remove(client.getId());
} else if (alive.equals("true")) {
logger.info(client.getIp()
@@ -408,7 +408,7 @@ public class Shutdown extends Thread {
/*
* sending the ping after shutdown message has been failed
*/
- client.setState(ClientState.ERROR);
+ client.setState(ClientState.SHUTDOWN_ERROR);
pingJobs.remove(client.getId());
}
}
@@ -417,7 +417,7 @@ public class Shutdown extends Thread {
logger.error(client.getIp() + " is alive after shutdown");
client.setError("Client is still alive after shutdown.");
// still alive, go in errorState
- client.setState(ClientState.ERROR);
+ client.setState(ClientState.SHUTDOWN_ERROR);
pingShutdownJobs.remove(client.getId());
}
}
@@ -487,7 +487,7 @@ public class Shutdown extends Thread {
/*
* cannot check if user is working, go in errorState
*/
- client.setState(ClientState.ERROR);
+ client.setState(ClientState.SHUTDOWN_ERROR);
psJobs.remove(client.getId());
}
}