From d471f117de6f79ee474af717ac3a759adc15c175 Mon Sep 17 00:00:00 2001 From: ldang264 <820704815@qq.com> Date: Sun, 29 Aug 2021 09:59:42 +0800 Subject: [PATCH] optimize --- README.md | 2 +- README_zh_CN.md | 2 +- pom.xml | 19 ++------------ .../quartz/impl/redisjobstore/HelloJob.java | 25 ++++++++++--------- .../quartz/impl/redisjobstore/Util.java | 5 ++-- 5 files changed, 19 insertions(+), 34 deletions(-) diff --git a/README.md b/README.md index 444964c..0298b41 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ com.github.attemper quartz-redis - 0.9.2 + 0.9.3 ``` diff --git a/README_zh_CN.md b/README_zh_CN.md index e6a455b..0cabd15 100644 --- a/README_zh_CN.md +++ b/README_zh_CN.md @@ -17,7 +17,7 @@ com.github.attemper quartz-redis - 0.9.2 + 0.9.3 ``` diff --git a/pom.xml b/pom.xml index 6046eb0..1ebc144 100644 --- a/pom.xml +++ b/pom.xml @@ -13,12 +13,10 @@ 1.8 2.3.2.2 5.0.2.RELEASE - 5.1.27 - 2.3.13 - 2.10.3 + 2.10.5.1 1.7.7 - 2.13.1 + 2.13.2 4.10 2.1 @@ -67,19 +65,6 @@ provided - - mysql - mysql-connector-java - ${mysql.connector.version} - test - - - com.zaxxer - HikariCP-java6 - ${hikari.version} - test - - junit junit-dep diff --git a/src/test/java/com/github/quartz/impl/redisjobstore/HelloJob.java b/src/test/java/com/github/quartz/impl/redisjobstore/HelloJob.java index fc79434..256d1f0 100644 --- a/src/test/java/com/github/quartz/impl/redisjobstore/HelloJob.java +++ b/src/test/java/com/github/quartz/impl/redisjobstore/HelloJob.java @@ -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 (?, ?)"; @@ -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(); @@ -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 { @@ -72,6 +73,6 @@ public void execute(JobExecutionContext context) throws JobExecutionException { } } } - + */ } } diff --git a/src/test/java/com/github/quartz/impl/redisjobstore/Util.java b/src/test/java/com/github/quartz/impl/redisjobstore/Util.java index d03bd43..65ef7e0 100644 --- a/src/test/java/com/github/quartz/impl/redisjobstore/Util.java +++ b/src/test/java/com/github/quartz/impl/redisjobstore/Util.java @@ -1,7 +1,5 @@ package com.github.quartz.impl.redisjobstore; -import com.zaxxer.hikari.HikariDataSource; - import java.util.Properties; public class Util { @@ -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"); @@ -50,5 +49,5 @@ public static HikariDataSource getDataSource() { dataSource.setMinimumIdle(10); dataSource.setMaximumPoolSize(10); return dataSource; - } + }*/ }