本地缓存 优化 增加各种统计信息
This commit is contained in:
@@ -17,6 +17,7 @@ import org.springframework.stereotype.Service;
|
|||||||
import javax.annotation.PostConstruct;
|
import javax.annotation.PostConstruct;
|
||||||
import javax.annotation.PreDestroy;
|
import javax.annotation.PreDestroy;
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -59,6 +60,9 @@ public class LocalCacheService {
|
|||||||
@Resource
|
@Resource
|
||||||
PMMLExecutor pmmlExecutor;
|
PMMLExecutor pmmlExecutor;
|
||||||
|
|
||||||
|
private static final String VERSION = "2025-02-12 16:30";
|
||||||
|
private final String startTime = LocalDateTime.now().toString();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -86,6 +90,9 @@ public class LocalCacheService {
|
|||||||
|
|
||||||
public Map<String,Object> getInfo(){
|
public Map<String,Object> getInfo(){
|
||||||
Map<String,Object> info = new HashMap<>();
|
Map<String,Object> info = new HashMap<>();
|
||||||
|
info.put("VERSION",VERSION);
|
||||||
|
info.put("startTime",startTime);
|
||||||
|
|
||||||
info.put("runCount",runCount.longValue());
|
info.put("runCount",runCount.longValue());
|
||||||
info.put("info",infoMap);
|
info.put("info",infoMap);
|
||||||
|
|
||||||
@@ -149,6 +156,7 @@ public class LocalCacheService {
|
|||||||
updateFieldsCache();
|
updateFieldsCache();
|
||||||
}catch(Throwable e){
|
}catch(Throwable e){
|
||||||
error = true;
|
error = true;
|
||||||
|
infoMap.put("updateFieldsCache_error",LocalDateTime.now()+":"+e);
|
||||||
logger.error("updateFieldsCache_error",e);
|
logger.error("updateFieldsCache_error",e);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -156,6 +164,7 @@ public class LocalCacheService {
|
|||||||
updateModelCache();
|
updateModelCache();
|
||||||
}catch(Throwable e){
|
}catch(Throwable e){
|
||||||
error = true;
|
error = true;
|
||||||
|
infoMap.put("updateModelCache_error",LocalDateTime.now()+":"+e);
|
||||||
logger.error("updateModelCache_error",e);
|
logger.error("updateModelCache_error",e);
|
||||||
}
|
}
|
||||||
if(throwsError && error){
|
if(throwsError && error){
|
||||||
@@ -188,11 +197,19 @@ public class LocalCacheService {
|
|||||||
}
|
}
|
||||||
CommUtil.doSleep(UPDATE_SLEEP_TIME_MS);
|
CommUtil.doSleep(UPDATE_SLEEP_TIME_MS);
|
||||||
runCount.getAndIncrement();
|
runCount.getAndIncrement();
|
||||||
|
long start = System.currentTimeMillis();
|
||||||
updateAllCache(false);
|
updateAllCache(false);
|
||||||
|
long end = System.currentTimeMillis();
|
||||||
|
long time = end - start;
|
||||||
|
infoMap.put("updateAllCache_use_time",time+"MS");
|
||||||
|
infoMap.put("updateAllCache_time",LocalDateTime.now().toString());
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user