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

[v3.x] Migrate genepi-libs and optimize job list #101

Merged
merged 5 commits into from
May 24, 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
30 changes: 12 additions & 18 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -106,18 +106,6 @@
</exclusions>
</dependency>

<dependency>
<groupId>genepi</groupId>
<artifactId>genepi-db</artifactId>
<version>1.2.1</version>
<exclusions>
<exclusion>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>genepi</groupId>
<artifactId>genepi-hadoop</artifactId>
Expand All @@ -138,6 +126,18 @@
</exclusions>
</dependency>

<dependency>
<groupId>commons-dbutils</groupId>
<artifactId>commons-dbutils</artifactId>
<version>1.7</version>
</dependency>

<dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
<version>1.4</version>
</dependency>

<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
Expand Down Expand Up @@ -383,12 +383,6 @@
<artifactId>netty-resolver-dns-native-macos</artifactId>
<scope>runtime</scope>
</dependency>

<dependency>
<groupId>jakarta.annotation</groupId>
<artifactId>jakarta.annotation-api</artifactId>
<scope>compile</scope>
</dependency>

<dependency>
<groupId>ch.qos.logback</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
import com.amazonaws.services.s3.model.S3ObjectSummary;

import cloudgene.mapred.core.User;
import cloudgene.mapred.database.util.DatabaseUpdater;
import cloudgene.mapred.util.GitHubException;
import cloudgene.mapred.util.GitHubUtil;
import cloudgene.mapred.util.GitHubUtil.Repository;
import cloudgene.mapred.wdl.WdlApp;
import genepi.db.DatabaseUpdater;
import genepi.hadoop.S3Util;
import genepi.io.FileUtil;
import net.lingala.zip4j.ZipFile;
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/cloudgene/mapred/database/CounterDao.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import cloudgene.mapred.database.util.Database;
import cloudgene.mapred.database.util.IRowMapMapper;
import cloudgene.mapred.database.util.JdbcDataAccessObject;
import cloudgene.mapred.jobs.AbstractJob;
import genepi.db.Database;
import genepi.db.IRowMapMapper;
import genepi.db.JdbcDataAccessObject;

public class CounterDao extends JdbcDataAccessObject {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import genepi.db.Database;
import genepi.db.JdbcDataAccessObject;
import cloudgene.mapred.database.util.Database;
import cloudgene.mapred.database.util.JdbcDataAccessObject;

public class CounterHistoryDao extends JdbcDataAccessObject {

Expand Down
6 changes: 3 additions & 3 deletions src/main/java/cloudgene/mapred/database/DownloadDao.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import cloudgene.mapred.database.util.Database;
import cloudgene.mapred.database.util.IRowMapper;
import cloudgene.mapred.database.util.JdbcDataAccessObject;
import cloudgene.mapred.jobs.CloudgeneParameterOutput;
import cloudgene.mapred.jobs.Download;
import genepi.db.Database;
import genepi.db.IRowMapper;
import genepi.db.JdbcDataAccessObject;

public class DownloadDao extends JdbcDataAccessObject {

Expand Down
19 changes: 12 additions & 7 deletions src/main/java/cloudgene/mapred/database/JobDao.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@

import cloudgene.mapred.core.User;
import cloudgene.mapred.database.UserDao.UserMapper;
import cloudgene.mapred.database.util.Database;
import cloudgene.mapred.database.util.IRowMapper;
import cloudgene.mapred.database.util.JdbcDataAccessObject;
import cloudgene.mapred.jobs.AbstractJob;
import cloudgene.mapred.jobs.CloudgeneJob;
import cloudgene.mapred.jobs.CloudgeneParameterInput;
import cloudgene.mapred.jobs.CloudgeneParameterOutput;
import cloudgene.mapred.jobs.CloudgeneStep;
import genepi.db.Database;
import genepi.db.IRowMapper;
import genepi.db.JdbcDataAccessObject;

public class JobDao extends JdbcDataAccessObject {

Expand Down 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
6 changes: 3 additions & 3 deletions src/main/java/cloudgene/mapred/database/MessageDao.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import cloudgene.mapred.database.util.Database;
import cloudgene.mapred.database.util.IRowMapper;
import cloudgene.mapred.database.util.JdbcDataAccessObject;
import cloudgene.mapred.jobs.CloudgeneStep;
import cloudgene.mapred.jobs.Message;
import genepi.db.Database;
import genepi.db.IRowMapper;
import genepi.db.JdbcDataAccessObject;

public class MessageDao extends JdbcDataAccessObject {

Expand Down
6 changes: 3 additions & 3 deletions src/main/java/cloudgene/mapred/database/ParameterDao.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import cloudgene.mapred.database.util.Database;
import cloudgene.mapred.database.util.IRowMapper;
import cloudgene.mapred.database.util.JdbcDataAccessObject;
import cloudgene.mapred.jobs.AbstractJob;
import cloudgene.mapred.jobs.CloudgeneParameterInput;
import cloudgene.mapred.jobs.CloudgeneParameterOutput;
import cloudgene.mapred.jobs.Download;
import cloudgene.mapred.wdl.WdlParameterInputType;
import cloudgene.mapred.wdl.WdlParameterOutputType;
import genepi.db.Database;
import genepi.db.IRowMapper;
import genepi.db.JdbcDataAccessObject;

public class ParameterDao extends JdbcDataAccessObject {

Expand Down
6 changes: 3 additions & 3 deletions src/main/java/cloudgene/mapred/database/StepDao.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import cloudgene.mapred.database.util.Database;
import cloudgene.mapred.database.util.IRowMapper;
import cloudgene.mapred.database.util.JdbcDataAccessObject;
import cloudgene.mapred.jobs.CloudgeneJob;
import cloudgene.mapred.jobs.CloudgeneStep;
import cloudgene.mapred.jobs.Message;
import cloudgene.mapred.steps.EmptyStep;
import genepi.db.Database;
import genepi.db.IRowMapper;
import genepi.db.JdbcDataAccessObject;

public class StepDao extends JdbcDataAccessObject {

Expand Down
6 changes: 3 additions & 3 deletions src/main/java/cloudgene/mapred/database/TemplateDao.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
import org.slf4j.LoggerFactory;

import cloudgene.mapred.core.Template;
import genepi.db.Database;
import genepi.db.IRowMapper;
import genepi.db.JdbcDataAccessObject;
import cloudgene.mapred.database.util.Database;
import cloudgene.mapred.database.util.IRowMapper;
import cloudgene.mapred.database.util.JdbcDataAccessObject;

public class TemplateDao extends JdbcDataAccessObject {

Expand Down
6 changes: 3 additions & 3 deletions src/main/java/cloudgene/mapred/database/UserDao.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
import org.slf4j.LoggerFactory;

import cloudgene.mapred.core.User;
import cloudgene.mapred.database.util.Database;
import cloudgene.mapred.database.util.IRowMapper;
import cloudgene.mapred.database.util.JdbcDataAccessObject;
import cloudgene.mapred.util.PublicUser;
import genepi.db.Database;
import genepi.db.IRowMapper;
import genepi.db.JdbcDataAccessObject;

public class UserDao extends JdbcDataAccessObject {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

import cloudgene.mapred.core.User;
import cloudgene.mapred.database.UserDao;
import genepi.db.Database;
import genepi.db.IUpdateListener;
import cloudgene.mapred.database.util.Database;
import cloudgene.mapred.database.util.IUpdateListener;

public class BcryptHashUpdate implements IUpdateListener {

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
package cloudgene.mapred.database.util;

import org.apache.commons.dbcp.BasicDataSource;

public abstract class AbstractDatabaseConnector implements DatabaseConnector {

private int maxActive = 10;

private int maxWait = 10000;

private boolean defaultAutoCommit = true;

private boolean testWhileIdle = true;

private int minEvictableIdleTimeMillis = 1800000;

private int timeBetweenEvictionRunsMillis = 1800000;

protected BasicDataSource createDataSource() {

BasicDataSource dataSource = new BasicDataSource();
dataSource.setMaxActive(maxActive);
dataSource.setMaxWait(maxWait);
dataSource.setMaxIdle(maxActive);
dataSource.setDefaultAutoCommit(defaultAutoCommit);
dataSource.setTestWhileIdle(testWhileIdle);
dataSource.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis);
dataSource.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis);
return dataSource;

}

public int getMaxActive() {
return maxActive;
}

public void setMaxActive(int maxActive) {
this.maxActive = maxActive;
}

public int getMaxWait() {
return maxWait;
}

public void setMaxWait(int maxWait) {
this.maxWait = maxWait;
}

public boolean isDefaultAutoCommit() {
return defaultAutoCommit;
}

public void setDefaultAutoCommit(boolean defaultAutoCommit) {
this.defaultAutoCommit = defaultAutoCommit;
}

public boolean isTestWhileIdle() {
return testWhileIdle;
}

public void setTestWhileIdle(boolean testWhileIdle) {
this.testWhileIdle = testWhileIdle;
}

public int getMinEvictableIdleTimeMillis() {
return minEvictableIdleTimeMillis;
}

public void setMinEvictableIdleTimeMillis(int minEvictableIdleTimeMillis) {
this.minEvictableIdleTimeMillis = minEvictableIdleTimeMillis;
}

public int getTimeBetweenEvictionRunsMillis() {
return timeBetweenEvictionRunsMillis;
}

public void setTimeBetweenEvictionRunsMillis(int timeBetweenEvictionRunsMillis) {
this.timeBetweenEvictionRunsMillis = timeBetweenEvictionRunsMillis;
}

}
Loading