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

Fixe job names #145

Merged
merged 4 commits into from
Mar 21, 2024
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
6 changes: 3 additions & 3 deletions src/main/html/webapp/components/core/job/detail/detail.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export default Control.extend({
'#delete-btn click': function(el, ev) {
var that = this;

bootbox.confirm("Are you sure you want to delete <b>" + that.job.attr('id') + "</b>?", function(result) {
bootbox.confirm("Are you sure you want to delete <b>" + that.job.attr('name') + "</b>?", function(result) {
if (result) {

var okButton = $("button[data-bb-handler='confirm']");
Expand Down Expand Up @@ -106,7 +106,7 @@ export default Control.extend({
'#cancel-btn click': function(el, ev) {
var that = this;

bootbox.confirm("Are you sure you want to cancel <b>" + that.job.attr('id') + "</b>?", function(result) {
bootbox.confirm("Are you sure you want to cancel <b>" + that.job.attr('name') + "</b>?", function(result) {
if (result) {

var okButton = $("button[data-bb-handler='confirm']");
Expand Down Expand Up @@ -136,7 +136,7 @@ export default Control.extend({
'#restart-btn click': function(el, ev) {
var that = this;

bootbox.confirm("Are you sure you want to restart <b>" + that.job.attr('id') + "</b>?", function(result) {
bootbox.confirm("Are you sure you want to restart <b>" + that.job.attr('name') + "</b>?", function(result) {
if (result) {

var okButton = $("button[data-bb-handler='confirm']");
Expand Down
4 changes: 2 additions & 2 deletions src/main/html/webapp/components/core/job/list/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export default Control.extend({
var card = $(el).closest('.card');
var job = domData.get.call(card[0], 'job');

bootbox.confirm("Are you sure you want to delete <b>" + job.attr('id') + "</b>?", function(result) {
bootbox.confirm("Are you sure you want to delete <b>" + job.attr('name') + "</b>?", function(result) {
if (result) {

var okButton = $("button[data-bb-handler='confirm']");
Expand Down Expand Up @@ -78,7 +78,7 @@ export default Control.extend({
var card = $(el).closest('.card');
var job = domData.get.call(card[0], 'job');

bootbox.confirm("Are you sure you want to cancel <b>" + job.attr('id') + "</b>?", function(result) {
bootbox.confirm("Are you sure you want to cancel <b>" + job.attr('name') + "</b>?", function(result) {
if (result) {

var okButton = $("button[data-bb-handler='confirm']");
Expand Down
3 changes: 0 additions & 3 deletions src/main/java/cloudgene/mapred/api/v2/admin/ArchiveJob.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,6 @@ public Representation get() {
job.setState(AbstractJob.STATE_RETIRED);
dao.update(job);

ParameterDao parameterDao = new ParameterDao(getDatabase());
parameterDao.deleteAllByJob(job);

if (externalWorkspace != null) {
try {
externalWorkspace.delete(job.getId());
Expand Down
3 changes: 0 additions & 3 deletions src/main/java/cloudgene/mapred/api/v2/jobs/GetJobDetails.java
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,6 @@ public Representation deleteJob(Representation entity) {
job.setState(AbstractJob.STATE_DELETED);
dao.update(job);

ParameterDao parameterDao = new ParameterDao(getDatabase());
parameterDao.deleteAllByJob(job);

Settings settings = getSettings();

IExternalWorkspace externalWorkspace = null;
Expand Down
8 changes: 6 additions & 2 deletions src/main/java/cloudgene/mapred/api/v2/server/GetCounter.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.util.Map;

import cloudgene.mapred.database.JobDao;
import org.restlet.representation.Representation;
import org.restlet.representation.StringRepresentation;
import org.restlet.resource.Get;
Expand Down Expand Up @@ -41,10 +42,13 @@ public Representation get() {
for (String key : counters.keySet()) {
jsonWaiting.put(key, counters.get(key));
}
JobDao jobDao = new JobDao(getDatabase());
int waitingJobs = jobDao.findAllByState(AbstractJob.STATE_WAITING).size();
jsonWaiting.put("runs", waitingJobs);
jsonCounters.put("waiting", jsonWaiting);

UserDao dao = new UserDao(getDatabase());
jsonCounters.put("users", dao.findAll().size());
UserDao dao = new UserDao(getDatabase());
jsonCounters.put("users", dao.countAll());


return new StringRepresentation(jsonCounters.toString());
Expand Down
4 changes: 0 additions & 4 deletions src/main/java/cloudgene/mapred/cron/CleanUpTasks.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ public class CleanUpTasks {
public static int executeRetire(Database database, Settings settings) {
JobDao dao = new JobDao(database);

ParameterDao parameterDao = new ParameterDao(database);

List<AbstractJob> oldJobs = dao.findAllNotifiedJobs();

int deleted = 0;
Expand Down Expand Up @@ -57,8 +55,6 @@ public static int executeRetire(Database database, Settings settings) {
dao.update(job);


parameterDao.deleteAllByJob(job);

log.info("Job " + job.getId() + " retired.");
deleted++;

Expand Down
25 changes: 25 additions & 0 deletions src/main/java/cloudgene/mapred/database/JobDao.java
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,31 @@ public List<AbstractJob> findAllByState(int state) {
}
}

@SuppressWarnings("unchecked")
public int countAllByState(int state) {

StringBuilder sql = new StringBuilder();
sql.append("select count(*) ");
sql.append("from job ");
sql.append("where state = ? ");

Object[] params = new Object[1];
params[0] = state;

int result = 0;

try {
result = (Integer) queryForObject(sql.toString(), params, new IntegerMapper());
log.debug("count all old jobs successful. results: " + result);

return result;
} catch (SQLException e) {
log.error("count all old jobs failed", e);
return 0;
}
}


public AbstractJob findById(String id) {

return findById(id, true);
Expand Down
23 changes: 0 additions & 23 deletions src/main/java/cloudgene/mapred/database/ParameterDao.java
Original file line number Diff line number Diff line change
Expand Up @@ -183,29 +183,6 @@ public CloudgeneParameterOutput findById(int id) {
}
}

public boolean deleteAllByJob(AbstractJob job) {
try {

StringBuilder sql = new StringBuilder();
sql.append("delete ");
sql.append("from parameter ");
sql.append("where job_id = ?");

Object[] params = new Object[1];
params[0] = job.getId();

update(sql.toString(), params);

log.debug("delete all parameters by job_id '" + job.getId() + "' successful.");

return true;

} catch (SQLException e) {
log.error("delete all parameters by job_id '" + job.getId() + "' failed.", e);
return false;
}
}

class ParameterInputMapper implements IRowMapper {

@Override
Expand Down
23 changes: 22 additions & 1 deletion src/main/java/cloudgene/mapred/database/UserDao.java
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,28 @@ public List<User> findAll() {
}
return result;
}


@SuppressWarnings("unchecked")
public int countAll() {

StringBuilder sql = new StringBuilder();
sql.append("select count(*) ");
sql.append("from `user` ");

int result = 0;

try {
result = (Integer) queryForObject(sql.toString(), new IntegerMapper());
log.debug("count all users successful. results: " + result);

return result;
} catch (SQLException e) {
log.error("count all users failed", e);
return 0;
}
}


@SuppressWarnings("unchecked")
public List<User> findByQuery(String query) {

Expand Down
Loading