Search in sources :

Example 6 with FileTailListDO

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;
}
Also used : FileTailListDO(com.orion.ops.entity.domain.FileTailListDO) MachineInfoDO(com.orion.ops.entity.domain.MachineInfoDO) FileTailDTO(com.orion.ops.entity.dto.FileTailDTO) FileTailVO(com.orion.ops.entity.vo.FileTailVO)

Example 7 with FileTailListDO

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;
}
Also used : FileTailListDO(com.orion.ops.entity.domain.FileTailListDO) MachineInfoDO(com.orion.ops.entity.domain.MachineInfoDO) FileTailVO(com.orion.ops.entity.vo.FileTailVO)

Example 8 with FileTailListDO

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);
}
Also used : FileTailListDO(com.orion.ops.entity.domain.FileTailListDO) Date(java.util.Date)

Aggregations

FileTailListDO (com.orion.ops.entity.domain.FileTailListDO)8 MachineInfoDO (com.orion.ops.entity.domain.MachineInfoDO)3 FileTailVO (com.orion.ops.entity.vo.FileTailVO)3 Date (java.util.Date)2 FileTransferLogDO (com.orion.ops.entity.domain.FileTransferLogDO)1 FileDownloadDTO (com.orion.ops.entity.dto.FileDownloadDTO)1 FileTailDTO (com.orion.ops.entity.dto.FileTailDTO)1 Files1 (com.orion.utils.io.Files1)1