Skip to content

Commit

Permalink
Optimize job list
Browse files Browse the repository at this point in the history
  • Loading branch information
seppinho committed Jun 3, 2023
1 parent e738a40 commit 79719d9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
11 changes: 2 additions & 9 deletions src/main/java/cloudgene/mapred/api/v2/admin/GetAllJobs.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,6 @@ public Representation getJobs() {
case "current":

jobs = dao.findAllNotRetiredJobs();
List<AbstractJob> toRemove = new Vector<AbstractJob>();
for (AbstractJob job : jobs) {
if (engine.isInQueue(job)) {
toRemove.add(job);
}
}
jobs.removeAll(toRemove);
break;

case "retired":
Expand Down Expand Up @@ -99,15 +92,15 @@ public Representation getJobs() {
int running = 0;

for (AbstractJob job : jobs) {

String workspace = getSettings().getLocalWorkspace();
String folder = FileUtil.path(workspace, job.getId());
File file = new File(folder);
if (file.exists()) {
long size = FileUtils.sizeOfDirectory(file);
job.setWorkspaceSize(FileUtils.byteCountToDisplaySize(size));
}

if (job.getState() == AbstractJob.STATE_EXPORTING || job.getState() == AbstractJob.STATE_RUNNING) {
running++;
}
Expand Down
13 changes: 9 additions & 4 deletions src/main/java/cloudgene/mapred/database/JobDao.java
Original file line number Diff line number Diff line change
Expand Up @@ -267,14 +267,19 @@ public List<AbstractJob> findAllNotRetiredJobs() {
sql.append("select * ");
sql.append("from job ");
sql.append("join `user` on job.user_id = `user`.id ");
sql.append("where state != ? AND state != ? ");
sql.append("where state not in (?,?,?,?,?,?,?) ");
sql.append("order by job.id desc ");

List<AbstractJob> result = new Vector<AbstractJob>();

Object[] params = new Object[2];
params[0] = AbstractJob.STATE_RETIRED;
params[1] = AbstractJob.STATE_DELETED;
Object[] params = new Object[7];
params[0] = AbstractJob.STATE_WAITING;
params[1] = AbstractJob.STATE_RUNNING;
params[2] = AbstractJob.STATE_EXPORTING;
params[3] = AbstractJob.STATE_RETIRED;
params[4] = AbstractJob.STATE_DELETED;
params[5] = AbstractJob.STATE_RETIRED;
params[6] = AbstractJob.STATE_DELETED;

try {

Expand Down

0 comments on commit 79719d9

Please sign in to comment.