summaryrefslogtreecommitdiffstats
path: root/gearman
diff options
context:
space:
mode:
authorBjörn Geiger2011-08-10 15:03:28 +0200
committerBjörn Geiger2011-08-10 15:03:28 +0200
commit98e6edac52352e7823db66f97ee73f701e69b438 (patch)
treecc1ab5b2333e8f5f12a6e2a5490d5a097ef02b15 /gearman
parentminor (diff)
downloadpoolctrl-98e6edac52352e7823db66f97ee73f701e69b438.tar.gz
poolctrl-98e6edac52352e7823db66f97ee73f701e69b438.tar.xz
poolctrl-98e6edac52352e7823db66f97ee73f701e69b438.zip
verschiedene Korrekturen
Diffstat (limited to 'gearman')
-rw-r--r--gearman/controllerWorker/ControllerWorker/Boot.java62
-rw-r--r--gearman/controllerWorker/ControllerWorker/Shutdown.java38
2 files changed, 61 insertions, 39 deletions
diff --git a/gearman/controllerWorker/ControllerWorker/Boot.java b/gearman/controllerWorker/ControllerWorker/Boot.java
index 3d2db11..4a3f8a4 100644
--- a/gearman/controllerWorker/ControllerWorker/Boot.java
+++ b/gearman/controllerWorker/ControllerWorker/Boot.java
@@ -253,11 +253,11 @@ public class Boot extends Thread {
// alive, go in successState
status.put(clientID, 19);
pingWoLJobs.remove(clientID);
- } else {
+ } else
System.out.println("ping again "
+ ipAddress);
- status.put(clientID, 6); // again ping
- }
+ status.put(clientID, 6); // again ping
+ pingWoLJobs.remove(clientID);
}
}
} else {
@@ -299,11 +299,11 @@ public class Boot extends Thread {
if (description.equals(this.bootOS)) {
System.out.println(ipAddress + " right OS");
status.put(clientID, 19); // right os
- pingJobs.remove(clientID);
+ osJobs.remove(clientID);
} else {
System.out.println(ipAddress + " wrong OS");
status.put(clientID, 9); // wrong os
- pingJobs.remove(clientID);
+ osJobs.remove(clientID);
}
} else {
System.out.println(ipAddress + " Cannot check os");
@@ -312,7 +312,7 @@ public class Boot extends Thread {
"The check for correct operating system has been failed.");
// cannot check os, go in errorState
status.put(clientID, 18);
- pingWoLJobs.remove(clientID);
+ osJobs.remove(clientID);
}
}
}
@@ -351,11 +351,11 @@ public class Boot extends Thread {
if (user.isEmpty()) {
System.out.println(ipAddress + " right User");
status.put(clientID, 13); // right user
- pingJobs.remove(clientID);
+ whoJobs.remove(clientID);
} else {
System.out.println(ipAddress + " wrong User");
status.put(clientID, 11); // wrong user
- pingJobs.remove(clientID);
+ whoJobs.remove(clientID);
}
} else {
System.out.println(ipAddress
@@ -368,7 +368,7 @@ public class Boot extends Thread {
* errorState
*/
status.put(clientID, 18);
- pingWoLJobs.remove(clientID);
+ whoJobs.remove(clientID);
}
}
}
@@ -381,7 +381,44 @@ public class Boot extends Thread {
break;
case 12:
- System.out.println("Status Logik");
+ GearmanJob checkStatusJob = checkStatusJobs.get(clientID);
+
+ if (checkStatusJob != null) {
+ GearmanJobStatus jobStatus = gearmanClient
+ .getJobStatus(checkStatusJob);
+
+ if (!jobStatus.isKnown() && checkStatusJob.isDone()) {
+ GearmanJobResult whoJobRes = checkStatusJob.get();
+ String result = ByteUtils.fromUTF8Bytes(whoJobRes
+ .getResults());
+
+ if (result != "") {
+ JSONObject resultObj = (JSONObject) JSONValue
+ .parse(result);
+ String rawoutput = resultObj.get("rawoutput")
+ .toString();
+ if (rawoutput.equals("is working")) {
+ System.out.println(ipAddress + " is working");
+ status.put(clientID, 17); // is working
+ checkStatusJobs.remove(clientID);
+ } else {
+ System.out.println(ipAddress
+ + " is not working");
+ status.put(clientID, 13); // is not working
+ checkStatusJobs.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, 18);
+ checkStatusJobs.remove(clientID);
+ }
+ }
+ }
break;
@@ -427,11 +464,12 @@ public class Boot extends Thread {
+ " is alive after restart");
// alive, go in successState
status.put(clientID, 19);
- pingWoLJobs.remove(clientID);
+ pingRestartJobs.remove(clientID);
} else {
System.out.println("ping again "
+ ipAddress);
status.put(clientID, 15); // again ping
+ pingRestartJobs.remove(clientID);
}
}
}
@@ -441,7 +479,7 @@ public class Boot extends Thread {
this.errors.put(clientID,
"The restart has been failed.");
status.put(clientID, 18); // not alive, go in errorState
- pingWoLJobs.remove(clientID);
+ pingRestartJobs.remove(clientID);
}
}
diff --git a/gearman/controllerWorker/ControllerWorker/Shutdown.java b/gearman/controllerWorker/ControllerWorker/Shutdown.java
index 1058464..f79ca84 100644
--- a/gearman/controllerWorker/ControllerWorker/Shutdown.java
+++ b/gearman/controllerWorker/ControllerWorker/Shutdown.java
@@ -34,7 +34,6 @@ public class Shutdown extends Thread {
private HashMap<Integer, GearmanJob> whoJobs;
private HashMap<Integer, GearmanJob> shutdownJobs;
private HashMap<Integer, GearmanJob> pingShutdownJobs;
- private HashMap<Integer, GearmanJob> sshJobs;
private HashMap<Integer, Integer> status;
private HashMap<Integer, String> errors;
private HashMap<Integer, Long> pingShutdownTime;
@@ -49,7 +48,6 @@ public class Shutdown extends Thread {
this.pingJobs = new HashMap<Integer, GearmanJob>();
this.whoJobs = new HashMap<Integer, GearmanJob>();
this.shutdownJobs = new HashMap<Integer, GearmanJob>();
- this.sshJobs = new HashMap<Integer, GearmanJob>();
this.status = new HashMap<Integer, Integer>();
this.errors = new HashMap<Integer, String>();
this.updateRate = updateRate; // updates per second
@@ -162,9 +160,9 @@ public class Shutdown extends Thread {
if (pingJobShutdown != null) {
Date currentDate = new Date();
Long currentTimestamp = currentDate.getTime();
+ // wait 2 min until shutdown
Long expectedTimestamp = this.pingShutdownTime
- .get(clientID) + 120000L; // wait 2 min until
- // WoL-Failed
+ .get(clientID) + 120000L;
if (expectedTimestamp >= currentTimestamp) {
GearmanJobStatus jobStatus = gearmanClient
.getJobStatus(pingJobShutdown);
@@ -181,15 +179,15 @@ public class Shutdown extends Thread {
System.out
.println(ipAddress
+ " is alive after shutdown. Ping again...");
- status.put(clientID, 4); // alive, ping
- // again
+ // alive, ping again
+ status.put(clientID, 4);
pingShutdownJobs.remove(clientID);
} else {
System.out
.println("not alive after shutdown"
+ ipAddress);
- status.put(clientID, 7); // go in
- // successState
+ // go in successState
+ status.put(clientID, 7);
}
}
}
@@ -204,7 +202,7 @@ public class Shutdown extends Thread {
break;
case 6:
- System.out.println("Shutdown failed after 2min"); // errorState
+ System.out.println("Shutdown failed"); // errorState
break;
@@ -214,9 +212,9 @@ public class Shutdown extends Thread {
break;
}
- if (clientStatus == 20) {
+ if (clientStatus == 6) {
allFinished = true;
- } else if (clientStatus == 19) {
+ } else if (clientStatus == 7) {
allFinished = true;
this.error = true;
} else {
@@ -254,7 +252,7 @@ public class Shutdown extends Thread {
gearmanClient.submit(job);
status.put(clientID, 1); // who started
- pingJobs.put(clientID, job);
+ whoJobs.put(clientID, job);
System.out.println("who " + ipAddress);
}
@@ -268,7 +266,7 @@ public class Shutdown extends Thread {
gearmanClient.submit(job);
status.put(clientID, 5); // shutdown started
- pingJobs.put(clientID, job);
+ shutdownJobs.put(clientID, job);
System.out.println("shutdown " + ipAddress);
}
@@ -287,20 +285,6 @@ public class Shutdown extends Thread {
System.out.println("ping " + ipAddress);
}
- private void ssh(HashMap<String, String> client) {
- String ipAddress = client.get("ip");
- int clientID = Integer.parseInt(client.get("id"));
-
- GearmanJob job = GearmanJobImpl.createJob("ssh", ipAddress.getBytes(),
- "ssh" + clientID);
- gearmanClient.submit(job);
-
- status.put(clientID, 6); // ssh started
- sshJobs.put(clientID, job);
-
- System.out.println("ssh " + ipAddress);
- }
-
public String getStatusText(HashMap<String, String> client) {
int clientID = Integer.parseInt(client.get("id"));
int clientStatus = this.status.get(clientID);