From ea855a74c2c1e2e4fffa30be84dc4becea15254d Mon Sep 17 00:00:00 2001 From: Björn Geiger Date: Wed, 10 Aug 2011 15:42:29 +0200 Subject: minor --- .../controllerWorker/ControllerWorker/Boot.java | 84 +++++++++++++++------- .../ControllerWorker/Shutdown.java | 2 +- 2 files changed, 59 insertions(+), 27 deletions(-) (limited to 'gearman') diff --git a/gearman/controllerWorker/ControllerWorker/Boot.java b/gearman/controllerWorker/ControllerWorker/Boot.java index 4a3f8a4..c6ff0f3 100644 --- a/gearman/controllerWorker/ControllerWorker/Boot.java +++ b/gearman/controllerWorker/ControllerWorker/Boot.java @@ -79,13 +79,13 @@ public class Boot extends Thread { this.finished = false; this.error = false; this.bootOS = bootOS; - this.statusText = new String[20]; + this.statusText = new String[21]; this.statusText[0] = "The booting process of the client has been started."; this.statusText[1] = "The ping has been started."; this.statusText[2] = "The client is alive."; this.statusText[3] = "The client is not alive."; this.statusText[4] = "The wake on LAN has been started."; - this.statusText[5] = "The Magic packet has been send."; + this.statusText[5] = "The Magic packet has been sent."; this.statusText[6] = "The ping after wake on LAN has been started."; this.statusText[7] = "Doing ping after wake on LAN again and again, until client is alive or two minutes has been elapsed"; this.statusText[8] = "The check for the correct operating system has been started."; @@ -95,11 +95,12 @@ public class Boot extends Thread { this.statusText[12] = "The check if the user is working has been started."; this.statusText[13] = "The user is not working."; this.statusText[14] = "A restart of the client has been triggered."; - this.statusText[15] = "The ping after restart has been started."; - this.statusText[16] = "Doing ping after restart again and again, until client is alive or two minutes has been elapsed"; - this.statusText[17] = "The user is working."; - this.statusText[18] = "Booting of the client has not been finished, due to an error."; - this.statusText[19] = "Booting of the client has been finished."; + this.statusText[15] = "The restart command has been sent."; + this.statusText[16] = "The ping after restart has been started."; + this.statusText[17] = "Doing ping after restart again and again, until client is alive or two minutes has been elapsed"; + this.statusText[18] = "The user is working."; + this.statusText[19] = "Booting of the client has not been finished, due to an error."; + this.statusText[20] = "Booting of the client has been finished."; } public void run() { @@ -207,7 +208,7 @@ public class Boot extends Thread { .put(clientID, "Sending the magic packet has been failed."); // cannot send magic packet, go in errorState - status.put(clientID, 18); + status.put(clientID, 19); wolJobs.remove(clientID); } } @@ -251,7 +252,7 @@ public class Boot extends Thread { System.out.println(ipAddress + " is alive after WoL"); // alive, go in successState - status.put(clientID, 19); + status.put(clientID, 20); pingWoLJobs.remove(clientID); } else System.out.println("ping again " @@ -265,7 +266,7 @@ public class Boot extends Thread { + " is not alive after WoL"); this.errors.put(clientID, "The wake on LAN has been failed."); - status.put(clientID, 18); // not alive, go in errorState + status.put(clientID, 19); // not alive, go in errorState pingWoLJobs.remove(clientID); } } @@ -298,7 +299,7 @@ public class Boot extends Thread { if (description.equals(this.bootOS)) { System.out.println(ipAddress + " right OS"); - status.put(clientID, 19); // right os + status.put(clientID, 20); // right os osJobs.remove(clientID); } else { System.out.println(ipAddress + " wrong OS"); @@ -311,7 +312,7 @@ public class Boot extends Thread { .put(clientID, "The check for correct operating system has been failed."); // cannot check os, go in errorState - status.put(clientID, 18); + status.put(clientID, 19); osJobs.remove(clientID); } } @@ -367,7 +368,7 @@ public class Boot extends Thread { * cannot check if a user is logged in, go in * errorState */ - status.put(clientID, 18); + status.put(clientID, 19); whoJobs.remove(clientID); } } @@ -399,7 +400,7 @@ public class Boot extends Thread { .toString(); if (rawoutput.equals("is working")) { System.out.println(ipAddress + " is working"); - status.put(clientID, 17); // is working + status.put(clientID, 18); // is working checkStatusJobs.remove(clientID); } else { System.out.println(ipAddress @@ -414,7 +415,7 @@ public class Boot extends Thread { .put(clientID, "The check if a user is working has been failed."); // cannot check if user is working, go in errorState - status.put(clientID, 18); + status.put(clientID, 19); checkStatusJobs.remove(clientID); } } @@ -428,19 +429,50 @@ public class Boot extends Thread { break; case 14: + GearmanJob restartJob = restartJobs.get(clientID); + if (restartJob != null) { + GearmanJobStatus jobStatus = gearmanClient + .getJobStatus(restartJob); + + if (!jobStatus.isKnown() && restartJob.isDone()) { + GearmanJobResult wolJobRes = restartJob.get(); + String result = ByteUtils.fromUTF8Bytes(wolJobRes + .getResults()); + System.out.println(result.toString()); + if (result.equals("")) { + System.out.println(ipAddress + + " Restart command send"); + status.put(clientID, 15); // restart command send + restartJobs.remove(clientID); + } else { + System.out.println(ipAddress + + " Cannot send restart command"); + this.errors + .put(clientID, + "Sending the restart command has been failed."); + // cannot send restart command, go in errorState + status.put(clientID, 19); + restartJobs.remove(clientID); + } + } + } + + break; + + case 15: date = new Date(); timestamp = date.getTime(); pingRestartTime.put(clientID, timestamp); - status.put(clientID, 15); // ping after restart + status.put(clientID, 16); // ping after restart break; - case 15: + case 16: pingRestart(client); break; - case 16: + case 17: GearmanJob pingJobRestart = pingRestartJobs.get(clientID); if (pingJobRestart != null) { Date currentDate = new Date(); @@ -463,12 +495,12 @@ public class Boot extends Thread { System.out.println(ipAddress + " is alive after restart"); // alive, go in successState - status.put(clientID, 19); + status.put(clientID, 20); pingRestartJobs.remove(clientID); } else { System.out.println("ping again " + ipAddress); - status.put(clientID, 15); // again ping + status.put(clientID, 16); // again ping pingRestartJobs.remove(clientID); } } @@ -478,33 +510,33 @@ public class Boot extends Thread { + " is not alive after restart"); this.errors.put(clientID, "The restart has been failed."); - status.put(clientID, 18); // not alive, go in errorState + status.put(clientID, 19); // not alive, go in errorState pingRestartJobs.remove(clientID); } } break; - case 17: + case 18: System.out.println("User is working Logik"); break; - case 18: + case 19: System.out.println("Boot failed"); // errorState break; - case 19: + case 20: System.out.println("Boot successful"); // successState break; } - if (clientStatus == 19) { + if (clientStatus == 20) { allFinished = true; - } else if (clientStatus == 18) { + } else if (clientStatus == 19) { allFinished = true; this.error = true; } else { diff --git a/gearman/controllerWorker/ControllerWorker/Shutdown.java b/gearman/controllerWorker/ControllerWorker/Shutdown.java index 470201d..1ba85ae 100644 --- a/gearman/controllerWorker/ControllerWorker/Shutdown.java +++ b/gearman/controllerWorker/ControllerWorker/Shutdown.java @@ -67,7 +67,7 @@ public class Shutdown extends Thread { } this.finished = false; this.error = false; - this.statusText = new String[20]; + this.statusText = new String[14]; this.statusText[0] = "The shutdown process of the client has been started."; } -- cgit v1.2.3-55-g7522