diff --git "a/doc/XXL-JOB\345\256\230\346\226\271\346\226\207\346\241\243.md" "b/doc/XXL-JOB\345\256\230\346\226\271\346\226\207\346\241\243.md" index 0e291d3..767db7e 100644 --- "a/doc/XXL-JOB\345\256\230\346\226\271\346\226\207\346\241\243.md" +++ "b/doc/XXL-JOB\345\256\230\346\226\271\346\226\207\346\241\243.md" @@ -1144,8 +1144,8 @@ - 1、修复打包部署时资源文件乱码问题; - 2、修复新版本chrome滚动到顶部失效问题; - 3、国际化:调度中心实现国际化,支持中文、英文两种语言,默认为中文。 -- 4、调度报表新增"运行中"中状态项,数据加载SQL优化; -- 5、调度报表缓存优化,修复大数据量执行日志加载缓慢的问题; +- 4、调度报表新增"运行中"中状态项; +- 5、调度报表优化,报表SQL调优并且新增LocalCache缓存(缓存时间60s),提高大数据量下报表加载速度; ### TODO LIST - 1、任务权限管理:执行器为粒度分配权限,核心操作校验权限; diff --git "a/doc/XXL-JOB\345\256\230\346\226\271\346\226\207\346\241\243.md" "b/doc/XXL-JOB\345\256\230\346\226\271\346\226\207\346\241\243.md" index 0e291d3..767db7e 100644 --- "a/doc/XXL-JOB\345\256\230\346\226\271\346\226\207\346\241\243.md" +++ "b/doc/XXL-JOB\345\256\230\346\226\271\346\226\207\346\241\243.md" @@ -1144,8 +1144,8 @@ - 1、修复打包部署时资源文件乱码问题; - 2、修复新版本chrome滚动到顶部失效问题; - 3、国际化:调度中心实现国际化,支持中文、英文两种语言,默认为中文。 -- 4、调度报表新增"运行中"中状态项,数据加载SQL优化; -- 5、调度报表缓存优化,修复大数据量执行日志加载缓慢的问题; +- 4、调度报表新增"运行中"中状态项; +- 5、调度报表优化,报表SQL调优并且新增LocalCache缓存(缓存时间60s),提高大数据量下报表加载速度; ### TODO LIST - 1、任务权限管理:执行器为粒度分配权限,核心操作校验权限; diff --git a/xxl-job-admin/src/main/java/com/xxl/job/admin/core/util/I18nUtil.java b/xxl-job-admin/src/main/java/com/xxl/job/admin/core/util/I18nUtil.java index 150604b..2330a44 100644 --- a/xxl-job-admin/src/main/java/com/xxl/job/admin/core/util/I18nUtil.java +++ b/xxl-job-admin/src/main/java/com/xxl/job/admin/core/util/I18nUtil.java @@ -23,12 +23,11 @@ public class I18nUtil { private static Logger logger = LoggerFactory.getLogger(I18nUtil.class); - private static Properties prop = null; - private static long lastCacheTim = 0L; - + private static final String I18N_PROP_CACHE = "i18n_prop_cache"; public static Properties loadI18nProp(){ - if (prop != null && (System.currentTimeMillis()-lastCacheTim)<60*1000) { - //return prop; + Properties prop = (Properties) LocalCacheUtil.get(I18N_PROP_CACHE); + if (prop != null) { + return prop; } try { // bild i18n prop @@ -40,11 +39,10 @@ Resource resource = new ClassPathResource(i18nFile); EncodedResource encodedResource = new EncodedResource(resource,"UTF-8"); prop = PropertiesLoaderUtils.loadProperties(encodedResource); - lastCacheTim = System.currentTimeMillis(); + LocalCacheUtil.set(I18N_PROP_CACHE, prop, 60*1000); // cache 60s } catch (IOException e) { logger.error(e.getMessage(), e); } - logger.warn("---111---"); return prop; } diff --git "a/doc/XXL-JOB\345\256\230\346\226\271\346\226\207\346\241\243.md" "b/doc/XXL-JOB\345\256\230\346\226\271\346\226\207\346\241\243.md" index 0e291d3..767db7e 100644 --- "a/doc/XXL-JOB\345\256\230\346\226\271\346\226\207\346\241\243.md" +++ "b/doc/XXL-JOB\345\256\230\346\226\271\346\226\207\346\241\243.md" @@ -1144,8 +1144,8 @@ - 1、修复打包部署时资源文件乱码问题; - 2、修复新版本chrome滚动到顶部失效问题; - 3、国际化:调度中心实现国际化,支持中文、英文两种语言,默认为中文。 -- 4、调度报表新增"运行中"中状态项,数据加载SQL优化; -- 5、调度报表缓存优化,修复大数据量执行日志加载缓慢的问题; +- 4、调度报表新增"运行中"中状态项; +- 5、调度报表优化,报表SQL调优并且新增LocalCache缓存(缓存时间60s),提高大数据量下报表加载速度; ### TODO LIST - 1、任务权限管理:执行器为粒度分配权限,核心操作校验权限; diff --git a/xxl-job-admin/src/main/java/com/xxl/job/admin/core/util/I18nUtil.java b/xxl-job-admin/src/main/java/com/xxl/job/admin/core/util/I18nUtil.java index 150604b..2330a44 100644 --- a/xxl-job-admin/src/main/java/com/xxl/job/admin/core/util/I18nUtil.java +++ b/xxl-job-admin/src/main/java/com/xxl/job/admin/core/util/I18nUtil.java @@ -23,12 +23,11 @@ public class I18nUtil { private static Logger logger = LoggerFactory.getLogger(I18nUtil.class); - private static Properties prop = null; - private static long lastCacheTim = 0L; - + private static final String I18N_PROP_CACHE = "i18n_prop_cache"; public static Properties loadI18nProp(){ - if (prop != null && (System.currentTimeMillis()-lastCacheTim)<60*1000) { - //return prop; + Properties prop = (Properties) LocalCacheUtil.get(I18N_PROP_CACHE); + if (prop != null) { + return prop; } try { // bild i18n prop @@ -40,11 +39,10 @@ Resource resource = new ClassPathResource(i18nFile); EncodedResource encodedResource = new EncodedResource(resource,"UTF-8"); prop = PropertiesLoaderUtils.loadProperties(encodedResource); - lastCacheTim = System.currentTimeMillis(); + LocalCacheUtil.set(I18N_PROP_CACHE, prop, 60*1000); // cache 60s } catch (IOException e) { logger.error(e.getMessage(), e); } - logger.warn("---111---"); return prop; } diff --git a/xxl-job-admin/src/main/java/com/xxl/job/admin/core/util/LocalCacheUtil.java b/xxl-job-admin/src/main/java/com/xxl/job/admin/core/util/LocalCacheUtil.java new file mode 100644 index 0000000..76bd23e --- /dev/null +++ b/xxl-job-admin/src/main/java/com/xxl/job/admin/core/util/LocalCacheUtil.java @@ -0,0 +1,112 @@ +package com.xxl.job.admin.core.util; + +import org.apache.commons.lang3.StringUtils; + +import java.util.concurrent.ConcurrentHashMap; + +/** + * local cache tool + * + * @author xuxueli 2018-01-22 21:37:34 + */ +public class LocalCacheUtil { + + private static ConcurrentHashMap cacheRepository = new ConcurrentHashMap<>(); + private static class LocalCacheData{ + private String key; + private Object val; + private long timeoutTime; + + public LocalCacheData() { + } + + public LocalCacheData(String key, Object val, long timeoutTime) { + this.key = key; + this.val = val; + this.timeoutTime = timeoutTime; + } + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + public Object getVal() { + return val; + } + + public void setVal(Object val) { + this.val = val; + } + + public long getTimeoutTime() { + return timeoutTime; + } + + public void setTimeoutTime(long timeoutTime) { + this.timeoutTime = timeoutTime; + } + } + + + /** + * set cache + * + * @param key + * @param val + * @param cacheTime + * @return + */ + public static boolean set(String key, Object val, long cacheTime){ + if (StringUtils.isBlank(key)) { + return false; + } + if (val == null) { + remove(key); + } + if (cacheTime <= 0) { + remove(key); + } + long timeoutTime = System.currentTimeMillis() + cacheTime; + LocalCacheData localCacheData = new LocalCacheData(key, val, timeoutTime); + cacheRepository.put(localCacheData.getKey(), localCacheData); + return true; + } + + /** + * remove cache + * + * @param key + * @return + */ + public static boolean remove(String key){ + if (StringUtils.isBlank(key)) { + return false; + } + cacheRepository.remove(key); + return true; + } + + /** + * get cache + * + * @param key + * @return + */ + public static Object get(String key){ + if (StringUtils.isBlank(key)) { + return null; + } + LocalCacheData localCacheData = cacheRepository.get(key); + if (localCacheData!=null && System.currentTimeMillis() cacheRepository = new ConcurrentHashMap<>(); + private static class LocalCacheData{ + private String key; + private Object val; + private long timeoutTime; + + public LocalCacheData() { + } + + public LocalCacheData(String key, Object val, long timeoutTime) { + this.key = key; + this.val = val; + this.timeoutTime = timeoutTime; + } + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + public Object getVal() { + return val; + } + + public void setVal(Object val) { + this.val = val; + } + + public long getTimeoutTime() { + return timeoutTime; + } + + public void setTimeoutTime(long timeoutTime) { + this.timeoutTime = timeoutTime; + } + } + + + /** + * set cache + * + * @param key + * @param val + * @param cacheTime + * @return + */ + public static boolean set(String key, Object val, long cacheTime){ + if (StringUtils.isBlank(key)) { + return false; + } + if (val == null) { + remove(key); + } + if (cacheTime <= 0) { + remove(key); + } + long timeoutTime = System.currentTimeMillis() + cacheTime; + LocalCacheData localCacheData = new LocalCacheData(key, val, timeoutTime); + cacheRepository.put(localCacheData.getKey(), localCacheData); + return true; + } + + /** + * remove cache + * + * @param key + * @return + */ + public static boolean remove(String key){ + if (StringUtils.isBlank(key)) { + return false; + } + cacheRepository.remove(key); + return true; + } + + /** + * get cache + * + * @param key + * @return + */ + public static Object get(String key){ + if (StringUtils.isBlank(key)) { + return null; + } + LocalCacheData localCacheData = cacheRepository.get(key); + if (localCacheData!=null && System.currentTimeMillis()> triggerChartDate(Date startDate, Date endDate) { + // get cache + Map triggerChartDateCache = (Map) LocalCacheUtil.get(TRIGGER_CHART_DATA_CACHE); + if (triggerChartDateCache != null) { + return new ReturnT>(triggerChartDateCache); + } + + // process List triggerDayList = new ArrayList(); List triggerDayCountRunningList = new ArrayList(); List triggerDayCountSucList = new ArrayList(); @@ -365,6 +374,10 @@ result.put("triggerCountRunningTotal", triggerCountRunningTotal); result.put("triggerCountSucTotal", triggerCountSucTotal); result.put("triggerCountFailTotal", triggerCountFailTotal); + + // set cache + LocalCacheUtil.set(TRIGGER_CHART_DATA_CACHE, result, 60*1000); // cache 60s + return new ReturnT>(result); } diff --git "a/doc/XXL-JOB\345\256\230\346\226\271\346\226\207\346\241\243.md" "b/doc/XXL-JOB\345\256\230\346\226\271\346\226\207\346\241\243.md" index 0e291d3..767db7e 100644 --- "a/doc/XXL-JOB\345\256\230\346\226\271\346\226\207\346\241\243.md" +++ "b/doc/XXL-JOB\345\256\230\346\226\271\346\226\207\346\241\243.md" @@ -1144,8 +1144,8 @@ - 1、修复打包部署时资源文件乱码问题; - 2、修复新版本chrome滚动到顶部失效问题; - 3、国际化:调度中心实现国际化,支持中文、英文两种语言,默认为中文。 -- 4、调度报表新增"运行中"中状态项,数据加载SQL优化; -- 5、调度报表缓存优化,修复大数据量执行日志加载缓慢的问题; +- 4、调度报表新增"运行中"中状态项; +- 5、调度报表优化,报表SQL调优并且新增LocalCache缓存(缓存时间60s),提高大数据量下报表加载速度; ### TODO LIST - 1、任务权限管理:执行器为粒度分配权限,核心操作校验权限; diff --git a/xxl-job-admin/src/main/java/com/xxl/job/admin/core/util/I18nUtil.java b/xxl-job-admin/src/main/java/com/xxl/job/admin/core/util/I18nUtil.java index 150604b..2330a44 100644 --- a/xxl-job-admin/src/main/java/com/xxl/job/admin/core/util/I18nUtil.java +++ b/xxl-job-admin/src/main/java/com/xxl/job/admin/core/util/I18nUtil.java @@ -23,12 +23,11 @@ public class I18nUtil { private static Logger logger = LoggerFactory.getLogger(I18nUtil.class); - private static Properties prop = null; - private static long lastCacheTim = 0L; - + private static final String I18N_PROP_CACHE = "i18n_prop_cache"; public static Properties loadI18nProp(){ - if (prop != null && (System.currentTimeMillis()-lastCacheTim)<60*1000) { - //return prop; + Properties prop = (Properties) LocalCacheUtil.get(I18N_PROP_CACHE); + if (prop != null) { + return prop; } try { // bild i18n prop @@ -40,11 +39,10 @@ Resource resource = new ClassPathResource(i18nFile); EncodedResource encodedResource = new EncodedResource(resource,"UTF-8"); prop = PropertiesLoaderUtils.loadProperties(encodedResource); - lastCacheTim = System.currentTimeMillis(); + LocalCacheUtil.set(I18N_PROP_CACHE, prop, 60*1000); // cache 60s } catch (IOException e) { logger.error(e.getMessage(), e); } - logger.warn("---111---"); return prop; } diff --git a/xxl-job-admin/src/main/java/com/xxl/job/admin/core/util/LocalCacheUtil.java b/xxl-job-admin/src/main/java/com/xxl/job/admin/core/util/LocalCacheUtil.java new file mode 100644 index 0000000..76bd23e --- /dev/null +++ b/xxl-job-admin/src/main/java/com/xxl/job/admin/core/util/LocalCacheUtil.java @@ -0,0 +1,112 @@ +package com.xxl.job.admin.core.util; + +import org.apache.commons.lang3.StringUtils; + +import java.util.concurrent.ConcurrentHashMap; + +/** + * local cache tool + * + * @author xuxueli 2018-01-22 21:37:34 + */ +public class LocalCacheUtil { + + private static ConcurrentHashMap cacheRepository = new ConcurrentHashMap<>(); + private static class LocalCacheData{ + private String key; + private Object val; + private long timeoutTime; + + public LocalCacheData() { + } + + public LocalCacheData(String key, Object val, long timeoutTime) { + this.key = key; + this.val = val; + this.timeoutTime = timeoutTime; + } + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + public Object getVal() { + return val; + } + + public void setVal(Object val) { + this.val = val; + } + + public long getTimeoutTime() { + return timeoutTime; + } + + public void setTimeoutTime(long timeoutTime) { + this.timeoutTime = timeoutTime; + } + } + + + /** + * set cache + * + * @param key + * @param val + * @param cacheTime + * @return + */ + public static boolean set(String key, Object val, long cacheTime){ + if (StringUtils.isBlank(key)) { + return false; + } + if (val == null) { + remove(key); + } + if (cacheTime <= 0) { + remove(key); + } + long timeoutTime = System.currentTimeMillis() + cacheTime; + LocalCacheData localCacheData = new LocalCacheData(key, val, timeoutTime); + cacheRepository.put(localCacheData.getKey(), localCacheData); + return true; + } + + /** + * remove cache + * + * @param key + * @return + */ + public static boolean remove(String key){ + if (StringUtils.isBlank(key)) { + return false; + } + cacheRepository.remove(key); + return true; + } + + /** + * get cache + * + * @param key + * @return + */ + public static Object get(String key){ + if (StringUtils.isBlank(key)) { + return null; + } + LocalCacheData localCacheData = cacheRepository.get(key); + if (localCacheData!=null && System.currentTimeMillis()> triggerChartDate(Date startDate, Date endDate) { + // get cache + Map triggerChartDateCache = (Map) LocalCacheUtil.get(TRIGGER_CHART_DATA_CACHE); + if (triggerChartDateCache != null) { + return new ReturnT>(triggerChartDateCache); + } + + // process List triggerDayList = new ArrayList(); List triggerDayCountRunningList = new ArrayList(); List triggerDayCountSucList = new ArrayList(); @@ -365,6 +374,10 @@ result.put("triggerCountRunningTotal", triggerCountRunningTotal); result.put("triggerCountSucTotal", triggerCountSucTotal); result.put("triggerCountFailTotal", triggerCountFailTotal); + + // set cache + LocalCacheUtil.set(TRIGGER_CHART_DATA_CACHE, result, 60*1000); // cache 60s + return new ReturnT>(result); } diff --git a/xxl-job-admin/src/main/webapp/static/js/joblog.index.1.js b/xxl-job-admin/src/main/webapp/static/js/joblog.index.1.js index 212812f..d12e3e4 100644 --- a/xxl-job-admin/src/main/webapp/static/js/joblog.index.1.js +++ b/xxl-job-admin/src/main/webapp/static/js/joblog.index.1.js @@ -76,6 +76,7 @@ "serverSide": true, "ajax": { url: base_url + "/joblog/pageList" , + type:"post", data : function ( d ) { var obj = {}; obj.jobGroup = $('#jobGroup').val();