use of com.orion.ops.entity.domain.FileTailListDO in project orion-ops by lijiahangmax.
the class FileTailServiceImpl method getTailToken.
@Override
public FileTailVO getTailToken(FileTailType type, Long relId) {
FileTailVO res;
// 获取日志路径
final boolean isLocal = type.isLocal();
if (isLocal) {
String path = this.getTailFilePath(type, relId);
res = new FileTailVO();
res.setPath(path);
res.setOffset(machineEnvService.getTailOffset(Const.HOST_MACHINE_ID));
res.setCharset(machineEnvService.getTailCharset(Const.HOST_MACHINE_ID));
res.setCommand(machineEnvService.getTailDefaultCommand(Const.HOST_MACHINE_ID));
} else {
// tail list
FileTailListDO fileTail = fileTailListDAO.selectById(relId);
Valid.notNull(fileTail, MessageConst.UNKNOWN_DATA);
res = Converts.to(fileTail, FileTailVO.class);
}
// 设置命令
this.replaceTailCommand(res);
// 设置机器信息
MachineInfoDO machine = machineInfoService.selectById(isLocal ? Const.HOST_MACHINE_ID : res.getMachineId());
Valid.notNull(machine, MessageConst.INVALID_MACHINE);
res.setMachineId(machine.getId());
res.setMachineName(machine.getMachineName());
res.setMachineHost(machine.getMachineHost());
// 设置token
String token = UUIds.random19();
res.setToken(token);
// 设置缓存
FileTailDTO tail = Converts.to(res, FileTailDTO.class);
tail.setUserId(Currents.getUserId());
// 追踪模式
String tailMode = isLocal ? systemEnvService.getTailMode() : res.getTailMode();
tail.setMode(tailMode);
String key = Strings.format(KeyConst.FILE_TAIL_ACCESS_TOKEN, token);
redisTemplate.opsForValue().set(key, JSON.toJSONString(tail), KeyConst.FILE_TAIL_ACCESS_EXPIRE, TimeUnit.SECONDS);
// 非列表不返回命令和路径
if (isLocal) {
res.setPath(null);
res.setCommand(null);
}
return res;
}
use of com.orion.ops.entity.domain.FileTailListDO in project orion-ops by lijiahangmax.
the class FileTailServiceImpl method tailFileDetail.
@Override
public FileTailVO tailFileDetail(Long id) {
FileTailListDO tail = fileTailListDAO.selectById(id);
Valid.notNull(tail, MessageConst.UNKNOWN_DATA);
FileTailVO vo = Converts.to(tail, FileTailVO.class);
// 设置机器信息
MachineInfoDO machine = machineInfoService.selectById(tail.getMachineId());
Valid.notNull(machine, MessageConst.INVALID_MACHINE);
vo.setMachineName(machine.getMachineName());
vo.setMachineHost(machine.getMachineHost());
return vo;
}
use of com.orion.ops.entity.domain.FileTailListDO in project orion-ops by lijiahangmax.
the class FileTailServiceImpl method updateFileUpdateTime.
@Override
public Integer updateFileUpdateTime(Long id) {
FileTailListDO update = new FileTailListDO();
update.setId(id);
update.setUpdateTime(new Date());
return fileTailListDAO.updateById(update);
}
Aggregations