From 69c98b9c2c47130745a3ebe0dc5454926b0bdd87 Mon Sep 17 00:00:00 2001 From: Sebastian Wagner Date: Mon, 5 Sep 2011 16:18:23 +0200 Subject: all cases in functions --- .../controllerWorker/ControllerWorker/Boot.java | 807 +++++++++++---------- .../ControllerWorker/Shutdown.java | 479 ++++++------ 2 files changed, 683 insertions(+), 603 deletions(-) (limited to 'gearman/controllerWorker') diff --git a/gearman/controllerWorker/ControllerWorker/Boot.java b/gearman/controllerWorker/ControllerWorker/Boot.java index 56adce6..61dd6b4 100644 --- a/gearman/controllerWorker/ControllerWorker/Boot.java +++ b/gearman/controllerWorker/ControllerWorker/Boot.java @@ -114,9 +114,14 @@ public class Boot extends Thread { logger.info("Booting of " + eventName + " finished"); } } + + /* + * -------------- + * boot logik + * -------------- + */ - private Boolean update() throws IllegalStateException, IOException, - InterruptedException, ExecutionException { + private Boolean update() throws Exception { Date date; long timestamp; @@ -129,38 +134,7 @@ public class Boot extends Thread { break; case CHECK_PING_PROGRESS: - GearmanJob pingJob = pingJobs.get(client.getId()); - if (pingJob != null) { - GearmanJobStatus jobStatus = gearmanClient - .getJobStatus(pingJob); - if (!jobStatus.isKnown() && pingJob.isDone()) { - GearmanJobResult pingJobRes = pingJob.get(); - String result = ByteUtils.fromUTF8Bytes(pingJobRes - .getResults()); - if (!result.isEmpty()) { - JSONObject resultObj = (JSONObject) JSONValue - .parse(result); - if (!resultObj.containsKey("err")) { - String alive = resultObj.get("alive") - .toString(); - if (alive.equals("true")) { - logger.info(client.getIp() + " alive"); - client.setState(ClientState.CLIENT_IS_ALIVE); - pingJobs.remove(client.getId()); - } else if (alive.equals("false")) { - logger.info(client.getIp() + " not alive"); - client.setState(ClientState.CLIENT_NOT_ALIVE); - pingJobs.remove(client.getId()); - } - } else { - logger.error(client.getIp() + " Cannot send the ping message."); - client.setError("Sending the ping message has been failed."); - client.setState(ClientState.ERROR); - pingJobs.remove(client.getId()); - } - } - } - } + checkPingProgress(client); break; @@ -175,28 +149,7 @@ public class Boot extends Thread { break; case CHECK_WAKE_ON_LAN_PROGRESS: - GearmanJob wolJob = wolJobs.get(client.getId()); - if (wolJob != null) { - GearmanJobStatus jobStatus = gearmanClient - .getJobStatus(wolJob); - - if (!jobStatus.isKnown() && wolJob.isDone()) { - GearmanJobResult wolJobRes = wolJob.get(); - String result = ByteUtils.fromUTF8Bytes(wolJobRes - .getResults()); - if (result.equals("Magic packet send.")) { - logger.info(client.getMac() + " Magic packet sent."); - client.setState(ClientState.MAGIC_PACKET_SENT); - wolJobs.remove(client.getId()); - } else { - logger.error(client.getIp() + " Cannot send magic packet."); - client.setError("Sending the magic packet has been failed."); - // cannot send magic packet, go in errorState - client.setState(ClientState.ERROR); - wolJobs.remove(client.getId()); - } - } - } + checkWakeOnLanProgress(client); break; @@ -214,97 +167,12 @@ public class Boot extends Thread { break; case CHECK_PING_WOL_PROGRESS: - GearmanJob pingJobWoL = pingWoLJobs.get(client.getId()); - if (pingJobWoL != null) { - Date currentDate = new Date(); - Long currentTimestamp = currentDate.getTime(); - // wait 2 min until WoL - Failed - Long expectedTimestamp = pingWolTime.get(client.getId()) + waitTime; - if (expectedTimestamp >= currentTimestamp) { - GearmanJobStatus jobStatus = gearmanClient - .getJobStatus(pingJobWoL); - if (!jobStatus.isKnown() && pingJobWoL.isDone()) { - GearmanJobResult pingJobRes = pingJobWoL.get(); - String result = ByteUtils.fromUTF8Bytes(pingJobRes.getResults()); - if (!result.isEmpty()) { - JSONObject resultObj = (JSONObject) JSONValue.parse(result); - if (!resultObj.containsKey("err")) { - String alive = resultObj.get("alive").toString(); - if (alive.equals("true")) { - logger.info(client.getIp() + " is alive after WoL"); - // alive, go in successState - client.setState(ClientState.SUCCESS); - pingWoLJobs.remove(client.getId()); - } else if (alive.equals("false")) { - logger.info("ping again " + client.getIp()); - client.setState(ClientState.PING_WOL_AGAIN); - pingWoLJobs.remove(client.getId()); - } - } else { - logger.error(client.getIp() + " Cannot send the ping after wake on LAN message."); - client.setError("Sending the ping after wake on LAN message has been failed."); - /* - * sending the ping after wake on LAN - * message has been failed, go to errorState - */ - client.setState(ClientState.ERROR); - pingWoLJobs.remove(client.getId()); - } - } - } - } else { - logger.error(client.getIp() + " is not alive after WoL"); - client.setError("The wake on LAN has been failed."); - // not alive, go in errorState - client.setState(ClientState.ERROR); - pingWoLJobs.remove(client.getId()); - } - } + checkPingWolProgress(client); break; case CHECK_CHECKOS_PROGRESS: - GearmanJob osJob = osJobs.get(client.getId()); - - if (osJob != null) { - GearmanJobStatus jobStatus = gearmanClient.getJobStatus(osJob); - - if (!jobStatus.isKnown() && osJob.isDone()) { - GearmanJobResult osJobRes = osJob.get(); - String result = ByteUtils.fromUTF8Bytes(osJobRes.getResults()); - - if (!result.isEmpty()) { - JSONObject resultObj = (JSONObject) JSONValue.parse(result); - if (!resultObj.containsKey("err")) { - /* - * String release = - * resultObj.get("Release").toString(); String - * distriputorID = - * resultObj.get("Distributor ID").toString(); - */ - String description = resultObj.get( - "Description").toString(); - - if (description.equals(bootOS)) { - logger.info(client.getIp() + " right OS"); - // right os, go to successState - client.setState(ClientState.SUCCESS); - osJobs.remove(client.getId()); - } else { - logger.info(client.getIp() + " wrong OS"); - client.setState(ClientState.WRONG_OS); - osJobs.remove(client.getId()); - } - } else { - logger.error(client.getIp() + " Cannot check os"); - client.setError("The check for correct operating system has been failed."); - // cannot check os, go in errorState - client.setState(ClientState.ERROR); - osJobs.remove(client.getId()); - } - } - } - } + checkCheckosProgress(client); break; @@ -314,52 +182,7 @@ public class Boot extends Thread { break; case CHECK_WHO_PROGRESS: - GearmanJob whoJob = whoJobs.get(client.getId()); - - if (whoJob != null) { - GearmanJobStatus jobStatus = gearmanClient.getJobStatus(whoJob); - - if (!jobStatus.isKnown() && whoJob.isDone()) { - GearmanJobResult whoJobRes = whoJob.get(); - String result = ByteUtils.fromUTF8Bytes(whoJobRes.getResults()); - - if (!result.isEmpty()) { - JSONObject resultObj = (JSONObject) JSONValue.parse(result); - if (!resultObj.containsKey("err")) { - String rawoutput = resultObj.get("rawoutput").toString(); - StringTokenizer str = new StringTokenizer( - rawoutput, " "); - String user = ""; - if (str.hasMoreTokens()) { - user = str.nextToken(); - } - - if (user.isEmpty()) { - logger.info(client.getIp() + " no user is logged in -CHECK PS-"); - // no user is logged in, doing restart - //----- - // didn´t work in test-pool, check ps - client.setState(ClientState.A_USER_IS_LOGGED_IN); - whoJobs.remove(client.getId()); - } else { - logger.info(client.getIp() + " a user is logged in"); - client.setState(ClientState.A_USER_IS_LOGGED_IN); - whoJobs.remove(client.getId()); - } - } else { - logger.error(client.getIp() + " Cannot check if a user is logged in."); - client.setError("The check if a user is logged in has been failed."); - /* - * cannot check if a user is logged in, go in - * errorState - */ - //client - client.setState(ClientState.ERROR); - whoJobs.remove(client.getId()); - } - } - } - } + checkWhoProgress(client); break; @@ -369,64 +192,7 @@ public class Boot extends Thread { break; case CHECK_PS_PROGRESS: - GearmanJob psJob = psJobs.get(client.getId()); - - if (psJob != null) { - GearmanJobStatus jobStatus = gearmanClient.getJobStatus(psJob); - - if (!jobStatus.isKnown() && psJob.isDone()) { - GearmanJobResult whoJobRes = psJob.get(); - String result = ByteUtils.fromUTF8Bytes(whoJobRes.getResults()); - - if (!result.isEmpty()) { - JSONObject resultObj = (JSONObject) JSONValue.parse(result); - if (!resultObj.containsKey("err")) { - JSONArray ps = (JSONArray) resultObj.get("ps"); - // boolean whitelistFound = false; - boolean blacklistFound = false; - - for (String blackEntry : psBlacklist) { - if (ps.toString().contains(blackEntry)) { - blacklistFound = true; - } - } - - /* - * for (String whiteEntry : psWhitelist) { if - * (ps.toString().contains(whiteEntry)) { - * whitelistFound = true; } } - */ - - if (blacklistFound) { - /* - * if (whitelistFound) { - * logger.info(client.getIp() + - * " is not working"); // is not working - * status.put(client.getId(), 13); - * psJobs.remove(client.getId()); } else { - */ - logger.info(client.getIp() + " is working"); - client.setState(ClientState.USER_IS_WORKING); - psJobs.remove(client.getId()); - // } - } else { - // user is not working, doing restart - client.setState(ClientState.RESTART_CLIENT); - psJobs.remove(client.getId()); - } - } else { - logger.error(client.getIp() + " Cannot check if user is working."); - client.setError("The check if a user is working has been failed."); - /* - * cannot check if user is working, go in - * errorState - */ - client.setState(ClientState.ERROR); - psJobs.remove(client.getId()); - } - } - } - } + checkPsProgress(client); break; @@ -436,29 +202,7 @@ public class Boot extends Thread { break; case CHECK_RESTART_PROGRESS: - GearmanJob restartJob = restartJobs.get(client.getId()); - if (restartJob != null) { - GearmanJobStatus jobStatus = gearmanClient.getJobStatus(restartJob); - - if (!jobStatus.isKnown() && restartJob.isDone()) { - GearmanJobResult wolJobRes = restartJob.get(); - String result = ByteUtils.fromUTF8Bytes(wolJobRes.getResults()); - if (!result.isEmpty()) { - JSONObject resultObj = (JSONObject) JSONValue.parse(result); - if (!resultObj.containsKey("err")) { - logger.info(client.getIp() + " Restart command sent"); - client.setState(ClientState.RESTART_COMMAND_SENT); - restartJobs.remove(client.getId()); - } else { - logger.error(client.getIp() + " Cannot send restart command"); - client.setError("Sending the restart command has been failed."); - // cannot send restart command, go in errorState - client.setState(ClientState.ERROR); - restartJobs.remove(client.getId()); - } - } - } - } + checkRestartProgress(client); break; @@ -476,53 +220,7 @@ public class Boot extends Thread { break; case CHECK_PING_RESTART_SHUTDOWN_PROGRESS: - GearmanJob pingJobRestartShutdown = pingRestartShutdownJobs.get(client.getId()); - if (pingJobRestartShutdown != null) { - Date currentDate = new Date(); - Long currentTimestamp = currentDate.getTime(); - // wait 2 min until Restart - Failed - Long expectedTimestamp = pingRestartShutdownTime.get(client.getId()) + waitTime; - if (expectedTimestamp >= currentTimestamp) { - GearmanJobStatus jobStatus = gearmanClient.getJobStatus(pingJobRestartShutdown); - if (!jobStatus.isKnown() - && pingJobRestartShutdown.isDone()) { - GearmanJobResult pingJobRestartRes = pingJobRestartShutdown.get(); - String result = ByteUtils.fromUTF8Bytes(pingJobRestartRes.getResults()); - if (!result.isEmpty()) { - JSONObject resultObj = (JSONObject) JSONValue.parse(result); - if (!resultObj.containsKey("err")) { - String alive = resultObj.get("alive").toString(); - if (alive.equals("true")) { - logger.info(client.getIp() + " is still alive"); - // still alive, ping again - client.setState(ClientState.PING_RESTART_SHUTDOWN_AGAIN); - pingRestartShutdownJobs.remove(client.getId()); - } else if (alive.equals("false")) { - logger.info(client.getIp() + " is down"); - // not alive, ping again - client.setState(ClientState.CLIENT_IS_DOWN); - pingRestartShutdownJobs.remove(client.getId()); - } - } else { - logger.error(client.getIp() + " Cannot send the ping after restart message."); - client.setError("Sending the ping after restart message has been failed."); - /* - * sending the ping after restart message - * has been failed - */ - client.setState(ClientState.ERROR); - pingRestartShutdownJobs.remove(client.getId()); - } - } - } - } else { - logger.error(client.getIp() + " shutdown failed"); - client.setError("The shutdown has been failed."); - // still alive, go in errorState - client.setState(ClientState.ERROR); - pingRestartShutdownJobs.remove(client.getId()); - } - } + checkPingRestartShutdownProgress(client); break; @@ -547,67 +245,7 @@ public class Boot extends Thread { break; case CHECK_PING_RESTART_BOOT_PROGRESS: - GearmanJob pingJobRestartBoot = pingRestartBootJobs.get(client - .getId()); - if (pingJobRestartBoot != null) { - Date currentDate = new Date(); - Long currentTimestamp = currentDate.getTime(); - // wait 2 min until Restart - Failed - Long expectedTimestamp = pingRestartBootTime.get(client - .getId()) - + waitTime; - if (expectedTimestamp >= currentTimestamp) { - GearmanJobStatus jobStatus = gearmanClient - .getJobStatus(pingJobRestartBoot); - if (!jobStatus.isKnown() && pingJobRestartBoot.isDone()) { - GearmanJobResult pingJobRestartRes = pingJobRestartBoot - .get(); - String result = ByteUtils - .fromUTF8Bytes(pingJobRestartRes - .getResults()); - if (!result.isEmpty()) { - JSONObject resultObj = (JSONObject) JSONValue - .parse(result); - if (!resultObj.containsKey("err")) { - String alive = resultObj.get("alive") - .toString(); - if (alive.equals("true")) { - logger.info(client.getIp() - + " is alive after restart"); - // alive, go to success state - client.setState(ClientState.SUCCESS); - pingRestartBootJobs.remove(client - .getId()); - } else if (alive.equals("false")) { - logger.info("ping again " - + client.getIp()); - // not alive, ping again - client.setState(ClientState.PING_RESTART_BOOT_AGAIN); - pingRestartBootJobs.remove(client - .getId()); - } - } else { - logger.error(client.getIp() - + " Cannot send the ping after shutdown message."); - client - .setError("Sending the ping after shutdown message has been failed."); - /* - * sending the ping after shutdown message - * has been failed - */ - client.setState(ClientState.ERROR); - } - } - } - } else { - logger.error(client.getIp() - + " is not alive after reboot"); - client.setError("The reboot has been failed."); - // not alive, go in errorState - client.setState(ClientState.ERROR); - pingRestartBootJobs.remove(client.getId()); - } - } + checkPingRestartBootProgress(client); break; @@ -647,6 +285,12 @@ public class Boot extends Thread { } } + /* + * ------------------------- + * function declarations + * ------------------------- + */ + private void ping(Client client) { GearmanJob job = GearmanJobImpl.createJob("ping", client.getIp() .getBytes(), "ping" + client.getId()); @@ -656,6 +300,42 @@ public class Boot extends Thread { logger.info("ping " + client.getIp()); } + private void checkPingProgress(Client client) throws Exception, IOException { + GearmanJob pingJob = pingJobs.get(client.getId()); + + if (pingJob != null) { + GearmanJobStatus jobStatus = gearmanClient + .getJobStatus(pingJob); + if (!jobStatus.isKnown() && pingJob.isDone()) { + GearmanJobResult pingJobRes = pingJob.get(); + String result = ByteUtils.fromUTF8Bytes(pingJobRes + .getResults()); + if (!result.isEmpty()) { + JSONObject resultObj = (JSONObject) JSONValue + .parse(result); + if (!resultObj.containsKey("err")) { + String alive = resultObj.get("alive") + .toString(); + if (alive.equals("true")) { + logger.info(client.getIp() + " alive"); + client.setState(ClientState.CLIENT_IS_ALIVE); + pingJobs.remove(client.getId()); + } else if (alive.equals("false")) { + logger.info(client.getIp() + " not alive"); + client.setState(ClientState.CLIENT_NOT_ALIVE); + pingJobs.remove(client.getId()); + } + } else { + logger.error(client.getIp() + " Cannot send the ping message."); + client.setError("Sending the ping message has been failed."); + client.setState(ClientState.ERROR); + pingJobs.remove(client.getId()); + } + } + } + } + } + private void pingWakeOnLan(Client client) { GearmanJob job = GearmanJobImpl.createJob("ping", client.getIp() .getBytes(), "ping" + client.getId()); @@ -664,6 +344,100 @@ public class Boot extends Thread { pingWoLJobs.put(client.getId(), job); logger.info("ping " + client.getIp()); } + + private void checkPingWolProgress(Client client) throws Exception, IOException { + GearmanJob pingJobWoL = pingWoLJobs.get(client.getId()); + + if (pingJobWoL != null) { + Date currentDate = new Date(); + Long currentTimestamp = currentDate.getTime(); + // wait 2 min until WoL - Failed + Long expectedTimestamp = pingWolTime.get(client.getId()) + waitTime; + if (expectedTimestamp >= currentTimestamp) { + GearmanJobStatus jobStatus = gearmanClient + .getJobStatus(pingJobWoL); + if (!jobStatus.isKnown() && pingJobWoL.isDone()) { + GearmanJobResult pingJobRes = pingJobWoL.get(); + String result = ByteUtils.fromUTF8Bytes(pingJobRes.getResults()); + if (!result.isEmpty()) { + JSONObject resultObj = (JSONObject) JSONValue.parse(result); + if (!resultObj.containsKey("err")) { + String alive = resultObj.get("alive").toString(); + if (alive.equals("true")) { + logger.info(client.getIp() + " is alive after WoL"); + // alive, go in successState + client.setState(ClientState.SUCCESS); + pingWoLJobs.remove(client.getId()); + } else if (alive.equals("false")) { + logger.info("ping again " + client.getIp()); + client.setState(ClientState.PING_WOL_AGAIN); + pingWoLJobs.remove(client.getId()); + } + } else { + logger.error(client.getIp() + " Cannot send the ping after wake on LAN message."); + client.setError("Sending the ping after wake on LAN message has been failed."); + /* + * sending the ping after wake on LAN + * message has been failed, go to errorState + */ + client.setState(ClientState.ERROR); + pingWoLJobs.remove(client.getId()); + } + } + } + } else { + logger.error(client.getIp() + " is not alive after WoL"); + client.setError("The wake on LAN has been failed."); + // not alive, go in errorState + client.setState(ClientState.ERROR); + pingWoLJobs.remove(client.getId()); + } + } + } + + private void checkCheckosProgress(Client client) throws Exception, IOException { + GearmanJob osJob = osJobs.get(client.getId()); + + if (osJob != null) { + GearmanJobStatus jobStatus = gearmanClient.getJobStatus(osJob); + + if (!jobStatus.isKnown() && osJob.isDone()) { + GearmanJobResult osJobRes = osJob.get(); + String result = ByteUtils.fromUTF8Bytes(osJobRes.getResults()); + + if (!result.isEmpty()) { + JSONObject resultObj = (JSONObject) JSONValue.parse(result); + if (!resultObj.containsKey("err")) { + /* + * String release = + * resultObj.get("Release").toString(); String + * distriputorID = + * resultObj.get("Distributor ID").toString(); + */ + String description = resultObj.get( + "Description").toString(); + + if (description.equals(bootOS)) { + logger.info(client.getIp() + " right OS"); + // right os, go to successState + client.setState(ClientState.SUCCESS); + osJobs.remove(client.getId()); + } else { + logger.info(client.getIp() + " wrong OS"); + client.setState(ClientState.WRONG_OS); + osJobs.remove(client.getId()); + } + } else { + logger.error(client.getIp() + " Cannot check os"); + client.setError("The check for correct operating system has been failed."); + // cannot check os, go in errorState + client.setState(ClientState.ERROR); + osJobs.remove(client.getId()); + } + } + } + } + } private void pingRestartShutdown(Client client) { GearmanJob job = GearmanJobImpl.createJob("ping", client.getIp() @@ -673,6 +447,56 @@ public class Boot extends Thread { pingRestartShutdownJobs.put(client.getId(), job); logger.info("ping " + client.getIp()); } + + private void checkPingRestartShutdownProgress(Client client) throws Exception, IOException { + GearmanJob pingJobRestartShutdown = pingRestartShutdownJobs.get(client.getId()); + if (pingJobRestartShutdown != null) { + Date currentDate = new Date(); + Long currentTimestamp = currentDate.getTime(); + // wait 2 min until Restart - Failed + Long expectedTimestamp = pingRestartShutdownTime.get(client.getId()) + waitTime; + if (expectedTimestamp >= currentTimestamp) { + GearmanJobStatus jobStatus = gearmanClient.getJobStatus(pingJobRestartShutdown); + if (!jobStatus.isKnown() + && pingJobRestartShutdown.isDone()) { + GearmanJobResult pingJobRestartRes = pingJobRestartShutdown.get(); + String result = ByteUtils.fromUTF8Bytes(pingJobRestartRes.getResults()); + if (!result.isEmpty()) { + JSONObject resultObj = (JSONObject) JSONValue.parse(result); + if (!resultObj.containsKey("err")) { + String alive = resultObj.get("alive").toString(); + if (alive.equals("true")) { + logger.info(client.getIp() + " is still alive"); + // still alive, ping again + client.setState(ClientState.PING_RESTART_SHUTDOWN_AGAIN); + pingRestartShutdownJobs.remove(client.getId()); + } else if (alive.equals("false")) { + logger.info(client.getIp() + " is down"); + // not alive, ping again + client.setState(ClientState.CLIENT_IS_DOWN); + pingRestartShutdownJobs.remove(client.getId()); + } + } else { + logger.error(client.getIp() + " Cannot send the ping after restart message."); + client.setError("Sending the ping after restart message has been failed."); + /* + * sending the ping after restart message + * has been failed + */ + client.setState(ClientState.ERROR); + pingRestartShutdownJobs.remove(client.getId()); + } + } + } + } else { + logger.error(client.getIp() + " shutdown failed"); + client.setError("The shutdown has been failed."); + // still alive, go in errorState + client.setState(ClientState.ERROR); + pingRestartShutdownJobs.remove(client.getId()); + } + } + } private void pingRestartBoot(Client client) { GearmanJob job = GearmanJobImpl.createJob("ping", client.getIp() @@ -682,6 +506,70 @@ public class Boot extends Thread { pingRestartBootJobs.put(client.getId(), job); logger.info("ping " + client.getIp()); } + + private void checkPingRestartBootProgress(Client client) throws Exception, IOException { + GearmanJob pingJobRestartBoot = pingRestartBootJobs.get(client.getId()); + + if (pingJobRestartBoot != null) { + Date currentDate = new Date(); + Long currentTimestamp = currentDate.getTime(); + // wait 2 min until Restart - Failed + Long expectedTimestamp = pingRestartBootTime.get(client + .getId()) + + waitTime; + if (expectedTimestamp >= currentTimestamp) { + GearmanJobStatus jobStatus = gearmanClient + .getJobStatus(pingJobRestartBoot); + if (!jobStatus.isKnown() && pingJobRestartBoot.isDone()) { + GearmanJobResult pingJobRestartRes = pingJobRestartBoot + .get(); + String result = ByteUtils + .fromUTF8Bytes(pingJobRestartRes + .getResults()); + if (!result.isEmpty()) { + JSONObject resultObj = (JSONObject) JSONValue + .parse(result); + if (!resultObj.containsKey("err")) { + String alive = resultObj.get("alive") + .toString(); + if (alive.equals("true")) { + logger.info(client.getIp() + + " is alive after restart"); + // alive, go to success state + client.setState(ClientState.SUCCESS); + pingRestartBootJobs.remove(client + .getId()); + } else if (alive.equals("false")) { + logger.info("ping again " + + client.getIp()); + // not alive, ping again + client.setState(ClientState.PING_RESTART_BOOT_AGAIN); + pingRestartBootJobs.remove(client + .getId()); + } + } else { + logger.error(client.getIp() + + " Cannot send the ping after shutdown message."); + client + .setError("Sending the ping after shutdown message has been failed."); + /* + * sending the ping after shutdown message + * has been failed + */ + client.setState(ClientState.ERROR); + } + } + } + } else { + logger.error(client.getIp() + + " is not alive after reboot"); + client.setError("The reboot has been failed."); + // not alive, go in errorState + client.setState(ClientState.ERROR); + pingRestartBootJobs.remove(client.getId()); + } + } + } private void wakeOnLan(Client client) { GearmanJob job = GearmanJobImpl.createJob("wol", client.getMac() @@ -691,6 +579,32 @@ public class Boot extends Thread { wolJobs.put(client.getId(), job); logger.info("wake on lan " + client.getMac()); } + + private void checkWakeOnLanProgress(Client client) throws Exception, IOException { + GearmanJob wolJob = wolJobs.get(client.getId()); + + if (wolJob != null) { + GearmanJobStatus jobStatus = gearmanClient + .getJobStatus(wolJob); + + if (!jobStatus.isKnown() && wolJob.isDone()) { + GearmanJobResult wolJobRes = wolJob.get(); + String result = ByteUtils.fromUTF8Bytes(wolJobRes + .getResults()); + if (result.equals("Magic packet send.")) { + logger.info(client.getMac() + " Magic packet sent."); + client.setState(ClientState.MAGIC_PACKET_SENT); + wolJobs.remove(client.getId()); + } else { + logger.error(client.getIp() + " Cannot send magic packet."); + client.setError("Sending the magic packet has been failed."); + // cannot send magic packet, go in errorState + client.setState(ClientState.ERROR); + wolJobs.remove(client.getId()); + } + } + } + } private void checkOS(Client client) { GearmanJob job = GearmanJobImpl.createJob("os", client.getIp() @@ -710,6 +624,55 @@ public class Boot extends Thread { logger.info("who " + client.getIp()); } + private void checkWhoProgress(Client client) throws Exception, IOException { + GearmanJob whoJob = whoJobs.get(client.getId()); + + if (whoJob != null) { + GearmanJobStatus jobStatus = gearmanClient.getJobStatus(whoJob); + + if (!jobStatus.isKnown() && whoJob.isDone()) { + GearmanJobResult whoJobRes = whoJob.get(); + String result = ByteUtils.fromUTF8Bytes(whoJobRes.getResults()); + + if (!result.isEmpty()) { + JSONObject resultObj = (JSONObject) JSONValue.parse(result); + if (!resultObj.containsKey("err")) { + String rawoutput = resultObj.get("rawoutput").toString(); + StringTokenizer str = new StringTokenizer( + rawoutput, " "); + String user = ""; + if (str.hasMoreTokens()) { + user = str.nextToken(); + } + + if (user.isEmpty()) { + logger.info(client.getIp() + " no user is logged in -CHECK PS-"); + // no user is logged in, doing restart + //----- + // didn´t work in test-pool, check ps + client.setState(ClientState.A_USER_IS_LOGGED_IN); + whoJobs.remove(client.getId()); + } else { + logger.info(client.getIp() + " a user is logged in"); + client.setState(ClientState.A_USER_IS_LOGGED_IN); + whoJobs.remove(client.getId()); + } + } else { + logger.error(client.getIp() + " Cannot check if a user is logged in."); + client.setError("The check if a user is logged in has been failed."); + /* + * cannot check if a user is logged in, go in + * errorState + */ + //client + client.setState(ClientState.ERROR); + whoJobs.remove(client.getId()); + } + } + } + } + } + private void ps(Client client) { GearmanJob job = GearmanJobImpl.createJob("ps", client.getIp() .getBytes(), "ps" + client.getId()); @@ -718,6 +681,67 @@ public class Boot extends Thread { psJobs.put(client.getId(), job); logger.info("ps " + client.getIp()); } + + private void checkPsProgress(Client client) throws Exception, IOException { + GearmanJob psJob = psJobs.get(client.getId()); + + if (psJob != null) { + GearmanJobStatus jobStatus = gearmanClient.getJobStatus(psJob); + + if (!jobStatus.isKnown() && psJob.isDone()) { + GearmanJobResult whoJobRes = psJob.get(); + String result = ByteUtils.fromUTF8Bytes(whoJobRes.getResults()); + + if (!result.isEmpty()) { + JSONObject resultObj = (JSONObject) JSONValue.parse(result); + if (!resultObj.containsKey("err")) { + JSONArray ps = (JSONArray) resultObj.get("ps"); + // boolean whitelistFound = false; + boolean blacklistFound = false; + + for (String blackEntry : psBlacklist) { + if (ps.toString().contains(blackEntry)) { + blacklistFound = true; + } + } + + /* + * for (String whiteEntry : psWhitelist) { if + * (ps.toString().contains(whiteEntry)) { + * whitelistFound = true; } } + */ + + if (blacklistFound) { + /* + * if (whitelistFound) { + * logger.info(client.getIp() + + * " is not working"); // is not working + * status.put(client.getId(), 13); + * psJobs.remove(client.getId()); } else { + */ + logger.info(client.getIp() + " is working"); + client.setState(ClientState.USER_IS_WORKING); + psJobs.remove(client.getId()); + // } + } else { + // user is not working, doing restart + client.setState(ClientState.RESTART_CLIENT); + psJobs.remove(client.getId()); + } + } else { + logger.error(client.getIp() + " Cannot check if user is working."); + client.setError("The check if a user is working has been failed."); + /* + * cannot check if user is working, go in + * errorState + */ + client.setState(ClientState.ERROR); + psJobs.remove(client.getId()); + } + } + } + } + } private void restart(Client client) { GearmanJob job = GearmanJobImpl.createJob("restart", client.getIp() @@ -727,6 +751,33 @@ public class Boot extends Thread { restartJobs.put(client.getId(), job); logger.info("restart " + client.getIp()); } + + private void checkRestartProgress(Client client) throws Exception, IOException { + GearmanJob restartJob = restartJobs.get(client.getId()); + + if (restartJob != null) { + GearmanJobStatus jobStatus = gearmanClient.getJobStatus(restartJob); + + if (!jobStatus.isKnown() && restartJob.isDone()) { + GearmanJobResult wolJobRes = restartJob.get(); + String result = ByteUtils.fromUTF8Bytes(wolJobRes.getResults()); + if (!result.isEmpty()) { + JSONObject resultObj = (JSONObject) JSONValue.parse(result); + if (!resultObj.containsKey("err")) { + logger.info(client.getIp() + " Restart command sent"); + client.setState(ClientState.RESTART_COMMAND_SENT); + restartJobs.remove(client.getId()); + } else { + logger.error(client.getIp() + " Cannot send restart command"); + client.setError("Sending the restart command has been failed."); + // cannot send restart command, go in errorState + client.setState(ClientState.ERROR); + restartJobs.remove(client.getId()); + } + } + } + } + } public Boolean isFinished() { return finished && !error; diff --git a/gearman/controllerWorker/ControllerWorker/Shutdown.java b/gearman/controllerWorker/ControllerWorker/Shutdown.java index 0b6d598..cdd588f 100644 --- a/gearman/controllerWorker/ControllerWorker/Shutdown.java +++ b/gearman/controllerWorker/ControllerWorker/Shutdown.java @@ -94,61 +94,30 @@ public class Shutdown extends Thread { } finished = true; if (error) { - logger.info("Shutdown of " + eventName + " failed"); + logger.error("Shutdown of " + eventName + " failed"); } else { logger.info("Shutdown of " + eventName + " finished"); } } + + /* + * -------------- + * shutdown logik + * -------------- + */ - private Boolean update() throws IllegalStateException, IOException, - InterruptedException, ExecutionException { + private Boolean update() throws Exception { for (Client client : clients) { switch (client.getState()) { case CLIENT_UNKNOWN: ping(client); - + break; case CHECK_PING_PROGRESS: - //checkPingProgress(); - GearmanJob pingJob = pingJobs.get(client.getId()); - - if (pingJob != null) { - GearmanJobStatus jobStatus = gearmanClient.getJobStatus(pingJob); - - if (!jobStatus.isKnown() && pingJob.isDone()) { - GearmanJobResult pingJobRes = pingJob.get(); - String result = ByteUtils.fromUTF8Bytes(pingJobRes.getResults()); - - if (!result.isEmpty()) { - JSONObject resultObj = (JSONObject) JSONValue.parse(result); - if (!resultObj.containsKey("err")) { - String alive = resultObj.get("alive").toString(); - - if (alive.equals("true")) { - logger.info(client.getIp() + " alive"); - client.setState(ClientState.CLIENT_IS_ALIVE); - // check - // Users - pingJobs.remove(client.getId()); - } else if (alive.equals("false")) { - logger.info(client.getIp() + " not alive"); - // not alive, go in successState - client.setState(ClientState.SUCCESS); - pingJobs.remove(client.getId()); - } - } else { - logger.error(client.getIp() + " Cannot send the ping message."); - client.setError("Sending the ping message has been failed."); - // sending the ping message has been failed - client.setState(ClientState.ERROR); - pingJobs.remove(client.getId()); - } - } - } - } - + checkPingProgress(client); + break; case CLIENT_IS_ALIVE: @@ -157,52 +126,7 @@ public class Shutdown extends Thread { break; case CHECK_WHO_PROGRESS: - GearmanJob whoJob = whoJobs.get(client.getId()); - - if (whoJob != null) { - GearmanJobStatus jobStatus = gearmanClient.getJobStatus(whoJob); - - if (!jobStatus.isKnown() && whoJob.isDone()) { - GearmanJobResult whoJobRes = whoJob.get(); - String result = ByteUtils.fromUTF8Bytes(whoJobRes.getResults()); - - if (!result.isEmpty()) { - JSONObject resultObj = (JSONObject) JSONValue.parse(result); - if (!resultObj.containsKey("err")) { - String rawoutput = resultObj.get("rawoutput").toString(); - StringTokenizer str = new StringTokenizer(rawoutput, " "); - String user = ""; - if (str.hasMoreTokens()) { - user = str.nextToken(); - } - - if (user.isEmpty()) { - logger.info(client.getIp() + " no user is logged in -CHECK PS-"); - // no user is logged in - //----- - // didn´t work in test-pool, check ps - client.setState(ClientState.USER_IS_LOGGED_IN); - whoJobs.remove(client.getId()); - } else { - logger.info(client.getIp() + " a user is logged in"); - // a user is logged in - client.setState(ClientState.USER_IS_LOGGED_IN); - whoJobs.remove(client.getId()); - } - } else { - logger.error(client.getIp() - + " Cannot check if a user is logged in."); - client - .setError("The check if a user is logged in has been failed."); - /* - * cannot check if a user is logged in, go in errorState - */ - client.setState(ClientState.ERROR); - whoJobs.remove(client.getId()); - } - } - } - } + checkWhoProgress(client); break; @@ -212,33 +136,7 @@ public class Shutdown extends Thread { break; case CHECK_SHUTDOWN_PROGRESS: - GearmanJob doShutdownJob = doShutdownJobs.get(client.getId()); - if (doShutdownJob != null) { - GearmanJobStatus jobStatus = gearmanClient - .getJobStatus(doShutdownJob); - - if (!jobStatus.isKnown() && doShutdownJob.isDone()) { - GearmanJobResult wolJobRes = doShutdownJob.get(); - String result = ByteUtils.fromUTF8Bytes(wolJobRes.getResults()); - if (!result.isEmpty()) { - JSONObject resultObj = (JSONObject) JSONValue.parse(result); - if (!resultObj.containsKey("err")) { - logger.info(client.getIp() + " Shutdown command sent"); - client.setState(ClientState.SHUTDOWN_COMMAND_SENT); - doShutdownJobs.remove(client.getId()); - } else { - logger.error(client.getIp() + " Cannot send shutdown command"); - client - .setError("Sending the shutdown command has been failed."); - /* - * cannot send shutdown command, go in / errorState - */ - client.setState(ClientState.ERROR); - doShutdownJobs.remove(client.getId()); - } - } - } - } + checkShutdownProgress(client); break; @@ -256,53 +154,7 @@ public class Shutdown extends Thread { break; case CHECK_PING_SHUTDOWN_PROGRESS: - GearmanJob pingJobShutdown = pingShutdownJobs.get(client.getId()); - if (pingJobShutdown != null) { - Date currentDate = new Date(); - Long currentTimestamp = currentDate.getTime(); - // wait 2 min until shutdown - Long expectedTimestamp = pingShutdownTime.get(client.getId()) - + waitTime; - if (expectedTimestamp >= currentTimestamp) { - GearmanJobStatus jobStatus = gearmanClient - .getJobStatus(pingJobShutdown); - if (!jobStatus.isKnown() && pingJobShutdown.isDone()) { - GearmanJobResult pingJobRes = pingJobShutdown.get(); - String result = ByteUtils.fromUTF8Bytes(pingJobRes.getResults()); - if (!result.isEmpty()) { - JSONObject resultObj = (JSONObject) JSONValue.parse(result); - if (!resultObj.containsKey("err")) { - String alive = resultObj.get("alive").toString(); - if (alive.equals("false")) { - logger.info(client.getIp() + " is not alive anymore"); - client.setState(ClientState.SUCCESS); - pingShutdownJobs.remove(client.getId()); - } else if (alive.equals("true")) { - logger.info(client.getIp() - + " is still alive after shutdown command"); - client.setState(ClientState.PING_SHUTDOWN_AGAIN); - } - } else { - logger.error(client.getIp() - + " Cannot send the ping after shutdown message."); - client - .setError("Sending the ping after shutdown message has been failed."); - /* - * sending the ping after shutdown message has been failed - */ - client.setState(ClientState.ERROR); - pingJobs.remove(client.getId()); - } - } - } - } else { - logger.error(client.getIp() + " is alive after shutdown"); - client.setError("Client is still alive after shutdown."); - // still alive, go in errorState - client.setState(ClientState.ERROR); - pingShutdownJobs.remove(client.getId()); - } - } + checkPingShutdwonProgress(client); break; @@ -312,66 +164,7 @@ public class Shutdown extends Thread { break; case CHECK_PS_PROGRESS: - GearmanJob psJob = psJobs.get(client.getId()); - - if (psJob != null) { - GearmanJobStatus jobStatus = gearmanClient.getJobStatus(psJob); - - if (!jobStatus.isKnown() && psJob.isDone()) { - GearmanJobResult whoJobRes = psJob.get(); - String result = ByteUtils.fromUTF8Bytes(whoJobRes.getResults()); - - if (!result.isEmpty()) { - JSONObject resultObj = (JSONObject) JSONValue.parse(result); - if (!resultObj.containsKey("err")) { - JSONArray ps = (JSONArray) resultObj.get("ps"); - // boolean whitelistFound = false; - boolean blacklistFound = false; - - for (String blackEntry : psBlacklist) { - if (ps.toString().contains(blackEntry)) { - blacklistFound = true; - } - } - - /* - * for (String whiteEntry : psWhitelist) { if - * (ps.toString().contains(whiteEntry)) { whitelistFound = true; - * } } - */ - - if (blacklistFound) { - /* - * if (whitelistFound) { logger.info(client.getIp() + - * " is not working"); // is not working - * status.put(client.getId(), 4); - * psJobs.remove(client.getId()); - * - * } else { - */ - client.setState(ClientState.USER_IS_WORKING); - psJobs.remove(client.getId()); - // } - } else { - logger.info(client.getIp() + " is not working"); - // is not working - client.setState(ClientState.SHUTDOWN_CLIENT); - psJobs.remove(client.getId()); - } - } else { - logger.error(client.getIp() - + " Cannot check if user is working."); - client - .setError("The check if a user is working has been failed."); - /* - * cannot check if user is working, go in errorState - */ - client.setState(ClientState.ERROR); - psJobs.remove(client.getId()); - } - } - } - } + checkPsProgress(client); break; @@ -383,7 +176,7 @@ public class Shutdown extends Thread { case ERROR: if (!client.isFinished()) { - logger.info(client.getIp() + " Shutdown failed"); // errorState + logger.error(client.getIp() + " Shutdown failed"); // errorState client.finish(); error = true; } @@ -418,6 +211,13 @@ public class Shutdown extends Thread { } } + /* + * ------------------------- + * function declarations + * ------------------------- + */ + + private void ping(Client client) { GearmanJob job = GearmanJobImpl.createJob("ping", client.getIp().getBytes(), "ping" + client.getId()); @@ -427,8 +227,43 @@ public class Shutdown extends Thread { logger.info("ping " + client.getIp()); } - private void checkPingProgress() { - + private void checkPingProgress(Client client) throws Exception, IOException { + GearmanJob pingJob = pingJobs.get(client.getId()); + + if (pingJob != null) { + GearmanJobStatus jobStatus = gearmanClient.getJobStatus(pingJob); + + if (!jobStatus.isKnown() && pingJob.isDone()) { + GearmanJobResult pingJobRes = pingJob.get(); + String result = ByteUtils.fromUTF8Bytes(pingJobRes.getResults()); + + if (!result.isEmpty()) { + JSONObject resultObj = (JSONObject) JSONValue.parse(result); + if (!resultObj.containsKey("err")) { + String alive = resultObj.get("alive").toString(); + + if (alive.equals("true")) { + logger.info(client.getIp() + " alive"); + client.setState(ClientState.CLIENT_IS_ALIVE); + // check + // Users + pingJobs.remove(client.getId()); + } else if (alive.equals("false")) { + logger.info(client.getIp() + " not alive"); + // not alive, go in successState + client.setState(ClientState.SUCCESS); + pingJobs.remove(client.getId()); + } + } else { + logger.error(client.getIp() + " Cannot send the ping message."); + client.setError("Sending the ping message has been failed."); + // sending the ping message has been failed + client.setState(ClientState.ERROR); + pingJobs.remove(client.getId()); + } + } + } + } } private void who(Client client) { @@ -439,9 +274,59 @@ public class Shutdown extends Thread { whoJobs.put(client.getId(), job); logger.info("who " + client.getIp()); } + + private void checkWhoProgress(Client client) throws Exception, IOException { + GearmanJob whoJob = whoJobs.get(client.getId()); + + if (whoJob != null) { + GearmanJobStatus jobStatus = gearmanClient.getJobStatus(whoJob); + + if (!jobStatus.isKnown() && whoJob.isDone()) { + GearmanJobResult whoJobRes = whoJob.get(); + String result = ByteUtils.fromUTF8Bytes(whoJobRes.getResults()); + + if (!result.isEmpty()) { + JSONObject resultObj = (JSONObject) JSONValue.parse(result); + if (!resultObj.containsKey("err")) { + String rawoutput = resultObj.get("rawoutput").toString(); + StringTokenizer str = new StringTokenizer(rawoutput, " "); + String user = ""; + if (str.hasMoreTokens()) { + user = str.nextToken(); + } + if (user.isEmpty()) { + logger.info(client.getIp() + " no user is logged in -CHECK PS-"); + // no user is logged in + //----- + // didn´t work in test-pool, check ps + client.setState(ClientState.USER_IS_LOGGED_IN); + whoJobs.remove(client.getId()); + } else { + logger.info(client.getIp() + " a user is logged in"); + // a user is logged in + client.setState(ClientState.USER_IS_LOGGED_IN); + whoJobs.remove(client.getId()); + } + } else { + logger.error(client.getIp() + + " Cannot check if a user is logged in."); + client + .setError("The check if a user is logged in has been failed."); + /* + * cannot check if a user is logged in, go in errorState + */ + client.setState(ClientState.ERROR); + whoJobs.remove(client.getId()); + } + } + } + } + } + private void doShutdown(Client client) { GearmanJob job = GearmanJobImpl.createJob("doShutdown", client.getIp() + .getBytes(), "doShutdown" + client.getId()); gearmanClient.submit(job); client.setState(ClientState.CHECK_SHUTDOWN_PROGRESS); @@ -449,6 +334,35 @@ public class Shutdown extends Thread { logger.info("doShutdown " + client.getIp()); } + private void checkShutdownProgress(Client client) throws Exception, IOException { + GearmanJob doShutdownJob = doShutdownJobs.get(client.getId()); + + if (doShutdownJob != null) { + GearmanJobStatus jobStatus = gearmanClient + .getJobStatus(doShutdownJob); + + if (!jobStatus.isKnown() && doShutdownJob.isDone()) { + GearmanJobResult wolJobRes = doShutdownJob.get(); + String result = ByteUtils.fromUTF8Bytes(wolJobRes.getResults()); + if (!result.isEmpty()) { + JSONObject resultObj = (JSONObject) JSONValue.parse(result); + if (!resultObj.containsKey("err")) { + logger.info(client.getIp() + " Shutdown command sent"); + client.setState(ClientState.SHUTDOWN_COMMAND_SENT); + doShutdownJobs.remove(client.getId()); + } else { + logger.error(client.getIp() + " Cannot send shutdown command"); + client + .setError("Sending the shutdown command has been failed."); + //cannot send shutdown command, go in / errorState + client.setState(ClientState.ERROR); + doShutdownJobs.remove(client.getId()); + } + } + } + } + } + private void pingShutdown(Client client) { GearmanJob job = GearmanJobImpl.createJob("ping", client.getIp().getBytes(), "ping" + client.getId()); @@ -458,6 +372,57 @@ public class Shutdown extends Thread { logger.info("ping " + client.getIp()); } + private void checkPingShutdwonProgress(Client client) throws Exception, IOException { + GearmanJob pingJobShutdown = pingShutdownJobs.get(client.getId()); + + if (pingJobShutdown != null) { + Date currentDate = new Date(); + Long currentTimestamp = currentDate.getTime(); + // wait 2 min until shutdown + Long expectedTimestamp = pingShutdownTime.get(client.getId()) + + waitTime; + if (expectedTimestamp >= currentTimestamp) { + GearmanJobStatus jobStatus = gearmanClient + .getJobStatus(pingJobShutdown); + if (!jobStatus.isKnown() && pingJobShutdown.isDone()) { + GearmanJobResult pingJobRes = pingJobShutdown.get(); + String result = ByteUtils.fromUTF8Bytes(pingJobRes.getResults()); + if (!result.isEmpty()) { + JSONObject resultObj = (JSONObject) JSONValue.parse(result); + if (!resultObj.containsKey("err")) { + String alive = resultObj.get("alive").toString(); + if (alive.equals("false")) { + logger.info(client.getIp() + " is not alive anymore"); + client.setState(ClientState.SUCCESS); + pingShutdownJobs.remove(client.getId()); + } else if (alive.equals("true")) { + logger.info(client.getIp() + + " is still alive after shutdown command"); + client.setState(ClientState.PING_SHUTDOWN_AGAIN); + } + } else { + logger.error(client.getIp() + + " Cannot send the ping after shutdown message."); + client + .setError("Sending the ping after shutdown message has been failed."); + /* + * sending the ping after shutdown message has been failed + */ + client.setState(ClientState.ERROR); + pingJobs.remove(client.getId()); + } + } + } + } else { + logger.error(client.getIp() + " is alive after shutdown"); + client.setError("Client is still alive after shutdown."); + // still alive, go in errorState + client.setState(ClientState.ERROR); + pingShutdownJobs.remove(client.getId()); + } + } + } + private void ps(Client client) { GearmanJob job = GearmanJobImpl.createJob("ps", client.getIp().getBytes(), "ps" + client.getId()); @@ -466,6 +431,69 @@ public class Shutdown extends Thread { psJobs.put(client.getId(), job); logger.info("ps " + client.getIp()); } + + private void checkPsProgress(Client client) throws Exception, IOException { + GearmanJob psJob = psJobs.get(client.getId()); + + if (psJob != null) { + GearmanJobStatus jobStatus = gearmanClient.getJobStatus(psJob); + + if (!jobStatus.isKnown() && psJob.isDone()) { + GearmanJobResult whoJobRes = psJob.get(); + String result = ByteUtils.fromUTF8Bytes(whoJobRes.getResults()); + + if (!result.isEmpty()) { + JSONObject resultObj = (JSONObject) JSONValue.parse(result); + if (!resultObj.containsKey("err")) { + JSONArray ps = (JSONArray) resultObj.get("ps"); + // boolean whitelistFound = false; + boolean blacklistFound = false; + + for (String blackEntry : psBlacklist) { + if (ps.toString().contains(blackEntry)) { + blacklistFound = true; + } + } + + /* + * for (String whiteEntry : psWhitelist) { if + * (ps.toString().contains(whiteEntry)) { whitelistFound = true; + * } } + */ + + if (blacklistFound) { + /* + * if (whitelistFound) { logger.info(client.getIp() + + * " is not working"); // is not working + * status.put(client.getId(), 4); + * psJobs.remove(client.getId()); + * + * } else { + */ + client.setState(ClientState.USER_IS_WORKING); + psJobs.remove(client.getId()); + // } + } else { + logger.info(client.getIp() + " is not working"); + // is not working + client.setState(ClientState.SHUTDOWN_CLIENT); + psJobs.remove(client.getId()); + } + } else { + logger.error(client.getIp() + + " Cannot check if user is working."); + client + .setError("The check if a user is working has been failed."); + /* + * cannot check if user is working, go in errorState + */ + client.setState(ClientState.ERROR); + psJobs.remove(client.getId()); + } + } + } + } + } public Boolean isFinished() { return finished && !error; @@ -482,4 +510,5 @@ public class Shutdown extends Thread { public String getEventName() { return eventName; } + } \ No newline at end of file -- cgit v1.2.3-55-g7522