public CommandResponse doRemergeque(CommandRequest request) throws ImproperUsageException { String slave; if (request.hasArgument()) { slave = request.getArgument().toLowerCase(); } else { slave = "all"; } ArrayList<String> arr = new ArrayList<String>(); for (RemoteSlave rslave : GlobalContext.getGlobalContext().getSlaveManager().getSlaves()) { if (!rslave.getName().contains(slave) && !slave.equals("all")) { continue; } int size = rslave.doRemergequeue(); if (!rslave.isOnline()) { arr.add(rslave.getName() + " is offline"); } else if (!rslave.isRemerging()) { arr.add(rslave.getName() + " remergeque is complete"); } else if (size > 0) { arr.add(rslave.getName() + " remergeque size is " + size); } else { arr.add(rslave.getName() + " remergeque size is 0 but remerge is ongoing"); } } arr.add("Total commit:" + CommitManager.getCommitManager().getQueueSize()); CommandResponse response = StandardCommandManager.genericResponse("RESPONSE_200_COMMAND_OK"); for (String str : arr) { response.addComment(str); } return response; }
private CommandResponse addSlaveStatus( CommandRequest request, CommandResponse response, boolean showMore, RemoteSlave rslave) { Session session = request.getSession(); if (showMore) { response.addComment(rslave.moreInfo()); } ReplacerEnvironment env = new ReplacerEnvironment(); env.add("slavename", rslave.getName()); try { env.add("slaveip", rslave.getPASVIP()); } catch (SlaveUnavailableException e) { env.add("slaveip", "OFFLINE"); } if (rslave.isOnline()) { if (!rslave.isAvailable()) { response.addComment( session.jprintf(_bundle, _keyPrefix + "slave.remerging", env, request.getUser())); } else { try { SlaveStatus status = rslave.getSlaveStatus(); fillEnvWithSlaveStatus(env, status); env.add("status", rslave.isRemerging() ? "REMERGING" : "ONLINE"); response.addComment( session.jprintf(_bundle, _keyPrefix + "slave.online", env, request.getUser())); } catch (SlaveUnavailableException e) { // should never happen since we tested slave status w/ isOnline and isAvaiable. throw new RuntimeException( "There's a bug somewhere in the code, the slave was available now it isn't.", e); } } } else { response.addComment( session.jprintf(_bundle, _keyPrefix + "slave.offline", env, request.getUser())); } return response; }
public CommandResponse doSITE_KICKSLAVE(CommandRequest request) { Session session = request.getSession(); if (!request.hasArgument()) { return StandardCommandManager.genericResponse("RESPONSE_501_SYNTAX_ERROR"); } RemoteSlave rslave; try { rslave = GlobalContext.getGlobalContext().getSlaveManager().getRemoteSlave(request.getArgument()); } catch (ObjectNotFoundException e) { return new CommandResponse(200, "No such slave"); } if (!rslave.isOnline()) { return new CommandResponse(200, "Slave is already offline"); } rslave.setOffline("Slave kicked by " + session.getUserNull(request.getUser()).getName()); return StandardCommandManager.genericResponse("RESPONSE_200_COMMAND_OK"); }