summaryrefslogtreecommitdiffstats
path: root/gearman
diff options
context:
space:
mode:
authorBjörn Geiger2011-08-10 14:17:07 +0200
committerBjörn Geiger2011-08-10 14:17:07 +0200
commitd35a25831e6b370650f9b04ec279bfde6a8c7233 (patch)
tree093e5f86faef509acffdb796fb4263cff6632fee /gearman
parentkleine korrektur (diff)
downloadpoolctrl-d35a25831e6b370650f9b04ec279bfde6a8c7233.tar.gz
poolctrl-d35a25831e6b370650f9b04ec279bfde6a8c7233.tar.xz
poolctrl-d35a25831e6b370650f9b04ec279bfde6a8c7233.zip
Fehler korrigiert
Diffstat (limited to 'gearman')
-rw-r--r--gearman/controllerWorker/ControllerWorker/StatusWorker.java121
1 files changed, 69 insertions, 52 deletions
diff --git a/gearman/controllerWorker/ControllerWorker/StatusWorker.java b/gearman/controllerWorker/ControllerWorker/StatusWorker.java
index f67eeb0..59f37d7 100644
--- a/gearman/controllerWorker/ControllerWorker/StatusWorker.java
+++ b/gearman/controllerWorker/ControllerWorker/StatusWorker.java
@@ -1,6 +1,7 @@
package ControllerWorker;
import java.util.HashMap;
+import java.util.LinkedHashMap;
import java.util.Vector;
import org.gearman.client.GearmanJobResult;
@@ -27,95 +28,111 @@ public class StatusWorker extends AbstractGearmanFunction {
JSONObject jsonObject = (JSONObject) JSONValue.parse(data);
String type = jsonObject.get("type").toString();
JSONArray jsonArray = (JSONArray) jsonObject.get("events");
-
for (Object eventObj : jsonArray) {
String event = eventObj.toString();
events.add(event);
}
-
- String[] res = new String[jsonArray.size()];
+ LinkedHashMap<String, String> res = new LinkedHashMap<String, String>();
int count = 0;
-
if (type.equals("boot")) {
for (String event : events) {
Boot boot = BOOTTHREADS.get(event);
- if (boot != null) {
+ if (BOOTTHREADS.containsKey(event)) {
Vector<HashMap<String, String>> clients = boot.getClients();
-
if (boot.isFinished()) {
- res[count] = "Booting of " + event
- + " has been finished!";
+ res.put(event, "Booting of " + event
+ + " has been finished!");
boot = null;
} else if (boot.isFinishedWithErrors()) {
- res[count] = "Booting of " + event
- + " has not been finished, due to errors!";
- String[] clientErrors = new String[clients.size()];
- int statusCount = 0;
+ 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[statusCount] = "Error of the client with the ip "
- + ipAddress + ": " + errorText;
- statusCount++;
+ clientErrors.put("Client " + clientID,
+ "Error of the client with the ip "
+ + ipAddress + ": " + errorText);
}
String jsonClientErrors = JSONValue
.toJSONString(clientErrors);
- res[count] += jsonClientErrors;
+ res.put(event, "Booting of " + event
+ + " has not been finished, due to errors!"
+ + jsonClientErrors);
+ boot = null;
} else {
- res[count] = "Booting of " + event
- + " has not yet been finished!";
- String[] clientStatus = new String[clients.size()];
- int statusCount = 0;
+ 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[statusCount] = "Status of the client with the ip "
- + ipAddress + ": " + statusText;
- statusCount++;
+ clientStatus.put("Client " + clientID,
+ "Status of the client with the ip "
+ + ipAddress + ": " + statusText);
}
String jsonClientStatus = JSONValue
.toJSONString(clientStatus);
- res[count] += jsonClientStatus;
- }
+ res.put(event, "Booting of " + event
+ + " has not yet been finished!"
+ + jsonClientStatus);
+ }
} else {
-
+ res
+ .put(event,
+ "The Boot process for the event has not been found.");
}
-
count++;
}
} else if (type.equals("shutdown")) {
for (String event : events) {
- Shutdown shutdown = SHUTDOWNTHREADS.get(event);
- Vector<HashMap<String, String>> clients = shutdown.getClients();
-
- if (shutdown.isFinished()) {
- res[count] = "Shutdown of " + event + " has been finished!";
- } else if (shutdown.isFinishedWithErrors()) {
- res[count] = "Shutdown of " + event
- + " finished with errors!";
- } else {
- res[count] = "Shutdown of " + event
- + " has not yet been finished!";
- String[] clientStatus = new String[clients.size()];
- int statusCount = 0;
- for (HashMap<String, String> client : clients) {
- String ipAddress = client.get("ip");
- String statusText = shutdown.getStatusText(client);
- clientStatus[statusCount] = "Status of the client with the ip "
- + ipAddress + ": " + statusText;
- statusCount++;
+ if (SHUTDOWNTHREADS.containsKey(event)) {
+ Shutdown shutdown = SHUTDOWNTHREADS.get(event);
+ Vector<HashMap<String, String>> clients = shutdown
+ .getClients();
+ if (shutdown.isFinished()) {
+ res.put(event, "Shutdown of " + event
+ + " has been finished!");
+ shutdown = null;
+ } else if (shutdown.isFinishedWithErrors()) {
+ 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);
+ }
+ String jsonClientErrors = JSONValue
+ .toJSONString(clientErrors);
+ res.put(event, "Shutdown of " + event
+ + " has not been finished, due to errors!"
+ + jsonClientErrors);
+ shutdown = null;
+ } else {
+ 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);
+ }
+ String jsonClientStatus = JSONValue
+ .toJSONString(clientStatus);
+ res.put(event, "Shutdown of " + event
+ + " has not yet been finished!"
+ + jsonClientStatus);
}
- String jsonClientStatus = JSONValue
- .toJSONString(clientStatus);
- res[count] += jsonClientStatus;
+ } else {
+ res
+ .put(event,
+ "The Shutdown process for the event has not been found.");
}
-
count++;
}
}
-
String jsonResult = JSONValue.toJSONString(res);
-
byte[] warnings = new byte[0];
byte[] exceptions = new byte[0];
int numerator = 0;