日志修改
This commit is contained in:
parent
54377af6df
commit
e16d90d3c4
@ -25,11 +25,11 @@ public class MemoryLogManager implements LoggerManager {
|
||||
/**
|
||||
* 第一级 是taskId,可能同一个账号、IP、建立多个连接所以保存为list
|
||||
* */
|
||||
private final static Map<String, List<SseEmitter>> taskIdSSEMap = new ConcurrentHashMap<>();
|
||||
private final Map<String, List<SseEmitter>> taskIdSSEMap = new ConcurrentHashMap<>();
|
||||
|
||||
private final static Map<String,StringBuffer> taskIdMemoryLogMap = new ConcurrentHashMap<>();
|
||||
private final Map<String,StringBuffer> taskIdMemoryLogMap = new ConcurrentHashMap<>();
|
||||
|
||||
public static final Integer FLUSH_DB_SIZE=2*1024*1024;
|
||||
public final Integer FLUSH_DB_SIZE=2*1024*1024;
|
||||
/**
|
||||
* 缓存最近一次执行的日志,key是taskId,val是数据库id(已入库的情况下)用于buffer满了增加日志内容
|
||||
* 读取日志的时候同时读取数据库和内存中的日志
|
||||
@ -59,7 +59,7 @@ public class MemoryLogManager implements LoggerManager {
|
||||
* 内存满4mb入库,查询日志和入库操作用同一把锁
|
||||
* 然后新内容推sse
|
||||
* */
|
||||
StringBuffer logCache = taskIdMemoryLogMap.getOrDefault(taskId, new StringBuffer());
|
||||
StringBuffer logCache = taskIdMemoryLogMap.computeIfAbsent(taskId, k -> new StringBuffer());
|
||||
int length = logCache.length();
|
||||
if (length>=FLUSH_DB_SIZE) {
|
||||
synchronized (this){
|
||||
|
@ -124,7 +124,6 @@ public class TaskServiceImpl extends ServiceImpl<PipTaskDao, PipTask> implements
|
||||
|
||||
@Override
|
||||
public CommonResult<String> getLogContentByTaskId(String taskId) {
|
||||
|
||||
return CommonResult.success(loggerManager.getLogContent(taskId));
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user