public CommandResponse doLISTJOBS(CommandRequest request) { CommandResponse response = StandardCommandManager.genericResponse("RESPONSE_200_COMMAND_OK"); ReplacerEnvironment env = new ReplacerEnvironment(); TreeSet<Job> treeSet = new TreeSet<Job>(new JobIndexComparator()); treeSet.addAll(getJobManager().getAllJobsFromQueue()); for (Job job : treeSet) { env.add("job", job); env.add("count", job.getIndex()); synchronized (job) { if (job.isTransferring()) { env.add("speed", Bytes.formatBytes(job.getSpeed())); env.add("progress", Bytes.formatBytes(job.getProgress())); try { env.add("total", Bytes.formatBytes(job.getFile().getSize())); } catch (FileNotFoundException e) { env.add("total", "0"); } env.add("srcslave", job.getSourceSlave().getName()); env.add("destslave", job.getDestinationSlave().getName()); response.addComment( request.getSession().jprintf(_bundle, env, _keyPrefix + "listjobrunning")); } else { response.addComment( request.getSession().jprintf(_bundle, env, _keyPrefix + "listjobwaiting")); } } } env = new ReplacerEnvironment(); env.add("total", treeSet.size()); response.addComment(request.getSession().jprintf(_bundle, env, _keyPrefix + "sizeofjobs")); return response; }
public CommandResponse doREMOVEJOBS(CommandRequest request) { TreeSet<Job> treeSet = new TreeSet<Job>(new JobIndexComparator()); treeSet.addAll(getJobManager().getAllJobsFromQueue()); CommandResponse response = StandardCommandManager.genericResponse("RESPONSE_200_COMMAND_OK"); for (Job job : treeSet) { if (!job.isTransferring()) { getJobManager().stopJob(job); } } response.addComment("Removing all non transfering jobs"); return response; }