Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize job list #102

Merged
merged 2 commits into from
Jun 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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