Skip to content

Commit

Permalink
optimize
Browse files Browse the repository at this point in the history
  • Loading branch information
ldang264 committed Aug 29, 2021
1 parent 6c0e22a commit d471f11
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 34 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<dependency>
<groupId>com.github.attemper</groupId>
<artifactId>quartz-redis</artifactId>
<version>0.9.2</version>
<version>0.9.3</version>
</dependency>
```

Expand Down
2 changes: 1 addition & 1 deletion README_zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<dependency>
<groupId>com.github.attemper</groupId>
<artifactId>quartz-redis</artifactId>
<version>0.9.2</version>
<version>0.9.3</version>
</dependency>
```

Expand Down
19 changes: 2 additions & 17 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,10 @@
<maven.compiler.target>1.8</maven.compiler.target>
<quartz.version>2.3.2.2</quartz.version>
<luttuce.core.version>5.0.2.RELEASE</luttuce.core.version>
<mysql.connector.version>5.1.27</mysql.connector.version>
<hikari.version>2.3.13</hikari.version>
<jackson.version>2.10.3</jackson.version>
<jackson.version>2.10.5.1</jackson.version>

<slf4j.version>1.7.7</slf4j.version>
<log4j.version>2.13.1</log4j.version>
<log4j.version>2.13.2</log4j.version>
<junit-dep.version>4.10</junit-dep.version>

<maven.compiler.plugin.version>2.1</maven.compiler.plugin.version>
Expand Down Expand Up @@ -67,19 +65,6 @@
<scope>provided</scope>
</dependency>

<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>${mysql.connector.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.zaxxer</groupId>
<artifactId>HikariCP-java6</artifactId>
<version>${hikari.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit-dep</artifactId>
Expand Down
25 changes: 13 additions & 12 deletions src/test/java/com/github/quartz/impl/redisjobstore/HelloJob.java
Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@
package com.github.quartz.impl.redisjobstore;

import com.zaxxer.hikari.HikariDataSource;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.UUID;
import java.util.Random;

/**
* @author ldang
*/
public class HelloJob implements Job {

public static HikariDataSource dataSource = Util.getDataSource();
//public static HikariDataSource dataSource = Util.getDataSource();

private static final String INSERT_INSTANCE = "insert into instance(time, name) values (?, ?)";

Expand All @@ -31,11 +27,17 @@ public class HelloJob implements Job {

@Override
public void execute(JobExecutionContext context) throws JobExecutionException {
Date now = new Date();
String name = context.getJobDetail().getKey().getName();
String time = new SimpleDateFormat(yyyyMMddHHmmss).format(now);
String start = new SimpleDateFormat(yyyyMMddHHmmssSSS).format(now);
System.out.println(start + " " + context.getJobDetail().getKey().getName() + " 开始执行");
String start = new SimpleDateFormat(yyyyMMddHHmmssSSS).format(new Date());
System.out.println(start + " " + name + " 开始执行");
try {
Thread.sleep((new Random().nextInt(3) + 2) * 1000L);
} catch (InterruptedException e) {
e.printStackTrace();
}
String end = new SimpleDateFormat(yyyyMMddHHmmss).format(new Date());
System.out.println(end + " " + name + " 结束执行");
/*
Connection connection = null;
try {
String id = UUID.randomUUID().toString();
Expand All @@ -60,7 +62,6 @@ public void execute(JobExecutionContext context) throws JobExecutionException {
ps3.setString(1, end);
ps3.setString(2, id);
ps3.execute();
System.out.println(new SimpleDateFormat(yyyyMMddHHmmssSSS).format(new Date()) + " " + context.getJobDetail().getKey().getName() + " 结束执行");
} catch (Exception e) {
e.printStackTrace();
} finally {
Expand All @@ -72,6 +73,6 @@ public void execute(JobExecutionContext context) throws JobExecutionException {
}
}
}

*/
}
}
5 changes: 2 additions & 3 deletions src/test/java/com/github/quartz/impl/redisjobstore/Util.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package com.github.quartz.impl.redisjobstore;

import com.zaxxer.hikari.HikariDataSource;

import java.util.Properties;

public class Util {
Expand Down Expand Up @@ -41,6 +39,7 @@ public static Properties getJdbcProperties() {
return properties;
}

/*
public static HikariDataSource getDataSource() {
HikariDataSource dataSource = new HikariDataSource();
dataSource.setJdbcUrl("jdbc:mysql://localhost:3306/ext?characterEncoding=utf-8");
Expand All @@ -50,5 +49,5 @@ public static HikariDataSource getDataSource() {
dataSource.setMinimumIdle(10);
dataSource.setMaximumPoolSize(10);
return dataSource;
}
}*/
}

0 comments on commit d471f11

Please sign in to comment.