summaryrefslogtreecommitdiffstats
path: root/gearman
diff options
context:
space:
mode:
authorBjörn Geiger2011-08-10 14:36:52 +0200
committerBjörn Geiger2011-08-10 14:36:52 +0200
commitdbf95027ebbbe1c46aa7746f29c810f3f4698ce0 (patch)
tree6b67b30ecd1bdb271d19fe26a62d5aed629bf842 /gearman
parentFehler korrigiert (diff)
downloadpoolctrl-dbf95027ebbbe1c46aa7746f29c810f3f4698ce0.tar.gz
poolctrl-dbf95027ebbbe1c46aa7746f29c810f3f4698ce0.tar.xz
poolctrl-dbf95027ebbbe1c46aa7746f29c810f3f4698ce0.zip
verschiedenes
Diffstat (limited to 'gearman')
-rw-r--r--gearman/controllerWorker/ControllerWorker/StatusWorker.java78
1 files changed, 32 insertions, 46 deletions
diff --git a/gearman/controllerWorker/ControllerWorker/StatusWorker.java b/gearman/controllerWorker/ControllerWorker/StatusWorker.java
index 59f37d7..e1450fe 100644
--- a/gearman/controllerWorker/ControllerWorker/StatusWorker.java
+++ b/gearman/controllerWorker/ControllerWorker/StatusWorker.java
@@ -32,55 +32,48 @@ public class StatusWorker extends AbstractGearmanFunction {
String event = eventObj.toString();
events.add(event);
}
- LinkedHashMap<String, String> res = new LinkedHashMap<String, String>();
- int count = 0;
+ LinkedHashMap<String, LinkedHashMap<String, Object>> res = new LinkedHashMap<String, LinkedHashMap<String, Object>>();
+ LinkedHashMap<String, Object> content = new LinkedHashMap<String, Object>();
if (type.equals("boot")) {
for (String event : events) {
Boot boot = BOOTTHREADS.get(event);
if (BOOTTHREADS.containsKey(event)) {
Vector<HashMap<String, String>> clients = boot.getClients();
if (boot.isFinished()) {
- res.put(event, "Booting of " + event
+ content.put("result", "Booting of " + event
+ " has been finished!");
boot = null;
+ res.put(event, content);
} else if (boot.isFinishedWithErrors()) {
+ content.put("result", "Booting of " + event
+ + " has not been finished, due to errors!");
LinkedHashMap<String, String> clientErrors = new LinkedHashMap<String, String>();
for (HashMap<String, String> client : clients) {
String ipAddress = client.get("ip");
- String clientID = client.get("id");
String errorText = boot.getError(client);
- clientErrors.put("Client " + clientID,
- "Error of the client with the ip "
- + ipAddress + ": " + errorText);
+ clientErrors.put("Client " + ipAddress, errorText);
}
- String jsonClientErrors = JSONValue
- .toJSONString(clientErrors);
- res.put(event, "Booting of " + event
- + " has not been finished, due to errors!"
- + jsonClientErrors);
+ content.put("errors", clientErrors);
+ res.put(event, content);
boot = null;
} else {
+ content.put("result", "Booting of " + event
+ + " has not yet been finished!");
LinkedHashMap<String, String> clientStatus = new LinkedHashMap<String, String>();
for (HashMap<String, String> client : clients) {
String ipAddress = client.get("ip");
- String clientID = client.get("id");
String statusText = boot.getStatusText(client);
- clientStatus.put("Client " + clientID,
- "Status of the client with the ip "
- + ipAddress + ": " + statusText);
+ clientStatus.put("Client " + ipAddress, statusText);
}
- String jsonClientStatus = JSONValue
- .toJSONString(clientStatus);
- res.put(event, "Booting of " + event
- + " has not yet been finished!"
- + jsonClientStatus);
+ content.put("status", clientStatus);
+ res.put(event, content);
}
} else {
- res
- .put(event,
+ content
+ .put("result",
"The Boot process for the event has not been found.");
+ res.put(event, content);
}
- count++;
}
} else if (type.equals("shutdown")) {
for (String event : events) {
@@ -89,47 +82,40 @@ public class StatusWorker extends AbstractGearmanFunction {
Vector<HashMap<String, String>> clients = shutdown
.getClients();
if (shutdown.isFinished()) {
- res.put(event, "Shutdown of " + event
+ content.put("result", "Shutdown of " + event
+ " has been finished!");
+ res.put(event, content);
shutdown = null;
} else if (shutdown.isFinishedWithErrors()) {
+ content.put("result", "Shutdown of " + event
+ + " has not been finished, due to errors!");
LinkedHashMap<String, String> clientErrors = new LinkedHashMap<String, String>();
for (HashMap<String, String> client : clients) {
String ipAddress = client.get("ip");
- String clientID = client.get("id");
String errorText = shutdown.getError(client);
- clientErrors.put("Client " + clientID,
- "Error of the client with the ip "
- + ipAddress + ": " + errorText);
+ clientErrors.put("Client " + ipAddress, errorText);
}
- String jsonClientErrors = JSONValue
- .toJSONString(clientErrors);
- res.put(event, "Shutdown of " + event
- + " has not been finished, due to errors!"
- + jsonClientErrors);
+ content.put("errors", clientErrors);
+ res.put(event, content);
shutdown = null;
} else {
+ content.put("result", "Shutdown of " + event
+ + " has not yet been finished!");
LinkedHashMap<String, String> clientStatus = new LinkedHashMap<String, String>();
for (HashMap<String, String> client : clients) {
String ipAddress = client.get("ip");
- String clientID = client.get("id");
String statusText = shutdown.getStatusText(client);
- clientStatus.put("Client " + clientID,
- "Status of the client with the ip "
- + ipAddress + ": " + statusText);
+ clientStatus.put("Client " + ipAddress, statusText);
}
- String jsonClientStatus = JSONValue
- .toJSONString(clientStatus);
- res.put(event, "Shutdown of " + event
- + " has not yet been finished!"
- + jsonClientStatus);
+ content.put("status", clientStatus);
+ res.put(event, content);
}
} else {
- res
- .put(event,
+ content
+ .put("result",
"The Shutdown process for the event has not been found.");
+ res.put(event, content);
}
- count++;
}
}
String jsonResult = JSONValue.toJSONString(res);