summaryrefslogtreecommitdiffstats
path: root/gearman
diff options
context:
space:
mode:
authorBjörn Geiger2011-07-26 16:37:13 +0200
committerBjörn Geiger2011-07-26 16:37:13 +0200
commit4b423e0db9783640bf3b1491b16331da1ff3a64c (patch)
tree3a51b4bdc8e4127aee3d6e06f10b63f802ad371a /gearman
parentminor (diff)
downloadpoolctrl-4b423e0db9783640bf3b1491b16331da1ff3a64c.tar.gz
poolctrl-4b423e0db9783640bf3b1491b16331da1ff3a64c.tar.xz
poolctrl-4b423e0db9783640bf3b1491b16331da1ff3a64c.zip
ControllerWorker Fehler korrigiert
Diffstat (limited to 'gearman')
-rw-r--r--gearman/controllerWorker/ControllerWorker/Boot.java65
1 files changed, 30 insertions, 35 deletions
diff --git a/gearman/controllerWorker/ControllerWorker/Boot.java b/gearman/controllerWorker/ControllerWorker/Boot.java
index 70d8540..cd43fb6 100644
--- a/gearman/controllerWorker/ControllerWorker/Boot.java
+++ b/gearman/controllerWorker/ControllerWorker/Boot.java
@@ -14,6 +14,7 @@ import org.gearman.client.GearmanClientImpl;
import org.gearman.client.GearmanJob;
import org.gearman.client.GearmanJobImpl;
import org.gearman.client.GearmanJobResult;
+import org.gearman.client.GearmanJobStatus;
import org.gearman.common.GearmanJobServerConnection;
import org.gearman.common.GearmanNIOJobServerConnection;
import org.gearman.util.ByteUtils;
@@ -80,30 +81,26 @@ public class Boot extends Thread {
case 1:
GearmanJob pingJob = PING_JOBS.get(clientID);
if (pingJob != null) {
- if (gearmanClient.getJobStatus(pingJob).isKnown()) {
- if (!gearmanClient.getJobStatus(pingJob).isRunning()) {
- 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 == "true") {
- System.out.println(ipAddress + " alive");
- STATUS.put(clientID, 2); // alive
- PING_JOBS.remove(clientID);
- } else {
- System.out
- .println(ipAddress + " not alive");
- STATUS.put(clientID, 3); // not alive
- PING_JOBS.remove(clientID);
- }
+ 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 == "true") {
+ System.out.println(ipAddress + " alive");
+ STATUS.put(clientID, 2); // alive
+ PING_JOBS.remove(clientID);
+ } else {
+ System.out.println(ipAddress + " not alive");
+ STATUS.put(clientID, 3); // not alive
+ PING_JOBS.remove(clientID);
}
}
- } else {
- // PING_JOBS.remove(clientID);
}
}
break;
@@ -116,20 +113,18 @@ public class Boot extends Thread {
case 4:
GearmanJob wolJob = WOL_JOBS.get(clientID);
if (wolJob != null) {
- if (gearmanClient.getJobStatus(wolJob).isKnown()) {
- if (!gearmanClient.getJobStatus(wolJob).isRunning()) {
- GearmanJobResult wolJobRes = wolJob.get();
- String result = ByteUtils.fromUTF8Bytes(wolJobRes
- .getResults());
- if (result == "Magic packet send.") {
- System.out.println(macAddress
- + "Magic packet send");
- STATUS.put(clientID, 5); // magic packet send
- WOL_JOBS.remove(clientID);
- }
+ GearmanJobStatus jobStatus = gearmanClient
+ .getJobStatus(wolJob);
+ if (!jobStatus.isKnown() && wolJob.isDone()) {
+ GearmanJobResult wolJobRes = wolJob.get();
+ String result = ByteUtils.fromUTF8Bytes(wolJobRes
+ .getResults());
+ if (result == "Magic packet send.") {
+ System.out
+ .println(macAddress + "Magic packet send");
+ STATUS.put(clientID, 5); // magic packet send
+ WOL_JOBS.remove(clientID);
}
- } else {
- // WOL_JOBS.remove(clientID);
}
}
break;