summaryrefslogtreecommitdiffstats
path: root/gearman
diff options
context:
space:
mode:
authorBjörn Geiger2011-08-10 13:42:54 +0200
committerBjörn Geiger2011-08-10 13:42:54 +0200
commit75fa6f86fce50b8b7a7ffd2dd167dfb4d1066398 (patch)
tree80738cae6667a824071bee42e48baa8119fc2f25 /gearman
parentminor (diff)
downloadpoolctrl-75fa6f86fce50b8b7a7ffd2dd167dfb4d1066398.tar.gz
poolctrl-75fa6f86fce50b8b7a7ffd2dd167dfb4d1066398.tar.xz
poolctrl-75fa6f86fce50b8b7a7ffd2dd167dfb4d1066398.zip
kleine korrektur
Diffstat (limited to 'gearman')
-rwxr-xr-xgearman/controllerWorker/ControllerWorker/ControllerWorkerMain.java16
-rw-r--r--gearman/controllerWorker/ControllerWorker/StatusWorker.java73
2 files changed, 47 insertions, 42 deletions
diff --git a/gearman/controllerWorker/ControllerWorker/ControllerWorkerMain.java b/gearman/controllerWorker/ControllerWorker/ControllerWorkerMain.java
index 044bf7d..dd8b0cc 100755
--- a/gearman/controllerWorker/ControllerWorker/ControllerWorkerMain.java
+++ b/gearman/controllerWorker/ControllerWorker/ControllerWorkerMain.java
@@ -9,12 +9,12 @@ public class ControllerWorkerMain {
public static void main(String[] args) {
final GearmanJobServerConnection connection = new GearmanNIOJobServerConnection(
"127.0.0.1", 4730);
- GearmanWorker bootWorker = new GearmanWorkerImpl();
- bootWorker.registerFunction(BootWorker.class);
- bootWorker.registerFunction(ShutdownWorker.class);
- bootWorker.registerFunction(StatusWorker.class);
- bootWorker.registerFunction(SomePingWorker.class);
- bootWorker.addServer(connection);
- bootWorker.work();
+ GearmanWorker worker = new GearmanWorkerImpl();
+ worker.registerFunction(SomePingWorker.class);
+ worker.registerFunction(BootWorker.class);
+ worker.registerFunction(ShutdownWorker.class);
+ worker.registerFunction(StatusWorker.class);
+ worker.addServer(connection);
+ worker.work();
}
-} \ No newline at end of file
+} \ No newline at end of file
diff --git a/gearman/controllerWorker/ControllerWorker/StatusWorker.java b/gearman/controllerWorker/ControllerWorker/StatusWorker.java
index 72dedbd..f67eeb0 100644
--- a/gearman/controllerWorker/ControllerWorker/StatusWorker.java
+++ b/gearman/controllerWorker/ControllerWorker/StatusWorker.java
@@ -39,43 +39,48 @@ public class StatusWorker extends AbstractGearmanFunction {
if (type.equals("boot")) {
for (String event : events) {
Boot boot = BOOTTHREADS.get(event);
- Vector<HashMap<String, String>> clients = boot.getClients();
+ if (boot != null) {
+ Vector<HashMap<String, String>> clients = boot.getClients();
- if (boot.isFinished()) {
- res[count] = "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;
- for (HashMap<String, String> client : clients) {
- String ipAddress = client.get("ip");
- String errorText = boot.getError(client);
- clientErrors[statusCount] = "Error of the client with the ip "
- + ipAddress + ": " + errorText;
- statusCount++;
- }
- String jsonClientErrors = JSONValue
- .toJSONString(clientErrors);
- res[count] += jsonClientErrors;
+ if (boot.isFinished()) {
+ res[count] = "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;
+ for (HashMap<String, String> client : clients) {
+ String ipAddress = client.get("ip");
+ String errorText = boot.getError(client);
+ clientErrors[statusCount] = "Error of the client with the ip "
+ + ipAddress + ": " + errorText;
+ statusCount++;
+ }
+ String jsonClientErrors = JSONValue
+ .toJSONString(clientErrors);
+ res[count] += jsonClientErrors;
+ } else {
+ res[count] = "Booting 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 = boot.getStatusText(client);
+ clientStatus[statusCount] = "Status of the client with the ip "
+ + ipAddress + ": " + statusText;
+ statusCount++;
+ }
+ String jsonClientStatus = JSONValue
+ .toJSONString(clientStatus);
+ res[count] += jsonClientStatus;
+ }
} else {
- res[count] = "Booting 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 = boot.getStatusText(client);
- clientStatus[statusCount] = "Status of the client with the ip "
- + ipAddress + ": " + statusText;
- statusCount++;
- }
- String jsonClientStatus = JSONValue
- .toJSONString(clientStatus);
- res[count] += jsonClientStatus;
+
}
-
+
count++;
}
} else if (type.equals("shutdown")) {