From 1ee21e0b0685c6e5db35ead7ccf4c6a573b832f6 Mon Sep 17 00:00:00 2001 From: Björn Geiger Date: Tue, 16 Aug 2011 11:59:24 +0200 Subject: verschiedenes --- .../controllerWorker/ControllerWorker/Boot.java | 27 +++++++++++---------- .../ControllerWorker/Shutdown.java | 28 ++++++++++++---------- gearman/worker.sh | 3 ++- 3 files changed, 31 insertions(+), 27 deletions(-) (limited to 'gearman') diff --git a/gearman/controllerWorker/ControllerWorker/Boot.java b/gearman/controllerWorker/ControllerWorker/Boot.java index faa75d3..462d888 100644 --- a/gearman/controllerWorker/ControllerWorker/Boot.java +++ b/gearman/controllerWorker/ControllerWorker/Boot.java @@ -37,7 +37,7 @@ public class Boot extends Thread { private HashMap pingWoLJobs; private HashMap osJobs; private HashMap whoJobs; - private HashMap checkStatusJobs; + private HashMap topJobs; private HashMap restartJobs; private HashMap pingRestartJobs; private HashMap status; @@ -58,7 +58,7 @@ public class Boot extends Thread { this.wolJobs = new HashMap(); this.osJobs = new HashMap(); this.whoJobs = new HashMap(); - this.checkStatusJobs = new HashMap(); + this.topJobs = new HashMap(); this.restartJobs = new HashMap(); this.pingRestartJobs = new HashMap(); this.status = new HashMap(); @@ -377,12 +377,12 @@ public class Boot extends Thread { break; case 11: - checkStatus(client); + top(client); break; case 12: - GearmanJob checkStatusJob = checkStatusJobs.get(clientID); + GearmanJob checkStatusJob = topJobs.get(clientID); if (checkStatusJob != null) { GearmanJobStatus jobStatus = gearmanClient @@ -398,15 +398,16 @@ public class Boot extends Thread { .parse(result); String rawoutput = resultObj.get("rawoutput") .toString(); + System.out.println(rawoutput); if (rawoutput.equals("is working")) { System.out.println(ipAddress + " is working"); status.put(clientID, 18); // is working - checkStatusJobs.remove(clientID); + topJobs.remove(clientID); } else { System.out.println(ipAddress + " is not working"); status.put(clientID, 13); // is not working - checkStatusJobs.remove(clientID); + topJobs.remove(clientID); } } else { System.out.println(ipAddress @@ -416,7 +417,7 @@ public class Boot extends Thread { "The check if a user is working has been failed."); // cannot check if user is working, go in errorState status.put(clientID, 19); - checkStatusJobs.remove(clientID); + topJobs.remove(clientID); } } } @@ -635,18 +636,18 @@ public class Boot extends Thread { System.out.println("who " + ipAddress); } - private void checkStatus(HashMap client) { + private void top(HashMap client) { String ipAddress = client.get("ip"); int clientID = Integer.parseInt(client.get("id")); - GearmanJob job = GearmanJobImpl.createJob("checkStatus", ipAddress - .getBytes(), "checkStatus" + clientID); + GearmanJob job = GearmanJobImpl.createJob("top", ipAddress.getBytes(), + "top" + clientID); gearmanClient.submit(job); - status.put(clientID, 12); // checkStatus started - checkStatusJobs.put(clientID, job); + status.put(clientID, 12); // top started + topJobs.put(clientID, job); - System.out.println("checkStatus " + ipAddress); + System.out.println("top " + ipAddress); } private void restart(HashMap client) { diff --git a/gearman/controllerWorker/ControllerWorker/Shutdown.java b/gearman/controllerWorker/ControllerWorker/Shutdown.java index 2ed59b6..01c2407 100644 --- a/gearman/controllerWorker/ControllerWorker/Shutdown.java +++ b/gearman/controllerWorker/ControllerWorker/Shutdown.java @@ -35,7 +35,7 @@ public class Shutdown extends Thread { private HashMap whoJobs; private HashMap shutdownJobs; private HashMap pingShutdownJobs; - private HashMap checkStatusJobs; + private HashMap topJobs; private HashMap status; private HashMap errors; private HashMap pingShutdownTime; @@ -51,7 +51,7 @@ public class Shutdown extends Thread { this.whoJobs = new HashMap(); this.shutdownJobs = new HashMap(); this.pingShutdownJobs = new HashMap(); - this.checkStatusJobs = new HashMap(); + this.topJobs = new HashMap(); this.status = new HashMap(); this.errors = new HashMap(); this.updateRate = updateRate; // updates per second @@ -298,12 +298,12 @@ public class Shutdown extends Thread { break; case 9: - checkStatus(client); + top(client); break; case 10: - GearmanJob checkStatusJob = checkStatusJobs.get(clientID); + GearmanJob checkStatusJob = topJobs.get(clientID); if (checkStatusJob != null) { GearmanJobStatus jobStatus = gearmanClient @@ -319,15 +319,16 @@ public class Shutdown extends Thread { .parse(result); String rawoutput = resultObj.get("rawoutput") .toString(); + System.out.println(rawoutput); if (rawoutput.equals("is working")) { System.out.println(ipAddress + " is working"); status.put(clientID, 11); // is working - checkStatusJobs.remove(clientID); + topJobs.remove(clientID); } else { System.out.println(ipAddress + " is not working"); status.put(clientID, 4); // is not working - checkStatusJobs.remove(clientID); + topJobs.remove(clientID); } } else { System.out.println(ipAddress @@ -337,7 +338,7 @@ public class Shutdown extends Thread { "The check if a user is working has been failed."); // cannot check if user is working, go in errorState status.put(clientID, 12); - checkStatusJobs.remove(clientID); + topJobs.remove(clientID); } } } @@ -345,6 +346,7 @@ public class Shutdown extends Thread { break; case 11: + System.out.println("User is working Logik"); break; @@ -432,18 +434,18 @@ public class Shutdown extends Thread { System.out.println("ping " + ipAddress); } - private void checkStatus(HashMap client) { + private void top(HashMap client) { String ipAddress = client.get("ip"); int clientID = Integer.parseInt(client.get("id")); - GearmanJob job = GearmanJobImpl.createJob("checkStatus", ipAddress - .getBytes(), "checkStatus" + clientID); + GearmanJob job = GearmanJobImpl.createJob("top", ipAddress.getBytes(), + "top" + clientID); gearmanClient.submit(job); - status.put(clientID, 9); // checkStatus started - checkStatusJobs.put(clientID, job); + status.put(clientID, 9); // top started + topJobs.put(clientID, job); - System.out.println("checkStatus " + ipAddress); + System.out.println("top " + ipAddress); } public String getStatusText(HashMap client) { diff --git a/gearman/worker.sh b/gearman/worker.sh index b68aca0..dd4d3a8 100755 --- a/gearman/worker.sh +++ b/gearman/worker.sh @@ -4,4 +4,5 @@ ./whoWorker.py >> whoWorker.log 2>&1 | ./wolWorker.py >> wolWorker.log 2>&1 | ./osWorker.py >> osWorker.log 2>&1 | -./shutdownWorker.py >> shutdownWorker.log 2>&1 +./shutdownWorker.py >> shutdownWorker.log 2>&1 | +./topWorker.py >> topWorker.log 2>&1 \ No newline at end of file -- cgit v1.2.3-55-g7522