调度报表优化,报表SQL调优并且新增LocalCache缓存(缓存时间60s),提高大数据量下报表加载速度;

pull/6/head
xuxueli 7 years ago
parent 0169d537ef
commit a1e11ea190

@ -1144,8 +1144,8 @@ Tips: 历史版本(V1.3.x)目前已经Release至稳定版本, 进入维护阶段
- 1、修复打包部署时资源文件乱码问题
- 2、修复新版本chrome滚动到顶部失效问题
- 3、国际化调度中心实现国际化支持中文、英文两种语言默认为中文。
- 4、调度报表新增"运行中"中状态项数据加载SQL优化
- 5、调度报表缓存优化,修复大数据量执行日志加载缓慢的问题
- 4、调度报表新增"运行中"中状态项;
- 5、调度报表优化报表SQL调优并且新增LocalCache缓存缓存时间60s提高大数据量下报表加载速度
### TODO LIST
- 1、任务权限管理执行器为粒度分配权限核心操作校验权限

@ -23,12 +23,11 @@ import java.util.Properties;
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 @@ public class I18nUtil {
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;
}

@ -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<String, LocalCacheData> 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()<localCacheData.getTimeoutTime()) {
return localCacheData.getVal();
} else {
remove(key);
return null;
}
}
}

@ -6,6 +6,7 @@ import com.xxl.job.admin.core.model.XxlJobInfo;
import com.xxl.job.admin.core.route.ExecutorRouteStrategyEnum;
import com.xxl.job.admin.core.schedule.XxlJobDynamicScheduler;
import com.xxl.job.admin.core.util.I18nUtil;
import com.xxl.job.admin.core.util.LocalCacheUtil;
import com.xxl.job.admin.dao.XxlJobGroupDao;
import com.xxl.job.admin.dao.XxlJobInfoDao;
import com.xxl.job.admin.dao.XxlJobLogDao;
@ -320,8 +321,16 @@ public class XxlJobServiceImpl implements XxlJobService {
return dashboardMap;
}
private static final String TRIGGER_CHART_DATA_CACHE = "trigger_chart_data_cache";
@Override
public ReturnT<Map<String, Object>> triggerChartDate(Date startDate, Date endDate) {
// get cache
Map<String, Object> triggerChartDateCache = (Map<String, Object>) LocalCacheUtil.get(TRIGGER_CHART_DATA_CACHE);
if (triggerChartDateCache != null) {
return new ReturnT<Map<String, Object>>(triggerChartDateCache);
}
// process
List<String> triggerDayList = new ArrayList<String>();
List<Integer> triggerDayCountRunningList = new ArrayList<Integer>();
List<Integer> triggerDayCountSucList = new ArrayList<Integer>();
@ -365,6 +374,10 @@ public class XxlJobServiceImpl implements XxlJobService {
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<Map<String, Object>>(result);
}

@ -76,6 +76,7 @@ $(function() {
"serverSide": true,
"ajax": {
url: base_url + "/joblog/pageList" ,
type:"post",
data : function ( d ) {
var obj = {};
obj.jobGroup = $('#jobGroup').val();

Loading…
Cancel
Save